/[escript]/trunk/escript/py_src/pdetools.py
ViewVC logotype

Diff of /trunk/escript/py_src/pdetools.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4070 by gross, Tue Nov 13 07:47:16 2012 UTC revision 4071 by gross, Tue Nov 13 21:43:11 2012 UTC
# Line 1345  class ArithmeticTuple(object): Line 1345  class ArithmeticTuple(object):
1345    
1346         from esys.escript import Data         from esys.escript import Data
1347         from numpy import array         from numpy import array
1348         a=Data(...)         a=eData(...)
1349         b=array([1.,4.])         b=array([1.,4.])
1350         x=ArithmeticTuple(a,b)         x=ArithmeticTuple(a,b)
1351         y=5.*x         y=5.*x
# Line 1395  class ArithmeticTuple(object): Line 1395  class ArithmeticTuple(object):
1395                 raise ValueError("length of arguments don't match.")                 raise ValueError("length of arguments don't match.")
1396             for i in range(l):             for i in range(l):
1397          if self.__isEmpty(self[i]) or self.__isEmpty(other[i]):          if self.__isEmpty(self[i]) or self.__isEmpty(other[i]):
1398              out.append(Data())              out.append(escore.Data())
1399          else:          else:
1400              out.append(self[i]*other[i])              out.append(self[i]*other[i])
1401         except TypeError:         except TypeError:
1402          for i in range(len(self)):            for i in range(len(self)):  
1403          if self.__isEmpty(self[i]) or self.__isEmpty(other):          if self.__isEmpty(self[i]) or self.__isEmpty(other):
1404              out.append(Data())              out.append(escore.Data())
1405          else:          else:
1406              out.append(self[i]*other)              out.append(self[i]*other)
1407         return ArithmeticTuple(*tuple(out))         return ArithmeticTuple(*tuple(out))
# Line 1422  class ArithmeticTuple(object): Line 1422  class ArithmeticTuple(object):
1422            raise ValueError("length of arguments don't match.")            raise ValueError("length of arguments don't match.")
1423        for i in range(l):        for i in range(l):
1424          if self.__isEmpty(self[i]) or self.__isEmpty(other[i]):          if self.__isEmpty(self[i]) or self.__isEmpty(other[i]):
1425              out.append(Data())              out.append(escore.Data())
1426          else:          else:
1427              out.append(other[i]*self[i])              out.append(other[i]*self[i])
1428        except TypeError:        except TypeError:
1429        for i in range(len(self)):          for i in range(len(self)):  
1430          if self.__isEmpty(self[i]) or self.__isEmpty(other):          if self.__isEmpty(self[i]) or self.__isEmpty(other):
1431              out.append(Data())              out.append(escore.Data())
1432          else:          else:
1433              out.append(other*self[i])              out.append(other*self[i])
1434        return ArithmeticTuple(*tuple(out))        return ArithmeticTuple(*tuple(out))
# Line 1464  class ArithmeticTuple(object): Line 1464  class ArithmeticTuple(object):
1464              raise ZeroDivisionError("in component %s"%i)              raise ZeroDivisionError("in component %s"%i)
1465          else:          else:
1466              if self.__isEmpty(other[i]):              if self.__isEmpty(other[i]):
1467              out.append(Data())              out.append(escore.Data())
1468              else:              else:
1469              out.append(other[i]/self[i])              out.append(other[i]/self[i])
1470        except TypeError:        except TypeError:
# Line 1473  class ArithmeticTuple(object): Line 1473  class ArithmeticTuple(object):
1473              raise ZeroDivisionError("in component %s"%i)              raise ZeroDivisionError("in component %s"%i)
1474          else:          else:
1475              if self.__isEmpty(other):              if self.__isEmpty(other):
1476              out.append(Data())              out.append(escore.Data())
1477              else:              else:
1478              out.append(other/self[i])              out.append(other/self[i])
1479        return ArithmeticTuple(*tuple(out))        return ArithmeticTuple(*tuple(out))
# Line 1578  class ArithmeticTuple(object): Line 1578  class ArithmeticTuple(object):
1578        out=[]        out=[]
1579        for i in range(len(self)):        for i in range(len(self)):
1580        if self.__isEmpty(self[i]):        if self.__isEmpty(self[i]):
1581            out.append(Data())            out.append(escore.Data())
1582        else:        else:
1583            out.append(-self[i])            out.append(-self[i])
1584                
1585        return ArithmeticTuple(*tuple(out))        return ArithmeticTuple(*tuple(out))
1586     def __isEmpty(self, d):     def __isEmpty(self, d):
1587      if isinstance(d, Data):      if isinstance(d, escore.Data):
1588      return d.isEmpty()      return d.isEmpty()
1589      else:      else:
1590      return False      return False

Legend:
Removed from v.4070  
changed lines
  Added in v.4071

  ViewVC Help
Powered by ViewVC 1.1.26