Skip to content

Commit

Permalink
GlobalFit now keeps better internal track of fit state
Browse files Browse the repository at this point in the history
  • Loading branch information
harmsm committed Jun 13, 2017
1 parent 531dad0 commit 69a03b6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pytc/global_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def remove_experiment(self,experiment):
expt_name = experiment.experiment_id

# Go through all global parameters
for k in self._global_param_mapping.keys():
global_param_map = list(self._global_param_mapping.keys())
for k in global_param_map:

# If the experiment links to that
for expt in self._global_param_mapping[k]:
Expand Down Expand Up @@ -155,6 +156,8 @@ def link_to_global(self,expt,expt_param,global_param_name):
if expt_name not in [m[0] for m in self._global_param_mapping[global_param_name]]:
self._global_param_mapping[global_param_name].append((expt_name,expt_param))

self.delete_current_fit()

def unlink_from_global(self,expt,expt_param):
"""
Remove the link between a local fitting parameter and a global
Expand Down Expand Up @@ -185,6 +188,8 @@ def unlink_from_global(self,expt,expt_param):
# remove expt --> global link
self._expt_dict[expt_name].model.update_aliases({expt_param:None})

self.delete_current_fit()

def remove_global(self,global_param_name):
"""
Remove a global parameter, unlinking all local parameters.
Expand Down Expand Up @@ -214,6 +219,7 @@ def remove_global(self,global_param_name):
self._global_param_mapping.pop(global_param_name)
self._global_params.pop(global_param_name)

self.delete_current_fit()

def fit(self,fitter=fitters.MLFitter):
"""
Expand Down Expand Up @@ -467,6 +473,8 @@ def delete_current_fit(self):
except AttributeError:
pass

self._prep_fit()

def plot(self,correct_molar_ratio=False,subtract_dilution=False,
color_list=None,data_symbol="o",linewidth=1.5,num_samples=100):
"""
Expand Down Expand Up @@ -946,8 +954,6 @@ def param_aliases(self):

return self._global_param_mapping, expt_to_global



#--------------------------------------------------------------------------
# parameter guesses

Expand Down Expand Up @@ -999,6 +1005,8 @@ def update_guess(self,param_name,param_guess,expt=None):
else:
self._expt_dict[expt.experiment_id].model.update_guesses({param_name:param_guess})

self.delete_current_fit()

#--------------------------------------------------------------------------
# parameter ranges

Expand Down Expand Up @@ -1058,6 +1066,8 @@ def update_range(self,param_name,param_range,expt=None):
else:
self._expt_dict[expt.experiment_id].model.update_guess_ranges({param_name:param_range})

self.delete_current_fit()

#--------------------------------------------------------------------------
# fixed parameters

Expand Down Expand Up @@ -1120,6 +1130,7 @@ def update_fixed(self,param_name,param_value,expt=None):
else:
self._expt_dict[expt.experiment_id].model.update_fixed({param_name:param_value})

self.delete_current_fit()

#--------------------------------------------------------------------------
# parameter bounds
Expand Down Expand Up @@ -1180,6 +1191,8 @@ def update_bounds(self,param_name,param_bounds,expt=None):
else:
self._expt_dict[expt.experiment_id].model.update_bounds({param_name:param_bounds})

self.delete_current_fit()

#--------------------------------------------------------------------------
# Functions for updating values directly (used in gui)

Expand Down

0 comments on commit 69a03b6

Please sign in to comment.