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

deep/shallow copy metadata #2779

Merged
merged 5 commits into from
Jun 15, 2022
Merged

deep/shallow copy metadata #2779

merged 5 commits into from
Jun 15, 2022

Conversation

akaszynski
Copy link
Member

Problem

As pointed out in this comment, metadata is always shallow copied (or not at all) when copying datasets:

>>> import numpy as np
>>> import pyvista as pv
>>> sphere_a = pv.Sphere()
>>> sphere_a['data0'] = np.random.random((sphere_a.n_points, 3))

>>> sphere_b = sphere_a.copy(deep=True)
>>> sphere_a._active_scalars_info is sphere_b._active_scalars_info
True

This should be False.

On the other hand, the textures themselves are always shallow copied, but a new set is created, being neither a shallow or deep copy.

Solution

This PR cleans up copy_meta_from and cleans up the implementation to either perform a true "deep copy" or "shallow copy" depending on the deep parameter.

@github-actions github-actions bot added the bug Uh-oh! Something isn't working as expected. label Jun 13, 2022
@codecov
Copy link

codecov bot commented Jun 13, 2022

Codecov Report

Merging #2779 (bd79d13) into main (d5c89f1) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2779      +/-   ##
==========================================
+ Coverage   93.86%   93.88%   +0.01%     
==========================================
  Files          76       76              
  Lines       16230    16265      +35     
==========================================
+ Hits        15235    15270      +35     
  Misses        995      995              

pyvista/core/dataset.py Outdated Show resolved Hide resolved
pyvista/core/filters/__init__.py Outdated Show resolved Hide resolved
pyvista/core/dataset.py Outdated Show resolved Hide resolved
tests/test_dataset.py Show resolved Hide resolved
tests/test_dataset.py Outdated Show resolved Hide resolved
@adeak
Copy link
Member

adeak commented Jun 13, 2022

CI failure is unrelated, due to an ongoing "incident" with GitHub Actions Cache.

Copy link
Member

@adeak adeak left a comment

Choose a reason for hiding this comment

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

LGTM!

@akaszynski akaszynski merged commit b4abf24 into main Jun 15, 2022
@akaszynski akaszynski deleted the fix/metadata_copy branch June 15, 2022 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh-oh! Something isn't working as expected.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants