Skip to content
Snippets Groups Projects
Commit 6862ea0b authored by Shanika Galaudage's avatar Shanika Galaudage Committed by Gregory Ashton
Browse files

Change infer function call in bilby.hyper.model

parent a61ded22
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......
from ..core.utils import infer_parameters_from_function
from ..core.utils import infer_args_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_parameters_from_function(func)
param_keys = infer_args_from_function_except_n_args(func, n=0)
ignore = ['dataset', 'self', 'cls']
for key in ignore:
if key in param_keys:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment