Пример #1
0
    def __cmp__(self, other):

        data = endl1dmathmisc.valid1dClassType(other, "endl1dmath.__cmp__",
                                               "comparison")
        if (self.data < other.data): return (-1)
        if (self.data == other.data): return (0)
        return (1)
Пример #2
0
    def set(self, other, duplicate=0, checkDataType=1):
        """Sets self.data = other.data. If duplicate is true (i.e., not 0) than a copy of other's data 
        is made so that other's and self's data can be modified independently."""

        if (type(other) == type([])):
            data = other
        else:
            data = endl1dmathmisc.valid1dClassType(other, "endl1dmath.set",
                                                   "setting")
        if (checkDataType): endl1dmathmisc.check1dData(data)
        if (duplicate):
            self.data = []
            for d in data:
                self.data.append(d)
        else:
            self.data = data
Пример #3
0
    def __sub__(self, v):
        """Returns an endl1dmath object that is self's points minus v.  v can be a number or
        an endl1dmath object that must be the same length as self."""

        d = []
        if (type(v) == type(1)) or (type(v) == type(1.)):
            for p in self.data:
                d.append(p - v)
        else:
            data = endl1dmathmisc.valid1dClassType(v, "endl1dmath.__sub__",
                                                   "subtraction")
            if (len(self.data) != len(data)):
                raise Exception(
                    "\nError in endl1dmath.__add__: data lengths differ.")
            i = 0
            for p in self.data:
                d.append(p - data[i])
                i += 1
        return endl1dmath(d, checkDataType=0, yLabel=self.yLabel)