Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
empyre
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dieter Weber
empyre
Commits
8ea719a5
Commit
8ea719a5
authored
8 years ago
by
Jan Caron
Browse files
Options
Downloads
Patches
Plain Diff
Implemented division (truediv and floordiv) for fielddata and phasemap.
parent
2fa049b7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyramid/fielddata.py
+19
-1
19 additions, 1 deletion
pyramid/fielddata.py
pyramid/phasemap.py
+17
-6
17 additions, 6 deletions
pyramid/phasemap.py
with
36 additions
and
7 deletions
pyramid/fielddata.py
+
19
−
1
View file @
8ea719a5
...
...
@@ -144,7 +144,17 @@ class FieldData(object, metaclass=abc.ABCMeta):
def
__mul__
(
self
,
other
):
# self * other
self
.
_log
.
debug
(
'
Calling __mul__
'
)
assert
isinstance
(
other
,
Number
),
'
FieldData objects can only be multiplied by numbers!
'
return
self
.
__class__
(
self
.
a
,
other
*
self
.
field
)
return
self
.
__class__
(
self
.
a
,
self
.
field
*
other
)
def
__truediv__
(
self
,
other
):
# self / other
self
.
_log
.
debug
(
'
Calling __truediv__
'
)
assert
isinstance
(
other
,
Number
),
'
FieldData objects can only be divided by numbers!
'
return
self
.
__class__
(
self
.
a
,
self
.
field
/
other
)
def
__floordiv__
(
self
,
other
):
# self // other
self
.
_log
.
debug
(
'
Calling __floordiv__
'
)
assert
isinstance
(
other
,
Number
),
'
FieldData objects can only be divided by numbers!
'
return
self
.
__class__
(
self
.
a
,
self
.
field
//
other
)
def
__radd__
(
self
,
other
):
# other + self
self
.
_log
.
debug
(
'
Calling __radd__
'
)
...
...
@@ -170,6 +180,14 @@ class FieldData(object, metaclass=abc.ABCMeta):
self
.
_log
.
debug
(
'
Calling __imul__
'
)
return
self
.
__mul__
(
other
)
def
__itruediv__
(
self
,
other
):
# self /= other
self
.
_log
.
debug
(
'
Calling __itruediv__
'
)
return
self
.
__truediv__
(
other
)
def
__ifloordiv__
(
self
,
other
):
# self //= other
self
.
_log
.
debug
(
'
Calling __ifloordiv__
'
)
return
self
.
__floordiv__
(
other
)
def
__array__
(
self
,
dtype
=
None
):
if
dtype
:
return
self
.
field
.
astype
(
dtype
)
...
...
This diff is collapsed.
Click to expand it.
pyramid/phasemap.py
+
17
−
6
View file @
8ea719a5
...
...
@@ -233,13 +233,20 @@ class PhaseMap(object):
'
PhaseMap objects can only be multiplied by scalar numbers or fitting arrays!
'
return
PhaseMap
(
self
.
a
,
self
.
phase
*
other
,
self
.
mask
,
self
.
confidence
,
self
.
unit
)
def
__div__
(
self
,
other
):
# self / other
self
.
_log
.
debug
(
'
Calling __div__
'
)
def
__
true
div__
(
self
,
other
):
# self / other
self
.
_log
.
debug
(
'
Calling __
true
div__
'
)
assert
(
isinstance
(
other
,
Number
)
or
(
isinstance
(
other
,
np
.
ndarray
)
and
other
.
shape
==
self
.
dim_uv
)),
\
'
PhaseMap objects can only be
multipli
ed by scalar numbers or fitting arrays!
'
'
PhaseMap objects can only be
divid
ed by scalar numbers or fitting arrays!
'
return
PhaseMap
(
self
.
a
,
self
.
phase
/
other
,
self
.
mask
,
self
.
confidence
,
self
.
unit
)
def
__floordiv__
(
self
,
other
):
# self // other
self
.
_log
.
debug
(
'
Calling __floordiv__
'
)
assert
(
isinstance
(
other
,
Number
)
or
(
isinstance
(
other
,
np
.
ndarray
)
and
other
.
shape
==
self
.
dim_uv
)),
\
'
PhaseMap objects can only be divided by scalar numbers or fitting arrays!
'
return
PhaseMap
(
self
.
a
,
self
.
phase
//
other
,
self
.
mask
,
self
.
confidence
,
self
.
unit
)
def
__radd__
(
self
,
other
):
# other + self
self
.
_log
.
debug
(
'
Calling __radd__
'
)
return
self
.
__add__
(
other
)
...
...
@@ -264,9 +271,13 @@ class PhaseMap(object):
self
.
_log
.
debug
(
'
Calling __imul__
'
)
return
self
.
__mul__
(
other
)
def
__idiv__
(
self
,
other
):
# self /= other
self
.
_log
.
debug
(
'
Calling __idiv__
'
)
return
self
.
__div__
(
other
)
def
__itruediv__
(
self
,
other
):
# self /= other
self
.
_log
.
debug
(
'
Calling __itruediv__
'
)
return
self
.
__truediv__
(
other
)
def
__ifloordiv__
(
self
,
other
):
# self //= other
self
.
_log
.
debug
(
'
Calling __ifloordiv__
'
)
return
self
.
__floordiv__
(
other
)
def
__array__
(
self
,
dtype
=
None
):
if
dtype
:
...
...
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