[Matrix-SIG] More on NaN and bugs? : was [Matrix-SIG] NaN

Yoon, Hoon (CICG - NY Program Trading) HYoon@exchange.ml.com
Thu, 8 Oct 1998 16:46:32 -0400


In case we are adding functions. I wrote the following.

def packr( M):
	"""
	Returns only rows or colums, which is Not NaN (Packr is Gauss by
Aptech func)
	works for 2d. axis is bit confusing for a Gauss person
	"""
	return take( M, isanx(M))

def  isanx(d, axis=1):
 	if len(d.shape) == 2:
			return nonzero(equal(add.reduce(equal(d,d),axis),
d.shape[axis]))
	elif len(d.shape) == 1:
	      return nonzero(equal(d,d))
	else: raise IndexError, "function : packr is for up to 2D matrix
only"

I can't really make this work for more than 2D. I hope someone can figure
out something better.
Thanks Janko,

Hoon,

> -----Original Message-----
> From:	Janko Hauser 
> Sent:	Thursday, October 08, 1998 5:37 PM
> To:	Yoon, Hoon (CICG - NY Program Trading)
> Cc:	matrix-sig@python.org
> Subject:	[Matrix-SIG] More on NaN and bugs? : was [Matrix-SIG] NaN
> 
> May I add these two functions to this thread?
> 
> def isnan(m):
>     """
>     Returns a condition array, which is true where m has a NaN value.
>     """
>     return Numeric.not_equal(m,m)
> 
> def isinf(m):
>     """
>     Returns a condition array, which is true where m has an Inf value.
>     Does not look for sign of Inf.
>     """
>     n = isnan(m)
>     return isnan(Numeric.where(n,0,m)*0.)
> 
> 
> Is there some obvious case, which is not covered?
> 
> __Janko
> 
> _______________________________________________
> Matrix-SIG maillist  -  Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig