Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
language: python
dist: bionic
dist: focal
python:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
env:
- UPGRADES="-U pint pandas"
- UPGRADES="-U --only-binary 'pint,pandas' pint pandas"
- UPGRADES=""
jobs:
exclude:
- python: '3.12'
env: UPGRADES=""
install:
- pip install --only-binary ':all:' -r requirements.txt
- test $TRAVIS_PYTHON_VERSION != "3.12" || perl -pi -E 's/^.*(?:pandas|flake8-docstrings).*$//' test_requirements.txt
- pip install --only-binary ':all:' -r test_requirements.txt
- pip install $UPGRADES -e .
script:
Expand Down
4 changes: 2 additions & 2 deletions gemd/demo/strehlow_and_cook.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,15 @@ def real_mapper(prop):
template = tmpl[name_map[attr['name']]]

# Move into GEMD structure
if type(template) == PropertyTemplate:
if isinstance(template, PropertyTemplate):
msr.properties.append(
Property(name=template.name,
template=template,
value=content_map[type(template.bounds)](attr),
origin=origin,
notes=method
))
elif type(template) == ConditionTemplate:
elif isinstance(template, ConditionTemplate):
msr.conditions.append(
Condition(name=template.name,
template=template,
Expand Down
2 changes: 1 addition & 1 deletion gemd/entity/base_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def to_link(self,

return LinkByUID(scope=scope, id=uid)

def all_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def all_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""Return a set of all immediate dependencies (no recursion)."""
result = set()
queue = [type(self)]
Expand Down
6 changes: 3 additions & 3 deletions gemd/entity/bounds/base_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class BaseBounds(DictSerializable):
"""Base class for bounds, including RealBounds and CategoricalBounds."""

@abstractmethod
def contains(self, bounds: Union["BaseBounds", "BaseValue"]):
def contains(self, bounds: Union["BaseBounds", "BaseValue"]): # noqa: F821
"""
Check if another bounds is contained within this bounds.

Expand All @@ -36,7 +36,7 @@ def contains(self, bounds: Union["BaseBounds", "BaseValue"]):
raise TypeError('{} is not a Bounds object'.format(bounds))

@abstractmethod
def union(self, *others: Union["BaseBounds", "BaseValue"]) -> "BaseBounds":
def union(self, *others: Union["BaseBounds", "BaseValue"]) -> "BaseBounds": # noqa: F821
"""
Return the union of this bounds and other bounds.

Expand All @@ -56,7 +56,7 @@ def union(self, *others: Union["BaseBounds", "BaseValue"]) -> "BaseBounds":
pass # pragma: no cover

@abstractmethod
def update(self, *others: Union["BaseBounds", "BaseValue"]):
def update(self, *others: Union["BaseBounds", "BaseValue"]): # noqa: F821
"""
Update this bounds to include other bounds.

Expand Down
8 changes: 4 additions & 4 deletions gemd/entity/bounds/categorical_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def categories(self, categories: Optional[Iterable[str]]):
if not all(isinstance(x, str) for x in self.categories):
raise ValueError("All the categories must be strings")

def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool:
def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: # noqa: F821
"""
Check if another bounds object or value objects is contained by this bounds.

Expand Down Expand Up @@ -69,8 +69,8 @@ def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool:
return bounds.categories.issubset(self.categories)

def union(self,
*others: Union["CategoricalBounds", "CategoricalValue"]
) -> "CategoricalBounds":
*others: Union["CategoricalBounds", "CategoricalValue"] # noqa: F821
) -> "CategoricalBounds": # noqa: F821
"""
Return the union of this bounds and other bounds.

Expand Down Expand Up @@ -102,7 +102,7 @@ def union(self,
result.update(bounds.categories)
return CategoricalBounds(result)

def update(self, *others: Union["CategoricalBounds", "CategoricalValue"]):
def update(self, *others: Union["CategoricalBounds", "CategoricalValue"]): # noqa: F821
"""
Update this bounds to include other bounds.

Expand Down
8 changes: 4 additions & 4 deletions gemd/entity/bounds/composition_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def components(self, value):
if not all(isinstance(x, str) for x in self.components):
raise ValueError("All the components must be strings")

def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool:
def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: # noqa: F821
"""
Check if another bounds or value object is contained by this bounds.

Expand Down Expand Up @@ -69,8 +69,8 @@ def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool:
return bounds.components.issubset(self.components)

def union(self,
*others: Union["CompositionBounds", "CompositionValue"]
) -> "CompositionBounds":
*others: Union["CompositionBounds", "CompositionValue"] # noqa: F821
) -> "CompositionBounds": # noqa: F821
"""
Return the union of this bounds and other bounds.

Expand Down Expand Up @@ -102,7 +102,7 @@ def union(self,
result.update(bounds.components)
return CompositionBounds(result)

def update(self, *others: Union["CompositionBounds", "CompositionValue"]):
def update(self, *others: Union["CompositionBounds", "CompositionValue"]): # noqa: F821
"""
Update this bounds to include other bounds.

Expand Down
8 changes: 5 additions & 3 deletions gemd/entity/bounds/integer_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, lower_bound=None, upper_bound=None):
if self.upper_bound < self.lower_bound:
raise ValueError("Upper bound must be greater than or equal to lower bound")

def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool:
def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: # noqa: F821
"""
Check if another bounds or value object is a subset of this range.

Expand Down Expand Up @@ -59,7 +59,9 @@ def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool:

return bounds.lower_bound >= self.lower_bound and bounds.upper_bound <= self.upper_bound

def union(self, *others: Union["IntegerBounds", "IntegerValue"]) -> "IntegerBounds":
def union(self,
*others: Union["IntegerBounds", "IntegerValue"] # noqa: F821
) -> "IntegerBounds": # noqa: F821
"""
Return the union of this bounds and other bounds.

Expand Down Expand Up @@ -94,7 +96,7 @@ def union(self, *others: Union["IntegerBounds", "IntegerValue"]) -> "IntegerBoun
upper = bounds.upper_bound
return IntegerBounds(lower_bound=lower, upper_bound=upper)

def update(self, *others: Union["IntegerBounds", "IntegerValue"]):
def update(self, *others: Union["IntegerBounds", "IntegerValue"]): # noqa: F821
"""
Update this bounds to include other bounds.

Expand Down
8 changes: 4 additions & 4 deletions gemd/entity/bounds/molecular_structure_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class MolecularStructureBounds(BaseBounds, typ="molecular_structure_bounds"):
"""Molecular bounds, with no component or substructural restrictions (yet)."""

def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool:
def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: # noqa: F821
"""
Check if another bounds or value object is contained by this bounds.

Expand Down Expand Up @@ -41,8 +41,8 @@ def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool:
return True

def union(self,
*others: Union["MolecularStructureBounds", "MolecularValue"]
) -> "MolecularStructureBounds":
*others: Union["MolecularStructureBounds", "MolecularValue"] # noqa: F821
) -> "MolecularStructureBounds": # noqa: F821
"""
Return the union of this bounds and other bounds.

Expand All @@ -69,7 +69,7 @@ def union(self,
f"expected molecular structure, found {misses}")
return MolecularStructureBounds()

def update(self, *others: Union["MolecularStructureBounds", "MolecularValue"]):
def update(self, *others: Union["MolecularStructureBounds", "MolecularValue"]): # noqa: F821
"""
Update this bounds to include other bounds.

Expand Down
6 changes: 3 additions & 3 deletions gemd/entity/bounds/real_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def default_units(self, default_units):
"Use an empty string for a dimensionless quantity.")
self._default_units = units.parse_units(default_units)

def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool:
def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: # noqa: F821
"""
Check if another bounds or value object is a subset of this range.

Expand Down Expand Up @@ -84,7 +84,7 @@ def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool:

return bounds.lower_bound >= lower and bounds.upper_bound <= upper

def union(self, *others: Union["RealBounds", "ContinuousValue"]) -> "RealBounds":
def union(self, *others: Union["RealBounds", "ContinuousValue"]) -> "RealBounds": # noqa: F821
"""
Return the union of this bounds and other bounds.

Expand Down Expand Up @@ -123,7 +123,7 @@ def union(self, *others: Union["RealBounds", "ContinuousValue"]) -> "RealBounds"
upper = bnd_hi
return RealBounds(lower_bound=lower, upper_bound=upper, default_units=unit_)

def update(self, *others: Union["RealBounds", "ContinuousValue"]):
def update(self, *others: Union["RealBounds", "ContinuousValue"]): # noqa: F821
"""
Update this bounds to include other bounds.

Expand Down
4 changes: 2 additions & 2 deletions gemd/entity/dict_serializable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class DictSerializableMeta(ABCMeta):

_class: Dict[str, type] = {}

def __new__(mcs, name, bases, *args,
def __new__(mcs, name, bases, *args, # noqa: D102
typ: str = None, skip: Set[str] = frozenset(),
**kwargs): # noqa: D102
**kwargs):
return super().__new__(mcs, name, bases, *args, **kwargs)

def __init__(cls, name, bases, *args, typ: str = None, skip: Set[str] = frozenset(), **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion gemd/entity/has_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ class HasDependencies(ABC):
"""Mix-in trait for objects that reference other objects."""

@abstractmethod
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""All dependencies (objects) that this class introduces."""
2 changes: 1 addition & 1 deletion gemd/entity/object/has_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ def conditions(self, conditions: Union[Condition, Iterable[Condition]]):
checker = self._generate_template_check(HasConditionTemplates.validate_condition)
self._conditions = validate_list(conditions, Condition, trigger=checker)

def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""Return a set of all immediate dependencies (no recursion)."""
return {cond.template for cond in self.conditions if cond.template is not None}
2 changes: 1 addition & 1 deletion gemd/entity/object/has_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def material(self) -> Union[BaseObject, LinkByUID]:
def material(self, spec: Union[BaseObject, LinkByUID]):
"""Set the material."""

def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""Return a set of all immediate dependencies (no recursion)."""
return {self.material} if self.material is not None else set()
2 changes: 1 addition & 1 deletion gemd/entity/object/has_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ def parameters(self, parameters: Union[Parameter, Iterable[Parameter]]):
checker = self._generate_template_check(HasParameterTemplates.validate_parameter)
self._parameters = validate_list(parameters, Parameter, trigger=checker)

def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""Return a set of all immediate dependencies (no recursion)."""
return {param.template for param in self.parameters if param.template is not None}
2 changes: 1 addition & 1 deletion gemd/entity/object/has_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def process(self) -> Union[BaseObject, LinkByUID]:
def process(self, process: Union[BaseObject, LinkByUID]):
"""Set the process."""

def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""Return a set of all immediate dependencies (no recursion)."""
return {self.process} if self.process is not None else set()
2 changes: 1 addition & 1 deletion gemd/entity/object/has_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ def properties(self, properties: Union[Property, Iterable[Property]]):
checker = self._generate_template_check(HasPropertyTemplates.validate_property)
self._properties = validate_list(properties, Property, trigger=checker)

def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""Return a set of all immediate dependencies (no recursion)."""
return {prop.template for prop in self.properties if prop.template is not None}
2 changes: 1 addition & 1 deletion gemd/entity/object/has_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ def template(self) -> Optional[Union[BaseTemplate, LinkByUID]]:
else:
return None

def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""Return a set of all immediate dependencies (no recursion)."""
return {self.spec} if self.spec is not None else set()
2 changes: 1 addition & 1 deletion gemd/entity/object/has_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ def template(self, template: Optional[Union[BaseTemplate, LinkByUID]]):
raise TypeError(f"Template must be a {self._template_type()} or LinkByUID, "
f"not {type(template)}")

def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""Return a set of all immediate dependencies (no recursion)."""
return {self.template} if self.template is not None else set()
2 changes: 1 addition & 1 deletion gemd/entity/object/material_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def process(self, process: Union[ProcessRun, LinkByUID]):
raise TypeError("process must be a ProcessRun or LinkByUID: {}".format(process))

@property
def measurements(self) -> List["MeasurementRun"]:
def measurements(self) -> List["MeasurementRun"]: # noqa: F821
"""Get a read-only list of the measurement runs."""
return self._measurements

Expand Down
4 changes: 2 additions & 2 deletions gemd/entity/object/process_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ def __init__(self,
self._output_material = None

@property
def output_material(self) -> Optional["MaterialRun"]:
def output_material(self) -> Optional["MaterialRun"]: # noqa: F821
"""Get the output material run."""
return self._output_material

@property
def ingredients(self) -> List["IngredientRun"]:
def ingredients(self) -> List["IngredientRun"]: # noqa: F821
"""Get the input ingredient runs."""
return self._ingredients

Expand Down
2 changes: 1 addition & 1 deletion gemd/entity/object/process_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _template_type() -> Type:
return ProcessTemplate

@property
def ingredients(self) -> List["IngredientSpec"]:
def ingredients(self) -> List["IngredientSpec"]: # noqa: F821
"""Get the list of input ingredient specs."""
return self._ingredients

Expand Down
2 changes: 1 addition & 1 deletion gemd/entity/template/has_condition_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ def validate_condition(self, condition: "Condition") -> bool: # noqa: F821
else:
return True # Nothing to check against

def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""Return a set of all immediate dependencies (no recursion)."""
return {attr[0] for attr in self.conditions}
2 changes: 1 addition & 1 deletion gemd/entity/template/has_parameter_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ def validate_parameter(self, parameter: "Parameter") -> bool: # noqa: F821
else:
return True # Nothing to check against

def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""Return a set of all immediate dependencies (no recursion)."""
return {attr[0] for attr in self.parameters}
6 changes: 4 additions & 2 deletions gemd/entity/template/has_property_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def properties(self, properties: Iterable[Union[Union[PropertyTemplate, LinkByUI
trigger=BaseTemplate._homogenize_ranges
)

def validate_property(self, prop: Union["Property", "PropertyAndConditions"]) -> bool:
def validate_property(self,
prop: Union["Property", "PropertyAndConditions"] # noqa: F821
) -> bool: # noqa: F821
"""Check if the property is consistent w/ this template."""
from gemd.entity.attribute import PropertyAndConditions
if isinstance(prop, PropertyAndConditions):
Expand All @@ -83,6 +85,6 @@ def validate_property(self, prop: Union["Property", "PropertyAndConditions"]) ->
else:
return True # Nothing to check against

def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]:
def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821
"""Return a set of all immediate dependencies (no recursion)."""
return {attr[0] for attr in self.properties}
2 changes: 1 addition & 1 deletion gemd/util/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def substitute_objects(obj,
method = _substitute

return method(obj,
sub=lambda l: index.get(l, l),
sub=lambda link: index.get(link, link),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

applies=lambda o: cached_isinstance(o, LinkByUID))


Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
packages.append("")

setup(name='gemd',
version='1.16.8',
version='1.16.9',
python_requires='>=3.8',
url='http://github.com/CitrineInformatics/gemd-python',
description="Python binding for Citrine's GEMD data model",
Expand Down Expand Up @@ -43,5 +43,6 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
],
)
4 changes: 2 additions & 2 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
flake8==3.7.8
flake8-docstrings==1.3.1
flake8==6.1.0
flake8-docstrings==1.7.0
pytest==7.3.1
pytest-cov==4.0.0
pandas==1.5.0
Expand Down