Skip to content

Commit

Permalink
Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterKraus committed Aug 31, 2023
1 parent 6abe63b commit d9fcfff
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/dgbowl_schemas/dgpost/recipe_2_1/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``."""
63 changes: 50 additions & 13 deletions tests/ref_recipe.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ts0 = {
le_1 = {
"version": "v1.0",
"load": [
{
Expand All @@ -25,7 +25,7 @@
"save": None,
}

ts1 = {
le_2 = {
"version": "v1.0",
"load": [
{
Expand Down Expand Up @@ -72,7 +72,7 @@
"save": None,
}

ts2 = {
lee_1 = {
"version": "v1.0",
"load": [
{
Expand Down Expand Up @@ -112,7 +112,7 @@
"save": None,
}

ts3 = {
lee_2 = {
"version": "v1.0",
"load": [
{
Expand Down Expand Up @@ -159,7 +159,7 @@
"save": None,
}

ts4 = {
les_1 = {
"version": "v1.0",
"load": [
{
Expand Down Expand Up @@ -191,7 +191,7 @@
],
}

ts5 = {
les_2 = {
"version": "v1.0",
"load": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -284,7 +321,7 @@
"save": None,
}

ts7 = {
let_2 = {
"version": "v1.0",
"load": [
{
Expand Down Expand Up @@ -330,7 +367,7 @@
"save": None,
}

ts8 = {
letp_1 = {
"version": "v1.0",
"load": [
{
Expand Down Expand Up @@ -415,7 +452,7 @@
"save": None,
}

ts9 = {
lp_1 = {
"version": "v1.0",
"load": [
{
Expand Down Expand Up @@ -489,7 +526,7 @@
"save": None,
}

js0 = {
lets = {
"version": "v1.0",
"load": [
{"as": "d1", "path": "table.pkl", "type": "table", "check": True},
Expand Down Expand Up @@ -525,7 +562,7 @@
"plot": None,
}

pivot1 = {
pivot_1 = {
"version": "2.1",
"load": [
{
Expand All @@ -551,7 +588,7 @@
"plot": None,
}

pivot2 = {
pivot_2 = {
"version": "2.1",
"load": [
{
Expand Down
31 changes: 15 additions & 16 deletions tests/test_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions tests/test_recipe/les_3.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d9fcfff

Please sign in to comment.