Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review 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
mantidproject
mantid
Commits
830d9410
Commit
830d9410
authored
4 years ago
by
Nick Draper
Browse files
Options
Downloads
Patches
Plain Diff
Add unit test for model filtering
parent
f22fb9ef
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_model.py
+37
-1
37 additions, 1 deletion
...mantidqt/widgets/samplelogs/test/test_samplelogs_model.py
with
37 additions
and
1 deletion
qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_model.py
+
37
−
1
View file @
830d9410
...
...
@@ -7,7 +7,7 @@
# This file is part of the mantid workbench.
#
#
from
mantid.simpleapi
import
LoadEventNexus
,
CreateMDWorkspace
from
mantid.simpleapi
import
Load
,
LoadEventNexus
,
CreateMDWorkspace
from
mantidqt.widgets.samplelogs.model
import
SampleLogsModel
import
unittest
...
...
@@ -40,6 +40,9 @@ class SampleLogsModelTest(unittest.TestCase):
self
.
assertTrue
(
model
.
is_log_plottable
(
"
Speed5
"
))
self
.
assertFalse
(
model
.
is_log_plottable
(
"
duration
"
))
self
.
assertFalse
(
model
.
get_is_log_filtered
(
"
Speed5
"
))
self
.
assertFalse
(
model
.
get_is_log_filtered
(
"
duration
"
))
stats
=
model
.
get_statistics
(
"
Speed5
"
)
self
.
assertEqual
(
stats
.
maximum
,
300.0
)
...
...
@@ -56,6 +59,39 @@ class SampleLogsModelTest(unittest.TestCase):
self
.
assertEqual
(
itemModel
.
item
(
0
,
2
).
text
(),
"
4.0 (2 entries)
"
)
self
.
assertEqual
(
itemModel
.
item
(
0
,
3
).
text
(),
""
)
def
test_model_with_filtered_data
(
self
):
wsTuple
=
Load
(
'
POLREF00014966.nxs
'
)
#get the first child workspace of the group
ws
=
wsTuple
[
0
]
model
=
SampleLogsModel
(
ws
)
log_names
=
model
.
get_log_names
()
self
.
assertEqual
(
len
(
log_names
),
152
)
self
.
assertIn
(
"
raw_uah_log
"
,
log_names
)
self
.
assertIn
(
"
current_period
"
,
log_names
)
self
.
assertIn
(
"
period
"
,
log_names
)
values
=
model
.
get_log_display_values
(
"
raw_uah_log
"
)
self
.
assertEqual
(
values
[
0
],
"
raw_uah_log
"
)
self
.
assertEqual
(
values
[
1
],
"
float series
"
)
self
.
assertEqual
(
values
[
2
],
"
(429 entries)
"
)
self
.
assertEqual
(
values
[
3
],
"
uAh
"
)
self
.
assertTrue
(
model
.
is_log_plottable
(
"
raw_uah_log
"
))
self
.
assertFalse
(
model
.
is_log_plottable
(
"
current_period
"
))
self
.
assertTrue
(
model
.
is_log_plottable
(
"
period
"
))
self
.
assertTrue
(
model
.
get_is_log_filtered
(
"
raw_uah_log
"
))
self
.
assertFalse
(
model
.
get_is_log_filtered
(
"
period
"
))
self
.
assertFalse
(
model
.
get_is_log_filtered
(
"
current_period
"
))
stats
=
model
.
get_statistics
(
"
raw_uah_log
"
,
filtered
=
True
)
self
.
assertAlmostEqual
(
stats
.
maximum
,
193.333
,
3
)
stats
=
model
.
get_statistics
(
"
raw_uah_log
"
,
filtered
=
False
)
self
.
assertAlmostEqual
(
stats
.
maximum
,
194.296
,
3
)
self
.
assertFalse
(
model
.
isMD
())
def
test_model_MD
(
self
):
ws1
=
LoadEventNexus
(
"
CNCS_7860
"
,
MetaDataOnly
=
True
)
ws2
=
LoadEventNexus
(
"
VIS_19351
"
,
MetaDataOnly
=
True
)
...
...
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