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

Use numpy>=2 #613

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ jobs:
python -m pip install --upgrade pip
python -m pip install wheel setuptools
python -m pip install mako
python -m pip install numpy==1.*
python -m pip install scipy matplotlib docutils pytest sphinx bumps unittest-xml-reporting tinycc
python -m pip install numpy scipy matplotlib docutils pytest sphinx bumps==0.* unittest-xml-reporting tinycc siphash24

- name: setup pyopencl on Linux + macOS
if: ${{ matrix.os != 'windows-latest' }}
Expand Down
2 changes: 1 addition & 1 deletion doc/guide/plugin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ value at a time::

Iq.vectorized = False

Return np.NaN if the parameters are not valid (e.g., cap_radius < radius in
Return np.nan if the parameters are not valid (e.g., cap_radius < radius in
barbell). If I(q; pars) is NaN for any $q$, then those parameters will be
ignored, and not included in the calculation of the weighted polydispersity.

Expand Down
4 changes: 2 additions & 2 deletions explore/realspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ def pad_vectors(boundary, *vectors):
if new_size > old_size:
new = np.empty(new_size, dtype=old.dtype)
new[:old_size] = old
new[old_size:] = np.NaN
new[old_size:] = np.nan
yield new
else:
yield old
Expand Down Expand Up @@ -1115,7 +1115,7 @@ def _sasmodels_Iqxy(kernel, qx, qy, pars, view):
# calculator avoids masked values; instead set masked values to NaN
result = np.empty_like(qx)
result[calculator.index] = Iqxy
result[~calculator.index] = np.NaN
result[~calculator.index] = np.nan
return result

def wrap_sasmodel(name, **pars):
Expand Down
6 changes: 3 additions & 3 deletions sasmodels/compare_many.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def try_model(fn, pars):
traceback.print_exc()
print("when comparing %s for %d"%(name, seed))
if hasattr(data, 'qx_data'):
result = np.NaN*data.data
result = np.nan*data.data
else:
result = np.NaN*data.x
result = np.nan*data.x
return result
def check_model(pars):
"""
Expand All @@ -165,7 +165,7 @@ def check_model(pars):
except Exception as exc:
#raise
print('"Error: %s"'%str(exc).replace('"', "'"))
print('"good","%d of %d","max diff",%g' % (0, N, np.NaN))
print('"good","%d of %d","max diff",%g' % (0, N, np.nan))
return
expected = max(PRECISION[base], PRECISION[comp])

Expand Down
6 changes: 3 additions & 3 deletions sasmodels/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def __init__(self, x=None, y=None, dx=None, dy=None):
self.y, self.dy = _as_numpy(y), _as_numpy(dy)
self.dxl = None
self.filename = None
self.qmin = self.x.min() if self.x is not None else np.NaN
self.qmax = self.x.max() if self.x is not None else np.NaN
self.qmin = self.x.min() if self.x is not None else np.nan
self.qmax = self.x.max() if self.x is not None else np.nan
# TODO: why is 1D mask False and 2D mask True?
self.mask = (np.isnan(y) if y is not None
else np.zeros_like(x, 'b') if x is not None
Expand Down Expand Up @@ -314,7 +314,7 @@ class Source(object):
"""
def __init__(self):
# type: () -> None
self.wavelength = np.NaN
self.wavelength = np.nan
self.wavelength_unit = "A"

class Sample(object):
Expand Down
4 changes: 2 additions & 2 deletions sasmodels/kernelpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ def _loops(parameters, form, form_volume, form_radius, nq, call_details,
weighted_form = 0.0
weighted_shell = 0.0
weighted_radius = 0.0
partial_weight = np.NaN
weight = np.NaN
partial_weight = np.nan
weight = np.nan

p0_par = call_details.pd_par[0]
p0_length = call_details.pd_length[0]
Expand Down
4 changes: 2 additions & 2 deletions sasmodels/modelinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def make_parameter_table(pars):
partable.check_angles(strict=True)
return partable

def parse_parameter(name, units='', default=np.NaN,
def parse_parameter(name, units='', default=np.nan,
user_limits=None, ptype='', description=''):
# type: (str, str, float, Sequence[Any], str, str) -> Parameter
"""
Expand Down Expand Up @@ -320,7 +320,7 @@ class Parameter(object):
parameter table is built using :func:`make_parameter_table` and
:func:`parse_parameter` therein.
"""
def __init__(self, name, units='', default=np.NaN, limits=(-np.inf, np.inf),
def __init__(self, name, units='', default=np.nan, limits=(-np.inf, np.inf),
ptype='', description=''):
# type: (str, str, float, Limits, str, str) -> None
self.id = name.split('[')[0].strip() # type: str
Expand Down
1 change: 1 addition & 0 deletions sasmodels/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@
:mod:`teubner_strey`
:mod:`two_lorentzian`
:mod:`unified_power_Rg`

"""
2 changes: 1 addition & 1 deletion sasmodels/models/spherical_sld.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
\end{cases}


Boucher[#Boucher1983]_:
Boucher [#Boucher1983]_:

.. math::

Expand Down
6 changes: 3 additions & 3 deletions sasmodels/sasview_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,9 @@ def getProfile(self):
if p.id == self.multiplicity_info.control:
value = float(self.multiplicity)
elif p.length == 1:
value = self.params.get(p.id, np.NaN)
value = self.params.get(p.id, np.nan)
else:
value = np.array([self.params.get(p.id+str(k), np.NaN)
value = np.array([self.params.get(p.id+str(k), np.nan)
for k in range(1, p.length+1)])
args[p.id] = value

Expand Down Expand Up @@ -841,7 +841,7 @@ def _get_weights(self, par):
else:
# For hidden parameters use default values. This sets
# scale=1 and background=0 for structure factors
default = self._model_info.parameters.defaults.get(par.name, np.NaN)
default = self._model_info.parameters.defaults.get(par.name, np.nan)
return default, [default], [1.0]
elif par.polydisperse:
value = self.params[par.name]
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def find_version(package):
return version[1:-1]
raise RuntimeError("Could not read version from %s/__init__.py"%package)

install_requires = ['numpy==1.*', 'scipy']
install_requires = ['numpy', 'scipy']

with open('README.rst') as fid:
long_description = fid.read()
Expand Down Expand Up @@ -70,8 +70,8 @@ def find_version(package):
},
install_requires=install_requires,
extras_require={
'full': ['docutils', 'bumps', 'matplotlib', 'columnize'],
'server': ['bumps'],
'full': ['docutils', 'bumps==0.*', 'matplotlib', 'columnize', 'siphash24'],
'server': ['bumps==0.*'],
'OpenCL': ["pyopencl"],
'CUDA': ["pycuda"],
},
Expand Down
Loading