You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How many times does MaskedColumn need to be finalized? #6721
Initialization (2 times): relatively easy: get one call from the creation of a BaseColumn instance (specifically, the self_data.view(cls) call), and then another in the creation of a MaskedArray instance. I think this is unavoidable in the current designs of BaseColumn and MaskedArray.
Slicing (3 times): the main problem is that .data returns a masked_BaseColumn - i.e., the masked array still knows that it is holding Column data, when really this should be a plain MaskedArray. This accounts for the 2 extraneous instances.
repr (2 times): again, the problem is that .data returns a masked_BaseColumn.
More generally, the problems seem to arise from both Column and MaskedArray essentially being container classes, and MaskedArray effectively insisting it is the "outer container". Possibly, things would be easier by rewriting with a different sub-class order, i.e., MaskedColumn(MaskedArray, Column). Sadly, that is a bit more involved than I have time for right now...
@himanshupathak21061998 - not sure what to add to my comment above. I'd just start with making the same changes as I did and then checking it indeed reduces the number of times __array_finalize__ gets called.
Note that for this issue ypu will need to understand how ndarray subclasses and MaskedArray work; without that, it may be tricky, though numpy has decent documentation about subclasses.
Activity
mhvk commentedon Oct 13, 2017
Just trying to work out what happens...
BaseColumninstance (specifically, theself_data.view(cls)call), and then another in the creation of aMaskedArrayinstance. I think this is unavoidable in the current designs ofBaseColumnandMaskedArray..datareturns amasked_BaseColumn- i.e., the masked array still knows that it is holdingColumndata, when really this should be a plainMaskedArray. This accounts for the 2 extraneous instances.repr(2 times): again, the problem is that.datareturns amasked_BaseColumn.I can resolve 2 & 3 by temporarily setting
self._baseclass = np.ndarrayinself.data-- see https://github.com/astropy/astropy/compare/master...mhvk:table-masked-column-array-finalize?expand=1 -- I also tried doing this in__new__, but that causes problems with properties not always propagating (might work with an adjusted shim, not sure).More generally, the problems seem to arise from both
ColumnandMaskedArrayessentially being container classes, andMaskedArrayeffectively insisting it is the "outer container". Possibly, things would be easier by rewriting with a different sub-class order, i.e.,MaskedColumn(MaskedArray, Column). Sadly, that is a bit more involved than I have time for right now...geekypathak21 commentedon May 30, 2019
@mhvk can you please elaborate a bit more about. How should I rewrite
MaskedColumn()? To resolve this.mhvk commentedon May 30, 2019
@himanshupathak21061998 - not sure what to add to my comment above. I'd just start with making the same changes as I did and then checking it indeed reduces the number of times
__array_finalize__gets called.Note that for this issue ypu will need to understand how
ndarraysubclasses andMaskedArraywork; without that, it may be tricky, though numpy has decent documentation about subclasses.geekypathak21 commentedon May 30, 2019
Ok, I will try to work on this. Thanks