Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spatial_data to csm serialization #364

Merged
merged 15 commits into from
Jun 22, 2021

Conversation

vhirtham
Copy link
Collaborator

@vhirtham vhirtham commented Jun 8, 2021

Changes

The data that is stored in the CSM is now also written to the asdf file.

Related Issues

Closes #348

Checks

  • updated CHANGELOG.md
  • updated tests
  • updated doc/
  • update example/tutorial notebooks

@vhirtham vhirtham added ASDF everything ASDF related (python + schemas) transformations everything related to the LCS / CSM labels Jun 8, 2021
@vhirtham vhirtham self-assigned this Jun 8, 2021
@codecov
Copy link

codecov bot commented Jun 8, 2021

Codecov Report

Merging #364 (ba5cd4f) into master (a98a4bd) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #364      +/-   ##
==========================================
+ Coverage   97.56%   97.60%   +0.04%     
==========================================
  Files          86       86              
  Lines        5376     5385       +9     
==========================================
+ Hits         5245     5256      +11     
+ Misses        131      129       -2     
Impacted Files Coverage Δ
weldx/transformations/cs_manager.py 98.89% <ø> (ø)
...eldx/asdf/tags/weldx/core/geometry/spatial_data.py 100.00% <100.00%> (ø)
...ore/transformations/coordinate_system_hierarchy.py 100.00% <100.00%> (ø)
weldx/util.py 98.74% <0.00%> (+0.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a98a4bd...ba5cd4f. Read the comment docs.

@vhirtham vhirtham marked this pull request as ready for review June 9, 2021 12:34
@CagtayFabry CagtayFabry self-requested a review June 18, 2021 11:55
@pep8speaks
Copy link

pep8speaks commented Jun 18, 2021

Hello @vhirtham! Thanks for updating this PR.

Line 469:26: E231 missing whitespace after ':'
Line 469:26: E999 SyntaxError: invalid syntax
Line 469:28: E251 unexpected spaces around keyword / parameter equals

Comment last updated at 2021-06-22 09:34:23 UTC

Copy link
Member

@CagtayFabry CagtayFabry left a comment

Choose a reason for hiding this comment

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

asdf implementation LGTM 👍 (should be even easier once switching to graph backend for serialization)

I think it's a good time to implement __eq__ for SpatialData

weldx/geometry.py Outdated Show resolved Hide resolved
Comment on lines 447 to 449
assert np.allclose(sd.coordinates.data, sd_buffer.coordinates.data)
if sd.triangles is not None:
assert np.allclose(np.array(sd.triangles), np.array(sd_buffer.triangles))
Copy link
Member

Choose a reason for hiding this comment

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

use == here once implemented

Copy link
Collaborator Author

@vhirtham vhirtham Jun 21, 2021

Choose a reason for hiding this comment

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

Doesn't compare equal:

SpatialData(coordinates=<xarray.DataArray 'core/ndarray' (n: 2, c: 3)>
vs.
SpatialData(coordinates=<xarray.DataArray (n: 2, c: 3)>

The data seems to be equal, but since compare nested is using xarrays identical function, we get a False returned.
I remember that we had trouble with the identical function before because it also considers the order of dimensions, coordinates etc. Alternatively, we can use equals for a more relaxed comparison but I am not sure if this is really what we want.

Copy link
Member

Choose a reason for hiding this comment

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

I think this happens because of the .name property that get's created when reading arrays from asdf files (due to NDArrayType wrapper)

see #110 and a possible workaround (reading explicitly as np.asarray from tree here 1dd1f23)

maybe we should ask for a solution over at asdf

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll try the workaround for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Works now. Think we can merge

@vhirtham vhirtham requested a review from CagtayFabry June 21, 2021 12:55
@vhirtham vhirtham merged commit f1cebd2 into BAMWelDX:master Jun 22, 2021
@vhirtham vhirtham deleted the 348_csm_spatial_data branch June 22, 2021 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASDF everything ASDF related (python + schemas) transformations everything related to the LCS / CSM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSM SpatialData serialization
3 participants