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
41fcdc78
Commit
41fcdc78
authored
3 years ago
by
Cammille Carinan
Browse files
Options
Downloads
Patches
Plain Diff
Better finite array retrieval
parent
1552b7b7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/toolbox_scs/base/knife_edge.py
+3
-7
3 additions, 7 deletions
src/toolbox_scs/base/knife_edge.py
with
3 additions
and
7 deletions
src/toolbox_scs/base/knife_edge.py
+
3
−
7
View file @
41fcdc78
...
@@ -49,17 +49,13 @@ def prepare_arrays(positions: np.ndarray, intensities: np.ndarray,
...
@@ -49,17 +49,13 @@ def prepare_arrays(positions: np.ndarray, intensities: np.ndarray,
assert
positions
.
shape
==
intensities
.
shape
assert
positions
.
shape
==
intensities
.
shape
# Clean both arrays by only getting finite values
# Clean both arrays by only getting finite values
positions
,
intensities
=
finite_array
(
positions
,
wrt
=
intensities
)
finite_idx
=
np
.
isfinite
(
positions
)
&
np
.
isfinite
(
intensities
)
intensities
,
positions
=
finite_array
(
intensities
,
wrt
=
positions
)
positions
=
positions
[
finite_idx
]
intensities
=
intensities
[
finite_idx
]
return
positions
,
intensities
return
positions
,
intensities
def
finite_array
(
array
,
*
,
wrt
):
index
=
np
.
isfinite
(
wrt
)
return
array
[
index
],
wrt
[
index
]
def
range_mask
(
array
,
minimum
=
None
,
maximum
=
None
):
def
range_mask
(
array
,
minimum
=
None
,
maximum
=
None
):
default
=
np
.
ones
(
array
.
shape
,
dtype
=
np
.
bool
)
default
=
np
.
ones
(
array
.
shape
,
dtype
=
np
.
bool
)
min_slice
,
max_slice
=
default
,
default
min_slice
,
max_slice
=
default
,
default
...
...
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