@@ -256,22 +256,23 @@ def sample_noise(
256256 observable_transformation = observable_row .get (
257257 petab .C .OBSERVABLE_TRANSFORMATION , petab .C .LIN
258258 )
259+ transform = lambda x : x
259260 # observableTransformation=log -> the log of the simulated value is
260261 # distributed according to `noise_distribution`
261262 if observable_transformation == petab .C .LOG :
262263 simulated_value = np .log (simulated_value )
264+ transform = np .exp
263265 elif observable_transformation == petab .C .LOG10 :
264266 simulated_value = np .log10 (simulated_value )
267+ transform = lambda x : np .power (10 , x )
265268
266269 # below is e.g.: `np.random.normal(loc=simulation, scale=noise_value)`
267270 simulated_value_with_noise = getattr (rng , noise_distribution )(
268271 loc = simulated_value , scale = noise_value * noise_scaling_factor
269272 )
270273
271- if observable_transformation == petab .C .LOG :
272- simulated_value_with_noise = np .exp (simulated_value_with_noise )
273- elif observable_transformation == petab .C .LOG10 :
274- simulated_value_with_noise = np .power (10 , simulated_value_with_noise )
274+ # apply observable transformation, ensure `float` type
275+ simulated_value_with_noise = float (transform (simulated_value_with_noise ))
275276
276277 if zero_bounded and np .sign (simulated_value ) != np .sign (
277278 simulated_value_with_noise
0 commit comments