Skip to content

Commit

Permalink
Axis can be number (float or int) or str. CompactAis can be number (f…
Browse files Browse the repository at this point in the history
…loat or int).
  • Loading branch information
PaulVanSchayck committed Feb 26, 2024
1 parent 87127e6 commit 1a76208
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/covjson_pydantic/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@


class CompactAxis(CovJsonBaseModel):
start: float
stop: float
start: Union[int, float]
stop: Union[int, float]
num: PositiveInt

@model_validator(mode="after")
Expand Down 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[int], ValuesAxis[str], CompactAxis]] = None
y: Optional[Union[ValuesAxis[float], ValuesAxis[int], ValuesAxis[str], CompactAxis]] = None
z: Optional[Union[ValuesAxis[float], ValuesAxis[int], ValuesAxis[str], CompactAxis]] = None
t: Optional[ValuesAxis[AwareDatetime]] = None
composite: Optional[ValuesAxis[Tuple]] = None

Expand Down
2 changes: 2 additions & 0 deletions tests/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

happy_cases = [
("spec-axes.json", Axes),
("int-axes.json", Axes),
("str-axes.json", Axes),
("coverage-json.json", Coverage),
("doc-example-coverage.json", Coverage),
("spec-vertical-profile-coverage.json", Coverage),
Expand Down
19 changes: 19 additions & 0 deletions tests/test_data/int-axes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"x": {
"values": [
20,
21
],
"bounds": [
19,
20,
20,
21
]
},
"y": {
"start": 0,
"stop": 5,
"num": 6
}
}
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": [
"1",
"2"
]
}
}

0 comments on commit 1a76208

Please sign in to comment.