Skip to content

Commit eff86e7

Browse files
hagenwfs446
andauthored
Replace Python 3.6, 3.7 with 3.9, 3.10 (#180)
* Replace Python 3.6, 3.7 with 3.9, 3.10 * Fix definition of Python version * Try to fix readthedocs config * Fix Python version in readthedocs config * Replace removed inner1d * Try changes from #179 * Fix remaining inner1d errors * Fix ptp() error * Don't limit numpy version * Fix _np import * Try to fix readthedocs config * Update test.yml * Update test.yml check with ubuntu only, current python only * Update test.yml redo * Update test.yml redo2 * Update test.yml go for 3.11, 3.12 there is still some code that is not working, but we merged into the main branch, such that most of the toolbox can be used out of the main branch --------- Co-authored-by: Frank Schultz <[email protected]>
1 parent 043e9dd commit eff86e7

File tree

8 files changed

+45
-45
lines changed

8 files changed

+45
-45
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, macOS-latest, windows-latest]
12-
python-version: [3.6, 3.7, 3.8]
13-
12+
python-version: ['3.11', '3.12']
13+
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1616
- name: Set up Python ${{ matrix.python-version }}
17-
uses: actions/setup-python@v2
17+
uses: actions/setup-python@v5
1818
with:
1919
python-version: ${{ matrix.python-version }}
2020
- name: Prepare Ubuntu

doc/readthedocs-environment.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

readthedocs.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
conda:
2-
file: doc/readthedocs-environment.yml
1+
version: 2
2+
3+
build:
4+
os: ubuntu-22.04
5+
tools:
6+
python: "3.8"
7+
38
python:
4-
pip_install: true
9+
install:
10+
- requirements: requirements.txt
11+
- requirements: doc/requirements.txt

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
version=__version__,
1414
packages=find_packages(),
1515
install_requires=[
16-
'numpy!=1.11.0', # https://github.com/sfstoolbox/sfs-python/issues/11
16+
'numpy',
1717
'scipy',
1818
],
1919
author="SFS Toolbox Developers",
@@ -31,8 +31,9 @@
3131
"Operating System :: OS Independent",
3232
"Programming Language :: Python",
3333
"Programming Language :: Python :: 3",
34-
"Programming Language :: Python :: 3.6",
35-
"Programming Language :: Python :: 3.7",
34+
"Programming Language :: Python :: 3.8",
35+
"Programming Language :: Python :: 3.9",
36+
"Programming Language :: Python :: 3.10",
3637
"Programming Language :: Python :: 3 :: Only",
3738
"Topic :: Scientific/Engineering",
3839
],

sfs/fd/wfs.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def plot(d, selection, secondary_source):
3232
3333
"""
3434
import numpy as _np
35-
from numpy.core.umath_tests import inner1d as _inner1d
3635
from scipy.special import hankel2 as _hankel2
3736

3837
from . import secondary_source_line as _secondary_source_line
@@ -91,7 +90,7 @@ def line_2d(omega, x0, n0, xs, *, c=None):
9190
k = _util.wavenumber(omega, c)
9291
ds = x0 - xs
9392
r = _np.linalg.norm(ds, axis=1)
94-
d = -1j/2 * k * _inner1d(ds, n0) / r * _hankel2(1, k * r)
93+
d = -1j/2 * k * _util._inner1d(ds, n0) / r * _hankel2(1, k * r)
9594
selection = _util.source_selection_line(n0, x0, xs)
9695
return d, selection, _secondary_source_line(omega, c)
9796

@@ -147,7 +146,7 @@ def _point(omega, x0, n0, xs, *, c=None):
147146
k = _util.wavenumber(omega, c)
148147
ds = x0 - xs
149148
r = _np.linalg.norm(ds, axis=1)
150-
d = 1j * k * _inner1d(ds, n0) / r ** (3 / 2) * _np.exp(-1j * k * r)
149+
d = 1j * k * _util._inner1d(ds, n0) / r ** (3 / 2) * _np.exp(-1j * k * r)
151150
selection = _util.source_selection_point(n0, x0, xs)
152151
return d, selection, _secondary_source_point(omega, c)
153152

@@ -234,7 +233,7 @@ def point_25d(omega, x0, n0, xs, xref=[0, 0, 0], c=None, omalias=None):
234233
preeq_25d(omega, omalias, c) *
235234
_np.sqrt(8 * _np.pi) *
236235
_np.sqrt((r * s) / (r + s)) *
237-
_inner1d(n0, ds) / s *
236+
_util._inner1d(n0, ds) / s *
238237
_np.exp(-1j * k * s) / (4 * _np.pi * s))
239238
selection = _util.source_selection_point(n0, x0, xs)
240239
return d, selection, _secondary_source_point(omega, c)
@@ -316,7 +315,7 @@ def point_25d_legacy(omega, x0, n0, xs, xref=[0, 0, 0], c=None, omalias=None):
316315
r = _np.linalg.norm(ds, axis=1)
317316
d = (
318317
preeq_25d(omega, omalias, c) *
319-
_np.sqrt(_np.linalg.norm(xref - x0)) * _inner1d(ds, n0) /
318+
_np.sqrt(_np.linalg.norm(xref - x0)) * _util._inner1d(ds, n0) /
320319
r ** (3 / 2) * _np.exp(-1j * k * r))
321320
selection = _util.source_selection_point(n0, x0, xs)
322321
return d, selection, _secondary_source_point(omega, c)
@@ -499,7 +498,7 @@ def _focused(omega, x0, n0, xs, ns, *, c=None):
499498
k = _util.wavenumber(omega, c)
500499
ds = x0 - xs
501500
r = _np.linalg.norm(ds, axis=1)
502-
d = 1j * k * _inner1d(ds, n0) / r ** (3 / 2) * _np.exp(1j * k * r)
501+
d = 1j * k * _util._inner1d(ds, n0) / r ** (3 / 2) * _np.exp(1j * k * r)
503502
selection = _util.source_selection_focused(ns, x0, xs)
504503
return d, selection, _secondary_source_point(omega, c)
505504

@@ -569,7 +568,7 @@ def focused_25d(omega, x0, n0, xs, ns, *, xref=[0, 0, 0], c=None,
569568
r = _np.linalg.norm(ds, axis=1)
570569
d = (
571570
preeq_25d(omega, omalias, c) *
572-
_np.sqrt(_np.linalg.norm(xref - x0)) * _inner1d(ds, n0) /
571+
_np.sqrt(_np.linalg.norm(xref - x0)) * _util._inner1d(ds, n0) /
573572
r ** (3 / 2) * _np.exp(1j * k * r))
574573
selection = _util.source_selection_focused(ns, x0, xs)
575574
return d, selection, _secondary_source_point(omega, c)

sfs/plot2d.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ def _register_cmap_clip(name, original_cmap, alpha):
1818
cmap = LinearSegmentedColormap.from_list(name, cdata)
1919
cmap.set_over([alpha * c + 1 - alpha for c in cmap(1.0)[:3]])
2020
cmap.set_under([alpha * c + 1 - alpha for c in cmap(0.0)[:3]])
21-
_plt.cm.register_cmap(cmap=cmap)
21+
_plt.colormaps.register(cmap=cmap)
2222

2323

2424
# The 'coolwarm' colormap is based on the paper
2525
# "Diverging Color Maps for Scientific Visualization" by Kenneth Moreland
2626
# http://www.sandia.gov/~kmorel/documents/ColorMaps/
27-
_register_cmap_clip('coolwarm_clip', 'coolwarm', 0.7)
27+
# already registered in MPL 3.9.0
28+
try:
29+
_register_cmap_clip('coolwarm_clip', 'coolwarm', 0.7)
30+
except ImportError:
31+
pass
2832

2933

3034
def _register_cmap_transparent(name, color):
@@ -36,7 +40,7 @@ def _register_cmap_transparent(name, color):
3640
'blue': ((0, blue, blue), (1, blue, blue)),
3741
'alpha': ((0, 0, 0), (1, 1, 1))}
3842
cmap = LinearSegmentedColormap(name, cdict)
39-
_plt.cm.register_cmap(cmap=cmap)
43+
_plt.colormaps.register(cmap=cmap)
4044

4145

4246
_register_cmap_transparent('blacktransparent', 'black')
@@ -285,8 +289,8 @@ def amplitude(p, grid, *, xnorm=None, cmap='coolwarm_clip',
285289
elif plotting_plane == 'yz':
286290
x, y = grid[[1, 2]]
287291

288-
dx = 0.5 * x.ptp() / p.shape[0]
289-
dy = 0.5 * y.ptp() / p.shape[1]
292+
dx = 0.5 * _np.ptp(x) / p.shape[0]
293+
dy = 0.5 * _np.ptp(y) / p.shape[1]
290294

291295
if ax is None:
292296
ax = _plt.gca()

sfs/td/wfs.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def plot(d, selection, secondary_source, t=0):
4444
4545
"""
4646
import numpy as _np
47-
from numpy.core.umath_tests import inner1d as _inner1d
4847

4948
from . import apply_delays as _apply_delays
5049
from . import secondary_source_point as _secondary_source_point
@@ -119,8 +118,8 @@ def plane_25d(x0, n0, n=[0, 1, 0], xref=[0, 0, 0], c=None):
119118
n = _util.normalize_vector(n)
120119
xref = _util.asarray_1d(xref)
121120
g0 = _np.sqrt(2 * _np.pi * _np.linalg.norm(xref - x0, axis=1))
122-
delays = _inner1d(n, x0) / c
123-
weights = 2 * g0 * _inner1d(n, n0)
121+
delays = _util._inner1d(n, x0) / c
122+
weights = 2 * g0 * _util._inner1d(n, n0)
124123
selection = _util.source_selection_plane(n0, n)
125124
return delays, weights, selection, _secondary_source_point(c)
126125

@@ -208,7 +207,7 @@ def point_25d(x0, n0, xs, xref=[0, 0, 0], c=None):
208207
g0 *= _np.sqrt((x0xs_n*x0xref_n)/(x0xs_n+x0xref_n))
209208

210209
delays = x0xs_n/c
211-
weights = g0*_inner1d(x0xs, n0)
210+
weights = g0 * _util._inner1d(x0xs, n0)
212211
selection = _util.source_selection_point(n0, x0, xs)
213212
return delays, weights, selection, _secondary_source_point(c)
214213

@@ -296,7 +295,7 @@ def point_25d_legacy(x0, n0, xs, xref=[0, 0, 0], c=None):
296295
ds = x0 - xs
297296
r = _np.linalg.norm(ds, axis=1)
298297
delays = r/c
299-
weights = g0 * _inner1d(ds, n0) / (2 * _np.pi * r**(3/2))
298+
weights = g0 * _util._inner1d(ds, n0) / (2 * _np.pi * r**(3/2))
300299
selection = _util.source_selection_point(n0, x0, xs)
301300
return delays, weights, selection, _secondary_source_point(c)
302301

@@ -379,7 +378,7 @@ def focused_25d(x0, n0, xs, ns, xref=[0, 0, 0], c=None):
379378
g0 = _np.sqrt(_np.linalg.norm(xref - x0, axis=1)
380379
/ (_np.linalg.norm(xref - x0, axis=1) + r))
381380
delays = -r/c
382-
weights = g0 * _inner1d(ds, n0) / (2 * _np.pi * r**(3/2))
381+
weights = g0 * _util._inner1d(ds, n0) / (2 * _np.pi * r**(3/2))
383382
selection = _util.source_selection_focused(ns, x0, xs)
384383
return delays, weights, selection, _secondary_source_point(c)
385384

sfs/util.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import collections
88
import numpy as np
9-
from numpy.core.umath_tests import inner1d
109
from scipy.special import spherical_jn, spherical_yn
1110
from . import default
1211

@@ -576,7 +575,7 @@ def source_selection_point(n0, x0, xs):
576575
x0 = asarray_of_rows(x0)
577576
xs = asarray_1d(xs)
578577
ds = x0 - xs
579-
return inner1d(ds, n0) >= default.selection_tolerance
578+
return _inner1d(ds, n0) >= default.selection_tolerance
580579

581580

582581
def source_selection_line(n0, x0, xs):
@@ -598,7 +597,7 @@ def source_selection_focused(ns, x0, xs):
598597
xs = asarray_1d(xs)
599598
ns = normalize_vector(ns)
600599
ds = xs - x0
601-
return inner1d(ns, ds) >= default.selection_tolerance
600+
return _inner1d(ns, ds) >= default.selection_tolerance
602601

603602

604603
def source_selection_all(N):
@@ -646,3 +645,8 @@ def max_order_spherical_harmonics(N):
646645
647646
"""
648647
return int(np.sqrt(N) - 1)
648+
649+
650+
def _inner1d(arr1, arr2):
651+
# https://github.com/numpy/numpy/issues/10815#issuecomment-376847774
652+
return (arr1 * arr2).sum(axis=1)

0 commit comments

Comments
 (0)