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
1bc3f502
Commit
1bc3f502
authored
Sep 02, 2016
by
theos
Browse files
Renamed base_field_type.py to field_type.py
parent
bbd1c13e
Changes
3
Hide whitespace changes
Inline
Side-by-side
nifty/field_types/__init__.py
View file @
1bc3f502
# -*- coding: utf-8 -*-
from
field_array
import
FieldType
,
\
FieldArray
\ No newline at end of file
from
field_type
import
FieldType
from
field_array
import
FieldArray
nifty/field_types/base_field_type.py
deleted
100644 → 0
View file @
bbd1c13e
# -*- coding: utf-8 -*-
import
numpy
as
np
class
FieldType
(
object
):
def
__init__
(
self
,
shape
,
dtype
):
try
:
new_shape
=
tuple
([
int
(
i
)
for
i
in
shape
])
except
TypeError
:
new_shape
=
(
int
(
shape
),
)
self
.
_shape
=
new_shape
self
.
_dtype
=
np
.
dtype
(
dtype
)
def
__hash__
(
self
):
# Extract the identifying parts from the vars(self) dict.
result_hash
=
0
for
(
key
,
item
)
in
vars
(
self
).
items
():
result_hash
^=
item
.
__hash__
()
^
int
(
hash
(
key
)
/
117
)
return
result_hash
def
__eq__
(
self
,
x
):
if
isinstance
(
x
,
type
(
self
)):
return
hash
(
self
)
==
hash
(
x
)
else
:
return
False
@
property
def
shape
(
self
):
return
self
.
_shape
@
property
def
dtype
(
self
):
return
self
.
_dtype
@
property
def
dim
(
self
):
raise
NotImplementedError
def
process
(
self
,
method_name
,
array
,
inplace
=
True
,
**
kwargs
):
try
:
result_array
=
self
.
__getattr__
(
method_name
)(
array
,
inplace
,
**
kwargs
)
except
AttributeError
:
if
inplace
:
result_array
=
array
else
:
result_array
=
array
.
copy
()
return
result_array
def
complement_cast
(
self
,
x
,
axes
=
None
):
return
x
nifty/field_types/field_array.py
View file @
1bc3f502
# -*- coding: utf-8 -*-
from
base_
field_type
import
FieldType
from
field_type
import
FieldType
class
FieldArray
(
FieldType
):
...
...
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