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

Copy of Dictionary of DimArrays creates views #709

Closed
alex-s-gardner opened this issue May 6, 2024 · 2 comments
Closed

Copy of Dictionary of DimArrays creates views #709

alex-s-gardner opened this issue May 6, 2024 · 2 comments

Comments

@alex-s-gardner
Copy link
Contributor

This behaviour surprised me:

copy of DimArray preforms as expected:

A = DimArray(fill(NaN, length(x), length(y)), (x=x, y=y))
B = copy(A)
A[1, 1] #NaN
B[1,1] = 100.
A[1, 1] # NaN

copy of a Dictionary of DimArrays does not preform as expected:

# create a dictionary of DimArrays
A = Dict();
items = ["a", "b", "c"];
x = 1:10;
y = 1:10;
for item in items
    push!(A, item => DimArray(fill(NaN, length(x), length(y)), (x=x, y=y)))
end;

# copy A
B = copy(A);

A["a"][1,1] # NaN
B["a"][1, 1] = 100.0;
A["a"][1, 1] # 100.0
@rafaqz
Copy link
Owner

rafaqz commented May 6, 2024

You may be looking fo deepcopy ;)

This is what copy is meant to do.

@rafaqz rafaqz closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2024
@alex-s-gardner
Copy link
Contributor Author

I am indeed.. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants