diff --git a/pyproject.toml b/pyproject.toml index 725b130..30dde20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ classifiers = [ "Topic :: Scientific/Engineering :: GIS", "Typing :: Typed", ] -version = "0.2.1" +version = "0.3.0" dependencies = ["pydantic>=2.3,<3"] [project.optional-dependencies] diff --git a/src/covjson_pydantic/domain.py b/src/covjson_pydantic/domain.py index 61dfdfb..af581c6 100644 --- a/src/covjson_pydantic/domain.py +++ b/src/covjson_pydantic/domain.py @@ -56,9 +56,9 @@ class DomainType(str, Enum): class Axes(CovJsonBaseModel): - x: Optional[Union[ValuesAxis[float], CompactAxis]] = None - y: Optional[Union[ValuesAxis[float], CompactAxis]] = None - z: Optional[Union[ValuesAxis[float], CompactAxis]] = None + x: Optional[Union[ValuesAxis[float], ValuesAxis[str], CompactAxis]] = None + y: Optional[Union[ValuesAxis[float], ValuesAxis[str], CompactAxis]] = None + z: Optional[Union[ValuesAxis[float], ValuesAxis[str], CompactAxis]] = None t: Optional[ValuesAxis[AwareDatetime]] = None composite: Optional[ValuesAxis[Tuple]] = None diff --git a/tests/test_coverage.py b/tests/test_coverage.py index e21ad75..4c678e6 100644 --- a/tests/test_coverage.py +++ b/tests/test_coverage.py @@ -16,6 +16,7 @@ happy_cases = [ ("spec-axes.json", Axes), + ("str-axes.json", Axes), ("coverage-json.json", Coverage), ("doc-example-coverage.json", Coverage), ("spec-vertical-profile-coverage.json", Coverage), @@ -60,6 +61,8 @@ def test_happy_cases(file_name, object_type): + "domain must contain a single value.", ), ("point-series-domain-no-t.json", Domain, r"A 'PointSeries' must have a 't'-axis."), + ("mixed-type-axes.json", Axes, r"Input should be a valid number"), + ("mixed-type-axes-2.json", Axes, r"Input should be a valid string"), ] diff --git a/tests/test_data/mixed-type-axes-2.json b/tests/test_data/mixed-type-axes-2.json new file mode 100644 index 0000000..538c6b9 --- /dev/null +++ b/tests/test_data/mixed-type-axes-2.json @@ -0,0 +1,8 @@ +{ + "x": { + "values": [ + "foo", + 42.0 + ] + } +} diff --git a/tests/test_data/mixed-type-axes.json b/tests/test_data/mixed-type-axes.json new file mode 100644 index 0000000..2546157 --- /dev/null +++ b/tests/test_data/mixed-type-axes.json @@ -0,0 +1,8 @@ +{ + "x": { + "values": [ + 42.0, + "foo" + ] + } +} diff --git a/tests/test_data/str-axes.json b/tests/test_data/str-axes.json new file mode 100644 index 0000000..525f7ce --- /dev/null +++ b/tests/test_data/str-axes.json @@ -0,0 +1,8 @@ +{ + "x": { + "values": [ + "foo", + "bar" + ] + } +}