def _default_surrogate_changed(self, old_obj, new_obj):
        """Callback whenever the default_surrogate model is changed."""

        if old_obj:
            old_obj.on_trait_change(self._def_surrogate_trait_modified,
                                    remove=True)
        if new_obj:
            new_obj.on_trait_change(self._def_surrogate_trait_modified)

            # due to the way "add" works, container will always remove the
            # old before it adds the new one. So you actually get this method
            # called twice on a replace. You only do this update when the new
            # one gets set

            for name in self._surrogate_output_names:
                if name not in self._surrogate_overrides:
                    surrogate = deepcopy(self.default_surrogate)
                    self._default_surrogate_copies[name] = surrogate
                    self._update_var_for_surrogate(surrogate, name)

        self.config_changed()
        self._train = True
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.lib/src/openmdao/lib/components/metamodel.py/MetaModel._default_surrogate_changed/original