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
13
Issues
13
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
9283df01
Commit
9283df01
authored
Jul 09, 2018
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small tweaks
parent
97829024
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
nifty5/field.py
nifty5/field.py
+11
-11
No files found.
nifty5/field.py
View file @
9283df01
...
...
@@ -214,14 +214,14 @@ class Field(object):
"""Field : The real part of the field"""
if
not
np
.
issubdtype
(
self
.
dtype
,
np
.
complexfloating
):
return
self
return
Field
(
self
.
_domain
,
self
.
val
.
real
)
return
Field
(
self
.
_domain
,
self
.
_
val
.
real
)
@
property
def
imag
(
self
):
"""Field : The imaginary part of the field"""
if
not
np
.
issubdtype
(
self
.
dtype
,
np
.
complexfloating
):
raise
ValueError
(
".imag called on a non-complex Field"
)
return
Field
(
self
.
_domain
,
self
.
val
.
imag
)
return
Field
(
self
.
_domain
,
self
.
_
val
.
imag
)
def
scalar_weight
(
self
,
spaces
=
None
):
"""Returns the uniform volume element for a sub-domain of `self`.
...
...
@@ -344,7 +344,7 @@ class Field(object):
spaces
=
utilities
.
parse_spaces
(
spaces
,
ndom
)
if
len
(
spaces
)
==
ndom
:
return
dobj
.
vdot
(
self
.
val
,
x
.
val
)
return
dobj
.
vdot
(
self
.
_val
,
x
.
_
val
)
# If we arrive here, we have to do a partial dot product.
# For the moment, do this the explicit, non-optimized way
return
(
self
.
conjugate
()
*
x
).
sum
(
spaces
=
spaces
)
...
...
@@ -377,7 +377,7 @@ class Field(object):
Field
The complex conjugated field.
"""
return
Field
(
self
.
_domain
,
self
.
val
.
conjugate
())
return
Field
(
self
.
_domain
,
self
.
_
val
.
conjugate
())
# ---General unary/contraction methods---
...
...
@@ -385,14 +385,14 @@ class Field(object):
return
self
def
__neg__
(
self
):
return
Field
(
self
.
_domain
,
-
self
.
val
)
return
Field
(
self
.
_domain
,
-
self
.
_
val
)
def
__abs__
(
self
):
return
Field
(
self
.
_domain
,
abs
(
self
.
val
))
return
Field
(
self
.
_domain
,
abs
(
self
.
_
val
))
def
_contraction_helper
(
self
,
op
,
spaces
):
if
spaces
is
None
:
return
getattr
(
self
.
val
,
op
)()
return
getattr
(
self
.
_
val
,
op
)()
spaces
=
utilities
.
parse_spaces
(
spaces
,
len
(
self
.
_domain
))
...
...
@@ -402,7 +402,7 @@ class Field(object):
axes_list
=
reduce
(
lambda
x
,
y
:
x
+
y
,
axes_list
)
# perform the contraction on the data
data
=
getattr
(
self
.
val
,
op
)(
axis
=
axes_list
)
data
=
getattr
(
self
.
_
val
,
op
)(
axis
=
axes_list
)
# check if the result is scalar or if a result_field must be constr.
if
np
.
isscalar
(
data
):
...
...
@@ -593,7 +593,7 @@ class Field(object):
def
__str__
(
self
):
return
"nifty5.Field instance
\n
- domain = "
+
\
self
.
_domain
.
__str__
()
+
\
"
\n
- val = "
+
repr
(
self
.
val
)
"
\n
- val = "
+
repr
(
self
.
_
val
)
def
isEquivalentTo
(
self
,
other
):
"""Determines (as quickly as possible) whether `self`'s content is
...
...
@@ -626,12 +626,12 @@ for op in ["__add__", "__radd__",
if
isinstance
(
other
,
Field
):
if
other
.
_domain
is
not
self
.
_domain
:
raise
ValueError
(
"domains are incompatible."
)
tval
=
getattr
(
self
.
val
,
op
)(
other
.
val
)
tval
=
getattr
(
self
.
_val
,
op
)(
other
.
_
val
)
return
Field
(
self
.
_domain
,
tval
)
if
(
np
.
isscalar
(
other
)
or
isinstance
(
other
,
(
dobj
.
data_object
,
np
.
ndarray
))):
tval
=
getattr
(
self
.
val
,
op
)(
other
)
tval
=
getattr
(
self
.
_
val
,
op
)(
other
)
return
Field
(
self
.
_domain
,
tval
)
raise
TypeError
(
"should not arrive here"
)
...
...
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