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

sys.big_endian to sys.byteorder #3422

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions contrib/vecs_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

def ivecs_read(fname):
a = np.fromfile(fname, dtype='int32')
if sys.big_endian:
if sys.byteorder == 'big':
a.byteswap(inplace=True)
d = a[0]
return a.reshape(-1, d + 1)[:, 1:].copy()
Expand All @@ -25,7 +25,7 @@ def fvecs_read(fname):


def ivecs_mmap(fname):
assert not sys.big_endian
assert sys.byteorder != 'big'
a = np.memmap(fname, dtype='int32', mode='r')
d = a[0]
return a.reshape(-1, d + 1)[:, 1:]
Expand All @@ -37,7 +37,7 @@ def fvecs_mmap(fname):

def bvecs_mmap(fname):
x = np.memmap(fname, dtype='uint8', mode='r')
if sys.big_endian:
if sys.byteorder == 'big':
da = x[:4][::-1].copy()
d = da.view('int32')[0]
else:
Expand All @@ -50,7 +50,7 @@ def ivecs_write(fname, m):
m1 = np.empty((n, d + 1), dtype='int32')
m1[:, 0] = d
m1[:, 1:] = m
if sys.big_endian:
if sys.byteorder == 'big':
m1.byteswap(inplace=True)
m1.tofile(fname)

Expand Down