- Timestamp:
- 11/19/2008 07:52:18 AM (7 weeks ago)
- Location:
- trunk/fipy
- Files:
-
- 6 modified
-
tools/dimensions/physicalField.py (modified) (1 diff)
-
tools/numerix.py (modified) (1 diff)
-
variables/cellVariable.py (modified) (1 diff)
-
variables/meshVariable.py (modified) (1 diff)
-
variables/operatorVariable.py (modified) (1 diff)
-
variables/variable.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fipy/tools/dimensions/physicalField.py
r2781 r2826 760 760 return tuple(result) 761 761 762 def getsctype(self, default=None): 763 """ 764 765 Returns the Numpy sctype of the underlying array. 766 767 >>> PhysicalField(1, 'm').getsctype() 768 <type 'numpy.int32'> 769 >>> PhysicalField(1., 'm').getsctype() 770 <type 'numpy.float64'> 771 >>> PhysicalField((1,1.), 'm').getsctype() 772 <type 'numpy.float64'> 773 774 """ 775 776 if not hasattr(self, 'typecode'): 777 self.typecode = numerix.obj2sctype(rep=numerix.array(self.getNumericValue()), 778 default=default) 779 780 return self.typecode 781 762 782 def getUnit(self): 763 783 """ -
trunk/fipy/tools/numerix.py
r2822 r2826 1170 1170 return lst 1171 1171 1172 def obj2sctype(rep, default=None): 1173 if _isPhysical(rep): 1174 sctype = rep.getsctype(default=default) 1175 else: 1176 if type(rep) in (type(()), type([])): 1177 rep = array(rep) 1178 sctype = NUMERIX.obj2sctype(rep=rep, default=default) 1179 1180 if sctype is None: 1181 return obj2sctype(type(rep), default=default) 1182 else: 1183 return sctype 1184 1185 1172 1186 def getTypecode(arr): 1173 1187 """ -
trunk/fipy/variables/cellVariable.py
r2825 r2826 85 85 >>> print b 86 86 [2] 87 >>> b.get Typecode()88 'l'87 >>> b.getsctype() 88 <type 'numpy.int32'> 89 89 90 90 replacing with the same thing is no problem -
trunk/fipy/variables/meshVariable.py
r2781 r2826 73 73 array = numerix.zeros(self.elementshape 74 74 + self._getShapeFromMesh(mesh), 75 numerix.obj2sctype( numerix.array(value)))75 numerix.obj2sctype(value)) 76 76 if numerix._broadcastShape(array.shape, numerix.shape(value)) is None: 77 77 if not isinstance(value, Variable): -
trunk/fipy/variables/operatorVariable.py
r2825 r2826 246 246 247 247 >>> a = Variable(1.) * Variable(1) 248 >>> a.get Typecode()249 'd'248 >>> a.getsctype() 249 <type 'numpy.float64'> 250 250 251 251 The following test is to correct an `--inline` bug that was -
trunk/fipy/variables/variable.py
r2825 r2826 316 316 317 317 def __repr__(self): 318 if len(self.name) > 0:318 if hasattr(self, 'name') and len(self.name) > 0: 319 319 return self.name 320 320 else: … … 549 549 550 550 if where is not None: 551 tmp = numerix.zeros(numerix.getShape(where), numerix. getTypecode(value))551 tmp = numerix.zeros(numerix.getShape(where), numerix.obj2sctype(value)) 552 552 tmp[:] = value 553 553 tmp = numerix.where(where, tmp, self.getValue()) … … 603 603 shape = property(fget=lambda self: self.getShape(), doc="Tuple of array dimensions.") 604 604 605 def getsctype(self, default=None): 606 """ 607 608 Returns the Numpy sctype of the underlying array. 609 610 >>> Variable(1).getsctype() 611 <type 'numpy.int32'> 612 >>> Variable(1.).getsctype() 613 <type 'numpy.float64'> 614 >>> Variable((1,1.)).getsctype() 615 <type 'numpy.float64'> 616 617 """ 618 619 if not hasattr(self, 'typecode'): 620 self.typecode = numerix.obj2sctype(rep=self.getNumericValue(), default=default) 621 622 return self.typecode 623 605 624 def getTypecode(self): 606 625 """ … … 618 637 619 638 if not hasattr(self, 'typecode'): 620 self.typecode = numerix.getTypecode(self.get Value())639 self.typecode = numerix.getTypecode(self.getNumericValue()) 621 640 622 641 return self.typecode … … 737 756 argDict['result'] = self.getValue() 738 757 self.canInline = True 739 self.typecode = numerix. getTypecode(argDict['result'])758 self.typecode = numerix.obj2sctype(argDict['result']) 740 759 else: 741 760 if self.value is None: 742 if self.get Typecode() == '?':743 argDict['result'] = numerix.empty(dim, 'b')761 if self.getsctype() == numpy.bool_: 762 argDict['result'] = numerix.empty(dim, numpy.int8) 744 763 else: 745 argDict['result'] = numerix.empty(dim, self.get Typecode())764 argDict['result'] = numerix.empty(dim, self.getsctype()) 746 765 else: 747 766 argDict['result'] = self.value
FiPy: A Finite Volume PDE Solver Using Python