@@ -121,21 +121,6 @@ def _residual_function(self,
121
121
# Sync parameters back to objects
122
122
self .minimizer ._sync_result_to_parameters (parameters , engine_params )
123
123
124
- # Update the excluded points in experiments
125
- # TODO: This should not be handled here every time
126
- # This implementation is just very quick and dirty
127
- for experiment in experiments ._items .values ():
128
- experiment .datastore .pattern .excluded = np .full (experiment .datastore .pattern .x .shape ,
129
- fill_value = False ,
130
- dtype = bool ) # Reset excluded points
131
- excluded_regions = experiment .excluded_regions ._items # List of excluded regions
132
- if excluded_regions : # If there are any excluded regions
133
- for idx , point in enumerate (experiment .datastore .pattern .x ): # Set excluded points
134
- for region in excluded_regions .values ():
135
- if region .minimum .value <= point <= region .maximum .value :
136
- experiment .datastore .pattern .excluded [idx ] = True
137
- break
138
-
139
124
# Prepare weights for joint fitting
140
125
num_expts : int = len (experiments .ids )
141
126
if weights is None :
@@ -161,13 +146,7 @@ def _residual_function(self,
161
146
y_meas : np .ndarray = experiment .datastore .pattern .meas
162
147
y_meas_su : np .ndarray = experiment .datastore .pattern .meas_su
163
148
excluded : np .ndarray = experiment .datastore .pattern .excluded
164
- # TODO: Excluded points must be handled differently.
165
- # They should not contribute to the residuals.
166
- diff = np .where (
167
- excluded ,
168
- 0.0 , # Excluded points contribute zero to the residuals
169
- (y_meas - y_calc ) / y_meas_su # Normalized residuals
170
- )
149
+ diff = ((y_meas - y_calc ) / y_meas_su )[~ excluded ] # Exclude points that are marked as excluded
171
150
diff *= np .sqrt (weight ) # Residuals are squared before going into reduced chi-squared
172
151
residuals .extend (diff )
173
152
0 commit comments