diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index 155b59065..5e86db3d5 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -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: | diff --git a/.github/workflows/test-code-functionality.yml b/.github/workflows/test-code-functionality.yml index 630b21c30..73c6bd9a8 100644 --- a/.github/workflows/test-code-functionality.yml +++ b/.github/workflows/test-code-functionality.yml @@ -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 }} diff --git a/SurfaceTopography/ChangeLog.md b/SurfaceTopography/ChangeLog.md index 79950f63d..2501cfbea 100644 --- a/SurfaceTopography/ChangeLog.md +++ b/SurfaceTopography/ChangeLog.md @@ -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 diff --git a/SurfaceTopography/Generation.py b/SurfaceTopography/Generation.py index afeee1e03..d35c402ae 100644 --- a/SurfaceTopography/Generation.py +++ b/SurfaceTopography/Generation.py @@ -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): diff --git a/SurfaceTopography/IO/SUR.py b/SurfaceTopography/IO/SUR.py index c05dee8a6..75ad45b85 100644 --- a/SurfaceTopography/IO/SUR.py +++ b/SurfaceTopography/IO/SUR.py @@ -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)] diff --git a/SurfaceTopography/Nonuniform/PowerSpectrum.py b/SurfaceTopography/Nonuniform/PowerSpectrum.py index ac59ab93a..fdedf8d1c 100644 --- a/SurfaceTopography/Nonuniform/PowerSpectrum.py +++ b/SurfaceTopography/Nonuniform/PowerSpectrum.py @@ -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: diff --git a/SurfaceTopography/Uniform/Filtering.py b/SurfaceTopography/Uniform/Filtering.py index 31a72d7e1..7d4fc7783 100644 --- a/SurfaceTopography/Uniform/Filtering.py +++ b/SurfaceTopography/Uniform/Filtering.py @@ -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: diff --git a/pyproject.toml b/pyproject.toml index b4a8d81a2..9fc0f5342 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] @@ -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", @@ -31,7 +31,7 @@ dependencies = [ "requests", "scipy", "tiffile", - "numpy" + "numpy<1.24.0" ] [project.optional-dependencies] diff --git a/test/IO/test_io.py b/test/IO/test_io.py index 33f5aa59a..00ba64139 100644 --- a/test/IO/test_io.py +++ b/test/IO/test_io.py @@ -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', @@ -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. @@ -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_)) diff --git a/test/IO/test_nc.py b/test/IO/test_nc.py index 580798973..003c31882 100644 --- a/test/IO/test_nc.py +++ b/test/IO/test_nc.py @@ -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)