Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
force-bdss
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Show more breadcrumbs
Adham Hashibon
force-bdss
Commits
d37c2975
Commit
d37c2975
authored
7 years ago
by
martinRenou
Browse files
Options
Downloads
Patches
Plain Diff
Refactor
parent
d932092c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!101
Create probe classes for tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
force_bdss/tests/probe_classes.py
+25
-26
25 additions, 26 deletions
force_bdss/tests/probe_classes.py
with
25 additions
and
26 deletions
force_bdss/tests/probe_classes.py
+
25
−
26
View file @
d37c2975
...
...
@@ -5,7 +5,8 @@ except ImportError:
from
envisage.plugin
import
Plugin
from
traits.api
import
HasStrictTraits
,
Bool
,
Function
,
Str
,
Int
,
Dict
from
traits.api
import
(
HasStrictTraits
,
Bool
,
Function
,
Str
,
Int
,
Dict
,
on_trait_change
)
from
force_bdss.api
import
(
BaseKPICalculatorFactory
,
BaseKPICalculatorModel
,
BaseKPICalculator
,
...
...
@@ -13,15 +14,9 @@ from force_bdss.api import (
)
class
ProbeEvaluator
(
H
as
StrictTraits
):
class
ProbeEvaluator
(
B
as
eKPICalculator
):
run_function
=
Function
input_slots_type
=
Str
(
'
PRESSURE
'
)
output_slots_type
=
Str
(
'
PRESSURE
'
)
input_slots_size
=
Int
(
0
)
output_slots_size
=
Int
(
0
)
run_called
=
Bool
(
False
)
slots_called
=
Bool
(
False
)
...
...
@@ -32,11 +27,11 @@ class ProbeEvaluator(HasStrictTraits):
def
slots
(
self
,
model
):
self
.
slots_called
=
True
return
(
tuple
(
Slot
(
type
=
s
el
f
.
input_slots_type
)
for
_
in
range
(
s
el
f
.
input_slots_size
))
tuple
(
Slot
(
type
=
mod
el
.
input_slots_type
)
for
_
in
range
(
mod
el
.
input_slots_size
))
),
(
tuple
(
Slot
(
type
=
s
el
f
.
output_slots_type
)
for
_
in
range
(
s
el
f
.
output_slots_size
))
tuple
(
Slot
(
type
=
mod
el
.
output_slots_type
)
for
_
in
range
(
mod
el
.
output_slots_size
))
)
...
...
@@ -59,17 +54,17 @@ class ProbeEvaluatorFactory(HasStrictTraits):
model_data
=
Dict
()
class
ProbeKPICalculator
(
BaseKPICalculator
,
ProbeEvaluator
):
pass
class
ProbeKPICalculatorModel
(
BaseKPICalculatorModel
):
def
__init__
(
self
,
factory
,
model_data
,
*
args
,
**
kwargs
):
for
key
,
value
in
model_data
.
items
():
setattr
(
self
,
key
,
value
)
input_slots_type
=
Str
(
'
PRESSURE
'
)
output_slots_type
=
Str
(
'
PRESSURE
'
)
input_slots_size
=
Int
(
0
)
output_slots_size
=
Int
(
0
)
super
(
ProbeKPICalculatorModel
,
self
).
__init__
(
self
,
factory
,
*
args
,
**
kwargs
)
@on_trait_change
(
'
input_slots_type,output_slots_type,
'
'
input_slots_size,output_slots_size
'
)
def
update_slots
(
self
):
self
.
changes_slots
=
True
class
ProbeKPICalculatorFactory
(
BaseKPICalculatorFactory
,
...
...
@@ -77,15 +72,19 @@ class ProbeKPICalculatorFactory(BaseKPICalculatorFactory,
id
=
Str
(
'
enthought.test.kpi_calculator
'
)
name
=
Str
(
'
test_kpi_calculator
'
)
def
create_model
(
self
,
model_data
=
None
):
return
ProbeKPICalculatorModel
(
self
,
self
.
model_data
)
model_class
=
ProbeKPICalculatorModel
def
create_
kpi_calculator
(
self
):
return
ProbeKPICalculator
(
def
create_
model
(
self
,
model_data
=
None
):
return
self
.
model_class
(
factory
=
self
,
run_function
=
self
.
run_function
,
input_slots_type
=
self
.
input_slots_type
,
output_slots_type
=
self
.
output_slots_type
,
input_slots_size
=
self
.
input_slots_size
,
output_slots_size
=
self
.
output_slots_size
)
def
create_kpi_calculator
(
self
):
return
ProbeEvaluator
(
factory
=
self
,
run_function
=
self
.
run_function
,
)
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