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
6862ea0b
Commit
6862ea0b
authored
5 years ago
by
Shanika Galaudage
Committed by
Gregory Ashton
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Change infer function call in bilby.hyper.model
parent
a61ded22
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
bilby/core/utils.py
+5
-5
5 additions, 5 deletions
bilby/core/utils.py
bilby/hyper/model.py
+2
-6
2 additions, 6 deletions
bilby/hyper/model.py
with
7 additions
and
11 deletions
bilby/core/utils.py
+
5
−
5
View file @
6862ea0b
...
...
@@ -59,7 +59,7 @@ def infer_parameters_from_function(func):
to be removed.
"""
if
isinstance
(
func
,
types
.
MethodType
):
return
_
infer_args_from_function_except_n_args
(
func
=
func
,
n
=
2
)
return
infer_args_from_function_except_n_args
(
func
=
func
,
n
=
2
)
elif
isinstance
(
func
,
types
.
FunctionType
):
return
_infer_args_from_function_except_for_first_arg
(
func
=
func
)
else
:
...
...
@@ -77,10 +77,10 @@ def infer_args_from_method(method):
---------
list: A list of strings with the parameters
"""
return
_
infer_args_from_function_except_n_args
(
func
=
method
,
n
=
1
)
return
infer_args_from_function_except_n_args
(
func
=
method
,
n
=
1
)
def
_
infer_args_from_function_except_n_args
(
func
,
n
=
1
):
def
infer_args_from_function_except_n_args
(
func
,
n
=
1
):
"""
Inspects a function to find its arguments, and ignoring the
first n of these, returns a list of arguments from the function
'
s
signature.
...
...
@@ -114,7 +114,7 @@ def _infer_args_from_function_except_n_args(func, n=1):
>>>
def
hello
(
a
,
b
,
c
,
d
):
>>>
pass
>>>
>>>
_
infer_args_from_function_except_n_args
(
hello
,
2
)
>>>
infer_args_from_function_except_n_args
(
hello
,
2
)
[
'
c
'
,
'
d
'
]
"""
try
:
...
...
@@ -126,7 +126,7 @@ def _infer_args_from_function_except_n_args(func, n=1):
def
_infer_args_from_function_except_for_first_arg
(
func
):
return
_
infer_args_from_function_except_n_args
(
func
=
func
,
n
=
1
)
return
infer_args_from_function_except_n_args
(
func
=
func
,
n
=
1
)
def
get_sampling_frequency
(
time_array
):
...
...
This diff is collapsed.
Click to expand it.
bilby/hyper/model.py
+
2
−
6
View file @
6862ea0b
from
..core.utils
import
infer_
p
ar
ameter
s_from_function
from
..core.utils
import
infer_ar
g
s_from_function
_except_n_args
class
Model
(
object
):
...
...
@@ -18,10 +18,6 @@ class Model(object):
self
.
models
=
model_functions
self
.
parameters
=
dict
()
for
func
in
self
.
models
:
param_keys
=
infer_parameters_from_function
(
func
)
for
key
in
param_keys
:
self
.
parameters
[
key
]
=
None
def
prob
(
self
,
data
,
**
kwargs
):
probability
=
1.0
...
...
@@ -31,7 +27,7 @@ class Model(object):
def
_get_function_parameters
(
self
,
func
):
"""
If the function is a class method we need to remove more arguments
"""
param_keys
=
infer_
p
ar
ameter
s_from_function
(
func
)
param_keys
=
infer_ar
g
s_from_function
_except_n_args
(
func
,
n
=
0
)
ignore
=
[
'
dataset
'
,
'
self
'
,
'
cls
'
]
for
key
in
ignore
:
if
key
in
param_keys
:
...
...
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