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
50ee7bc7
Commit
50ee7bc7
authored
1 month ago
by
Wolfgang Kastaun
Browse files
Options
Downloads
Patches
Plain Diff
Added unit test for numpy-based adaptive shift wrapper
parent
33c7e03c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#388922
passed
1 month ago
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_fixed_shift_numpy.py
+45
-2
45 additions, 2 deletions
tests/test_fixed_shift_numpy.py
with
45 additions
and
2 deletions
tests/test_fixed_shift_numpy.py
+
45
−
2
View file @
50ee7bc7
...
...
@@ -4,10 +4,15 @@ import numpy as np
import
pytest
from
lisainstrument.dynamic_delay_numpy
import
ShiftBC
from
lisainstrument.fixed_shift_numpy
import
make_fixed_shift_lagrange_numpy
from
lisainstrument.fixed_shift_numpy
import
(
AdaptiveShiftNumpy
,
make_fixed_shift_lagrange_numpy
,
)
def
test_fixed_shift_lagrange_dask
()
->
None
:
def
test_fixed_shift_lagrange_numpy
()
->
None
:
"""
Test Lagrange interpolation of numpy arrays specialized to fixed shift
"""
order
=
5
t
,
dt
=
np
.
linspace
(
-
5.345
,
10.345
,
1003
,
retstep
=
True
)
...
...
@@ -53,3 +58,41 @@ def test_fixed_shift_lagrange_dask() -> None:
with
pytest
.
raises
(
RuntimeError
):
op2_np
(
y
,
-
d
)
def
test_adaptive_shift_numpy
()
->
None
:
"""
Test AdaptiveShiftNumpy wrapper
Only checks that it calls correct methods based on argument type combinations.
"""
def
mock_fix
(
d
:
np
.
ndarray
,
s
:
float
)
->
np
.
ndarray
:
"""
Bogus but unique result to check this function was used
"""
return
d
*
s
def
mock_dyn
(
d
:
np
.
ndarray
,
s
:
np
.
ndarray
)
->
np
.
ndarray
:
"""
Bogus but unique result to check this function was used
"""
return
d
/
s
mock_fsamp
=
13
op
=
AdaptiveShiftNumpy
(
mock_fix
,
mock_dyn
,
mock_fsamp
)
y_fix
=
12.0
y_dyn
=
np
.
ones
(
10
)
*
y_fix
s_fix
=
6.0
s_dyn
=
np
.
ones
(
10
)
*
s_fix
r_dyn_fix
=
op
(
y_dyn
,
s_fix
)
assert
np
.
all
(
r_dyn_fix
==
mock_fix
(
y_dyn
,
s_fix
*
mock_fsamp
))
r_dyn_dyn
=
op
(
y_dyn
,
s_dyn
)
assert
np
.
all
(
r_dyn_dyn
==
mock_dyn
(
y_dyn
,
s_dyn
*
mock_fsamp
))
r_fix_fix
=
op
(
y_fix
,
s_fix
)
assert
r_fix_fix
==
y_fix
r_fix_zero
=
op
(
y_fix
,
0.0
)
assert
r_fix_zero
==
y_fix
r_fix_dyn
=
op
(
y_fix
,
s_dyn
)
assert
r_fix_dyn
==
y_fix
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