Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
d51eb5f6
Commit
d51eb5f6
authored
8 years ago
by
Axel Naumann
Browse files
Options
Downloads
Patches
Plain Diff
Increase coverage.
parent
abe4ec8d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hist/hist/v7/unit/axis.cxx
+29
-0
29 additions, 0 deletions
hist/hist/v7/unit/axis.cxx
hist/hist/v7/unit/biniter.cxx
+40
-1
40 additions, 1 deletion
hist/hist/v7/unit/biniter.cxx
with
69 additions
and
1 deletion
hist/hist/v7/unit/axis.cxx
+
29
−
0
View file @
d51eb5f6
...
...
@@ -63,6 +63,7 @@ TEST(AxisTest, NumBins) {
// Through concrete axis incarnations (and to TAxisConfig)
{
TAxisEquidistant
ax
(
"TITLE"
,
10
,
-
1.
,
1.
);
EXPECT_EQ
(
10
+
nOverflow
,
ax
.
GetNBins
());
EXPECT_EQ
(
10
,
ax
.
GetNBinsNoOver
());
EXPECT_EQ
(
0
,
ax
.
GetUnderflowBin
());
...
...
@@ -72,6 +73,34 @@ TEST(AxisTest, NumBins) {
EXPECT_EQ
(
true
,
ax
.
IsOverflowBin
(
11
));
EXPECT_EQ
(
true
,
ax
.
IsOverflowBin
(
16
));
EXPECT_FLOAT_EQ
(
0.2
,
ax
.
GetBinWidth
());
EXPECT_EQ
(
7
,
ax
.
FindBin
(
0.22
));
EXPECT_EQ
(
0
,
ax
.
FindBin
(
-
2.
));
EXPECT_EQ
(
10
,
ax
.
FindBin
(
0.99
));
EXPECT_EQ
(
11
,
ax
.
FindBin
(
1.01
));
EXPECT_EQ
(
11
,
ax
.
FindBin
(
101.
));
EXPECT_FLOAT_EQ
(
0.7
,
ax
.
GetBinCenter
(
9
));
EXPECT_FLOAT_EQ
(
0.6
,
ax
.
GetBinFrom
(
9
));
EXPECT_FLOAT_EQ
(
0.8
,
ax
.
GetBinTo
(
9
));
EXPECT_LT
(
ax
.
GetBinCenter
(
0
),
-
1.
);
EXPECT_LT
(
ax
.
GetBinFrom
(
0
),
-
1.
);
EXPECT_FLOAT_EQ
(
-
1.
,
ax
.
GetBinTo
(
0
));
EXPECT_LT
(
ax
.
GetBinCenter
(
-
1
),
-
1.
);
EXPECT_LT
(
ax
.
GetBinFrom
(
-
2
),
-
1.
);
EXPECT_LE
(
ax
.
GetBinTo
(
-
3
),
-
1.
);
EXPECT_LT
(
1.
,
ax
.
GetBinCenter
(
11
));
EXPECT_FLOAT_EQ
(
1.
,
ax
.
GetBinFrom
(
11
));
EXPECT_LT
(
1.
,
ax
.
GetBinTo
(
11
));
EXPECT_LT
(
1.
,
ax
.
GetBinCenter
(
111
));
EXPECT_LE
(
1.
,
ax
.
GetBinFrom
(
111
));
EXPECT_LT
(
1.
,
ax
.
GetBinTo
(
111
));
TAxisConfig
axcfg
(
ax
);
EXPECT_EQ
(
ax
.
GetNBins
(),
axcfg
.
GetNBins
());
EXPECT_EQ
(
10
,
axcfg
.
GetNBinsNoOver
());
...
...
This diff is collapsed.
Click to expand it.
hist/hist/v7/unit/biniter.cxx
+
40
−
1
View file @
d51eb5f6
#include
"gtest/gtest.h"
#include
<ROOT/THist.h>
#include
<ROOT/THistBinIter.h>
#include
<cmath>
using
namespace
ROOT
::
Experimental
;
// Tests the number of bins
TEST
(
BinIterNBins
,
NumBins
)
{
TH2F
h
({
10
,
-
1.
,
1.
},
{
10
,
-
1.
,
1.
});
EXPECT_EQ
(
12
*
12
,
h
.
GetImpl
()
->
GetNBins
());
double
x
=
0.11
;
double
y
=
0.33
;
double
w
=
3.141
;
h
.
Fill
({{
x
,
y
}},
w
);
h
.
Fill
({{
x
,
y
}},
2.
*
w
);
EXPECT_FLOAT_EQ
(
3.
*
w
,
h
.
GetBinContent
({{
x
,
y
}}));
int
xbin
=
h
.
GetImpl
()
->
GetAxis
(
0
).
FindBin
(
x
);
EXPECT_EQ
(
6
,
xbin
);
int
ybin
=
h
.
GetImpl
()
->
GetAxis
(
1
).
FindBin
(
y
);
EXPECT_EQ
(
7
,
ybin
);
int
linbin
=
h
.
GetImpl
()
->
GetBinIndex
({{
x
,
y
}});
const
int
expectedLinBin
=
xbin
+
ybin
*
12
;
EXPECT_EQ
(
expectedLinBin
,
linbin
);
EXPECT_FLOAT_EQ
(
3.
*
w
,
h
.
GetImpl
()
->
GetBinContent
(
linbin
));
int
foundbin
=
-
1
;
double
foundweight
=
-
1.
;
double
founduncert
=
-
1.
;
std
::
array
<
double
,
2
>
foundcoord
{};
int
nBins
=
0
;
for
(
auto
&&
bin
:
h
)
{
(
void
)
bin
;
auto
binCenter
=
bin
.
GetCenter
();
if
(
std
::
fabs
(
binCenter
[
0
]
-
x
)
<
0.1
&&
std
::
fabs
(
binCenter
[
1
]
-
y
)
<
0.1
)
{
foundbin
=
nBins
;
foundcoord
=
binCenter
;
foundweight
=
bin
.
GetContent
();
founduncert
=
bin
.
GetUncertainty
();
}
++
nBins
;
}
EXPECT_EQ
(
h
.
GetImpl
()
->
GetNBins
(),
nBins
);
EXPECT_FLOAT_EQ
(
0.1
,
foundcoord
[
0
]);
EXPECT_FLOAT_EQ
(
0.3
,
foundcoord
[
1
]);
EXPECT_EQ
(
expectedLinBin
,
foundbin
);
EXPECT_FLOAT_EQ
(
3.
*
w
,
foundweight
);
EXPECT_FLOAT_EQ
(
std
::
sqrt
(
w
*
w
+
(
2
*
w
)
*
(
2
*
w
)),
founduncert
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment