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

Axis can be number (float or int) or str. CompactAxis can be number #15

Merged
merged 7 commits into from
Apr 2, 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 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"
]
}
}