Skip to content

Commit

Permalink
Merge pull request #15 from KNMI/int-axis
Browse files Browse the repository at this point in the history
Axis can be number (float) or str
  • Loading branch information
PaulVanSchayck authored Apr 2, 2024
2 parents 87127e6 + dd6cd46 commit c21ceb6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions src/covjson_pydantic/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions tests/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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"),
]


Expand Down
8 changes: 8 additions & 0 deletions tests/test_data/mixed-type-axes-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"x": {
"values": [
"foo",
42.0
]
}
}
8 changes: 8 additions & 0 deletions tests/test_data/mixed-type-axes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"x": {
"values": [
42.0,
"foo"
]
}
}
8 changes: 8 additions & 0 deletions tests/test_data/str-axes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"x": {
"values": [
"foo",
"bar"
]
}
}

0 comments on commit c21ceb6

Please sign in to comment.