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
ift
D2O
Commits
a8223de5
Commit
a8223de5
authored
May 04, 2017
by
Theo Steininger
Browse files
Fixed dtype bug in distribute_data.
parent
d5c7bb26
Changes
1
Hide whitespace changes
Inline
Side-by-side
d2o/distributor_factory.py
View file @
a8223de5
...
...
@@ -317,15 +317,16 @@ class distributor(object):
h5py_dataset_Q
=
isinstance
(
data
,
h5py
.
Dataset
)
if
data
is
None
:
re
turn
np
.
empty
(
self
.
local_shape
,
dtype
=
self
.
dtype
)
re
sult_data
=
np
.
empty
(
self
.
local_shape
,
dtype
=
self
.
dtype
)
elif
np
.
isscalar
(
data
):
return
np
.
ones
(
self
.
local_shape
,
dtype
=
self
.
dtype
)
*
data
result_data
=
np
.
empty
(
self
.
local_shape
,
dtype
=
self
.
dtype
)
result_data
[:]
=
data
elif
isinstance
(
data
,
np
.
ndarray
)
or
\
isinstance
(
data
,
distributed_data_object
)
or
\
h5py_dataset_Q
:
data
=
self
.
extract_local_data
(
data
)
if
data
.
shape
is
not
self
.
local_shape
:
if
data
.
shape
!=
self
.
local_shape
:
copy
=
True
if
copy
:
...
...
@@ -334,12 +335,14 @@ class distributor(object):
else
:
result_data
=
data
return
result_data
# fix dtype
result_data
=
result_data
.
astype
(
self
.
dtype
,
copy
=
False
)
else
:
new_data
=
np
.
array
(
data
)
return
new_data
.
astype
(
self
.
dtype
,
copy
=
copy
).
reshape
(
self
.
local_shape
)
result_data
=
new_data
.
astype
(
self
.
dtype
,
copy
=
copy
).
reshape
(
self
.
local_shape
)
return
result_data
def
disperse_data
(
self
,
data
,
to_key
,
data_update
,
from_key
=
None
,
local_keys
=
False
,
copy
=
True
,
**
kwargs
):
...
...
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