Skip to content

Commit

Permalink
groot/rjson: test TGraph{,Errors,AsymErrors,MultiErrors}
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastien Binet <[email protected]>
  • Loading branch information
sbinet committed Sep 14, 2023
1 parent 66348c9 commit 921ddd2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 10 deletions.
58 changes: 48 additions & 10 deletions groot/rjson/rjson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,54 @@ func TestMarshal(t *testing.T) {
return rhist.NewH2DFrom(h)
},
},
// FIXME(sbinet)
// {
// name: "graph",
// gen: func() root.Object {
// s := hbook.NewS2DFrom([]float64{1, 2, 3}, []float64{2, 4, 6})
// s.Annotation()["name"] = "s2"
// s.Annotation()["title"] = "my title"
// return rhist.NewGraphFrom(s)
// },
// },
{
name: "graph",
gen: func() root.Object {
s := hbook.NewS2DFrom([]float64{1, 2, 3}, []float64{2, 4, 6})
s.Annotation()["name"] = "s2"
s.Annotation()["title"] = "my title"
return rhist.NewGraphFrom(s)
},
},
{
name: "tge",
gen: func() root.Object {
s := hbook.NewS2D([]hbook.Point2D{
{X: 1, Y: 2, ErrX: hbook.Range{Min: 10, Max: 20}, ErrY: hbook.Range{Min: 11, Max: 22}},
{X: 2, Y: 4, ErrX: hbook.Range{Min: 20, Max: 30}, ErrY: hbook.Range{Min: 12, Max: 23}},
{X: 3, Y: 6, ErrX: hbook.Range{Min: 30, Max: 40}, ErrY: hbook.Range{Min: 13, Max: 24}},
}...)
s.Annotation()["name"] = "s2"
s.Annotation()["title"] = "my title"
return rhist.NewGraphErrorsFrom(s)
},
},
{
name: "tgae",
gen: func() root.Object {
s := hbook.NewS2D([]hbook.Point2D{
{X: 1, Y: 2, ErrX: hbook.Range{Min: 10, Max: 20}, ErrY: hbook.Range{Min: 11, Max: 22}},
{X: 2, Y: 4, ErrX: hbook.Range{Min: 20, Max: 30}, ErrY: hbook.Range{Min: 12, Max: 23}},
{X: 3, Y: 6, ErrX: hbook.Range{Min: 30, Max: 40}, ErrY: hbook.Range{Min: 13, Max: 24}},
}...)
s.Annotation()["name"] = "s2"
s.Annotation()["title"] = "my title"
return rhist.NewGraphAsymmErrorsFrom(s)
},
},
{
name: "tgme",
gen: func() root.Object {
s := hbook.NewS2D([]hbook.Point2D{
{X: 1, Y: 2, ErrX: hbook.Range{Min: 10, Max: 20}, ErrY: hbook.Range{Min: 11, Max: 22}},
{X: 2, Y: 4, ErrX: hbook.Range{Min: 20, Max: 30}, ErrY: hbook.Range{Min: 12, Max: 23}},
{X: 3, Y: 6, ErrX: hbook.Range{Min: 30, Max: 40}, ErrY: hbook.Range{Min: 13, Max: 24}},
}...)
s.Annotation()["name"] = "s2"
s.Annotation()["title"] = "my title"
return rhist.NewGraphMultiErrorsFrom(s)
},
},
} {
t.Run(tc.name, func(t *testing.T) {
var (
Expand Down
1 change: 1 addition & 0 deletions groot/rjson/testdata/graph_golden.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"_typename": "TGraph", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6}
1 change: 1 addition & 0 deletions groot/rjson/testdata/tgae_golden.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"_typename": "TGraphAsymmErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fEXlow": [10,20,30], "fEXhigh": [20,30,40], "fEYlow": [11,12,13], "fEYhigh": [22,23,24]}
1 change: 1 addition & 0 deletions groot/rjson/testdata/tge_golden.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"_typename": "TGraphErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fEX": [10,20,30], "fEY": [11,12,13]}
1 change: 1 addition & 0 deletions groot/rjson/testdata/tgme_golden.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"_typename": "TGraphMultiErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fNYErrors": 1, "fSumErrorsMode": 0, "fExL": [10,20,30], "fExH": [20,30,40], "fEyL": [[11,12,13]], "fEyH": [[22,23,24]], "fAttFill": [{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0},{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0},{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0}], "fAttLine": [{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0},{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0},{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0}]}

0 comments on commit 921ddd2

Please sign in to comment.