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

Move to numpy 2+ #103

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
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
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
krzywon marked this conversation as resolved.
Show resolved Hide resolved

# 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