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
72670f97
Commit
72670f97
authored
Feb 17, 2018
by
Martin Reinecke
Browse files
rework _needed_for_hash
parent
f516d934
Changes
9
Hide whitespace changes
Inline
Side-by-side
nifty4/domain_tuple.py
View file @
72670f97
...
...
@@ -11,7 +11,7 @@
# You should have received a copy of the GNU General Public License
# 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
# 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
class
DOFSpace
(
StructuredDomain
):
"""Generic degree-of-freedom space."""
_needed_for_hash
=
[
"_dvol"
]
def
__init__
(
self
,
dof_weights
):
super
(
DOFSpace
,
self
).
__init__
()
self
.
_dvol
=
tuple
(
dof_weights
)
self
.
_needed_for_hash
+=
[
'_dvol'
]
@
property
def
harmonic
(
self
):
...
...
nifty4/domains/domain.py
View file @
72670f97
...
...
@@ -25,16 +25,10 @@ import numpy as np
class
Domain
(
with_metaclass
(
NiftyMeta
,
type
(
'NewBase'
,
(
object
,),
{}))):
"""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
):
self
.
_needed_for_hash
=
[]
pass
@
abc
.
abstractmethod
def
__repr__
(
self
):
...
...
@@ -68,7 +62,7 @@ class Domain(with_metaclass(
Notes
-----
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__`,
: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):
Default value is 2*nlat + 1.
"""
_needed_for_hash
=
[
"_nlat"
,
"_nlon"
]
def
__init__
(
self
,
nlat
,
nlon
=
None
):
super
(
GLSpace
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
"_nlat"
,
"_nlon"
]
self
.
_nlat
=
int
(
nlat
)
if
self
.
_nlat
<
1
:
...
...
nifty4/domains/hp_space.py
View file @
72670f97
...
...
@@ -34,9 +34,10 @@ class HPSpace(StructuredDomain):
and typically is a power of 2.
"""
_needed_for_hash
=
[
"_nside"
]
def
__init__
(
self
,
nside
):
super
(
HPSpace
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
"_nside"
]
self
.
_nside
=
int
(
nside
)
if
self
.
_nside
<
1
:
raise
ValueError
(
"nside must be >=1."
)
...
...
nifty4/domains/lm_space.py
View file @
72670f97
...
...
@@ -43,9 +43,10 @@ class LMSpace(StructuredDomain):
Must be :math:`\ge 0` and :math:`\le` `lmax`.
"""
_needed_for_hash
=
[
"_lmax"
,
"_mmax"
]
def
__init__
(
self
,
lmax
,
mmax
=
None
):
super
(
LMSpace
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
"_lmax"
,
"_mmax"
]
self
.
_lmax
=
np
.
int
(
lmax
)
if
self
.
_lmax
<
0
:
raise
ValueError
(
"lmax must be >=0."
)
...
...
nifty4/domains/power_space.py
View file @
72670f97
...
...
@@ -46,6 +46,7 @@ class PowerSpace(StructuredDomain):
"""
_powerIndexCache
=
{}
_needed_for_hash
=
[
"_harmonic_partner"
,
"_binbounds"
]
@
staticmethod
def
linear_binbounds
(
nbin
,
first_bound
,
last_bound
):
...
...
@@ -138,7 +139,6 @@ class PowerSpace(StructuredDomain):
def
__init__
(
self
,
harmonic_partner
,
binbounds
=
None
):
super
(
PowerSpace
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
'_harmonic_partner'
,
'_binbounds'
]
if
not
(
isinstance
(
harmonic_partner
,
StructuredDomain
)
and
harmonic_partner
.
harmonic
):
...
...
nifty4/domains/rg_space.py
View file @
72670f97
...
...
@@ -47,10 +47,10 @@ class RGSpace(StructuredDomain):
Whether the space represents a grid in position or harmonic space.
(default: False).
"""
_needed_for_hash
=
[
"_distances"
,
"_shape"
,
"_harmonic"
]
def
__init__
(
self
,
shape
,
distances
=
None
,
harmonic
=
False
):
super
(
RGSpace
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
"_distances"
,
"_shape"
,
"_harmonic"
]
self
.
_harmonic
=
bool
(
harmonic
)
if
np
.
isscalar
(
shape
):
...
...
nifty4/domains/unstructured_domain.py
View file @
72670f97
...
...
@@ -26,10 +26,10 @@ class UnstructuredDomain(Domain):
Typically used for data spaces.
"""
_needed_for_hash
=
[
"_shape"
]
def
__init__
(
self
,
shape
):
super
(
UnstructuredDomain
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
"_shape"
]
try
:
self
.
_shape
=
tuple
([
int
(
i
)
for
i
in
shape
])
except
TypeError
:
...
...
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