Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions gmso/abc/abstract_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ def tag_names_iter(self) -> Iterator[str]:
@field_serializer("potential_expression_")
def serialize_expression(self, potential_expression_: PotentialExpression):
expr = str(potential_expression_.expression)
ind = sorted(
list(str(ind) for ind in potential_expression_.independent_variables)
)
ind = sorted(str(ind) for ind in potential_expression_.independent_variables)
params = {
param: unyt_to_dict(val)
for param, val in potential_expression_.parameters.items()
Expand All @@ -133,7 +131,7 @@ def serialize_expression(self, potential_expression_: PotentialExpression):

@field_serializer("tags_")
def serialize_tags(self, tags_):
return_dict = dict()
return_dict = {}
for key, val in tags_.items():
if isinstance(val, u.unyt_array):
return_dict[key] = unyt_to_dict(val)
Expand Down
8 changes: 4 additions & 4 deletions gmso/abc/abstract_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging
from collections.abc import Sequence
from typing import Any, ClassVar, TypeVar, Union
from typing import Any, ClassVar, TypeVar

import numpy as np
import unyt as u
Expand All @@ -21,7 +21,7 @@

logger = logging.getLogger(__name__)

PositionType = Union[Sequence[float], np.ndarray, u.unyt_array]
PositionType = Sequence[float] | np.ndarray | u.unyt_array


class Molecule(GMSOBase):
Expand Down Expand Up @@ -83,7 +83,7 @@ def __eq__(self, other):
"""Test if two objects are equivalent."""
if isinstance(other, (list, tuple)):
return all(
[val1 == val2 for val1, val2 in zip(self.__dict__.values(), other)]
val1 == val2 for val1, val2 in zip(self.__dict__.values(), other)
)
else:
return self.__dict__ == other.__dict__
Expand Down Expand Up @@ -135,7 +135,7 @@ def __eq__(self, other):
"""Test if two objects are equivalent."""
if isinstance(other, (list, tuple)):
return all(
[val1 == val2 for val1, val2 in zip(self.__dict__.values(), other)]
val1 == val2 for val1, val2 in zip(self.__dict__.values(), other)
)
else:
return self.__dict__ == other.__dict__
Expand Down
2 changes: 1 addition & 1 deletion gmso/abc/serialization_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def dict_to_unyt(dict_obj) -> None:
dict_to_unyt(value)
else:
np_array = np.array(value["array"], dtype=float)
if np_array.shape == tuple():
if np_array.shape == ():
unyt_func = u.unyt_quantity
else:
unyt_func = u.unyt_array
Expand Down
2 changes: 1 addition & 1 deletion gmso/core/atom_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def clone(self, fast_copy=False):
charge=u.unyt_quantity(self.charge.value, self.charge.units),
atomclass=self.atomclass,
doi=self.doi,
overrides=(set(o for o in self.overrides) if self.overrides else None),
overrides=(set(self.overrides) if self.overrides else None),
description=self.description,
definition=self.definition,
)
Expand Down
15 changes: 5 additions & 10 deletions gmso/core/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,8 @@ def __eq__(self, other):
if self is other:
return True

if not isinstance(other, Box):
return False

if not allclose_units(self.lengths, other.lengths, rtol=1e-5, atol=1e-8):
return False

if not allclose_units(self.angles, other.angles, rtol=1e-5, atol=1e-8):
return False

return True
return (
isinstance(other, Box)
and allclose_units(self.lengths, other.lengths, rtol=1e-5, atol=1e-8)
and allclose_units(self.angles, other.angles, rtol=1e-5, atol=1e-8)
)
10 changes: 5 additions & 5 deletions gmso/core/forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ def non_element_types(self):
"""Get the non-element types in the ForceField."""
non_element_types = set()

for name, atom_type in self.atom_types.items():
for atom_type in self.atom_types.values():
element_symbol = atom_type.get_tag(
"element"
) # FixMe: Should we make this a first class citizen?
) # TODO: Should we make this a first class citizen?
if element_symbol:
element = element_by_symbol(element_symbol)
non_element_types.add(element_symbol) if not element else None
Expand Down Expand Up @@ -842,16 +842,16 @@ def from_xml(cls, xmls_or_etrees, strict=True, greedy=True):

should_parse_xml = False
if not (
all(map(lambda x: isinstance(x, str), xmls_or_etrees))
or all(map(lambda x: isinstance(x, etree._ElementTree), xmls_or_etrees))
all(isinstance(x, str) for x in xmls_or_etrees)
or all(isinstance(x, etree._ElementTree) for x in xmls_or_etrees)
):
raise TypeError(
"Please provide an iterable of strings "
"as locations of the XML files "
"or equivalent element Trees"
)

if all(map(lambda x: isinstance(x, str), xmls_or_etrees)):
if all(isinstance(x, str) for x in xmls_or_etrees):
should_parse_xml = True

versions = []
Expand Down
Loading
Loading