Skip to content

Commit 65baf4c

Browse files
authored
Merge pull request #268 from ContactEngineering/22_sur_reader_height_scale_factor
BUG: SUR reader reported wrong `height_scale_factor` in channel info
2 parents 6f42e82 + 12fb51d commit 65baf4c

File tree

10 files changed

+31
-21
lines changed

10 files changed

+31
-21
lines changed

.github/workflows/flake8.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
1921

2022
- name: Set up python3 ${{ matrix.python-version }}
21-
uses: actions/setup-python@v2
23+
uses: actions/setup-python@v4
2224
with:
2325
python-version: ${{ matrix.python-version }}
2426

2527
- name: Install dependencies
2628
run: |
2729
sudo apt-get update -qy
28-
sudo apt-get install -y python3-dev python3-pip libfftw3-dev libopenblas-dev
30+
sudo apt-get install -y python3-dev python3-pip libfftw3-dev libopenblas-dev meson
2931
3032
- name: Build extension module
3133
run: |
32-
python3 -m pip install --no-binary numpy ".[test]"
34+
python3 -m pip install ".[test]"
3335
3436
- name: Flake8 via pytest
3537
run: |

.github/workflows/test-code-functionality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
fetch-depth: 0
3030

3131
- name: Set up python3 ${{ matrix.python-version }}
32-
uses: actions/setup-python@v2
32+
uses: actions/setup-python@v4
3333
with:
3434
python-version: ${{ matrix.python-version }}
3535

SurfaceTopography/ChangeLog.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
Change log for SurfaceTopography
2-
=============================
2+
================================
33

4-
v1.2.6 (not yet released)
5-
-------------------------
4+
v1.2.6 (29Dec22)
5+
----------------
66

7+
- BUG: SUR reader reported wrong `height_scale_factor` in channel info
78
- BUILD: Yet another fix for version discovery when installing from source
89
package
910

SurfaceTopography/Generation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,13 @@ def fourier_synthesis(nb_grid_pts, physical_sizes,
263263

264264
# Create in-memory or memory-mapped arrays as storage buffers
265265
if rfn is None:
266-
rarr = np.empty(nb_grid_pts, dtype=np.float64)
266+
rarr = np.empty(nb_grid_pts, dtype=float)
267267
else:
268-
rarr = np.memmap(rfn, np.float64, 'w+', shape=nb_grid_pts)
268+
rarr = np.memmap(rfn, float, 'w+', shape=nb_grid_pts)
269269
if kfn is None:
270-
karr = np.empty(kshape, dtype=np.complex128)
270+
karr = np.empty(kshape, dtype=complex)
271271
else:
272-
karr = np.memmap(kfn, np.complex128, 'w+', shape=kshape)
272+
karr = np.memmap(kfn, complex, 'w+', shape=kshape)
273273

274274
qy = 2 * np.pi * np.arange(kny) / sy
275275
for x in range(nx):

SurfaceTopography/IO/SUR.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def channels(self):
179179
dim=2,
180180
nb_grid_pts=self._nb_grid_pts,
181181
physical_sizes=self._physical_sizes,
182+
height_scale_factor=float(self._header['height_scale_factor']),
182183
uniform=True,
183184
unit=self._unit)]
184185

SurfaceTopography/Nonuniform/PowerSpectrum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def power_spectrum(self, reliable=True, algorithm='fft', wavevectors=None, nb_in
191191
L = x[-1] - x[0]
192192
if wavevectors is None:
193193
wavevectors = 2 * np.pi * np.arange(int(L / np.diff(x).min())) / L
194-
y_q = np.zeros_like(wavevectors, dtype=np.complex128)
194+
y_q = np.zeros_like(wavevectors, dtype=complex)
195195
for x1, x2, y1, y2 in zip(x[:-1], x[1:], y[:-1], y[1:]):
196196
dx = x2 - x1
197197
if dx > 0:

SurfaceTopography/Uniform/Filtering.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ def heights(self):
199199
nx, ny = self.parent_topography.nb_grid_pts
200200
sx, sy = self.parent_topography.physical_sizes
201201

202-
qx = np.arange(0, nx, dtype=np.float64).reshape(-1, 1)
202+
qx = np.arange(0, nx, dtype=float).reshape(-1, 1)
203203
qx = np.where(qx <= nx // 2, qx / sx, (qx - nx) / sx)
204204
qx *= 2 * np.pi
205205

206-
qy = np.arange(0, ny // 2 + 1, dtype=np.float64).reshape(1, -1)
206+
qy = np.arange(0, ny // 2 + 1, dtype=float).reshape(1, -1)
207207
qy *= 2 * np.pi / sy
208208

209209
if self.is_filter_isotropic:

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["meson>=0.46.0", "meson-python>=0.11.0", "ninja", "numpy"]
2+
requires = ["meson>=0.46.0", "meson-python>=0.11.0", "ninja", "numpy<1.24.0"]
33
build-backend = "mesonpy"
44

55
[project]
@@ -19,7 +19,7 @@ dynamic = [ "version" ]
1919
dependencies = [
2020
"defusedxml",
2121
"h5py",
22-
"igor",
22+
"igor", # FIXME! Igor no longer works with numpy 1.24.0 or later
2323
"matplotlib>=1.0.0",
2424
"muFFT>=0.24.0",
2525
"NuMPI>=0.3.1",
@@ -31,7 +31,7 @@ dependencies = [
3131
"requests",
3232
"scipy",
3333
"tiffile",
34-
"numpy"
34+
"numpy<1.24.0"
3535
]
3636

3737
[project.optional-dependencies]

test/IO/test_io.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def _convert_filelist(filelist):
9898
'example.vk3',
9999
'example.vk4',
100100
'example.vk6',
101+
'example.sur',
101102
'mitutoyo_mock.xlsx',
102103
'mitutoyo_nonuniform_mock.xlsx',
103104
'example_ps.tiff',
@@ -339,7 +340,7 @@ def test_nb_grid_pts_and_physical_sizes_are_tuples_or_none(fn):
339340

340341
@pytest.mark.parametrize('fn', text_example_file_list + text_example_without_size_file_list + binary_example_file_list +
341342
binary_without_stream_support_example_file_list)
342-
def test_reader_topography_same(fn):
343+
def test_channel_info_and_topography_have_same_metadata(fn):
343344
"""
344345
Tests that properties like physical sizes, units and nb_grid_pts are
345346
the same in the ChannelInfo and the loaded topography.
@@ -366,8 +367,10 @@ def test_reader_topography_same(fn):
366367
if channel.physical_sizes is not None:
367368
assert channel.physical_sizes == topography.physical_sizes
368369

369-
if channel.height_scale_factor is not None and hasattr(topography, 'scale_factor'):
370-
assert channel.height_scale_factor == topography.scale_factor
370+
if channel.height_scale_factor is not None:
371+
assert channel.height_scale_factor == topography.height_scale_factor
372+
else:
373+
assert not hasattr(topography, 'height_scale_factor')
371374

372375
if channel.is_periodic is not None:
373376
assert isinstance(channel.is_periodic, (bool, np.bool_))

test/IO/test_nc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
from .test_io import binary_example_file_list, explicit_physical_sizes
4040

4141

42+
@pytest.mark.skipif(
43+
MPI.COMM_WORLD.Get_size() > 1,
44+
reason="FIXME! This tests often stalls (randomly) on multiple MPI processes; disabling for now")
4245
def test_save_and_load(maxcomm):
4346
nb_grid_pts = (128, 128)
4447
size = (3, 3)

0 commit comments

Comments
 (0)