Skip to content

BUG: SUR reader reported wrong height_scale_factor in channel info #268

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

Merged
merged 17 commits into from
Dec 29, 2022
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
10 changes: 6 additions & 4 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up python3 ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
sudo apt-get update -qy
sudo apt-get install -y python3-dev python3-pip libfftw3-dev libopenblas-dev
sudo apt-get install -y python3-dev python3-pip libfftw3-dev libopenblas-dev meson

- name: Build extension module
run: |
python3 -m pip install --no-binary numpy ".[test]"
python3 -m pip install ".[test]"

- name: Flake8 via pytest
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-code-functionality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
fetch-depth: 0

- name: Set up python3 ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand Down
7 changes: 4 additions & 3 deletions SurfaceTopography/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Change log for SurfaceTopography
=============================
================================

v1.2.6 (not yet released)
-------------------------
v1.2.6 (29Dec22)
----------------

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

Expand Down
8 changes: 4 additions & 4 deletions SurfaceTopography/Generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ def fourier_synthesis(nb_grid_pts, physical_sizes,

# Create in-memory or memory-mapped arrays as storage buffers
if rfn is None:
rarr = np.empty(nb_grid_pts, dtype=np.float64)
rarr = np.empty(nb_grid_pts, dtype=float)
else:
rarr = np.memmap(rfn, np.float64, 'w+', shape=nb_grid_pts)
rarr = np.memmap(rfn, float, 'w+', shape=nb_grid_pts)
if kfn is None:
karr = np.empty(kshape, dtype=np.complex128)
karr = np.empty(kshape, dtype=complex)
else:
karr = np.memmap(kfn, np.complex128, 'w+', shape=kshape)
karr = np.memmap(kfn, complex, 'w+', shape=kshape)

qy = 2 * np.pi * np.arange(kny) / sy
for x in range(nx):
Expand Down
1 change: 1 addition & 0 deletions SurfaceTopography/IO/SUR.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def channels(self):
dim=2,
nb_grid_pts=self._nb_grid_pts,
physical_sizes=self._physical_sizes,
height_scale_factor=float(self._header['height_scale_factor']),
uniform=True,
unit=self._unit)]

Expand Down
2 changes: 1 addition & 1 deletion SurfaceTopography/Nonuniform/PowerSpectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def power_spectrum(self, reliable=True, algorithm='fft', wavevectors=None, nb_in
L = x[-1] - x[0]
if wavevectors is None:
wavevectors = 2 * np.pi * np.arange(int(L / np.diff(x).min())) / L
y_q = np.zeros_like(wavevectors, dtype=np.complex128)
y_q = np.zeros_like(wavevectors, dtype=complex)
for x1, x2, y1, y2 in zip(x[:-1], x[1:], y[:-1], y[1:]):
dx = x2 - x1
if dx > 0:
Expand Down
4 changes: 2 additions & 2 deletions SurfaceTopography/Uniform/Filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ def heights(self):
nx, ny = self.parent_topography.nb_grid_pts
sx, sy = self.parent_topography.physical_sizes

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

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

if self.is_filter_isotropic:
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["meson>=0.46.0", "meson-python>=0.11.0", "ninja", "numpy"]
requires = ["meson>=0.46.0", "meson-python>=0.11.0", "ninja", "numpy<1.24.0"]
build-backend = "mesonpy"

[project]
Expand All @@ -19,7 +19,7 @@ dynamic = [ "version" ]
dependencies = [
"defusedxml",
"h5py",
"igor",
"igor", # FIXME! Igor no longer works with numpy 1.24.0 or later
"matplotlib>=1.0.0",
"muFFT>=0.24.0",
"NuMPI>=0.3.1",
Expand All @@ -31,7 +31,7 @@ dependencies = [
"requests",
"scipy",
"tiffile",
"numpy"
"numpy<1.24.0"
]

[project.optional-dependencies]
Expand Down
9 changes: 6 additions & 3 deletions test/IO/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def _convert_filelist(filelist):
'example.vk3',
'example.vk4',
'example.vk6',
'example.sur',
'mitutoyo_mock.xlsx',
'mitutoyo_nonuniform_mock.xlsx',
'example_ps.tiff',
Expand Down Expand Up @@ -339,7 +340,7 @@ def test_nb_grid_pts_and_physical_sizes_are_tuples_or_none(fn):

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

if channel.height_scale_factor is not None and hasattr(topography, 'scale_factor'):
assert channel.height_scale_factor == topography.scale_factor
if channel.height_scale_factor is not None:
assert channel.height_scale_factor == topography.height_scale_factor
else:
assert not hasattr(topography, 'height_scale_factor')

if channel.is_periodic is not None:
assert isinstance(channel.is_periodic, (bool, np.bool_))
Expand Down
3 changes: 3 additions & 0 deletions test/IO/test_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
from .test_io import binary_example_file_list, explicit_physical_sizes


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