[Numpy]Can't make fromfunction() work

Junkie Dolphin junkie.dolphin at NOSPAMlibero.it
Mon Oct 6 15:37:56 EDT 2003


Hi, I'm trying this piece of code, but y returns as a
float. x and e are created regulary. 
I'm a beginner with this amazing language, and haven't 
read (all) the fucking manual yet (shame on me!).
If someone used with Numeric could give me an 
hint I would be very glad.. Thank you! =)

from Numeric import *;

G = 200.
N = 15.

def abscissa(i):
	return i/N
	
def ordinate(i):
	x = i/N
	if (0.<=x) & (x<0.3): return 0.	
	elif (0.3<=x) & (x<=0.35): return 20.*x-6.
	elif (0.35<x) & (x<0.65): return 1.
	elif (0.65<=x) & (x<=0.7): return 14.-20.*x
	elif (0.7<x) & (x<=1.): return 0.
	raise ArithmeticError("function is undefined for ",x)
	
def errors(i): 
	return i/G

# from command line (unix script style)
if __name__ == '__main__':
	x = fromfunction(abscissa,(16,))
	y = fromfunction(ordinate,(16,))
	e = fromfunction(errors,(16,))
	print type(y)

*****************
bash-2.05b$ python ex1.py
<type 'float'>
bash-2.05b$
-- 
Ciao, Giovanni aka Junkie Dolphin

Political language...is designed to make lies 
sound truthful and murder respectable, and to 
give an appearance of solidity to pure wind.

George Orwell




More information about the Python-list mailing list