Skip to content

Commit

Permalink
test upgrade 1.0.1 to itself
Browse files Browse the repository at this point in the history
  • Loading branch information
kratsg committed Dec 8, 2022
1 parent 9ab3898 commit d22e37d
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_upgrade_to_latest(datadir):

def test_1_0_0_workspace(datadir, caplog, monkeypatch):
"""
Test upgrading a workspace from 1.0.0
Test upgrading a workspace from 1.0.0 to 1.0.1
"""
spec = json.load(open(datadir.joinpath("workspace_1.0.0.json"), encoding="utf-8"))

Expand All @@ -37,7 +37,7 @@ def test_1_0_0_workspace(datadir, caplog, monkeypatch):

def test_1_0_0_patchset(datadir, caplog, monkeypatch):
"""
Test upgrading a patchset from 1.0.0
Test upgrading a patchset from 1.0.0 to 1.0.1
"""
spec = json.load(open(datadir.joinpath("patchset_1.0.0.json"), encoding="utf-8"))

Expand All @@ -50,3 +50,23 @@ def test_1_0_0_patchset(datadir, caplog, monkeypatch):

new_spec = pyhf.schema.upgrade(to_version='1.0.1').patchset(spec)
assert new_spec['version'] == '1.0.1'


def test_1_0_1_workspace(datadir):
"""
Test upgrading a workspace from 1.0.1 to 1.0.1
"""
spec = json.load(open(datadir.joinpath("workspace_1.0.1.json"), encoding="utf-8"))

new_spec = pyhf.schema.upgrade(to_version='1.0.1').workspace(spec)
assert new_spec['version'] == '1.0.1'


def test_1_0_1_patchset(datadir):
"""
Test upgrading a patchset from 1.0.1 to 1.0.1
"""
spec = json.load(open(datadir.joinpath("patchset_1.0.1.json"), encoding="utf-8"))

new_spec = pyhf.schema.upgrade(to_version='1.0.1').patchset(spec)
assert new_spec['version'] == '1.0.1'
29 changes: 29 additions & 0 deletions tests/test_upgrade/patchset_1.0.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"metadata": {
"references": { "hepdata": "ins1234567" },
"description": "patchset for validation/xmlimport_input/config/example.xml",
"digests": { "sha256": "7c32ca3b8db75cbafcf5cd7ed4672fa2b1fa69e391c9b89068dd947a521866ec" },
"labels": ["x"]
},
"patches": [
{
"metadata": {
"name": "patch_channel1_signal_syst1",
"values": [0]
},
"patch": [
{
"op": "replace",
"path": "/channels/0/samples/0/modifiers/0/data/hi",
"value": 1.2
},
{
"op": "replace",
"path": "/channels/0/samples/0/modifiers/0/data/lo",
"value": 0.8
}
]
}
],
"version": "1.0.0"
}
82 changes: 82 additions & 0 deletions tests/test_upgrade/workspace_1.0.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"channels": [
{
"name": "singlechannel",
"samples": [
{
"data": [
5
],
"modifiers": [
{
"data": null,
"name": "mu",
"type": "normfactor"
}
],
"name": "signal"
},
{
"data": [
50
],
"modifiers": [
{
"data": [
6
],
"name": "uncorr_bkguncrt",
"type": "shapesys"
}
],
"name": "background"
}
]
}
],
"measurements": [
{
"config": {
"parameters": [
{
"bounds": [
[
0,
10
]
],
"fixed": false,
"inits": [
1
],
"name": "mu"
},
{
"bounds": [
[
1e-10,
10
]
],
"fixed": false,
"inits": [
1
],
"name": "uncorr_bkguncrt"
}
],
"poi": "mu"
},
"name": "measurement"
}
],
"observations": [
{
"data": [
50
],
"name": "singlechannel"
}
],
"version": "1.0.0"
}

0 comments on commit d22e37d

Please sign in to comment.