Skip to content

Commit

Permalink
Rewrite newbyteorder() calls to be compatible with numpy 2.0.0 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswilburlewis committed Oct 17, 2024
1 parent c50ff14 commit 95dba0b
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions pytplot/importers/tplot_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ def tplot_restore(filename):
#Change from little endian to big endian, since pandas apparently hates little endian
#We might want to move this into the store_data procedure eventually
if (temp_x_data.dtype.byteorder == '>'):
temp_x_data = temp_x_data.byteswap().newbyteorder()
temp_x_data = temp_x_data.byteswap().view(temp_x_data.dtype.newbyteorder())
if (temp_y_data.dtype.byteorder == '>'):
temp_y_data = temp_y_data.byteswap().newbyteorder()
temp_y_data = temp_y_data.byteswap().view(temp_y_data.dtype.newbyteorder())
if (temp_v1_data.dtype.byteorder == '>'):
temp_v1_data = temp_v1_data.byteswap().newbyteorder()
temp_v1_data = temp_v1_data.byteswap().view(temp_v1_data.dtype.newbyteorder())
if (temp_v2_data.dtype.byteorder == '>'):
temp_v2_data = temp_v2_data.byteswap().newbyteorder()
temp_v2_data = temp_v2_data.byteswap().view(temp_v2_data.dtype.newbyteorder())
if (temp_v3_data.dtype.byteorder == '>'):
temp_v3_data = temp_v3_data.byteswap().newbyteorder()
temp_v3_data = temp_v3_data.byteswap().view(temp_v3_data.dtype.newbyteorder())

# support time-varying depends
if len(temp_v1_data.shape) == 2:
Expand All @@ -111,13 +111,13 @@ def tplot_restore(filename):
#Change from little endian to big endian, since pandas apparently hates little endian
#We might want to move this into the store_data procedure eventually
if (temp_x_data.dtype.byteorder == '>'):
temp_x_data = temp_x_data.byteswap().newbyteorder()
temp_x_data = temp_x_data.byteswap().view(temp_x_data.dtype.newbyteorder())
if (temp_y_data.dtype.byteorder == '>'):
temp_y_data = temp_y_data.byteswap().newbyteorder()
temp_y_data = temp_y_data.byteswap().view(temp_y_data.dtype.newbyteorder())
if (temp_v1_data.dtype.byteorder == '>'):
temp_v1_data = temp_v1_data.byteswap().newbyteorder()
temp_v1_data = temp_v1_data.byteswap().view(temp_v1_data.dtype.newbyteorder())
if (temp_v2_data.dtype.byteorder == '>'):
temp_v2_data = temp_v2_data.byteswap().newbyteorder()
temp_v2_data = temp_v2_data.byteswap().view(temp_v2_data.dtype.newbyteorder())

# support time-varying depends
if len(temp_v1_data.shape) == 2:
Expand All @@ -134,11 +134,11 @@ def tplot_restore(filename):
#Change from little endian to big endian, since pandas apparently hates little endian
#We might want to move this into the store_data procedure eventually
if (temp_x_data.dtype.byteorder == '>'):
temp_x_data = temp_x_data.byteswap().newbyteorder()
temp_x_data = temp_x_data.byteswap().view(temp_x_data.dtype.newbyteorder())
if (temp_y_data.dtype.byteorder == '>'):
temp_y_data = temp_y_data.byteswap().newbyteorder()
temp_y_data = temp_y_data.byteswap().view(temp_y_data.dtype.newbyteorder())
if (temp_v_data.dtype.byteorder == '>'):
temp_v_data = temp_v_data.byteswap().newbyteorder()
temp_v_data = temp_v_data.byteswap().view(temp_v_data.dtype.newbyteorder())

# support time-varying depends
if len(temp_v_data.shape) == 2:
Expand All @@ -149,9 +149,9 @@ def tplot_restore(filename):
#Change from little endian to big endian, since pandas apparently hates little endian
#We might want to move this into the store_data procedure eventually
if (temp_x_data.dtype.byteorder == '>'):
temp_x_data = temp_x_data.byteswap().newbyteorder()
temp_x_data = temp_x_data.byteswap().view(temp_x_data.dtype.newbyteorder())
if (temp_y_data.dtype.byteorder == '>'):
temp_y_data = temp_y_data.byteswap().newbyteorder()
temp_y_data = temp_y_data.byteswap().view(temp_y_data.dtype.newbyteorder())
store_data(data_name, data={'x':temp_x_data, 'y':temp_y_data})

if temp_tplot['dq'][i][3].dtype.names is not None:
Expand Down

0 comments on commit 95dba0b

Please sign in to comment.