Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
85db45e4
Commit
85db45e4
authored
May 12, 2018
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make ScalingOperator work on MultiField
parent
e759eb60
Pipeline
#29014
passed with stages
in 3 minutes and 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
nifty4/multi/multi_field.py
nifty4/multi/multi_field.py
+7
-0
nifty4/operators/scaling_operator.py
nifty4/operators/scaling_operator.py
+4
-2
No files found.
nifty4/multi/multi_field.py
View file @
85db45e4
...
@@ -32,6 +32,13 @@ class MultiField(object):
...
@@ -32,6 +32,13 @@ class MultiField(object):
def
dtype
(
self
):
def
dtype
(
self
):
return
{
key
:
val
.
dtype
for
key
,
val
in
self
.
_val
.
items
()}
return
{
key
:
val
.
dtype
for
key
,
val
in
self
.
_val
.
items
()}
@
staticmethod
def
from_random
(
random_type
,
domain
,
dtype
=
np
.
float64
,
**
kwargs
):
dtype
=
self
.
build_dtype
(
dtype
)
return
MultiField
({
key
:
Field
.
from_random
(
random_type
,
domain
[
key
],
dtype
[
key
],
**
kwargs
)
for
key
in
domain
.
keys
})
def
_check_domain
(
self
,
other
):
def
_check_domain
(
self
,
other
):
if
other
.
domain
!=
self
.
domain
:
if
other
.
domain
!=
self
.
domain
:
raise
ValueError
(
"domains are incompatible."
)
raise
ValueError
(
"domains are incompatible."
)
...
...
nifty4/operators/scaling_operator.py
View file @
85db45e4
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
from
__future__
import
division
from
__future__
import
division
import
numpy
as
np
import
numpy
as
np
from
..field
import
Field
from
..field
import
Field
from
..multi.multi_field
import
MultiField
from
..domain_tuple
import
DomainTuple
from
..domain_tuple
import
DomainTuple
from
.endomorphic_operator
import
EndomorphicOperator
from
.endomorphic_operator
import
EndomorphicOperator
...
@@ -61,7 +62,7 @@ class ScalingOperator(EndomorphicOperator):
...
@@ -61,7 +62,7 @@ class ScalingOperator(EndomorphicOperator):
if
self
.
_factor
==
1.
:
if
self
.
_factor
==
1.
:
return
x
.
copy
()
return
x
.
copy
()
if
self
.
_factor
==
0.
:
if
self
.
_factor
==
0.
:
return
Field
.
zeros_like
(
x
)
return
x
.
zeros_like
(
x
)
if
mode
==
self
.
TIMES
:
if
mode
==
self
.
TIMES
:
return
x
*
self
.
_factor
return
x
*
self
.
_factor
...
@@ -103,5 +104,6 @@ class ScalingOperator(EndomorphicOperator):
...
@@ -103,5 +104,6 @@ class ScalingOperator(EndomorphicOperator):
if
fct
.
real
==
0.
and
from_inverse
:
if
fct
.
real
==
0.
and
from_inverse
:
raise
ValueError
(
"operator not positive definite"
)
raise
ValueError
(
"operator not positive definite"
)
fct
=
1.
/
np
.
sqrt
(
fct
)
if
from_inverse
else
np
.
sqrt
(
fct
)
fct
=
1.
/
np
.
sqrt
(
fct
)
if
from_inverse
else
np
.
sqrt
(
fct
)
return
Field
.
from_random
(
cls
=
Field
if
isinstance
(
self
.
_domain
,
DomainTuple
)
else
MultiField
return
cls
.
from_random
(
random_type
=
"normal"
,
domain
=
self
.
_domain
,
std
=
fct
,
dtype
=
dtype
)
random_type
=
"normal"
,
domain
=
self
.
_domain
,
std
=
fct
,
dtype
=
dtype
)
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