diff --git a/firecrown/likelihood/gauss_family/statistic/source/number_counts.py b/firecrown/likelihood/gauss_family/statistic/source/number_counts.py index 8888e188..3d0141f4 100644 --- a/firecrown/likelihood/gauss_family/statistic/source/number_counts.py +++ b/firecrown/likelihood/gauss_family/statistic/source/number_counts.py @@ -251,7 +251,7 @@ class NumberCounts(Source): """Source class for number counts.""" systematics: UpdatableCollection - tracer_arg: NumberCountsArgs + tracer_args: NumberCountsArgs def __init__( self, @@ -278,7 +278,7 @@ def __init__( self.systematics.append(systematic) self.scale = scale - self.current_tracer_args = None + self.current_tracer_args: Optional[NumberCountsArgs] = None self.scale_ = None self.tracer_ = None diff --git a/firecrown/likelihood/gauss_family/statistic/two_point.py b/firecrown/likelihood/gauss_family/statistic/two_point.py index cec7d497..d000cf5a 100644 --- a/firecrown/likelihood/gauss_family/statistic/two_point.py +++ b/firecrown/likelihood/gauss_family/statistic/two_point.py @@ -238,7 +238,6 @@ def read(self, sacc_data): warnings.warn( f"Tracers '{tracers}' have 2pt data and you have specified " "`ell_or_theta` in the configuration. `ell_or_theta` is being ignored!", - warnings.UserWarning, stacklevel=2, ) @@ -315,12 +314,11 @@ def log_interpolator(x, y): np.log(x), np.log(y), ext=2 ) return lambda x_, intp=intp: np.exp(intp(np.log(x_))) - else: - # only use log for x - intp = scipy.interpolate.InterpolatedUnivariateSpline( - np.log(x), y, ext=2 - ) - return lambda x_, intp=intp: intp(np.log(x_)) + # only use log for x + intp = scipy.interpolate.InterpolatedUnivariateSpline( + np.log(x), y, ext=2 + ) + return lambda x_, intp=intp: intp(np.log(x_)) theory_interpolator = log_interpolator(self.ell_or_theta_, theory_vector) ell = self.theory_window_function.values diff --git a/firecrown/likelihood/likelihood.py b/firecrown/likelihood/likelihood.py index 49b3b523..401d8c68 100644 --- a/firecrown/likelihood/likelihood.py +++ b/firecrown/likelihood/likelihood.py @@ -109,16 +109,15 @@ def load_likelihood( f"Firecrown initialization script {filename} does not define " f"a `build_likelihood` factory function." ) - else: - warnings.simplefilter("always", DeprecationWarning) - warnings.warn( - "The use of a likelihood variable in Firecrown's initialization " - "script is deprecated. Any parameters passed to the likelihood " - "will be ignored. The script should define a `build_likelihood` " - "factory function.", - category=DeprecationWarning, - ) - likelihood = mod.likelihood + warnings.simplefilter("always", DeprecationWarning) + warnings.warn( + "The use of a likelihood variable in Firecrown's initialization " + "script is deprecated. Any parameters passed to the likelihood " + "will be ignored. The script should define a `build_likelihood` " + "factory function.", + category=DeprecationWarning, + ) + likelihood = mod.likelihood else: if not callable(mod.build_likelihood): raise TypeError( diff --git a/firecrown/parameters.py b/firecrown/parameters.py index bb3eb91c..99d95386 100644 --- a/firecrown/parameters.py +++ b/firecrown/parameters.py @@ -42,6 +42,10 @@ def __init__(self, *args, **kwargs) -> None: self.lower_case: bool = False def use_lower_case_keys(self, enable: bool) -> None: + """Control whether keys will be translated into lower case. + If `enable` is True, such translation will be done. + This can help make sure code works with CosmoSIS, because such translation + is done inside CosmoSIS itself.""" self.lower_case = enable def get_from_prefix_param(self, prefix: Optional[str], param: str) -> float: @@ -161,8 +165,8 @@ def __init__(self, derived_parameters: List[DerivedParameter]): self.derived_parameters: Dict[str, DerivedParameter] = {} - for dp in derived_parameters: - self.add_required_parameter(dp) + for parameter in derived_parameters: + self.add_required_parameter(parameter) def __add__(self, other: Optional[DerivedParameterCollection]): """Return a new DerivedParameterCollection with the lists of DerivedParameter @@ -230,9 +234,11 @@ def __init__(self): self.value = None def set_value(self, value: float): + """Set the value of this parameter.""" self.value = value def get_value(self) -> float: + """Get the current value of this parameter.""" return self.value @@ -245,13 +251,25 @@ def __init__(self, value: float): self.value = value def set_value(self, value: float): + """Set the value of this parameter.""" self.value = value def get_value(self) -> float: + """Return the current value of this parameter.""" return self.value def create(value: Optional[float] = None): + """Create a new parameter. + + If `value` is `None`, the result will be a `SamplerParameter`; Firecrown + will expect this value to be supplied by the sampling framwork. If `value` + is a `float` quantity, then Firecrown will expect this parameter to *not* + be supplied by the sampling framework, and instead the provided value will + be used for every sample. + + Only `None` or a `float` value is allowed. + """ if value is None: return SamplerParameter() return InternalParameter(value)