예제 #1
0
    def setRoot(self, root):
        """Set the root of the Literal tree.

        Raises:
        ValueError if errors are found in the Literal tree.

        """

        # Validate the new root
        validate(root)

        # Stop observing the old root
        if self.root is not None:
            self.root.removeObserver(self._flush)

        # Add the new root
        self.root = root
        self.root.addObserver(self._flush)
        self._flush(self)

        # Get the args
        args = getArgs(root, getconsts=False)
        self.argdict = OrderedDict( [(arg.name, arg) for arg in args] )

        # Set Operator attributes
        self.nin = len(self.args)

        return
예제 #2
0
    def _validate(self):
        """Validate my state.

        This validates that par is not None.
        This validates eq.

        Raises SrFitError if validation fails.

        """
        if self.par is None:
            raise SrFitError("par is None")
        if self.eq is None:
            raise SrFitError("eq is None")
        self.par._validate()
        from diffpy.srfit.equation.visitors import validate
        try:
            validate(self.eq)
        except ValueError as e:
            raise SrFitError(e)

        # Try to get the value of eq.
        try:
            val = self.eq()
            self.par.setValue(val)
        except TypeError:
            raise SrFitError("eq cannot be evaluated")
        finally:
            if val is None:
                raise SrFitError("eq evaluates to None")

        return
예제 #3
0
    def setRoot(self, root):
        """Set the root of the Literal tree.

        Raises:
        ValueError if errors are found in the Literal tree.

        """

        # Validate the new root
        validate(root)

        # Stop observing the old root
        if self.root is not None:
            self.root.removeObserver(self._flush)

        # Add the new root
        self.root = root
        self.root.addObserver(self._flush)
        self._flush(other=(self, ))

        # Get the args
        args = getArgs(root, getconsts=False)
        self.argdict = OrderedDict([(arg.name, arg) for arg in args])

        # Set Operator attributes
        self.nin = len(self.args)

        return
예제 #4
0
    def _validate(self):
        """Validate my state.

        This validates eq.

        Raises SrFitError if validation fails.

        """
        if self.eq is None:
            raise SrFitError("eq is None")
        from diffpy.srfit.equation.visitors import validate
        try:
            validate(self.eq)
        except ValueError as e:
            raise SrFitError(e)

        # Try to get the value of eq.
        try:
            val = self.eq()
        except TypeError:
            raise SrFitError("eq cannot be evaluated")
        finally:
            if val is None:
                raise SrFitError("eq evaluates to None")

        return
예제 #5
0
    def _validate(self):
        """Validate my state.

        This validates eq.

        Raises SrFitError if validation fails.

        """
        if self.eq is None:
            raise SrFitError("eq is None")
        from diffpy.srfit.equation.visitors import validate
        try:
            validate(self.eq)
        except ValueError, e:
            raise SrFitError(e)
예제 #6
0
    def _validate(self):
        """Validate my state.

        This performs profile validations.
        This performs ProfileGenerator validations.
        This validates _eq.
        This validates _reseq and residual.

        Raises SrFitError if validation fails.

        """
        self.profile._validate()
        ParameterSet._validate(self)

        # Try to get the value of eq.
        from diffpy.srfit.equation.visitors import validate
        try:
            validate(self._eq)
        except ValueError as e:
            raise SrFitError(e)
        if self._eq is None:
            raise SrFitError("_eq is None")

        val = None
        try:
            val = self._eq()
        except TypeError as e:
            raise SrFitError("_eq cannot be evaluated: %s"%e)

        if val is None:
            raise SrFitError("_eq evaluates to None")

        # Try to get the value for residual
        try:
            validate(self._reseq)
        except ValueError as e:
            raise SrFitError(e)
        try:
            val = self.residual()
        except TypeError:
            raise SrFitError("residual cannot be evaluated")
        if val is None:
            raise SrFitError("residual evaluates to None")
        return
예제 #7
0
    def _validate(self):
        """Validate my state.

        This validates that par is not None.
        This validates eq.

        Raises AttributeError if validation fails.

        """
        if self.par is None:
            raise AttributeError("par is None")
        if self.eq is None:
            raise AttributeError("eq is None")
        self.par._validate()
        from diffpy.srfit.equation.visitors import validate
        try:
            validate(self.eq)
        except ValueError, e:
            raise AttributeError(e)
예제 #8
0
    def _validate(self):
        """Validate my state.

        This performs profile validations.
        This performs ProfileGenerator validations.
        This validates _eq.
        This validates _reseq and residual.

        Raises AttributeError if validation fails.

        """
        self.profile._validate()
        ParameterSet._validate(self)

        # Try to get the value of eq.
        from diffpy.srfit.equation.visitors import validate
        try:
            validate(self._eq)
        except ValueError, e:
            raise AttributeError(e)
예제 #9
0
    def _validate(self):
        """Validate my state.

        This performs profile validations.
        This performs ProfileGenerator validations.
        This validates _eq.
        This validates _reseq and residual.

        Raises SrFitError if validation fails.

        """
        self.profile._validate()
        ParameterSet._validate(self)

        # Try to get the value of eq.
        from diffpy.srfit.equation.visitors import validate
        try:
            validate(self._eq)
        except ValueError, e:
            raise SrFitError(e)
예제 #10
0
        try:
            validate(self._eq)
        except ValueError, e:
            raise AttributeError(e)
        if self._eq is None:
            raise AttributeError("_eq is None")

        val = None
        try:
            val = self._eq()
        except TypeError, e:
            raise AttributeError("_eq cannot be evaluated: %s"%e)

        if val is None:
            raise AttributeError("_eq evaluates to None")

        # Try to get the value for residual
        try:
            validate(self._reseq)
        except ValueError, e:
            raise AttributeError(e)
        try:
            val = self.residual()
        except TypeError, e:
            raise AttributeError("residual cannot be evaluated")
        if val is None:
            raise AttributeError("residual evaluates to None")
        return

# End of file
예제 #11
0
        try:
            validate(self._eq)
        except ValueError, e:
            raise SrFitError(e)
        if self._eq is None:
            raise SrFitError("_eq is None")

        val = None
        try:
            val = self._eq()
        except TypeError, e:
            raise SrFitError("_eq cannot be evaluated: %s"%e)

        if val is None:
            raise SrFitError("_eq evaluates to None")

        # Try to get the value for residual
        try:
            validate(self._reseq)
        except ValueError, e:
            raise SrFitError(e)
        try:
            val = self.residual()
        except TypeError, e:
            raise SrFitError("residual cannot be evaluated")
        if val is None:
            raise SrFitError("residual evaluates to None")
        return

# End of file