Skip to content
GitLab
Menu
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
75145bf8
Commit
75145bf8
authored
Sep 18, 2017
by
Martin Reinecke
Browse files
further small tweaks
parent
76145cba
Pipeline
#18337
passed with stage
in 6 minutes and 3 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty2go/domain_object.py
View file @
75145bf8
...
...
@@ -41,7 +41,7 @@ class DomainObject(with_metaclass(
"""
def
__init__
(
self
):
self
.
_ignore_for_hash
=
[]
self
.
_ignore_for_hash
=
[
'_ignore_for_hash'
]
@
abc
.
abstractmethod
def
__repr__
(
self
):
...
...
@@ -51,10 +51,8 @@ class DomainObject(with_metaclass(
# Extract the identifying parts from the vars(self) dict.
result_hash
=
0
for
key
in
sorted
(
vars
(
self
).
keys
()):
item
=
vars
(
self
)[
key
]
if
key
in
self
.
_ignore_for_hash
or
key
==
'_ignore_for_hash'
:
continue
result_hash
^=
item
.
__hash__
()
^
int
(
hash
(
key
)
//
117
)
if
key
not
in
self
.
_ignore_for_hash
:
result_hash
^=
vars
(
self
)[
key
].
__hash__
()
^
int
(
hash
(
key
)
//
117
)
return
result_hash
def
__eq__
(
self
,
x
):
...
...
@@ -73,18 +71,13 @@ class DomainObject(with_metaclass(
"""
if
self
is
x
:
# shortcut for simple case
return
True
if
isinstance
(
x
,
type
(
self
)):
for
key
in
list
(
vars
(
self
).
keys
()):
item1
=
vars
(
self
)[
key
]
if
key
in
self
.
_ignore_for_hash
or
key
==
'_ignore_for_hash'
:
continue
item2
=
vars
(
x
)[
key
]
if
item1
!=
item2
:
return
False
return
True
else
:
if
not
isinstance
(
x
,
type
(
self
)):
return
False
for
key
in
list
(
vars
(
self
).
keys
()):
if
key
not
in
self
.
_ignore_for_hash
:
if
vars
(
self
)[
key
]
!=
vars
(
x
)[
key
]:
return
False
return
True
def
__ne__
(
self
,
x
):
return
not
self
.
__eq__
(
x
)
...
...
nifty2go/spaces/gl_space/gl_space.py
View file @
75145bf8
...
...
@@ -82,9 +82,11 @@ class GLSpace(Space):
def
__init__
(
self
,
nlat
,
nlon
=
None
):
super
(
GLSpace
,
self
).
__init__
()
self
.
_ignore_for_hash
+=
[
"_wgt"
]
self
.
_nlat
=
self
.
_parse_nlat
(
nlat
)
self
.
_nlon
=
self
.
_parse_nlon
(
nlon
)
self
.
_wgt
=
None
# ---Mandatory properties and methods---
...
...
@@ -113,10 +115,13 @@ class GLSpace(Space):
def
scalar_weight
(
self
):
return
None
# MR FIXME: this is potentially wasteful, since the return array is
# blown up by a factor of self.nlon
def
weight
(
self
):
from
pyHealpix
import
GL_weights
vol
=
GL_weights
(
self
.
nlat
,
self
.
nlon
)
return
np
.
outer
(
vol
,
np
.
ones
(
self
.
nlon
,
dtype
=
np
.
float64
)).
ravel
()
if
self
.
_wgt
is
None
:
self
.
_wgt
=
GL_weights
(
self
.
nlat
,
self
.
nlon
)
return
np
.
repeat
(
self
.
_wgt
,
self
.
nlon
)
# ---Added properties and methods---
...
...
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