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
11
Merge Requests
11
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
72670f97
Commit
72670f97
authored
Feb 17, 2018
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rework _needed_for_hash
parent
f516d934
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
15 additions
and
16 deletions
+15
-16
nifty4/domain_tuple.py
nifty4/domain_tuple.py
+1
-1
nifty4/domains/dof_space.py
nifty4/domains/dof_space.py
+3
-1
nifty4/domains/domain.py
nifty4/domains/domain.py
+2
-8
nifty4/domains/gl_space.py
nifty4/domains/gl_space.py
+2
-1
nifty4/domains/hp_space.py
nifty4/domains/hp_space.py
+2
-1
nifty4/domains/lm_space.py
nifty4/domains/lm_space.py
+2
-1
nifty4/domains/power_space.py
nifty4/domains/power_space.py
+1
-1
nifty4/domains/rg_space.py
nifty4/domains/rg_space.py
+1
-1
nifty4/domains/unstructured_domain.py
nifty4/domains/unstructured_domain.py
+1
-1
No files found.
nifty4/domain_tuple.py
View file @
72670f97
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# Copyright(C) 2013-201
7
Max-Planck-Society
# Copyright(C) 2013-201
8
Max-Planck-Society
#
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
# and financially supported by the Studienstiftung des deutschen Volkes.
...
...
nifty4/domains/dof_space.py
View file @
72670f97
...
@@ -22,10 +22,12 @@ from .structured_domain import StructuredDomain
...
@@ -22,10 +22,12 @@ from .structured_domain import StructuredDomain
class
DOFSpace
(
StructuredDomain
):
class
DOFSpace
(
StructuredDomain
):
"""Generic degree-of-freedom space."""
"""Generic degree-of-freedom space."""
_needed_for_hash
=
[
"_dvol"
]
def
__init__
(
self
,
dof_weights
):
def
__init__
(
self
,
dof_weights
):
super
(
DOFSpace
,
self
).
__init__
()
super
(
DOFSpace
,
self
).
__init__
()
self
.
_dvol
=
tuple
(
dof_weights
)
self
.
_dvol
=
tuple
(
dof_weights
)
self
.
_needed_for_hash
+=
[
'_dvol'
]
@
property
@
property
def
harmonic
(
self
):
def
harmonic
(
self
):
...
...
nifty4/domains/domain.py
View file @
72670f97
...
@@ -25,16 +25,10 @@ import numpy as np
...
@@ -25,16 +25,10 @@ import numpy as np
class
Domain
(
with_metaclass
(
class
Domain
(
with_metaclass
(
NiftyMeta
,
type
(
'NewBase'
,
(
object
,),
{}))):
NiftyMeta
,
type
(
'NewBase'
,
(
object
,),
{}))):
"""The abstract class repesenting a (structured or unstructured) domain.
"""The abstract class repesenting a (structured or unstructured) domain.
Attributes:
-----------
_needed_for_hash : list of str
the names of all members that are relevant for comparison against
other Domain objects.
"""
"""
def
__init__
(
self
):
def
__init__
(
self
):
self
.
_needed_for_hash
=
[]
pass
@
abc
.
abstractmethod
@
abc
.
abstractmethod
def
__repr__
(
self
):
def
__repr__
(
self
):
...
@@ -68,7 +62,7 @@ class Domain(with_metaclass(
...
@@ -68,7 +62,7 @@ class Domain(with_metaclass(
Notes
Notes
-----
-----
Only members that are explicitly added to
Only members that are explicitly added to
:attr:`._needed_for_hash` will be used for compariso
m
.
:attr:`._needed_for_hash` will be used for compariso
n
.
Subclasses of Domain should not re-define :meth:`__eq__`,
Subclasses of Domain should not re-define :meth:`__eq__`,
:meth:`__ne__`, or :meth:`__hash__`; they should instead add their
:meth:`__ne__`, or :meth:`__hash__`; they should instead add their
...
...
nifty4/domains/gl_space.py
View file @
72670f97
...
@@ -37,9 +37,10 @@ class GLSpace(StructuredDomain):
...
@@ -37,9 +37,10 @@ class GLSpace(StructuredDomain):
Default value is 2*nlat + 1.
Default value is 2*nlat + 1.
"""
"""
_needed_for_hash
=
[
"_nlat"
,
"_nlon"
]
def
__init__
(
self
,
nlat
,
nlon
=
None
):
def
__init__
(
self
,
nlat
,
nlon
=
None
):
super
(
GLSpace
,
self
).
__init__
()
super
(
GLSpace
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
"_nlat"
,
"_nlon"
]
self
.
_nlat
=
int
(
nlat
)
self
.
_nlat
=
int
(
nlat
)
if
self
.
_nlat
<
1
:
if
self
.
_nlat
<
1
:
...
...
nifty4/domains/hp_space.py
View file @
72670f97
...
@@ -34,9 +34,10 @@ class HPSpace(StructuredDomain):
...
@@ -34,9 +34,10 @@ class HPSpace(StructuredDomain):
and typically is a power of 2.
and typically is a power of 2.
"""
"""
_needed_for_hash
=
[
"_nside"
]
def
__init__
(
self
,
nside
):
def
__init__
(
self
,
nside
):
super
(
HPSpace
,
self
).
__init__
()
super
(
HPSpace
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
"_nside"
]
self
.
_nside
=
int
(
nside
)
self
.
_nside
=
int
(
nside
)
if
self
.
_nside
<
1
:
if
self
.
_nside
<
1
:
raise
ValueError
(
"nside must be >=1."
)
raise
ValueError
(
"nside must be >=1."
)
...
...
nifty4/domains/lm_space.py
View file @
72670f97
...
@@ -43,9 +43,10 @@ class LMSpace(StructuredDomain):
...
@@ -43,9 +43,10 @@ class LMSpace(StructuredDomain):
Must be :math:`\ge 0` and :math:`\le` `lmax`.
Must be :math:`\ge 0` and :math:`\le` `lmax`.
"""
"""
_needed_for_hash
=
[
"_lmax"
,
"_mmax"
]
def
__init__
(
self
,
lmax
,
mmax
=
None
):
def
__init__
(
self
,
lmax
,
mmax
=
None
):
super
(
LMSpace
,
self
).
__init__
()
super
(
LMSpace
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
"_lmax"
,
"_mmax"
]
self
.
_lmax
=
np
.
int
(
lmax
)
self
.
_lmax
=
np
.
int
(
lmax
)
if
self
.
_lmax
<
0
:
if
self
.
_lmax
<
0
:
raise
ValueError
(
"lmax must be >=0."
)
raise
ValueError
(
"lmax must be >=0."
)
...
...
nifty4/domains/power_space.py
View file @
72670f97
...
@@ -46,6 +46,7 @@ class PowerSpace(StructuredDomain):
...
@@ -46,6 +46,7 @@ class PowerSpace(StructuredDomain):
"""
"""
_powerIndexCache
=
{}
_powerIndexCache
=
{}
_needed_for_hash
=
[
"_harmonic_partner"
,
"_binbounds"
]
@
staticmethod
@
staticmethod
def
linear_binbounds
(
nbin
,
first_bound
,
last_bound
):
def
linear_binbounds
(
nbin
,
first_bound
,
last_bound
):
...
@@ -138,7 +139,6 @@ class PowerSpace(StructuredDomain):
...
@@ -138,7 +139,6 @@ class PowerSpace(StructuredDomain):
def
__init__
(
self
,
harmonic_partner
,
binbounds
=
None
):
def
__init__
(
self
,
harmonic_partner
,
binbounds
=
None
):
super
(
PowerSpace
,
self
).
__init__
()
super
(
PowerSpace
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
'_harmonic_partner'
,
'_binbounds'
]
if
not
(
isinstance
(
harmonic_partner
,
StructuredDomain
)
and
if
not
(
isinstance
(
harmonic_partner
,
StructuredDomain
)
and
harmonic_partner
.
harmonic
):
harmonic_partner
.
harmonic
):
...
...
nifty4/domains/rg_space.py
View file @
72670f97
...
@@ -47,10 +47,10 @@ class RGSpace(StructuredDomain):
...
@@ -47,10 +47,10 @@ class RGSpace(StructuredDomain):
Whether the space represents a grid in position or harmonic space.
Whether the space represents a grid in position or harmonic space.
(default: False).
(default: False).
"""
"""
_needed_for_hash
=
[
"_distances"
,
"_shape"
,
"_harmonic"
]
def
__init__
(
self
,
shape
,
distances
=
None
,
harmonic
=
False
):
def
__init__
(
self
,
shape
,
distances
=
None
,
harmonic
=
False
):
super
(
RGSpace
,
self
).
__init__
()
super
(
RGSpace
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
"_distances"
,
"_shape"
,
"_harmonic"
]
self
.
_harmonic
=
bool
(
harmonic
)
self
.
_harmonic
=
bool
(
harmonic
)
if
np
.
isscalar
(
shape
):
if
np
.
isscalar
(
shape
):
...
...
nifty4/domains/unstructured_domain.py
View file @
72670f97
...
@@ -26,10 +26,10 @@ class UnstructuredDomain(Domain):
...
@@ -26,10 +26,10 @@ class UnstructuredDomain(Domain):
Typically used for data spaces.
Typically used for data spaces.
"""
"""
_needed_for_hash
=
[
"_shape"
]
def
__init__
(
self
,
shape
):
def
__init__
(
self
,
shape
):
super
(
UnstructuredDomain
,
self
).
__init__
()
super
(
UnstructuredDomain
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
"_shape"
]
try
:
try
:
self
.
_shape
=
tuple
([
int
(
i
)
for
i
in
shape
])
self
.
_shape
=
tuple
([
int
(
i
)
for
i
in
shape
])
except
TypeError
:
except
TypeError
:
...
...
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