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
2f5dab3d
Commit
2f5dab3d
authored
Aug 11, 2018
by
Martin Reinecke
Browse files
cosmetics
parent
48076063
Changes
11
Hide whitespace changes
Inline
Side-by-side
nifty5/domain_tuple.py
View file @
2f5dab3d
...
...
@@ -44,9 +44,9 @@ class DomainTuple(object):
raise
NotImplementedError
self
.
_dom
=
self
.
_parse_domain
(
domain
)
self
.
_axtuple
=
self
.
_get_axes_tuple
()
s
hape_tuple
=
tuple
(
sp
.
shape
for
sp
in
self
.
_dom
)
self
.
_shape
=
reduce
(
lambda
x
,
y
:
x
+
y
,
shape_tuple
,
())
self
.
_size
=
reduce
(
lambda
x
,
y
:
x
*
y
,
self
.
_shape
,
1
)
s
elf
.
_shape
=
reduce
(
lambda
x
,
y
:
x
+
y
,
(
sp
.
shape
for
sp
in
self
.
_dom
)
,
())
self
.
_size
=
reduce
(
lambda
x
,
y
:
x
*
y
,
self
.
_shape
,
1
)
def
_get_axes_tuple
(
self
):
i
=
0
...
...
@@ -139,18 +139,14 @@ class DomainTuple(object):
return
self
.
_dom
.
__hash__
()
def
__eq__
(
self
,
x
):
if
self
is
x
:
return
True
return
self
.
_dom
==
x
.
_dom
return
(
self
is
x
)
or
(
self
.
_dom
==
x
.
_dom
)
def
__ne__
(
self
,
x
):
return
not
self
.
__eq__
(
x
)
def
__str__
(
self
):
res
=
"DomainTuple, len: "
+
str
(
len
(
self
))
for
i
in
self
:
res
+=
"
\n
"
+
str
(
i
)
return
res
return
(
"DomainTuple, len: {}
\n
"
.
format
(
len
(
self
))
+
"
\n
"
.
join
(
str
(
i
)
for
i
in
self
))
@
staticmethod
def
scalar_domain
():
...
...
nifty5/domains/domain.py
View file @
2f5dab3d
...
...
@@ -39,10 +39,9 @@ class Domain(NiftyMetaBase()):
try
:
return
self
.
_hash
except
AttributeError
:
h
=
0
for
key
in
self
.
_needed_for_hash
:
h
^=
hash
(
vars
(
self
)[
key
])
self
.
_hash
=
h
v
=
vars
(
self
)
self
.
_hash
=
reduce
(
lambda
x
,
y
:
x
^
y
,
(
hash
(
v
[
key
])
for
key
in
self
.
_needed_for_hash
),
0
)
return
self
.
_hash
def
__eq__
(
self
,
x
):
...
...
nifty5/domains/gl_space.py
View file @
2f5dab3d
...
...
@@ -55,7 +55,7 @@ class GLSpace(StructuredDomain):
self
.
_dvol
=
None
def
__repr__
(
self
):
return
(
"GLSpace(nlat=
%r
, nlon=
%r)"
%
(
self
.
nlat
,
self
.
nlon
)
)
return
"GLSpace(nlat=
{}
, nlon=
{})"
.
format
(
self
.
nlat
,
self
.
nlon
)
@
property
def
harmonic
(
self
):
...
...
nifty5/domains/hp_space.py
View file @
2f5dab3d
...
...
@@ -45,7 +45,7 @@ class HPSpace(StructuredDomain):
raise
ValueError
(
"nside must be >=1."
)
def
__repr__
(
self
):
return
(
"HPSpace(nside=
%r)"
%
self
.
nside
)
return
"HPSpace(nside=
{})"
.
format
(
self
.
nside
)
@
property
def
harmonic
(
self
):
...
...
nifty5/domains/lm_space.py
View file @
2f5dab3d
...
...
@@ -48,17 +48,17 @@ class LMSpace(StructuredDomain):
_needed_for_hash
=
[
"_lmax"
,
"_mmax"
]
def
__init__
(
self
,
lmax
,
mmax
=
None
):
self
.
_lmax
=
np
.
int
(
lmax
)
self
.
_lmax
=
int
(
lmax
)
if
self
.
_lmax
<
0
:
raise
ValueError
(
"lmax must be >=0."
)
if
mmax
is
None
:
mmax
=
self
.
_lmax
self
.
_mmax
=
np
.
int
(
mmax
)
self
.
_mmax
=
int
(
mmax
)
if
self
.
_mmax
<
0
or
self
.
_mmax
>
self
.
_lmax
:
raise
ValueError
(
"mmax must be >=0 and <=lmax."
)
def
__repr__
(
self
):
return
(
"LMSpace(lmax=
%r
, mmax=
%r)"
%
(
self
.
lmax
,
self
.
mmax
)
)
return
"LMSpace(lmax=
{}
, mmax=
{})"
.
format
(
self
.
lmax
,
self
.
mmax
)
@
property
def
harmonic
(
self
):
...
...
@@ -66,12 +66,11 @@ class LMSpace(StructuredDomain):
@
property
def
shape
(
self
):
return
(
self
.
size
,
)
return
(
self
.
size
,)
@
property
def
size
(
self
):
l
=
self
.
_lmax
m
=
self
.
_mmax
l
,
m
=
self
.
_lmax
,
self
.
_mmax
# the LMSpace consists of the full triangle (including -m's!),
# minus two little triangles if mmax < lmax
return
(
l
+
1
)
**
2
-
(
l
-
m
)
*
(
l
-
m
+
1
)
...
...
nifty5/domains/log_rg_space.py
View file @
2f5dab3d
...
...
@@ -68,8 +68,8 @@ class LogRGSpace(StructuredDomain):
return
np
.
array
(
self
.
_t_0
)
def
__repr__
(
self
):
return
(
"LogRGSpace(shape=
%r
, harmonic=
%r
)"
%
(
self
.
shape
,
self
.
harmonic
))
return
(
"LogRGSpace(shape=
{}
, harmonic=
{}
)"
.
format
(
self
.
shape
,
self
.
harmonic
))
def
get_default_codomain
(
self
):
codomain_bindistances
=
1.
/
(
self
.
bindistances
*
self
.
shape
)
...
...
nifty5/domains/power_space.py
View file @
2f5dab3d
...
...
@@ -207,8 +207,8 @@ class PowerSpace(StructuredDomain):
self
.
_powerIndexCache
[
key
]
def
__repr__
(
self
):
return
(
"PowerSpace(harmonic_partner=
%r
, binbounds=
%r
)"
%
(
self
.
harmonic_partner
,
self
.
_binbounds
))
return
(
"PowerSpace(harmonic_partner=
{}
, binbounds=
{}
)"
.
format
(
self
.
harmonic_partner
,
self
.
_binbounds
))
@
property
def
harmonic
(
self
):
...
...
nifty5/domains/rg_space.py
View file @
2f5dab3d
...
...
@@ -72,8 +72,8 @@ class RGSpace(StructuredDomain):
self
.
_size
=
int
(
reduce
(
lambda
x
,
y
:
x
*
y
,
self
.
_shape
))
def
__repr__
(
self
):
return
(
"RGSpace(shape=
%r
, distances=
%r
, harmonic=
%r
)"
%
(
self
.
shape
,
self
.
distances
,
self
.
harmonic
))
return
(
"RGSpace(shape=
{}
, distances=
{}
, harmonic=
{}
)"
.
format
(
self
.
shape
,
self
.
distances
,
self
.
harmonic
))
@
property
def
harmonic
(
self
):
...
...
nifty5/domains/unstructured_domain.py
View file @
2f5dab3d
...
...
@@ -44,7 +44,7 @@ class UnstructuredDomain(Domain):
self
.
_shape
=
(
int
(
shape
),
)
def
__repr__
(
self
):
return
"UnstructuredDomain(shape=
%r)"
%
(
self
.
shape
,
)
return
"UnstructuredDomain(shape=
{})"
.
format
(
self
.
shape
)
@
property
def
shape
(
self
):
...
...
nifty5/utilities.py
View file @
2f5dab3d
...
...
@@ -327,7 +327,7 @@ class frozendict(collections.Mapping):
return
len
(
self
.
_dict
)
def
__repr__
(
self
):
return
'<
%s %r>'
%
(
self
.
__class__
.
__name__
,
self
.
_dict
)
return
'<
{} {}>'
.
format
(
self
.
__class__
.
__name__
,
self
.
_dict
)
def
__hash__
(
self
):
if
self
.
_hash
is
None
:
...
...
test/common.py
View file @
2f5dab3d
...
...
@@ -25,7 +25,7 @@ np.seterr(all='raise', under='ignore')
def
_custom_name_func
(
testcase_func
,
param_num
,
param
):
return
"
%s_%s"
%
(
return
"
{}_{}"
.
format
(
testcase_func
.
__name__
,
parameterized
.
to_safe_name
(
"_"
.
join
(
str
(
x
)
for
x
in
param
.
args
)),
)
...
...
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