[Edu-sig] Properties use case

Arthur ajsiegel at optonline.net
Thu Mar 16 05:22:02 CET 2006


Michael Tobis wrote:

>A Numeric array is mutable; it refers to allocated memory. So any
>subpart of it is mutable. So I suggest you use a 1-element complex
>numeric array as your mutable complex type.
>
>  
>
>>>>import Numeric as N
>>>>a = N.ones((20,20),N.Complex)
>>>>b = N.ravel(a[1:2,1:2])
>>>>b
>>>>        
>>>>
>array([ 1.+0.j])
>  
>
>>>>id(b)
>>>>        
>>>>
>2741696
>  
>
>>>>b += 1 + 1j
>>>>b
>>>>        
>>>>
>array([ 2.+1.j])
>  
>
>>>>id(b)
>>>>        
>>>>
>2741696
>
>Admittedly the str() of this object is ugly, and because Numeric isn't
>inheritance-friendly this is hard to work around elegantly. If this is
>a problem it might provide the occasion to upgrade to a newer
>numerical package.
>  
>
Yeah, I should be moving along to understand what the newer numerical 
packages do differently.  One of the reasons I haven't is because I have 
had the impression that differences are more at the level of 
implementation detail, rather  than user-facing, and there is no  
fundamental difference in these kinds of functional issues.  but that 
has only been an impression, and you seem to be  implying  otherwise. 

>Still, why do you care about mutability of your complex number
>instances once they are outside Numeric? That seems unusual.
>  
>
Well outside of Numeric they represent dynamic, graphical geometric 
objects, whose identity needs to stay intact as they run through their 
paces.

Art






More information about the Edu-sig mailing list