Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bilby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
lscsoft
bilby
Commits
31439b55
Commit
31439b55
authored
4 years ago
by
Moritz Huebner
Browse files
Options
Downloads
Plain Diff
Merge branch 'custom-interpolation' into 'master'
Add custom interpolation See merge request
lscsoft/bilby!917
parents
52ceb4a7
1e047f7c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!917
Add custom interpolation
Pipeline
#193355
failed
4 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bilby/core/utils.py
+32
-3
32 additions, 3 deletions
bilby/core/utils.py
with
32 additions
and
3 deletions
bilby/core/utils.py
+
32
−
3
View file @
31439b55
...
...
@@ -925,7 +925,10 @@ class Counter(object):
class
UnsortedInterp2d
(
interp2d
):
def
__call__
(
self
,
x
,
y
,
dx
=
0
,
dy
=
0
,
assume_sorted
=
False
):
"""
Wrapper to scipy.interpolate.interp2d which preserves the input ordering.
"""
Modified version of the interp2d call method.
This avoids the outer product that is done when two numpy
arrays are passed.
Parameters
----------
...
...
@@ -942,8 +945,34 @@ class UnsortedInterp2d(interp2d):
array_like: See superclass
"""
unsorted_idxs
=
np
.
argsort
(
np
.
argsort
(
x
))
return
super
(
UnsortedInterp2d
,
self
).
__call__
(
x
,
y
,
dx
=
dx
,
dy
=
dy
,
assume_sorted
=
False
)[
unsorted_idxs
]
from
scipy.interpolate.dfitpack
import
bispeu
out_of_bounds_x
=
(
x
<
self
.
x_min
)
|
(
x
>
self
.
x_max
)
out_of_bounds_y
=
(
y
<
self
.
y_min
)
|
(
y
>
self
.
y_max
)
bad
=
out_of_bounds_x
|
out_of_bounds_y
if
isinstance
(
x
,
float
)
and
isinstance
(
y
,
float
):
if
bad
:
output
=
self
.
fill_value
ier
=
0
else
:
output
,
ier
=
bispeu
(
*
self
.
tck
,
x
,
y
)
else
:
if
isinstance
(
x
,
np
.
ndarray
):
output
=
np
.
zeros_like
(
x
)
x_
=
x
[
~
bad
]
else
:
x_
=
x
*
np
.
ones_like
(
y
)
if
isinstance
(
y
,
np
.
ndarray
):
output
=
np
.
zeros_like
(
y
)
y_
=
y
[
~
bad
]
else
:
y_
=
y
*
np
.
ones_like
(
x
)
output
[
bad
]
=
self
.
fill_value
output
[
~
bad
],
ier
=
bispeu
(
*
self
.
tck
,
x_
,
y_
)
if
ier
==
10
:
raise
ValueError
(
"
Invalid input data
"
)
elif
ier
:
raise
TypeError
(
"
An error occurred
"
)
return
output
# Instantiate the default argument parser at runtime
...
...
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