Skip to content
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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ doc/sg_execution_times.rst
MANIFEST
dask-worker-space
.coverage.*
harmonica/_version.py
src/harmonica/_version.py
.DS_Store
.spyproject/*
.spyproject/*
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
prune .github
prune doc
prune env
prune test
exclude .*.yml
exclude .*rc
exclude .gitignore
Expand Down
17 changes: 4 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Build, package, test, and clean
PROJECT=harmonica
TESTDIR=tmp-test-dir-with-unique-name
STYLE_CHECK_FILES=$(PROJECT) doc
STYLE_CHECK_FILES=src/$(PROJECT) test doc
GITHUB_ACTIONS=.github/workflows

.PHONY: build install test test_coverage test_numba format check check-format check-style check-actions clean
Expand All @@ -28,18 +27,10 @@ install:
test: test_coverage test_numba

test_coverage:
# Run a tmp folder to make sure the tests are run on the installed version.
# Need to specify configuration file for coverage since we change directiory.
mkdir -p $(TESTDIR)
cd $(TESTDIR); NUMBA_DISABLE_JIT=1 MPLBACKEND='agg' pytest --verbose --cov --cov-config="../pyproject.toml" --doctest-modules --doctest-continue-on-failure ../$(PROJECT)
cp $(TESTDIR)/.coverage* .
rm -rvf $(TESTDIR)
NUMBA_DISABLE_JIT=1 MPLBACKEND='agg' pytest --verbose --cov --cov-config="pyproject.toml" --doctest-modules --doctest-continue-on-failure src/$(PROJECT) test

test_numba:
# Run a tmp folder to make sure the tests are run on the installed version
mkdir -p $(TESTDIR)
cd $(TESTDIR); NUMBA_DISABLE_JIT=0 MPLBACKEND='agg' pytest --verbose --doctest-modules --doctest-continue-on-failure -m use_numba ../$(PROJECT)
rm -rvf $(TESTDIR)
NUMBA_DISABLE_JIT=0 MPLBACKEND='agg' pytest --verbose --doctest-modules --doctest-continue-on-failure -m use_numba src/$(PROJECT) test

format:
ruff check --select I --fix $(STYLE_CHECK_FILES) # fix isort errors
Expand All @@ -62,4 +53,4 @@ clean:
find . -name "*.pyc" -exec rm -v {} \;
find . -name ".coverage.*" -exec rm -v {} \;
rm -rvf build dist MANIFEST *.egg-info __pycache__ .coverage .cache .pytest_cache $(PROJECT)/_version.py
rm -rvf $(TESTDIR) dask-worker-space
rm -rvf dask-worker-space
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
version_scheme = "post-release"
local_scheme = "node-and-date"
version_file = "harmonica/_version.py"
version_file = "src/harmonica/_version.py"

[tool.pytest.ini_options]
doctest_optionflags = "NUMBER"
Expand All @@ -80,7 +80,7 @@ line-length = 88
exclude = [
"doc/_build",
"doc/gallery",
"harmonica/_version.py",
"src/harmonica/_version.py",
]

[tool.ruff.lint]
Expand Down Expand Up @@ -124,7 +124,7 @@ ignore = [
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # disable unused-imports errors on __init__.py
"_kernels.py" = ["ARG001"] # disable unused arguments in kernel files
"harmonica/tests/**" = [
"test/**" = [
"T20", # allow print statements in tests
"D", # ignore pydocstyle warnings in tests
"RUF012", # ignore undecorated mutable class attributes
Expand All @@ -151,7 +151,7 @@ relative_files = true

[tool.coverage.paths]
source = [
"harmonica",
"src/harmonica",
"*/harmonica",
"*\\harmonica",
]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions harmonica/tests/test_dipole.py → test/test_dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
except ImportError: # pragma: no cover
ProgressBar = None

from .. import dipole_magnetic
from .._forward.dipole import VALID_FIELDS
from harmonica import dipole_magnetic
from harmonica._forward.dipole import VALID_FIELDS

from .utils import run_only_with_numba


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
import verde as vd
import verde.base as vdb

from .. import EquivalentSources, point_gravity
from .._equivalent_sources.cartesian import greens_func_cartesian
from .._equivalent_sources.utils import jacobian_numba_serial
from harmonica import EquivalentSources, point_gravity
from harmonica._equivalent_sources.cartesian import greens_func_cartesian
from harmonica._equivalent_sources.utils import jacobian_numba_serial

from .utils import run_only_with_numba


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import pytest
import verde as vd

from .. import EquivalentSourcesSph, point_gravity
from harmonica import EquivalentSourcesSph, point_gravity

from .utils import run_only_with_numba


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pytest
from verde import scatter_points

from .._equivalent_sources.utils import cast_fit_input, pop_extra_coords
from harmonica._equivalent_sources.utils import cast_fit_input, pop_extra_coords


def test_pop_extra_coords():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import numpy.testing as npt
import verde as vd

from .. import (
from harmonica import (
EulerDeconvolution,
derivative_easting,
derivative_northing,
derivative_upward,
dipole_magnetic,
magnetic_angles_to_vec,
)
from .._forward.point import point_gravity
from harmonica._forward.point import point_gravity


def test_euler_with_numeric_derivatives():
Expand Down
6 changes: 3 additions & 3 deletions harmonica/tests/test_filters.py → test/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import xarray.testing as xrt
from verde import grid_coordinates, make_xarray_grid

from ..filters._fft import fft, ifft
from ..filters._filters import (
from harmonica.filters._fft import fft, ifft
from harmonica.filters._filters import (
derivative_easting_kernel,
derivative_northing_kernel,
derivative_upward_kernel,
Expand All @@ -27,7 +27,7 @@
reduction_to_pole_kernel,
upward_continuation_kernel,
)
from ..filters._utils import apply_filter
from harmonica.filters._utils import apply_filter

# -------------------------------
# Fixtures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
import numpy.testing as npt
import pytest

from .._forward.utils import check_coordinate_system, distance, initialize_progressbar
from harmonica._forward.utils import (
check_coordinate_system,
distance,
initialize_progressbar,
)

try:
from numba_progress import ProgressBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
import pytest
import verde as vd

from .. import EquivalentSourcesGB, point_gravity
from .._equivalent_sources.gradient_boosted import _get_region_data_sources
from harmonica import EquivalentSourcesGB, point_gravity
from harmonica._equivalent_sources.gradient_boosted import _get_region_data_sources

from .utils import run_only_with_numba


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import numpy.testing as npt
import xarray as xr

from .. import bouguer_correction
from ..constants import GRAVITATIONAL_CONST
from harmonica import bouguer_correction
from harmonica.constants import GRAVITATIONAL_CONST


def test_bouguer_correction():
Expand Down
2 changes: 1 addition & 1 deletion harmonica/tests/test_icgem.py → test/test_icgem.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import numpy.testing as npt
import pytest

from .. import load_icgem_gdf
from harmonica import load_icgem_gdf

MODULE_DIR = Path(__file__).parent
TEST_DATA_DIR = MODULE_DIR / "data"
Expand Down
2 changes: 1 addition & 1 deletion harmonica/tests/test_igrf.py → test/test_igrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pytest
import verde as vd

from .._spherical_harmonics.igrf import (
from harmonica._spherical_harmonics.igrf import (
IGRF14,
interpolate_coefficients,
load_igrf,
Expand Down
2 changes: 1 addition & 1 deletion harmonica/tests/test_isostasy.py → test/test_isostasy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pytest
import xarray as xr

from .. import isostatic_moho_airy
from harmonica import isostatic_moho_airy


@pytest.mark.parametrize("reference_depth", [0, 30e3])
Expand Down
3 changes: 2 additions & 1 deletion harmonica/tests/test_legendre.py → test/test_legendre.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
import numpy as np
import pytest

from .._spherical_harmonics.legendre import (
from harmonica._spherical_harmonics.legendre import (
associated_legendre,
associated_legendre_derivative,
associated_legendre_full,
associated_legendre_full_derivative,
associated_legendre_schmidt,
associated_legendre_schmidt_derivative,
)

from .utils import run_only_with_numba


Expand Down
4 changes: 2 additions & 2 deletions harmonica/tests/test_oasis.py → test/test_oasis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import xarray as xr
import xarray.testing as xrt

from .. import load_oasis_montaj_grid
from .._io.oasis_montaj_grd import _check_ordering, _check_sign_flag
from harmonica import load_oasis_montaj_grid
from harmonica._io.oasis_montaj_grd import _check_ordering, _check_sign_flag

MODULE_DIR = Path(__file__).parent
TEST_DATA_DIR = MODULE_DIR / "data"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
gravity_uu,
)

from .._forward.point import point_gravity
from .._forward.utils import distance_cartesian
from ..constants import GRAVITATIONAL_CONST
from harmonica._forward.point import point_gravity
from harmonica._forward.utils import distance_cartesian
from harmonica.constants import GRAVITATIONAL_CONST

from .utils import run_only_with_numba

MODULE_DIR = Path(__file__).parent
Expand Down
9 changes: 7 additions & 2 deletions harmonica/tests/test_prism.py → test/test_prism.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@
except ImportError: # pragma: no cover
ProgressBar = None

from .. import bouguer_correction
from .._forward.prism_gravity import _check_prisms, _discard_null_prisms, prism_gravity
from harmonica import bouguer_correction
from harmonica._forward.prism_gravity import (
_check_prisms,
_discard_null_prisms,
prism_gravity,
)

from .utils import run_only_with_numba


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import verde as vd
import xarray as xr

from .. import prism_gravity, prism_layer
from .._forward.prism_layer import _discard_thin_prisms
from harmonica import prism_gravity, prism_layer
from harmonica._forward.prism_layer import _discard_thin_prisms

try:
import pyvista
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
except ImportError: # pragma: no cover
ProgressBar = None

from .. import prism_magnetic
from .._forward.prism_magnetic import VALID_FIELDS
from harmonica import prism_magnetic
from harmonica._forward.prism_magnetic import VALID_FIELDS

from .utils import run_only_with_numba


Expand Down
7 changes: 4 additions & 3 deletions harmonica/tests/test_tesseroid.py → test/test_tesseroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@
import verde as vd
from verde import grid_coordinates

from .._forward._tesseroid_utils import (
from harmonica._forward._tesseroid_utils import (
_discard_null_tesseroids,
_distance_tesseroid_point,
_longitude_continuity,
_split_tesseroid,
_tesseroid_dimensions,
)
from .._forward.tesseroid_gravity import (
from harmonica._forward.tesseroid_gravity import (
MAX_DISCRETIZATIONS,
STACK_SIZE,
_adaptive_discretization,
_check_tesseroids,
check_points_outside_tesseroids,
tesseroid_gravity,
)
from ..constants import GRAVITATIONAL_CONST
from harmonica.constants import GRAVITATIONAL_CONST

from .utils import run_only_with_numba

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import verde as vd
import xarray as xr

from .. import tesseroid_gravity, tesseroid_layer
from .._forward.tesseroid_layer import _discard_thin_tesseroids
from harmonica import tesseroid_gravity, tesseroid_layer
from harmonica._forward.tesseroid_layer import _discard_thin_tesseroids

try:
from numba_progress import ProgressBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
from verde import grid_coordinates

import harmonica

from .. import tesseroid_gravity
from .._forward._tesseroid_variable_density import (
from harmonica import tesseroid_gravity
from harmonica._forward._tesseroid_variable_density import (
_density_based_discretization,
density_minmax,
maximum_absolute_diff,
straight_line,
)
from ..constants import GRAVITATIONAL_CONST
from harmonica.constants import GRAVITATIONAL_CONST

from .utils import run_only_with_numba

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
import xarray as xr
import xarray.testing as xrt

from .. import (
from harmonica import (
dipole_magnetic,
magnetic_angles_to_vec,
point_gravity,
total_field_anomaly,
)
from .._transformations import (
from harmonica._transformations import (
_get_dataarray_coordinate,
derivative_easting,
derivative_northing,
Expand All @@ -36,6 +36,7 @@
total_gradient_amplitude,
upward_continuation,
)

from .utils import root_mean_square_error

MODULE_DIR = Path(__file__).parent
Expand Down
Loading
Loading