I have a large matrix of data that I wish to create hundreds of views from. These views help me with setindexing and actually using my data in the program. This works perfectly for me, especially if I want to deepcopy to make different versions of the matrix.
However, when using the Serialization package, I notice that the views are decoupled pointers to the actual matrix ie. the views no longer update the matrix with setindex. Here is a minimal example:
# Make matrix and views x = rand(100, 100) xv = [view(x, i, :) for i in axes(x, 1)] # Struct to hold views and data together struct test x xv end mytest = test(x, xv) # Example of updating, works! setindex!(mytest.xv, 1:100, :) using Serialization # Save and load to new struct serialize("myteststruct", mytest) myload = deserialize("myteststruct") # Example of updating, decoupled! setindex!(myload.xv, 101:200, :)
Is this intended or something easy that I’m missing. Didn’t really see any topics on this. Any help would be appreciated.