Skip to content

Commit

Permalink
Remove attr 19.2 depreciated cmp=False (#68)
Browse files Browse the repository at this point in the history
* remove attr 19.2 depreciated cmp=False

* [skip ci] update release notes

* remove remaining cmp=False

* ci bump minimal attrs version to 19.2.0

* disable compare process cls instances across models

It doesn't make sense to compare process instances between two models as
state (variable value) is not meant to be exposed during a simulation
and there is no state (no simulation store) attached to a model that is
not running.

* bump attrs version in doc environment

* fix model comparison

Compare the name and the type of each process
  • Loading branch information
benbovy committed Dec 9, 2019
1 parent 9277950 commit 4c64d06
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ci/requirements-py35.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test_env_py35
channels:
- conda-forge
dependencies:
- attrs>=18.1.0
- attrs>=19.2.0
- python=3.5
- pytest
- numpy
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py36-xarray-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test_env_py36-xarray-dev
channels:
- conda-forge
dependencies:
- attrs>=18.1.0
- attrs>=19.2.0
- python=3.6
- pytest
- numpy
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py36.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test_env_py36
channels:
- conda-forge
dependencies:
- attrs>=18.1.0
- attrs>=19.2.0
- python=3.6
- pytest
- numpy
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test_env_py37
channels:
- conda-forge
dependencies:
- attrs>=18.1.0
- attrs>=19.2.0
- python=3.7
- pytest
- numpy
Expand Down
2 changes: 1 addition & 1 deletion doc/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
- defaults
dependencies:
- attrs=19.1.0
- attrs=19.2.0
- python=3.7
- numpy=1.17.2
- pandas=0.25.1
Expand Down
2 changes: 2 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Release Notes
v0.4.0 (Unreleased)
-------------------

- Remove ``attrs`` 19.2.0 depreciation warning (:issue:`68`).

v0.3.0 (30 September 2019)
--------------------------

Expand Down
7 changes: 7 additions & 0 deletions xsimlab/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,5 +571,12 @@ def drop_processes(self, keys):
if k not in keys}
return type(self)(processes_cls)

def __eq__(self, other):
if not isinstance(other, self.__class__):
return NotImplemented
return all([k1 == k2 and type(v1) is type(v2)
for (k1, v1), (k2, v2) in
zip(self._processes.items(), other._processes.items())])

def __repr__(self):
return repr_model(self)
1 change: 0 additions & 1 deletion xsimlab/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ def _reset_attributes(self):
validator=attrib.validator,
default=attr.NOTHING,
init=False,
cmp=False,
repr=False
)

Expand Down
2 changes: 1 addition & 1 deletion xsimlab/tests/fixture_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ExampleProcess:

group_var = xs.group('some_group')

other_attrib = attr.attrib(init=False, cmp=False, repr=False)
other_attrib = attr.attrib(init=False, repr=False)
other_attr = "this is not a xsimlab variable attribute"

@od_var.compute
Expand Down
9 changes: 4 additions & 5 deletions xsimlab/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def variable(dims=(), intent='in', group=None, default=attr.NOTHING,
_repr = True

return attr.attrib(metadata=metadata, default=default, validator=validator,
init=_init, cmp=False, repr=_repr, kw_only=True)
init=_init, repr=_repr, kw_only=True)


def on_demand(dims=(), group=None, description='', attrs=None):
Expand Down Expand Up @@ -191,7 +191,7 @@ def on_demand(dims=(), group=None, description='', attrs=None):
'attrs': attrs or {},
'description': description}

return attr.attrib(metadata=metadata, init=False, cmp=False, repr=False)
return attr.attrib(metadata=metadata, init=False, repr=False)


def foreign(other_process_cls, var_name, intent='in'):
Expand Down Expand Up @@ -243,8 +243,7 @@ def foreign(other_process_cls, var_name, intent='in'):
_init = True
_repr = True

return attr.attrib(metadata=metadata, init=_init, cmp=False, repr=_repr,
kw_only=True)
return attr.attrib(metadata=metadata, init=_init, repr=_repr, kw_only=True)


def group(name):
Expand Down Expand Up @@ -275,5 +274,5 @@ def group(name):
'intent': VarIntent.IN,
'description': description}

return attr.attrib(metadata=metadata, init=True, cmp=False, repr=True,
return attr.attrib(metadata=metadata, init=True, repr=True,
default=tuple(), kw_only=True)

0 comments on commit 4c64d06

Please sign in to comment.