Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
NIFTy
Commits
1b598d99
Commit
1b598d99
authored
8 years ago
by
theos
Browse files
Options
Downloads
Patches
Plain Diff
Added missing field_type.py
parent
ad5ddd5c
No related branches found
No related tags found
1 merge request
!29
Nif ty3 temp
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nifty/field_types/field_type.py
+55
-0
55 additions, 0 deletions
nifty/field_types/field_type.py
with
55 additions
and
0 deletions
nifty/field_types/field_type.py
0 → 100644
+
55
−
0
View file @
1b598d99
# -*- 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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment