Skip to content

Commit 2c0fdc7

Browse files
dweindldilpath
andauthored
Apply suggestions from code review
Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com>
1 parent e593688 commit 2c0fdc7

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

petab/v2/calculate.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,13 @@ def calculate_residuals_for_table(
155155
measurement = scale(measurement, trafo)
156156

157157
# non-normalized residual is just the difference
158-
residual = simulation - measurement
158+
residual = measurement - simulation
159159

160-
noise_value = 1
161160
if normalize:
162-
# look up noise standard deviation
163-
noise_value = evaluate_noise_formula(
161+
# divide by standard deviation
162+
residual /= evaluate_noise_formula(
164163
row, noise_formulas, parameter_df, simulation, observable
165164
)
166-
residual /= noise_value
167165

168166
# fill in value
169167
residual_df.loc[irow, RESIDUAL] = residual
@@ -181,13 +179,9 @@ def get_symbolic_noise_formulas(observable_df) -> dict[str, sp.Expr]:
181179
"""
182180
noise_formulas = {}
183181
# iterate over observables
184-
for row in observable_df.itertuples():
185-
observable_id = row.Index
186-
if NOISE_FORMULA not in observable_df.columns:
187-
noise_formula = None
188-
else:
189-
noise_formula = sympify_petab(row.noiseFormula)
190-
noise_formulas[observable_id] = noise_formula
182+
for observable_id, row in observable_df.iterrows():
183+
noise_formulas[observable_id] = \
184+
sympify_petab(row.noiseFormula) if NOISE_FORMULA in row else None
191185
return noise_formulas
192186

193187

0 commit comments

Comments
 (0)