Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
ToolBox
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SCS
ToolBox
Commits
aff1d06d
Commit
aff1d06d
authored
3 years ago
by
Cammille Carinan
Browse files
Options
Downloads
Patches
Plain Diff
Support unknown signal dims
parent
ba43eb53
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/toolbox_scs/base/knife_edge.py
+1
-2
1 addition, 2 deletions
src/toolbox_scs/base/knife_edge.py
src/toolbox_scs/base/tests/test_knife_edge.py
+18
-1
18 additions, 1 deletion
src/toolbox_scs/base/tests/test_knife_edge.py
with
19 additions
and
3 deletions
src/toolbox_scs/base/knife_edge.py
+
1
−
2
View file @
aff1d06d
...
...
@@ -43,9 +43,8 @@ def prepare_arrays(positions: np.ndarray, intensities: np.ndarray,
intensities
=
intensities
[
slice_
]
# Convert both arrays to 1D of the same size
n_pulses
=
intensities
.
shape
[
1
]
positions
=
np
.
repeat
(
positions
,
n_pulses
)
intensities
=
intensities
.
flatten
()
positions
=
np
.
repeat
(
positions
,
len
(
intensities
)
//
len
(
positions
))
assert
positions
.
shape
==
intensities
.
shape
# Clean both arrays by only getting finite values
...
...
This diff is collapsed.
Click to expand it.
src/toolbox_scs/base/tests/test_knife_edge.py
+
18
−
1
View file @
aff1d06d
...
...
@@ -45,7 +45,7 @@ def test_range_mask():
np
.
testing
.
assert_array_equal
(
slice_
,
[
False
,
False
,
True
,
False
,
True
])
def
test_prepare_arrays
():
def
test_prepare_arrays
_nans
():
# Setup test values
trains
,
pulses
=
5
,
10
size
=
trains
*
pulses
...
...
@@ -74,6 +74,23 @@ def test_prepare_arrays():
assert
np
.
isfinite
(
intensities
).
all
()
def
test_prepare_arrays_size
():
trains
,
pulses
=
5
,
10
size
=
trains
*
pulses
motor
=
np
.
arange
(
trains
)
signal
=
np
.
random
.
randint
(
100
,
size
=
(
trains
,
pulses
))
# Test finite motor and 2D signals
positions
,
intensities
=
prepare_arrays
(
motor
,
signal
)
assert
positions
.
shape
==
(
size
,)
assert
intensities
.
shape
==
(
size
,)
# Test finite motor and 1D signals
positions
,
intensities
=
prepare_arrays
(
motor
,
signal
.
reshape
(
1
,
-
1
))
assert
positions
.
shape
==
(
size
,)
assert
intensities
.
shape
==
(
size
,)
def
with_values
(
array
,
value
,
num
=
5
):
copy
=
array
.
astype
(
np
.
float
)
copy
.
ravel
()[
np
.
random
.
choice
(
copy
.
size
,
num
,
replace
=
False
)]
=
value
...
...
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