Skip to content

Offset is not updated when slicing memmaps #471

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

Closed
GaelVaroquaux opened this issue Sep 30, 2012 · 5 comments
Closed

Offset is not updated when slicing memmaps #471

GaelVaroquaux opened this issue Sep 30, 2012 · 5 comments
Labels
00 - Bug 57 - Close? Issues which may be closable unless discussion continued component: numpy._core

Comments

@GaelVaroquaux
Copy link
Contributor

>>> import numpy as np
>>> a = np.ones((10, 10))
>>> np.save('a.npy', a)
>>> b = np.load('a.npy', mmap_mode='r')
>>> c = b[3:]
>>> c.offset
80
>>> b.offset
80

The offset of c is wrong: it does not take in account the fact that the slicing has changed the offset.

@charris
Copy link
Member

charris commented Feb 16, 2014

Still true in 1.9-devel.

@Nodd
Copy link
Contributor

Nodd commented Feb 8, 2018

Still true in 1.14.0, but I think it's fine: in the code offset is the offset on the underlying mmap object in the file, it's normal that it doesn"t change in a view.
Otherwise what would the offset for d=b[9:5:-1] be ?
I think this issue should be closed.

@mattip
Copy link
Member

mattip commented Aug 8, 2018

@GaelVaroquaux do you agree the offset should remain unchanged?

@mattip mattip added 00 - Bug component: numpy._core 57 - Close? Issues which may be closable unless discussion continued labels Aug 8, 2018
@GaelVaroquaux
Copy link
Contributor Author

I don't know :).

@mattip
Copy link
Member

mattip commented Jan 16, 2019

Closing. offset is documented at the bottom of the link as "Offset position in the file". Perhaps that could be "Offset position in the underlying file" but I think it is good enough as-is.

@mattip mattip closed this as completed Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 57 - Close? Issues which may be closable unless discussion continued component: numpy._core
Projects
None yet
Development

No branches or pull requests

4 participants