Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
kmap
xsocs
Commits
b0587814
Commit
b0587814
authored
Nov 29, 2018
by
Thomas Vincent
Browse files
use str_to_hdf5_utf8 and _get_array_str
parent
7eb6822c
Changes
2
Hide whitespace changes
Inline
Side-by-side
xsocs/io/QSpaceH5.py
View file @
b0587814
...
...
@@ -156,10 +156,8 @@ class QSpaceH5(XsocsH5Base):
def
selected_entries
(
self
):
"""Returns the input entries used for the conversion."""
path
=
self
.
_ENTRIES_PATH
+
'/selected'
entries
=
self
.
_get_array_data
(
path
)
if
entries
is
not
None
:
return
[
entry
.
decode
()
for
entry
in
entries
]
return
[]
entries
=
self
.
_get_array_str
(
path
)
return
entries
if
entries
is
not
None
else
[]
@
property
def
shifts
(
self
):
...
...
@@ -207,10 +205,8 @@ class QSpaceH5(XsocsH5Base):
Returns the input entries that were not used for the conversion.
"""
path
=
self
.
_ENTRIES_PATH
+
'/discarded'
entries
=
self
.
_get_array_data
(
path
)
if
entries
is
not
None
:
return
[
entry
.
decode
()
for
entry
in
entries
]
return
[]
entries
=
self
.
_get_array_str
(
path
)
return
entries
if
entries
is
not
None
else
[]
@
property
def
image_mask
(
self
):
...
...
@@ -434,11 +430,10 @@ class QSpaceH5Writer(QSpaceH5):
number of selected entries. The shift is in grid coordinates.
"""
path
=
self
.
_ENTRIES_PATH
+
'/selected'
selected
=
_np
.
array
(
selected
,
dtype
=
_np
.
string_
)
selected
=
str_to_h5_utf8
(
selected
)
self
.
_set_array_data
(
path
,
selected
)
path
=
self
.
_ENTRIES_PATH
+
'/discarded'
discarded
=
_np
.
array
((
discarded
is
not
None
and
discarded
)
or
[],
dtype
=
_np
.
string_
)
discarded
=
str_to_h5_utf8
(
discarded
if
discarded
is
not
None
or
[])
self
.
_set_array_data
(
path
,
discarded
)
if
sample_shifts
is
not
None
:
...
...
xsocs/io/XsocsH5Base.py
View file @
b0587814
...
...
@@ -160,6 +160,18 @@ class XsocsH5Base(object):
except
KeyError
:
return
None
def
_get_array_str
(
self
,
path
):
"""Returns the array of string contained in the dataset.
:param str path: The path of the dataset in the HDF5 file
:rtype: List[str]
"""
strings
=
self
.
_get_array_data
(
path
=
path
)
if
strings
is
None
:
return
None
else
:
return
[
s
.
decode
()
if
hasattr
(
s
,
'decode'
)
else
s
for
s
in
strings
]
def
_set_scalar_data
(
self
,
path
,
value
):
with
self
.
_get_file
()
as
h5_f
:
value_np
=
_np
.
array
(
value
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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