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
NIFTy
Commits
4067aa04
Commit
4067aa04
authored
Jul 25, 2018
by
Martin Reinecke
Browse files
bug fixes
parent
3081351a
Changes
3
Hide whitespace changes
Inline
Side-by-side
nifty5/data_objects/distributed_do.py
View file @
4067aa04
...
...
@@ -262,6 +262,8 @@ def empty_like(a, dtype=None):
def
vdot
(
a
,
b
):
tmp
=
np
.
array
(
np
.
vdot
(
a
.
_data
,
b
.
_data
))
if
a
.
_distaxis
==-
1
:
return
tmp
[()]
res
=
np
.
empty
((),
dtype
=
tmp
.
dtype
)
_comm
.
Allreduce
(
tmp
,
res
,
MPI
.
SUM
)
return
res
[()]
...
...
@@ -309,6 +311,10 @@ def from_object(object, dtype, copy, set_locked):
# algorithm.
def
from_random
(
random_type
,
shape
,
dtype
=
np
.
float64
,
**
kwargs
):
generator_function
=
getattr
(
Random
,
random_type
)
if
shape
==
():
ldat
=
generator_function
(
dtype
=
dtype
,
shape
=
shape
,
**
kwargs
)
ldat
=
_comm
.
bcast
(
ldat
)
return
from_local_data
(
shape
,
ldat
,
distaxis
=-
1
)
for
i
in
range
(
ntask
):
lshape
=
list
(
shape
)
lshape
[
0
]
=
_shareSize
(
shape
[
0
],
ntask
,
i
)
...
...
nifty5/operators/vdot_operator.py
View file @
4067aa04
...
...
@@ -31,7 +31,7 @@ class VdotOperator(LinearOperator):
def
__init__
(
self
,
field
):
super
(
VdotOperator
,
self
).
__init__
()
self
.
_field
=
field
self
.
_target
=
DomainTuple
.
make
(
UnstructuredDomain
(
1
))
self
.
_target
=
DomainTuple
.
make
(
(
))
@
property
def
domain
(
self
):
...
...
@@ -49,4 +49,4 @@ class VdotOperator(LinearOperator):
self
.
_check_input
(
x
,
mode
)
if
mode
==
self
.
TIMES
:
return
full
(
self
.
_target
,
self
.
_field
.
vdot
(
x
))
return
self
.
_field
*
x
.
to_g
lo
b
al_data
()
[()]
return
self
.
_field
*
x
.
lo
c
al_data
[()]
test/test_field.py
View file @
4067aa04
...
...
@@ -243,3 +243,13 @@ class Test_Functionality(unittest.TestCase):
assert_equal
((
f
/
f2
).
local_data
,
f
.
local_data
/
f2
.
local_data
)
assert_equal
((
-
f
).
local_data
,
-
(
f
.
local_data
))
assert_equal
(
abs
(
f
).
local_data
,
abs
(
f
.
local_data
))
def
test_emptydomain
(
self
):
f
=
ift
.
Field
.
full
((),
3.
)
assert_equal
(
f
.
sum
(),
3.
)
assert_equal
(
f
.
prod
(),
3.
)
assert_equal
(
f
.
local_data
,
3.
)
assert_equal
(
f
.
local_data
.
shape
,
())
assert_equal
(
f
.
local_data
.
size
,
1
)
assert_equal
(
f
.
vdot
(
f
),
9.
)
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