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
ift
NIFTy
Commits
9d7fe771
Commit
9d7fe771
authored
Dec 01, 2017
by
Martin Reinecke
Browse files
a few fixes
parent
6dd60a22
Pipeline
#22442
passed with stage
in 4 minutes and 46 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/operators/dof_projection_operator.py
View file @
9d7fe771
...
...
@@ -5,9 +5,11 @@ from ..spaces import DOFSpace
class
DOFProjectionOperator
(
LinearOperator
):
def
__init__
(
self
,
do
main
,
dofdex
,
space
=
None
):
def
__init__
(
self
,
do
fdex
,
domain
=
None
,
space
=
None
):
super
(
DOFProjectionOperator
,
self
).
__init__
()
if
domain
is
None
:
domain
=
dofdex
.
domain
self
.
_domain
=
DomainTuple
.
make
(
domain
)
if
space
is
None
and
len
(
self
.
_domain
)
==
1
:
space
=
0
...
...
@@ -17,15 +19,19 @@ class DOFProjectionOperator(LinearOperator):
partner
=
self
.
_domain
[
space
]
if
not
isinstance
(
dofdex
,
Field
):
raise
TypeError
(
"dofdex must be a Field"
)
if
not
isinstance
(
dofdex
.
dtype
,
np
.
integer
):
if
not
len
(
dofdex
.
domain
)
==
1
:
raise
ValueError
(
"dofdex must live on exactly one Space"
)
if
not
np
.
issubdtype
(
dofdex
.
dtype
,
np
.
integer
):
print
(
dofdex
.
dtype
.
type
,
np
.
integer
)
raise
TypeError
(
"dofdex must contain integer numbers"
)
if
partner
!=
dofdex
.
domain
:
if
partner
!=
dofdex
.
domain
[
0
]:
print
(
partner
,
dofdex
.
domain
[
0
])
raise
ValueError
(
"incorrect dofdex domain"
)
nbin
=
dofdex
.
max
()
if
partner
.
scalar_dvol
()
is
not
None
:
wgt
=
np
.
bincount
(
dobj
.
local_data
(
dofdex
.
val
).
ravel
(),
minlength
=
nbin
)
minlength
=
nbin
)
.
astype
(
np
.
float64
)
wgt
*=
partner
.
scalar_dvol
()
else
:
dvol
=
dobj
.
local_data
(
partner
.
dvol
())
...
...
@@ -45,9 +51,9 @@ class DOFProjectionOperator(LinearOperator):
self
.
_target
=
DomainTuple
.
make
(
tgt
)
if
dobj
.
default_distaxis
()
in
self
.
domain
.
axes
[
self
.
_space
]:
dofdex
=
dobj
.
local_data
(
dofdex
)
dofdex
=
dobj
.
local_data
(
dofdex
.
val
)
else
:
# dofdex must be available fully on every task
dofdex
=
dobj
.
to_global_data
(
dofdex
)
dofdex
=
dobj
.
to_global_data
(
dofdex
.
val
)
self
.
_dofdex
=
dofdex
.
ravel
()
firstaxis
=
self
.
_domain
.
axes
[
self
.
_space
][
0
]
lastaxis
=
self
.
_domain
.
axes
[
self
.
_space
][
-
1
]
...
...
nifty/spaces/dof_space.py
View file @
9d7fe771
import
numpy
as
np
from
.space
import
Space
...
...
@@ -23,7 +24,7 @@ class DOFSpace(Space):
return
None
def
dvol
(
self
):
return
self
.
_dvol
return
np
.
array
(
self
.
_dvol
)
def
__repr__
(
self
):
return
'this is a dof space'
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