def copy(self, other=None): """Copy self to other. if other is None, create new instance other -- ref to other object returns reference to copied object """ # check arguments if other is None: other = FitDataSet(self.name) PDFDataSet.copy(self, other) if isinstance(other, FitDataSet): # assigned attributes other._fitrmin = self._fitrmin other._fitrmax = self._fitrmax other._fitrstep = self._fitrstep other._rcalc_changed = self._rcalc_changed # copied attributes other.constraints = copy.deepcopy(self.constraints) other.initial = copy.deepcopy(self.initial) other.refined = copy.deepcopy(self.refined) # must also update the sampling on the new object st = self.getFitSamplingType() other.setFitSamplingType(st, self.fitrstep) return other