def run_em_unless_loadable(self, run_dir):
    '\n        Run and EM fit, but only if not loadable from a previous run\n\n        '
    try:
        try:
            med_and_spans = np.load(os.path.join(run_dir, 'final/', self.final_med_and_spans_file))
        except ValueError:
            logging.info('med_and_spans not read. Presumably you are using gradient descent optimisation procedure?')
            med_and_spans = [None]
        memb_probs = np.load(os.path.join(run_dir, 'final/', self.final_memb_probs_file))
        comps = self.Component.load_raw_components(str(os.path.join(run_dir, 'final/', self.final_comps_file)))
        logging.info('Loaded from previous run')
    except AttributeError:
        comps = self.build_comps_from_chains(run_dir)
    except IOError:
        (comps, med_and_spans, memb_probs) = expectmax.fit_many_comps(data=self.data_dict, ncomps=self.ncomps, rdir=run_dir, **self.fit_pars)
    self.fit_pars['init_comps'] = None
    self.fit_pars['init_memb_probs'] = None
    return {'comps': comps, 'med_and_spans': med_and_spans, 'memb_probs': memb_probs}
Run and EM fit, but only if not loadable from a previous run
def run_em_unless_loadable(self, run_dir):
    '\n        \n\n        '
    try:
        try:
            med_and_spans = np.load(os.path.join(run_dir, 'final/', self.final_med_and_spans_file))
        except ValueError:
            logging.info('med_and_spans not read. Presumably you are using gradient descent optimisation procedure?')
            med_and_spans = [None]
        memb_probs = np.load(os.path.join(run_dir, 'final/', self.final_memb_probs_file))
        comps = self.Component.load_raw_components(str(os.path.join(run_dir, 'final/', self.final_comps_file)))
        logging.info('Loaded from previous run')
    except AttributeError:
        comps = self.build_comps_from_chains(run_dir)
    except IOError:
        (comps, med_and_spans, memb_probs) = expectmax.fit_many_comps(data=self.data_dict, ncomps=self.ncomps, rdir=run_dir, **self.fit_pars)
    self.fit_pars['init_comps'] = None
    self.fit_pars['init_memb_probs'] = None
    return {'comps': comps, 'med_and_spans': med_and_spans, 'memb_probs': memb_probs}