Skip to content
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

bmi-tester v0.5.9 #41

Merged
merged 8 commits into from
Mar 3, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Test
run: |
pip install nox
nox -s test --force-pythons="${{ matrix.python-version }}"
nox -s test

- name: Test CLI
run: |
Expand Down
11 changes: 4 additions & 7 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
PYTHON_VERSION = "3.12"


@nox.session(python=PYTHON_VERSION, venv_backend="conda")
@nox.session
def test(session: nox.Session) -> None:
"""Run the tests."""
session.install(".[testing]")
session.conda_install("gimli.units", channel=["nodefaults", "conda-forge"])
session.install(".[units,testing]")

args = ["--cov", PROJECT, "-vvv"] + session.posargs

Expand All @@ -30,10 +29,8 @@ def test(session: nox.Session) -> None:
@nox.session(name="test-cli", python=PYTHON_VERSION, venv_backend="conda")
def test_cli(session: nox.Session) -> None:
"""Run the tests."""
session.install(".")
session.conda_install(
"gimli.units", "pymt_topography", channel=["nodefaults", "conda-forge"]
)
session.install(".[units]")
session.conda_install("pymt_topography", channel=["nodefaults", "conda-forge"])

session.run("bmi-test", "pymt_topography:Topography")

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ classifiers = [
]
dependencies = [
"importlib-resources; python_version < '3.12'",
"model-metadata>=0.8",
"model-metadata>=0.8.1",
"numpy",
"pytest",
"pytest-dependency",
"standard-names",
"standard-names>=0.2.8",
]
dynamic = [
"readme",
Expand All @@ -48,7 +48,7 @@ text = "MIT"

[project.optional-dependencies]
units = [
"gimli.units"
"gimli.units>=0.3.2"
]
dev = [
"black",
Expand Down
7 changes: 4 additions & 3 deletions src/bmi_tester/_tests/stage_1/info_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import warnings

import pytest
import standard_names
from standard_names.standardname import StandardName
from standard_names.standardname import is_valid_name


def test_get_component_name(initialized_bmi):
Expand All @@ -15,8 +16,8 @@ def test_get_component_name(initialized_bmi):
def test_var_names(var_name):
"""Test var names are valid."""
assert isinstance(var_name, str)
if standard_names.is_valid_name(var_name):
standard_names.StandardName(var_name)
if is_valid_name(var_name):
StandardName(var_name)
else:
warnings.warn(f"not a valid standard name: {var_name}", stacklevel=2)

Expand Down
2 changes: 1 addition & 1 deletion src/bmi_tester/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.8.dev0"
__version__ = "0.5.10.dev0"
17 changes: 10 additions & 7 deletions src/bmi_tester/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
from collections.abc import Sequence

try:
import gimli
from gimli._udunits2 import UdunitsError
from gimli.errors import IncompatibleUnitsError
from gimli.errors import UnitNameError
from gimli.units import units
except ImportError:
WITH_GIMLI_UNITS = False
SECONDS = None
else:
WITH_GIMLI_UNITS = True
SECONDS = gimli.units.Unit("s")
SECONDS = units.Unit("s")

import pytest

Expand Down Expand Up @@ -57,21 +60,21 @@ def check_bmi(

def check_unit_is_valid(unit):
try:
gimli.units.Unit(unit)
except gimli.UnitNameError:
units.Unit(unit)
except (UnitNameError, UdunitsError):
return False
else:
return True


def check_unit_is_time(unit):
try:
gimli.units.Unit(unit).to(SECONDS)
except gimli.IncompatibleUnitsError:
units.Unit(unit).to(SECONDS)
except (IncompatibleUnitsError, UdunitsError):
return False
else:
return True


def check_unit_is_dimensionless(unit):
return gimli.units.Unit(unit).is_dimensionless
return units.Unit(unit).is_dimensionless
Loading