Skip to content

Commit

Permalink
update pytz dep (#69)
Browse files Browse the repository at this point in the history
* update pytz, nzshm-model, mkdocstrings-python dependencies
* handle tests and imports when optional dependencies not present
  • Loading branch information
chrisdicaprio authored Feb 10, 2025
1 parent 09fbcc4 commit f5a3261
Show file tree
Hide file tree
Showing 6 changed files with 442 additions and 398 deletions.
804 changes: 423 additions & 381 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ nshm-toshi-client = {version = "^1.0.0", optional = true}
pyproj = "^3.3"
python = ">=3.9,<4.0"
python-dateutil = "^2.8.2"
pytz = "2021.3"
pyvista = {version = "^0.44.1", optional = true}
geopandas = "^1.0.1"

nzshm-common = "^0.8.1"
nzshm-model = "^0.10.6"

# see https://github.com/orgs/python-poetry/discussions/7937
# urllib3 = "<2"
pandera = {extras = ["mypy"], version = "^0.20.4"}
pytz = "^2025.1"
nzshm-model = {git = "https://github.com/GNS-Science/nzshm-model.git", rev = "pre-release"}



Expand All @@ -63,7 +63,7 @@ optional = true

[tool.poetry.group.doc.dependencies]
mkdocs = "^1.6.1"
mkdocstrings = "^0.26.2"
mkdocstrings = {version = "^0.26.2", extras = ["python"]}
mkdocs-autorefs = "^1.0.1"
mkdocs-include-markdown-plugin = "^6.0.6"
mkdocs-material = "^9.5.21"
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ exclude = .git,
ignore_missing_imports = True
# plugins = numpy.typing.mypy_plugin
plugins = pandera.mypy
exclude = solvis/fault_system_solution_helper.py


[coverage:run]
# exclude = */test_geometry_performance.py
Expand Down
3 changes: 1 addition & 2 deletions solvis/dochelper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Package supporting dynamic dosstrings."""

from .extension import DynamicDocstrings
from .inherit_docstrings import inherit_docstrings

__all__ = ["DynamicDocstrings", "inherit_docstrings"]
__all__ = ["inherit_docstrings"]
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def get_branch_inversion_solution_id(branch: ModelLogicTreeBranch) -> str:
This distinction may go away in future versions, simplifying this issue:
https://github.com/GNS-Science/nzshm-model/issues/81
"""
if isinstance(branch, nm.logic_tree.source_logic_tree.version2.logic_tree.SourceBranch):
if isinstance(branch, nm.logic_tree.SourceBranch):
# NZSHM Model 0.6: v2 branches take inversion ID from first InversionSource
for source in branch.sources:
if source.type == "inversion":
Expand Down
23 changes: 12 additions & 11 deletions test/geometry/test_geometry_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@
import geopandas as gpd
import numpy as np
import pytest
import pyvista as pv
from nzshm_common.location.location import location_by_id
from pyproj import Transformer
from pytest import approx

from solvis import InversionSolution, geometry

pyvista = pytest.importorskip("pyvista")

TEST_FOLDER = pathlib.PurePath(os.path.realpath(__file__)).parent.parent


class TestPyvistaDistances(unittest.TestCase):
def test_basic_0_rake_90(self):

mesh0 = pv.PolyData([[0, 0, 0]], force_float=False)
mesh0 = pyvista.PolyData([[0, 0, 0]], force_float=False)

p0 = [0, 1, 0] # 1st top-trace point
p1 = [0, 2, 0] # 2nd top-trace point
p2 = [1, 1, 10] # 1st botton trace point
p3 = [1, 2, 10] # 2nd bottom trace point

mesh1 = pv.PolyData([p0, p1, p2, p3], force_float=False)
mesh1 = pyvista.PolyData([p0, p1, p2, p3], force_float=False)
closest_cells, closest_points = mesh1.find_closest_cell(mesh0.points, return_closest_point=True)
d_exact = np.linalg.norm(mesh0.points - closest_points, axis=1)

Expand All @@ -36,14 +37,14 @@ def test_basic_0_rake_90(self):
assert d_exact[0] == 1

def test_basic_1_further_at_depth(self):
mesh0 = pv.PolyData([0, 0, 0], force_float=False)
mesh0 = pyvista.PolyData([0, 0, 0], force_float=False)

p0 = [0, 2, 0] # 1st top-trace point
p1 = [0, 3, 0] # 2nd top-trace point
p2 = [2, 2, 10] # 1st botton trace point
p3 = [2, 3, 10] # 2nd bottom trace point

mesh1 = pv.PolyData([p0, p1, p2, p3], force_float=False)
mesh1 = pyvista.PolyData([p0, p1, p2, p3], force_float=False)

closest_cells, closest_points = mesh1.find_closest_cell(mesh0.points, return_closest_point=True)
d_exact = np.linalg.norm(mesh0.points - closest_points, axis=1)
Expand All @@ -55,14 +56,14 @@ def test_basic_1_further_at_depth(self):
assert d_exact[0] == 2.0

def test_basic_2_closer_at_depth(self):
mesh0 = pv.PolyData([0, 0, 0], force_float=False)
mesh0 = pyvista.PolyData([0, 0, 0], force_float=False)

p0 = [10, 2, 0] # 1st top-trace point
p1 = [10, 3, 0] # 2nd top-trace point
p2 = [0, 2, 5] # 1st botton trace point
p3 = [0, 3, 5] # 2nd bottom trace point

mesh1 = pv.PolyData([p0, p1, p2, p3], force_float=False)
mesh1 = pyvista.PolyData([p0, p1, p2, p3], force_float=False)
closest_cells, closest_points = mesh1.find_closest_cell(mesh0.points, return_closest_point=True)
d_exact = np.linalg.norm(mesh0.points - closest_points, axis=1)

Expand All @@ -73,8 +74,8 @@ def test_basic_2_closer_at_depth(self):
assert d_exact[0] > 5

def test_calc_distance_345_line(self):
origin = pv.PolyData([0, 0, 0], force_float=False)
surface = pv.PolyData([[3, 0, 4], [3, 1, 4]], force_float=False)
origin = pyvista.PolyData([0, 0, 0], force_float=False)
surface = pyvista.PolyData([[3, 0, 4], [3, 1, 4]], force_float=False)

closest_cells, closest_points = surface.find_closest_cell(origin.points, return_closest_point=True)
d_exact = np.linalg.norm(origin.points - closest_points, axis=1)
Expand All @@ -84,8 +85,8 @@ def test_calc_distance_345_line(self):
assert d_exact[0] == 5

def test_calc_distance_345_surface(self):
origin = pv.PolyData([0, 0, 0], force_float=False)
surface = pv.PolyData([[3, 0, 4], [15, 0, 4], [15, 1, 10], [3, 1, 10]], force_float=False)
origin = pyvista.PolyData([0, 0, 0], force_float=False)
surface = pyvista.PolyData([[3, 0, 4], [15, 0, 4], [15, 1, 10], [3, 1, 10]], force_float=False)
closest_cells, closest_points = surface.find_closest_cell(origin.points, return_closest_point=True)
d_exact = np.linalg.norm(origin.points - closest_points, axis=1)

Expand Down

0 comments on commit f5a3261

Please sign in to comment.