Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
XRD
darfix
Commits
7c5f9793
Commit
7c5f9793
authored
Aug 19, 2021
by
Julia Garriga Ferrer
Browse files
[core][dataset][data] Improve code
parent
66dc02cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
darfix/core/dataset.py
View file @
7c5f9793
...
...
@@ -1359,18 +1359,16 @@ class Data(numpy.ndarray):
def
__new__
(
cls
,
urls
,
metadata
,
in_memory
=
True
,
data
=
None
):
urls
=
numpy
.
asarray
(
urls
)
if
in_memory
:
if
data
is
not
None
and
urls
.
shape
==
data
.
shape
[:
-
2
]:
input_data
=
data
else
:
if
data
is
None
or
urls
.
shape
!=
data
.
shape
[:
-
2
]:
# Create array as stack of images
input_data
=
[]
for
url
in
urls
.
flatten
():
input_data
+=
[
utils
.
get_data
(
url
)
]
input_
data
=
numpy
.
asarray
(
input_data
)
input_data
.
append
(
utils
.
get_data
(
url
)
)
data
=
numpy
.
asarray
(
input_data
)
shape
=
list
(
urls
.
shape
)
shape
.
append
(
input_
data
.
shape
[
-
2
])
shape
.
append
(
input_
data
.
shape
[
-
1
])
obj
=
input_
data
.
reshape
(
shape
).
view
(
cls
)
shape
.
append
(
data
.
shape
[
-
2
])
shape
.
append
(
data
.
shape
[
-
1
])
obj
=
data
.
reshape
(
shape
).
view
(
cls
)
else
:
# Access image one at a time using url
obj
=
super
(
Data
,
cls
).
__new__
(
cls
,
urls
.
shape
)
...
...
Write
Preview
Markdown
is supported
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