@@ -162,7 +162,7 @@ def positions_from_delta( # noqa: PLR0912, PLR0913, PLR0915
162162 bias : float | FloatArray | None = None ,
163163 vis : FloatArray | None = None ,
164164 * ,
165- bias_model : str | Callable [..., Any ] = "linear" ,
165+ bias_model : Callable [..., Any ] = linear_bias ,
166166 remove_monopole : bool = False ,
167167 batch : int = 1_000_000 ,
168168 rng : np .random .Generator | None = None ,
@@ -207,10 +207,8 @@ def positions_from_delta( # noqa: PLR0912, PLR0913, PLR0915
207207 Visibility map for the observed points. This is multiplied with
208208 the full sky number count map, and must hence be of compatible shape.
209209 bias_model
210- The bias model to apply. If a string, refers to a function in
211- the :mod:`~glass.points` module, e.g. ``'linear'`` for
212- :func:`glass.linear_bias()` or ``'glass.loglinear'`` for
213- :func:`glass.loglinear_bias`.
210+ The bias model to apply. For examples, :func:`glass.linear_bias`
211+ or :func:`glass.loglinear_bias`.
214212 remove_monopole
215213 If true, the monopole of the density contrast
216214 after biasing is fixed to zero.
@@ -239,13 +237,9 @@ def positions_from_delta( # noqa: PLR0912, PLR0913, PLR0915
239237 if rng is None :
240238 rng = np .random .default_rng (42 )
241239
242- # get the bias model
243- if isinstance (bias_model , str ):
244- bias_model_callable = globals ()[f"{ bias_model } _bias" ]
245- elif not callable (bias_model ):
246- raise TypeError ("bias_model must be string or callable" )
247- else :
248- bias_model_callable = bias_model
240+ # ensure bias_model is a function
241+ if not callable (bias_model ):
242+ raise TypeError ("bias_model must be callable" )
249243
250244 # broadcast inputs to common shape of extra dimensions
251245 inputs : list [tuple [float | FloatArray , int ]] = [(ngal , 0 ), (delta , 1 )]
@@ -263,11 +257,7 @@ def positions_from_delta( # noqa: PLR0912, PLR0913, PLR0915
263257 # iterate the leading dimensions
264258 for k in np .ndindex (dims ):
265259 # compute density contrast from bias model, or copy
266- n = (
267- np .copy (delta [k ])
268- if bias is None
269- else bias_model_callable (delta [k ], bias [k ])
270- )
260+ n = np .copy (delta [k ]) if bias is None else bias_model (delta [k ], bias [k ])
271261
272262 # remove monopole if asked to
273263 if remove_monopole :
0 commit comments