Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
workflow
ewoksapps
est
Commits
4aef19a5
Commit
4aef19a5
authored
Jul 22, 2021
by
payno
Browse files
[io][test_input_information] add test on the input information
parent
bac7880a
Changes
2
Hide whitespace changes
Inline
Side-by-side
est/io/test/test_input_information.py
View file @
4aef19a5
...
...
@@ -29,6 +29,7 @@ __date__ = "07/21/2021"
from
est.io.utils.information
import
InputInformation
from
est.io.utils.information
import
SpecInputInformation
from
est.app.utils
import
get_xas_obj
from
silx.io.url
import
DataUrl
import
unittest
import
os
...
...
@@ -50,6 +51,7 @@ class TestInputInformation(unittest.TestCase):
"""Test the different way of providing a spec file entry are
all valid"""
self
.
data_input_file
=
os
.
path
.
join
(
PYMCA_DATA_DIR
,
"EXAFS_Cu.dat"
)
# first way providing directly url
input_information_1
=
InputInformation
(
spectra_url
=
DataUrl
(
file_path
=
self
.
data_input_file
,
...
...
@@ -62,18 +64,28 @@ class TestInputInformation(unittest.TestCase):
data_path
=
"Column 2"
,
),
)
xas_obj_1
=
get_xas_obj
(
input_information_1
)
self
.
assertTrue
(
input_information_1
.
channel_url
is
not
None
)
self
.
assertTrue
(
xas_obj_1
.
energy
is
not
None
)
# second way providing only a spec file
input_information_2
=
InputInformation
(
spec_input
=
SpecInputInformation
(
spec_file
=
self
.
data_input_file
)
)
input_information_3
=
InputInformation
(
spec_input
=
SpecInputInformation
(
spec_file
=
self
.
data_input_file
,
energy_abs_col_name
=
"Column 1"
,
input_abs_col_name
=
"Column 2"
,
)
)
,
)
xas_obj_2
=
get_xas_obj
(
input_information_2
)
self
.
assertTrue
(
xas_obj_2
.
energy
is
not
None
)
self
.
assertTrue
(
xas_obj_2
.
spectra
.
data
.
flat
[
0
]
is
not
None
)
self
.
assertEqual
(
input_information_1
,
input_information_2
)
self
.
assertEqual
(
input_information_1
,
input_information_3
)
# third way providing a spec file and column names
input_information_3
=
InputInformation
(
spec_input
=
SpecInputInformation
(
spec_file
=
self
.
data_input_file
,
),
)
xas_obj_3
=
get_xas_obj
(
input_information_3
)
self
.
assertTrue
(
xas_obj_3
.
energy
is
not
None
)
self
.
assertTrue
(
xas_obj_3
.
spectra
.
data
.
flat
[
0
]
is
not
None
)
est/io/utils/information.py
View file @
4aef19a5
...
...
@@ -40,10 +40,10 @@ class SpecInputInformation:
def
__init__
(
self
,
spec_file
,
energy_abs_col_name
,
input_abs_col_name
,
input_monitor_col_name
,
scan_title
,
energy_abs_col_name
=
None
,
input_abs_col_name
=
None
,
input_monitor_col_name
=
None
,
scan_title
=
None
,
):
self
.
__spec_file
=
None
self
.
__scan_title
=
None
...
...
@@ -110,8 +110,8 @@ class InputInformation:
def
__init__
(
self
,
spectra_url
,
channel_url
,
spectra_url
=
None
,
channel_url
=
None
,
config_url
=
None
,
dimensions
=
(
Dim
.
DIM_2
,
Dim
.
DIM_1
,
Dim
.
DIM_0
),
energy_unit
=
ur
.
eV
,
...
...
@@ -133,6 +133,14 @@ class InputInformation:
self
.
__I2_url
=
None
self
.
__mu_ref_url
=
None
if
(
spectra_url
is
not
None
or
channel_url
is
not
None
)
and
spec_input
is
not
None
:
raise
ValueError
(
"Either spec input or urls (spectra and channel) "
"must be provided. Not both"
)
self
.
spectra_url
=
spectra_url
self
.
channel_url
=
channel_url
self
.
config_url
=
config_url
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment