Skip to content
Snippets Groups Projects
Unverified Commit 1ed3af47 authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Remove all style/plotting properties from Process

parent 4b93bb19
No related branches found
No related tags found
2 merge requests!4Resolve "Implement ROC",!2Resolve "Properties of a process"
......@@ -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):
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment