From d9fcfff2f26cf5aa0ab3cdf1df3603f61b41e500 Mon Sep 17 00:00:00 2001 From: Peter Kraus Date: Thu, 31 Aug 2023 08:09:33 +0200 Subject: [PATCH] Tests. --- src/dgbowl_schemas/dgpost/recipe_2_1/save.py | 1 - tests/ref_recipe.py | 63 ++++++++++++++++---- tests/test_recipe.py | 31 +++++----- tests/test_recipe/les_3.yaml | 21 +++++++ 4 files changed, 86 insertions(+), 30 deletions(-) create mode 100644 tests/test_recipe/les_3.yaml diff --git a/src/dgbowl_schemas/dgpost/recipe_2_1/save.py b/src/dgbowl_schemas/dgpost/recipe_2_1/save.py index 49bd143..c2c144d 100644 --- a/src/dgbowl_schemas/dgpost/recipe_2_1/save.py +++ b/src/dgbowl_schemas/dgpost/recipe_2_1/save.py @@ -35,7 +35,6 @@ class Save(BaseModel, extra="forbid", populate_by_name=True): """ - sigma: bool = True """Whether uncertainties/error estimates in the data should be stripped. Particularly useful when exporting into ``xlsx`` or ``csv``.""" diff --git a/tests/ref_recipe.py b/tests/ref_recipe.py index 6134c0b..d0b7cba 100644 --- a/tests/ref_recipe.py +++ b/tests/ref_recipe.py @@ -1,4 +1,4 @@ -ts0 = { +le_1 = { "version": "v1.0", "load": [ { @@ -25,7 +25,7 @@ "save": None, } -ts1 = { +le_2 = { "version": "v1.0", "load": [ { @@ -72,7 +72,7 @@ "save": None, } -ts2 = { +lee_1 = { "version": "v1.0", "load": [ { @@ -112,7 +112,7 @@ "save": None, } -ts3 = { +lee_2 = { "version": "v1.0", "load": [ { @@ -159,7 +159,7 @@ "save": None, } -ts4 = { +les_1 = { "version": "v1.0", "load": [ { @@ -191,7 +191,7 @@ ], } -ts5 = { +les_2 = { "version": "v1.0", "load": [ { @@ -225,7 +225,44 @@ ], } -ts6 = { + +les_3 = { + "version": "2.1", + "load": [ + { + "as": "sparse", + "path": "sparse.dg.json", + "check": None, + "type": "datagram", + }, + ], + "extract": [ + { + "into": "table 1", + "from": "sparse", + "at": {"steps": ["a"], "indices": None, "timestamps": None}, + "columns": [ + {"key": "raw->T_f", "as": "rawT"}, + {"key": "derived->T", "as": "derT"}, + ], + "constants": None, + }, + ], + "transform": None, + "plot": None, + "pivot": None, + "save": [ + { + "table": "table 1", + "as": "sparse.extension", + "type": "nc", + "columns": ["rawT"], + "sigma": False, + }, + ], +} + +let_1 = { "version": "v1.0", "load": [ { @@ -284,7 +321,7 @@ "save": None, } -ts7 = { +let_2 = { "version": "v1.0", "load": [ { @@ -330,7 +367,7 @@ "save": None, } -ts8 = { +letp_1 = { "version": "v1.0", "load": [ { @@ -415,7 +452,7 @@ "save": None, } -ts9 = { +lp_1 = { "version": "v1.0", "load": [ { @@ -489,7 +526,7 @@ "save": None, } -js0 = { +lets = { "version": "v1.0", "load": [ {"as": "d1", "path": "table.pkl", "type": "table", "check": True}, @@ -525,7 +562,7 @@ "plot": None, } -pivot1 = { +pivot_1 = { "version": "2.1", "load": [ { @@ -551,7 +588,7 @@ "plot": None, } -pivot2 = { +pivot_2 = { "version": "2.1", "load": [ { diff --git a/tests/test_recipe.py b/tests/test_recipe.py index d6f553a..5f3a7a6 100644 --- a/tests/test_recipe.py +++ b/tests/test_recipe.py @@ -4,26 +4,25 @@ import json from dgbowl_schemas.dgpost import to_recipe -from ref_recipe import ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7, ts8, ts9 -from ref_recipe import js0 -from ref_recipe import pivot1, pivot2 +from ref_recipe import * @pytest.mark.parametrize( "inpath, outdict", [ - ("le_1.yaml", ts0), - ("le_2.yaml", ts1), - ("lee_1.yaml", ts2), - ("lee_2.yaml", ts3), - ("les_1.yaml", ts4), - ("les_2.yaml", ts5), - ("let_1.yaml", ts6), - ("let_2.yaml", ts7), - ("letp_1.yaml", ts8), - ("lp_1.yaml", ts9), - ("pivot_1.yaml", pivot1), - ("pivot_2.yaml", pivot2), + ("le_1.yaml", le_1), + ("le_2.yaml", le_2), + ("lee_1.yaml", lee_1), + ("lee_2.yaml", lee_2), + ("les_1.yaml", les_1), + ("les_2.yaml", les_2), + ("les_3.yaml", les_3), + ("let_1.yaml", let_1), + ("let_2.yaml", let_2), + ("letp_1.yaml", letp_1), + ("lp_1.yaml", lp_1), + ("pivot_1.yaml", pivot_1), + ("pivot_2.yaml", pivot_2), ], ) def test_recipe_from_yml(inpath, outdict, datadir): @@ -36,7 +35,7 @@ def test_recipe_from_yml(inpath, outdict, datadir): @pytest.mark.parametrize( "inpath, outdict", - [("lets.json", js0)], + [("lets.json", lets)], ) def test_recipe_from_json(inpath, outdict, datadir): os.chdir(datadir) diff --git a/tests/test_recipe/les_3.yaml b/tests/test_recipe/les_3.yaml new file mode 100644 index 0000000..859107e --- /dev/null +++ b/tests/test_recipe/les_3.yaml @@ -0,0 +1,21 @@ +version: '2.1' +load: + - as: sparse + path: sparse.dg.json + check: True +extract: + - into: table 1 + from: sparse + at: + step: "a" + columns: + - key: raw->T_f + as: rawT + - key: derived->T + as: derT +save: + - table: table 1 + as: sparse.extension + type: nc + columns: ["rawT"] + sigma: false \ No newline at end of file