From 109020a8377afe7dc46ff7950cbb72f20e08aa85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BRIOL?= Date: Sat, 29 Jun 2024 19:48:05 +0200 Subject: [PATCH] Refactor file paths in examples to use relative paths for better portability --- examples/ex_interpolation.py | 4 ++-- examples/ex_mapping.py | 4 ++-- examples/ex_prediction.py | 4 ++-- tests/python/core/test_astronomic_angle.py | 3 +-- tests/python/core/test_axis.py | 3 +-- tests/python/core/test_evaluate_tide.py | 3 +-- tests/python/core/test_tidal_model_cartesian.py | 3 +-- tests/python/core/test_wave_table.py | 3 +-- tests/python/test_leap_seconds.py | 1 - tests/python/test_lgp.py | 3 +-- 10 files changed, 12 insertions(+), 19 deletions(-) diff --git a/examples/ex_interpolation.py b/examples/ex_interpolation.py index c0270f4..728433d 100644 --- a/examples/ex_interpolation.py +++ b/examples/ex_interpolation.py @@ -23,8 +23,8 @@ import pyfes # %% -MODEL = str(pathlib.Path().absolute().parent / 'src' / 'python' / 'pyfes' / - 'tests' / 'dataset' / 'fes_2014.nc') +MODEL = str(pathlib.Path().absolute().parent / 'tests' / 'python' / 'dataset' / + 'fes_2014.nc') # %% diff --git a/examples/ex_mapping.py b/examples/ex_mapping.py index fc47ba0..a620044 100644 --- a/examples/ex_mapping.py +++ b/examples/ex_mapping.py @@ -23,8 +23,8 @@ # %% # First we create an environment variable to store the path to the model file. -os.environ['DATASET_DIR'] = str(pathlib.Path().absolute().parent / 'src' / - 'python' / 'pyfes' / 'tests' / 'dataset') +os.environ['DATASET_DIR'] = str(pathlib.Path().absolute().parent / 'tests' / + 'python' / 'dataset') # %% # Now we need to create the instances of the model used to calculate the ocean diff --git a/examples/ex_prediction.py b/examples/ex_prediction.py index 3676df0..84c321b 100644 --- a/examples/ex_prediction.py +++ b/examples/ex_prediction.py @@ -22,8 +22,8 @@ # %% # First we create an environment variable to store the path to the model file. -os.environ['DATASET_DIR'] = str(pathlib.Path().absolute().parent / 'src' / - 'python' / 'pyfes' / 'tests' / 'dataset') +os.environ['DATASET_DIR'] = str(pathlib.Path().absolute().parent / 'tests' / + 'python' / 'dataset') # %% # Now we need to create the instances of the model used to calculate the ocean diff --git a/tests/python/core/test_astronomic_angle.py b/tests/python/core/test_astronomic_angle.py index a004e59..b4c853f 100644 --- a/tests/python/core/test_astronomic_angle.py +++ b/tests/python/core/test_astronomic_angle.py @@ -4,9 +4,8 @@ # BSD-style license that can be found in the LICENSE file. import datetime -import pytest - from pyfes import core +import pytest def test_astronomic_angle(): diff --git a/tests/python/core/test_axis.py b/tests/python/core/test_axis.py index 90d7726..2d1f2ca 100644 --- a/tests/python/core/test_axis.py +++ b/tests/python/core/test_axis.py @@ -3,10 +3,9 @@ # All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. import numpy +from pyfes import core import pytest -from pyfes import core - def test_axis(): points = numpy.arange(0, 10, 0.1) diff --git a/tests/python/core/test_evaluate_tide.py b/tests/python/core/test_evaluate_tide.py index f04db9f..f954582 100644 --- a/tests/python/core/test_evaluate_tide.py +++ b/tests/python/core/test_evaluate_tide.py @@ -6,10 +6,9 @@ import netCDF4 import numpy -import pytest - from pyfes import core from pyfes.leap_seconds import get_leap_seconds +import pytest DATASET = pathlib.Path(__file__).parent.parent / 'dataset' diff --git a/tests/python/core/test_tidal_model_cartesian.py b/tests/python/core/test_tidal_model_cartesian.py index bf2a4e2..1572eb3 100644 --- a/tests/python/core/test_tidal_model_cartesian.py +++ b/tests/python/core/test_tidal_model_cartesian.py @@ -6,9 +6,8 @@ import netCDF4 import numpy -import pytest - from pyfes import core +import pytest S2 = pathlib.Path(__file__).parent.parent / 'dataset' / 'S2_tide.nc' diff --git a/tests/python/core/test_wave_table.py b/tests/python/core/test_wave_table.py index 727df33..ede9b57 100644 --- a/tests/python/core/test_wave_table.py +++ b/tests/python/core/test_wave_table.py @@ -6,10 +6,9 @@ import pathlib import netCDF4 -import pytest - from pyfes import core from pyfes.leap_seconds import get_leap_seconds +import pytest FES_TIDE_TIME_SERIES = pathlib.Path( __file__).parent.parent / 'dataset' / 'fes_tide_time_series.nc' diff --git a/tests/python/test_leap_seconds.py b/tests/python/test_leap_seconds.py index 6847bc3..3a9bf5a 100644 --- a/tests/python/test_leap_seconds.py +++ b/tests/python/test_leap_seconds.py @@ -4,7 +4,6 @@ # BSD-style license that can be found in the LICENSE file. """Testing leap seconds.""" import numpy - from pyfes.leap_seconds import get_leap_seconds diff --git a/tests/python/test_lgp.py b/tests/python/test_lgp.py index 23ff6d0..50c5b3e 100644 --- a/tests/python/test_lgp.py +++ b/tests/python/test_lgp.py @@ -5,9 +5,8 @@ import pathlib import numpy - -import pyfes.config as config_handler from pyfes import evaluate_tide +import pyfes.config as config_handler DATASET = pathlib.Path(__file__).parent / 'dataset'