Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FreeForestML
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CERN
fsauerbu
FreeForestML
Commits
1ed3af47
Unverified
Commit
1ed3af47
authored
5 years ago
by
Frank Sauerburger
Browse files
Options
Downloads
Patches
Plain Diff
Remove all style/plotting properties from Process
parent
4b93bb19
No related branches found
Branches containing commit
No related tags found
2 merge requests
!4
Resolve "Implement ROC"
,
!2
Resolve "Properties of a process"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nnfwtbn/process.py
+5
-23
5 additions, 23 deletions
nnfwtbn/process.py
nnfwtbn/tests/test_process.py
+16
-22
16 additions, 22 deletions
nnfwtbn/tests/test_process.py
with
21 additions
and
45 deletions
nnfwtbn/process.py
+
5
−
23
View file @
1ed3af47
...
...
@@ -11,15 +11,13 @@ class Process:
DEFAULT_RANGE_VAR
=
'
fpid
'
def
__init__
(
self
,
label
,
selection
=
None
,
type
=
"
fill
"
,
range
=
None
,
range_var
=
None
,
**
kwds
):
def
__init__
(
self
,
label
,
selection
=
None
,
range
=
None
,
range_var
=
None
):
r
"""
Returns a new process object. The process has a human-readable name
(potentially using latex) and a selection cut. The selection argument
can be a cut object or any callable. The optional argument
'
type
'
defines how the process is displayed in a histogram. Possible values
are are
'
fill
'
,
'
line
'
and
'
points
'
. Stacking of processes is handled by
the plotting method. The default value is
'
fill
'
.
can be a cut object or any callable. Stacking of processes is handled by
the plotting method.
>>>
Process
(
"
Top
"
,
lambda
d
:
d
.
is_top
)
<
Process
'
Top
'
:
(
func
)
>
...
...
@@ -37,12 +35,6 @@ class Process:
If the range_var argument is omitted, the value of
Process.DEFAULT_RANGE_VAR is used, this defaults to
'
fpid
'
.
Any other Keyword argument is passed directly to the matplotlib upon
plotting.
>>>
Process
(
"
VBF
"
,
lambda
d
:
d
.
is_VBFH
,
linestyle
=
"
--
"
)
<
Process
'
VBF
'
:
(
func
)
>
"""
#######################################################
# Selection
...
...
@@ -77,18 +69,8 @@ class Process:
"
can be used.
"
)
#######################################################
# Type
allowed_types
=
[
"
fill
"
,
"
line
"
,
"
point
"
]
if
not
type
in
allowed_types
:
raise
err
.
InvalidProcessType
(
"
Process type must be one of %s.
"
%
repr
(
allowed_types
))
self
.
type
=
type
#######################################################
# Other
# Label
self
.
label
=
label
self
.
type
=
type
self
.
mpl_kwds
=
kwds
def
__repr__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
nnfwtbn/tests/test_process.py
+
16
−
22
View file @
1ed3af47
...
...
@@ -11,14 +11,25 @@ class ProcessTestCase(unittest.TestCase):
"""
Check that all arguments are stored internally.
"""
process
=
Process
(
"
Top
"
,
selection
=
lambda
d
:
d
.
is_top
,
color
=
'
#fe0134
'
,
linewidth
=
2
)
process
=
Process
(
"
Top
"
,
selection
=
lambda
d
:
d
.
is_top
)
self
.
assertEqual
(
process
.
label
,
"
Top
"
)
self
.
assertIsNotNone
(
process
.
selection
)
self
.
assertEqual
(
process
.
type
,
"
fill
"
)
self
.
assertEqual
(
process
.
mpl_kwds
,
{
'
color
'
:
'
#fe0134
'
,
'
linewidth
'
:
2
})
def
test_no_type
(
self
):
"""
Check that processes don
'
t accept the
'
type
'
argument.
"""
self
.
assertRaises
(
TypeError
,
Process
,
"
Top
"
,
type
=
"
fill
"
,
selection
=
lambda
d
:
d
.
is_top
)
def
test_no_color
(
self
):
"""
Check that processes don
'
t accept the
'
color
'
argument.
"""
self
.
assertRaises
(
TypeError
,
Process
,
"
Top
"
,
color
=
"
#ff0000
"
,
selection
=
lambda
d
:
d
.
is_top
)
def
test_lambda
(
self
):
...
...
@@ -82,23 +93,6 @@ class ProcessTestCase(unittest.TestCase):
process
=
Process
(
"
Top
"
,
range
=
(
5
,
10
),
range_var
=
"
yet_another
"
)
self
.
assertEqual
(
process
.
range_var
,
"
yet_another
"
)
def
test_type_values
(
self
):
"""
Check that allowed type values are stored. Check that an error is
raised if an illegal value is passed to the constructor.
"""
process
=
Process
(
"
Top
"
,
selection
=
lambda
d
:
d
.
is_top
,
type
=
'
fill
'
)
self
.
assertEqual
(
process
.
type
,
'
fill
'
)
process
=
Process
(
"
Top
"
,
selection
=
lambda
d
:
d
.
is_top
,
type
=
'
point
'
)
self
.
assertEqual
(
process
.
type
,
'
point
'
)
process
=
Process
(
"
Top
"
,
selection
=
lambda
d
:
d
.
is_top
,
type
=
'
line
'
)
self
.
assertEqual
(
process
.
type
,
'
line
'
)
self
.
assertRaises
(
ValueError
,
Process
,
"
Top
"
,
selection
=
lambda
d
:
d
.
is_top
,
type
=
'
other
'
)
def
test_range_type
(
self
):
"""
Check that an exception is raised if the range argument is not a tuple
...
...
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