Repository navigation
Fix repeated slicing causing missing uns, AttributeError - #133
Conversation
Codecov Report
@@ Coverage Diff @@
## master #133 +/- ##
==========================================
+ Coverage 73.57% 73.61% +0.03%
==========================================
Files 11 11
Lines 2006 2009 +3
==========================================
+ Hits 1476 1479 +3
Misses 530 530
Continue to review full report at Codecov.
|
|
Interesting and thank you! It should definitely make the current way of dealing with Thanks again! |
|
PS: We could drop the |
|
Is this ready to go? I don't totally follow the suggestion about dropping the |
|
Oh sorry, I wanted to merge this ages ago... Thank you! 😄 |
Fixes #77
Minimal repro of
AttributeError(before this fix)Stack trace
Reasons for the AttributeError
Three things combined to cause a slice of a slice of a slice to crash:
Views can't be
deepcopy'd:__setitem__calls_init_actual_AnnDatacallsisbacked→filename→filefileisn't set whiledeepcopyis iterating through KVs calling__setitem__.I considered just checking whether
filewas set yet when accessingfilename, but this is not a very robust solution. This deepcopy problem was causing other issues (for example,unson a slice of a slice was erroneously empty), and was liable to affect lots of fields._unsgetsdeepcopy'd when making a viewcode:
On views,
_unsholds a reference to its enclosing AnnDatacode:
Fix
I resolved this problem by overriding
_ViewMixin.__deepcopy__to make adeepcopyof [the view's parent AnnData]'s copy of the field in question.I think this should make things strictly more robust (as opposed to this being a hack to just make things work), but if it may break other assumptions lmk.