Skip to content

Commit

Permalink
Compare nested check keys (#377)
Browse files Browse the repository at this point in the history
* check mappings key difference in compare_nested

* add test

* update CHANGELOG.md

* deepsource fix
  • Loading branch information
CagtayFabry authored Jun 22, 2021
1 parent e19fbc4 commit f2dcc43
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
23 changes: 13 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,25 @@
structures. [[#328]](https://github.com/BAMWelDX/weldx/pull/328)
- added `WeldxFile` wrapper to handle asdf files with history and schemas more
easily. [[#341]](https://github.com/BAMWelDX/weldx/pull/341).
- added `WeldxFile` wrapper to handle asdf files with
history and schemas more easily. [[#341]](https://github.com/BAMWelDX/weldx/pull/341).
- added `WeldxFile` wrapper to handle asdf files with history and schemas more
easily. [[#341]](https://github.com/BAMWelDX/weldx/pull/341).
- add `"step"` as additional method to `util.xr_interp_like` [[#363]](https://github.com/BAMWelDX/weldx/pull/363)


### changes

- `WXRotation.from_euler()` now accepts a `pint.Quantity` as input. [[#318]](https://github.com/BAMWelDX/weldx/pull/318)
- move tests folder to `weldx/tests` [[#323]](https://github.com/BAMWelDX/weldx/pull/323)
- `get_yaml_header` received a new option parse, which optionally returns the parsed YAML header
as `asdf.tagged.TaggedDict`. [[#338]](https://github.com/BAMWelDX/weldx/pull/338)
- refactor `asdf_json_repr` into `view_tree` [[#339]](https://github.com/BAMWelDX/weldx/pull/339)
- The `MeasurementChain` is now internally based on a `networkx.DiGraph`. New functions are also added to the class to
- The `MeasurementChain` is now internally based on a `networkx.DiGraph`. New functions are also added to the class to
simplify its usage. [[#326]](https://github.com/BAMWelDX/weldx/pull/326)
The following additional changes were applied during the update of the `MeasurementChain`:
- renamed `DataTransformation` class to `SignalTransformation`
- renamed `Source` to `SignalSource`
- Added additional functionality to `Signal`, `SignalTransformation` and `GenericEquipment`
- Removed `Data` class
- Updated asdf schemas of all modified classes and the ones that contained references to those classes

- renamed `DataTransformation` class to `SignalTransformation`
- renamed `Source` to `SignalSource`
- Added additional functionality to `Signal`, `SignalTransformation` and `GenericEquipment`
- Removed `Data` class
- Updated asdf schemas of all modified classes and the ones that contained references to those classes

### documentation

Expand All @@ -49,6 +47,11 @@
- update `single-pass-weldx.1.0.0.schema` to allow groove types by
wildcard [[#373]](https://github.com/BAMWelDX/weldx/pull/373)

### fixes

- added check for symmetric key difference for mappings
with `util.compare_nested` [[#377]](https://github.com/BAMWelDX/weldx/pull/377)

## 0.3.3 (30.03.2021)

This is a bugfix release to correctly include the asdf schema files in conda
Expand Down
6 changes: 6 additions & 0 deletions weldx/tests/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,12 @@ def test_key_changed2(_default_dicts): # noqa: D102
b["y"] = x
assert not ut.compare_nested(a, b)

@staticmethod
def test_key_added(_default_dicts): # noqa: D102
a, b = (dict(a=1), dict(a=1, b=1))
assert not ut.compare_nested(a, b)
assert not ut.compare_nested(b, a)

@staticmethod
def test_array_accessible_by_two_roots(): # noqa: D102
a = {"l1": {"l2": np.arange(5)}}
Expand Down
4 changes: 4 additions & 0 deletions weldx/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,10 @@ def _visit(path, key, value, a, b) -> bool:
other_data_structure
) != len(iterutils.get_path(a, path)):
raise RuntimeError("len does not match")
if isinstance(other_data_structure, Mapping) and any(
other_data_structure.keys() ^ iterutils.get_path(a, path).keys()
):
raise RuntimeError("keys do not match")
if not _Eq_compare_nested._compare(value, other_value):
raise RuntimeError("not equal")
return True
Expand Down

0 comments on commit f2dcc43

Please sign in to comment.