-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from KNMI/ndarray-str
Add integer and string support for NdArray values
- Loading branch information
Showing
14 changed files
with
383 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import timeit | ||
from pathlib import Path | ||
|
||
filename = Path(__file__).parent.resolve() / "tests" / "test_data" / "coverage-json.json" | ||
|
||
setup = f""" | ||
import json | ||
from covjson_pydantic.coverage import Coverage | ||
file = "{filename}" | ||
# Put JSON in default unindented format | ||
with open(file, "r") as f: | ||
data = json.load(f) | ||
json_string = json.dumps(data, separators=(",", ":")) | ||
cj = Coverage.model_validate_json(json_string) | ||
""" | ||
|
||
# This can be used to quickly check performance. The first call checks JSON to Python conversion | ||
# The second call checks Python to JSON conversion | ||
# Consider generating a larger CoverageJSON file | ||
print(timeit.timeit("Coverage.model_validate_json(json_string)", setup, number=1000)) | ||
print(timeit.timeit("cj.model_dump_json(exclude_none=True)", setup, number=1000)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.