Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LISA Instrument
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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LISA Simulation
LISA Instrument
Commits
b7a306a7
Commit
b7a306a7
authored
1 month ago
by
Wolfgang Kastaun
Browse files
Options
Downloads
Patches
Plain Diff
improving type annotations
parent
3d0c5073
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#384093
passed
1 month ago
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lisainstrument/shift_inversion_numpy.py
+12
-9
12 additions, 9 deletions
lisainstrument/shift_inversion_numpy.py
with
12 additions
and
9 deletions
lisainstrument/shift_inversion_numpy.py
+
12
−
9
View file @
b7a306a7
...
@@ -8,11 +8,11 @@ interpolation.
...
@@ -8,11 +8,11 @@ interpolation.
from
__future__
import
annotations
from
__future__
import
annotations
from
typing
import
Final
from
typing
import
Callable
,
Final
import
numpy
as
np
import
numpy
as
np
from
lisainstrument.fir_filters_numpy
import
NumpyArray1D
from
lisainstrument.fir_filters_numpy
import
NumpyArray1D
,
make_numpy_array_1d
from
lisainstrument.regular_interpolators
import
(
from
lisainstrument.regular_interpolators
import
(
RegularInterpolator
,
RegularInterpolator
,
make_regular_interpolator_lagrange
,
make_regular_interpolator_lagrange
,
...
@@ -37,7 +37,7 @@ class ShiftInverseNumpy: # pylint: disable=too-few-public-methods
...
@@ -37,7 +37,7 @@ class ShiftInverseNumpy: # pylint: disable=too-few-public-methods
max_iter: Maximum iterations before fail
max_iter: Maximum iterations before fail
tolerance: Maximum absolute error of result
tolerance: Maximum absolute error of result
"""
"""
self
.
_max_abs_shift
:
Final
=
float
(
max_abs_shift
)
self
.
_max_abs_shift
:
Final
=
int
(
np
.
ceil
(
max_abs_shift
)
)
self
.
_interp_np
:
Final
=
interp
self
.
_interp_np
:
Final
=
interp
self
.
_max_iter
=
int
(
max_iter
)
self
.
_max_iter
=
int
(
max_iter
)
self
.
_tolerance
=
float
(
tolerance
)
self
.
_tolerance
=
float
(
tolerance
)
...
@@ -58,7 +58,9 @@ class ShiftInverseNumpy: # pylint: disable=too-few-public-methods
...
@@ -58,7 +58,9 @@ class ShiftInverseNumpy: # pylint: disable=too-few-public-methods
"""
"""
return
self
.
_interp_np
.
margin_right
+
self
.
_max_abs_shift
return
self
.
_interp_np
.
margin_right
+
self
.
_max_abs_shift
def
_fixed_point_iter
(
self
,
f
,
x
):
def
_fixed_point_iter
(
self
,
f
:
Callable
[[
NumpyArray1D
],
NumpyArray1D
],
x
:
NumpyArray1D
):
for
_
in
range
(
self
.
_max_iter
):
for
_
in
range
(
self
.
_max_iter
):
x_next
=
f
(
x
)
x_next
=
f
(
x
)
error
=
np
.
max
(
np
.
abs
(
x
-
x_next
))
error
=
np
.
max
(
np
.
abs
(
x
-
x_next
))
...
@@ -81,18 +83,19 @@ class ShiftInverseNumpy: # pylint: disable=too-few-public-methods
...
@@ -81,18 +83,19 @@ class ShiftInverseNumpy: # pylint: disable=too-few-public-methods
Returns:
Returns:
1D numpy array with shift for inverse coordinate transform
1D numpy array with shift for inverse coordinate transform
"""
"""
dx
=
make_numpy_array_1d
(
shift
)
shift
_pad
=
np
.
pad
(
dx
_pad
=
np
.
pad
(
shift
,
dx
,
(
self
.
_margin_left
,
self
.
_margin_right
),
(
self
.
_margin_left
,
self
.
_margin_right
),
mode
=
"
constant
"
,
mode
=
"
constant
"
,
constant_values
=
(
shift
[
0
],
shift
[
-
1
]),
constant_values
=
(
shift
[
0
],
shift
[
-
1
]),
)
)
def
f_iter
(
x
:
np
.
nda
rray
)
->
np
.
nda
rray
:
def
f_iter
(
x
:
NumpyA
rray
1D
)
->
NumpyA
rray
1D
:
return
self
.
_interp_np
.
apply_shift
(
shift
_pad
,
-
x
,
self
.
_margin_left
)
return
self
.
_interp_np
.
apply_shift
(
dx
_pad
,
-
x
,
self
.
_margin_left
)
return
self
.
_fixed_point_iter
(
f_iter
,
shift
)
return
self
.
_fixed_point_iter
(
f_iter
,
dx
)
def
make_shift_inverse_lagrange_numpy
(
def
make_shift_inverse_lagrange_numpy
(
...
...
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