Skip to content
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

Fix buffer assignment in compression.py #909

Merged
merged 3 commits into from
Jan 15, 2021

Conversation

eslavich
Copy link
Contributor

I missed that we were setting buffer[...] here and not buffer.data[...]! That's the real source of the problem. This is the difference between them:

In [10]: buffer = np.zeros((10,), np.uint8)
    ...: buffer.data[0:5] = b'12345'
    ...: buffer
Out[10]: array([49, 50, 51, 52, 53,  0,  0,  0,  0,  0], dtype=uint8)

In [11]: buffer = np.zeros((10,), np.uint8)
    ...: buffer[0:5] = b'12345'
    ...: buffer
Out[11]: array([57, 57, 57, 57, 57,  0,  0,  0,  0,  0], dtype=uint8)

(where 57 is 12345 % 2**8)

@eslavich eslavich added this to the 2.7.2 milestone Jan 15, 2021
Copy link
Contributor

@jdavies-st jdavies-st left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@eslavich eslavich merged commit 3719d6a into asdf-format:master Jan 15, 2021
@eslavich eslavich deleted the eslavich-better-compression-fix branch January 15, 2021 18:17
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