Skip to content

Commit

Permalink
Merge pull request #103 from SasView/numpy-latest
Browse files Browse the repository at this point in the history
Move to numpy 2+
  • Loading branch information
krzywon authored Dec 3, 2024
2 parents 0efca66 + 3d15031 commit ff06923
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ h5py
lxml

# Calculation
numpy==1.*
numpy

# Unit testing
pytest
Expand Down
8 changes: 4 additions & 4 deletions sasdata/data_util/formatnum.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ def test_compact():
# non-finite values
assert value_str(-np.inf,None) == "-inf"
assert value_str(np.inf,None) == "inf"
assert value_str(np.NaN,None) == "NaN"
assert value_str(np.nan,None) == "NaN"

# bad or missing uncertainty
assert value_str(-1.23567,np.NaN) == "-1.23567"
assert value_str(-1.23567,np.nan) == "-1.23567"
assert value_str(-1.23567,-np.inf) == "-1.23567"
assert value_str(-1.23567,-0.1) == "-1.23567"
assert value_str(-1.23567,0) == "-1.23567"
Expand Down Expand Up @@ -409,10 +409,10 @@ def test_pm():
# non-finite values
assert value_str(-np.inf,None) == "-inf"
assert value_str(np.inf,None) == "inf"
assert value_str(np.NaN,None) == "NaN"
assert value_str(np.nan,None) == "NaN"

# bad or missing uncertainty
assert value_str(-1.23567,np.NaN) == "-1.23567"
assert value_str(-1.23567,np.nan) == "-1.23567"
assert value_str(-1.23567,-np.inf) == "-1.23567"
assert value_str(-1.23567,-0.1) == "-1.23567"
assert value_str(-1.23567,0) == "-1.23567"
Expand Down
10 changes: 5 additions & 5 deletions sasdata/file_converter/nxcansas_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _h5_string(string):
elif not isinstance(string, str):
string = str(string)

return np.array([np.string_(string)])
return np.array([np.bytes_(string)])

def _write_h5_string(entry, value, key):
entry[key] = _h5_string(value)
Expand Down Expand Up @@ -143,7 +143,7 @@ def _write_h5_vector(entry, vector, names=['x_position', 'y_position'],
and data_info.sample.details != []:
details = None
if len(data_info.sample.details) > 1:
details = [np.string_(d) for d in data_info.sample.details]
details = [np.bytes_(d) for d in data_info.sample.details]
details = np.array(details)
elif data_info.sample.details != []:
details = _h5_string(data_info.sample.details[0])
Expand Down Expand Up @@ -288,13 +288,13 @@ def _write_h5_vector(entry, vector, names=['x_position', 'y_position'],

if np.isscalar(data_info.notes) and data_info.notes:
# Handle scalars that aren't empty arrays, None, '', etc.
notes = [np.string_(data_info.notes)]
notes = [np.bytes_(data_info.notes)]
elif len(data_info.notes) > 1:
# Handle iterables that aren't empty
notes = [np.string_(n) for n in data_info.notes]
notes = [np.bytes_(n) for n in data_info.notes]
else:
# Notes are required in NXcanSAS format
notes = [np.string_('')]
notes = [np.bytes_('')]
if notes is not None:
for i, note in enumerate(notes):
note_entry = sasentry.create_group('sasnote{0}'.format(i))
Expand Down

0 comments on commit ff06923

Please sign in to comment.