Skip to content

ENH: Make memmaps return arrays in ufuncs and fancy indexing#2932

Closed
seberg wants to merge 2 commits intonumpy:masterfrom
seberg:memmap-to-array
Closed

ENH: Make memmaps return arrays in ufuncs and fancy indexing#2932
seberg wants to merge 2 commits intonumpy:masterfrom
seberg:memmap-to-array

Conversation

@seberg
Copy link
Copy Markdown
Member

@seberg seberg commented Jan 18, 2013

A long while back when there was some discussion about memmaps, I wondered if this would not make sense... So putting it in a pull request. Of course if someone out there tries to access _mmap even though it does not actually have that attribute any more, that would result in an array like that, but I remember finding it annoying that memmap + 1 would print as memmap all the time...

This makes memmeps return an array instead of a memmap instance
for fancy indexing or ufuncs, etc. that use array_wrap and
array_prepare. The type is preserved for subclasses however.
Also copy is one example that still returns a memmap even if it
does not point to the same memory.

This makes memmeps return an array instead of a memmap instance
for fancy indexing or ufuncs, etc. that use __array_wrap__ and
__array_prepare__. The type is preserved for subclasses however.
Also copy is one example that still returns a memmap even if it
does not point to the same memory.
@teoliphant
Copy link
Copy Markdown
Member

This looks like a useful patch. There may be long-term ramifications that I don't personally see right now, but I suspect memmaps are not used a great deal because of usability issues like this patch seeks to improve.

@seberg
Copy link
Copy Markdown
Member Author

seberg commented Jan 22, 2013

Actually, had to just realize that this behaves different for subclasses that do not provide an __array_wrap__ method, because their finalize is then called with the array instance, instead of self. And I am not sure how to do an __array_wrap__ that acts like it is not there.

Need to call the underlying __array_*__ function to look exactly
the same to a class subclassing memmap. To make sure that multiply
inheritence would keep working exactly the same, need to do the
try/excepts. However __array_finalize__ does not really support
multiple inheritences well in any case.
@seberg
Copy link
Copy Markdown
Member Author

seberg commented Jan 22, 2013

I tweaked it, but honestly it gets a bit ugly to make sure there are no possible regressions for (possible weird) inheritance, so likely it is not worth the trouble...

@seberg
Copy link
Copy Markdown
Member Author

seberg commented Apr 1, 2013

I will close this, since I am not quite sure it is worth the trouble. But if anyone thinks so, please feel free to ping.

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

Successfully merging this pull request may close these issues.

2 participants