[Tutor] problem in ploting cylinders with different colour.

2012-02-14 Thread Debashish Saha
import numpy

from enthought.mayavi import mlab

#def test_mesh():
#A very pretty picture of spherical harmonics translated from

#the octaviz example.
for r in range (1,5):
print r


pi = numpy.pi

cos = numpy.cos

sin = numpy.sin

dphi, dtheta, dz = pi/250.0, pi/250.0, 0.01

#[phi,theta] = numpy.mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta]
[phi,z] = numpy.mgrid[0:2*pi+dphi*1.5:dphi,0:2+dz*1.5:dz]

m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4;

   # r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + 5*sin(m4*theta)**m5 +
cos(m6*theta)**m7

#x = 1*sin(phi)*cos(theta)

#y = 1*sin(phi)*sin(theta)

#z = 1*cos(phi);
x=r*cos(phi)
y=r*sin(phi)
z=z
i=['Reds','greens','autumn','purples']
print i[r-1]
e=i[r-1]

mlab.mesh(x, y, z,colormap='e')
#print i[r-1]

Error:
TypeError Traceback (most recent call last)
C:\Python27\lib\site-packages\IPython\utils\py3compat.pyc in
execfile(fname, glob, loc)
166 else:
167 filename = fname
-- 168 exec compile(scripttext, filename, 'exec') in glob, loc
169 else:
170 def execfile(fname, *where):

C:\Users\as\jhgf.py in module()
 24 print i[r-1]
 25 e=i[r-1]
--- 26 mlab.mesh(x, y, z,'e')
 27 #print i[r-1]

 28

C:\Python27\lib\site-packages\mayavi\tools\helper_functions.pyc in
the_function(*args, **kwargs)
 32 def document_pipeline(pipeline):
 33 def the_function(*args, **kwargs):
--- 34 return pipeline(*args, **kwargs)
 35
 36 if hasattr(pipeline, 'doc'):

C:\Python27\lib\site-packages\mayavi\tools\helper_functions.pyc in
__call__(self, *args, **kwargs)
 77 scene.disable_render = True
 78 # Then call the real logic

--- 79 output = self.__call_internal__(*args, **kwargs)
 80 # And re-enable the rendering, if needed.

 81 if scene is not None:

C:\Python27\lib\site-packages\mayavi\tools\helper_functions.pyc in
__call_internal__(self, *args, **kwargs)
830 filters.
831 
-- 832 self.source = self._source_function(*args, **kwargs)
833 kwargs.pop('name', None)
834 self.store_kwargs(kwargs)

TypeError: grid_source() takes exactly 3 arguments (4 given)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] problem in plotting circular plates at regular separation

2012-02-14 Thread Debashish Saha
from __future__ import division
import numpy
from enthought.mayavi import mlab
for r in range (1,5):
print r

pi = numpy.pi
cos = numpy.cos
sin = numpy.sin
dphi, dtheta, dz = pi/250.0, pi/250.0, 0.01
[s,theta]=numpy.mgrid[0.01:r+0.015:.01,0:2*pi+dtheta*1.5:dtheta]
x=s*cos(theta)
y=s*sin(theta)
z=r
mlab.mesh(x, y,z, colormap='Greens')

error:

AssertionErrorTraceback (most recent call last)
C:\Users\as\ipython-input-81-1360d2653557 in module()
 13 y=s*sin(theta)
 14 z=r
--- 15 mlab.mesh(x, y,z, colormap='Greens')

C:\Python27\lib\site-packages\mayavi\tools\helper_functions.pyc in
the_function(*args, **kwargs)
 32 def document_pipeline(pipeline):
 33 def the_function(*args, **kwargs):
--- 34 return pipeline(*args, **kwargs)
 35
 36 if hasattr(pipeline, 'doc'):

C:\Python27\lib\site-packages\mayavi\tools\helper_functions.pyc in
__call__(self, *args, **kwargs)
 77 scene.disable_render = True
 78 # Then call the real logic

--- 79 output = self.__call_internal__(*args, **kwargs)
 80 # And re-enable the rendering, if needed.

 81 if scene is not None:

C:\Python27\lib\site-packages\mayavi\tools\helper_functions.pyc in
__call_internal__(self, *args, **kwargs)
830 filters.
831 
-- 832 self.source = self._source_function(*args, **kwargs)
833 kwargs.pop('name', None)
834 self.store_kwargs(kwargs)

C:\Python27\lib\site-packages\mayavi\tools\sources.pyc in
grid_source(x, y, z, **kwargs)
   1259 x, y, z, scalars = convert_to_arrays((x, y, z, scalars))
   1260 data_source = MGridSource()
- 1261 data_source.reset(x=x, y=y, z=z, scalars=scalars)
   1262
   1263 name = kwargs.pop('name', 'GridSource')

C:\Python27\lib\site-packages\mayavi\tools\sources.pyc in reset(self, **traits)
689 assert len(x.shape) == 2, Array x must be 2 dimensional.
690 assert len(y.shape) == 2, Array y must be 2 dimensional.
-- 691 assert len(z.shape) == 2, Array z must be 2 dimensional.
692 assert x.shape == y.shape, Arrays x and y must have
same shape.
693 assert y.shape == z.shape, Arrays y and z must have
same shape.

AssertionError: Array z must be 2 dimensional.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] problem in plotting circular plates at regular separation

2012-02-14 Thread Alan Gauld

On 14/02/12 13:56, Debashish Saha wrote:


for r in range (1,5):

...

 z=r
 mlab.mesh(x, y,z, colormap='Greens')

...

AssertionError: Array z must be 2 dimensional.



And your question is?

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] problem in ploting cylinders with different colour.

2012-02-14 Thread Steven D'Aprano

Debashish Saha wrote:


TypeError: grid_source() takes exactly 3 arguments (4 given)



Is this error not clear enough? The function expects 3 arguments, you have 
given it 4. You need to give one fewer.


The only tricky thing to remember is that when you have a method, one argument 
is the automatically provided self argument:


function(a, b, c, d)  # This is FOUR arguments.

instance.method(a, b, c)  # So is this, because there is also a self arg.



--
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] problem in plotting circular plates at regular separation

2012-02-14 Thread Mark Lawrence

On 14/02/2012 14:07, Alan Gauld wrote:

On 14/02/12 13:56, Debashish Saha wrote:


for r in range (1,5):

...

z=r
mlab.mesh(x, y,z, colormap='Greens')

...

AssertionError: Array z must be 2 dimensional.



And your question is?



It's implied, please do my work for me because I can't be bothered to 
phrase a question.


--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Using __ini__.py for common fonctions

2012-02-14 Thread Karim


Hello All,

I have 3 functions,  common utilities which I use several times in many 
modules of a main package.
I don't want to create an utilies.py  module in the package. Instead I 
declare it in the __init__.py of

the package. Then to use it inside my package I do the following:

from package import my_common_utility_fonction.

Is it ok to do this? Is it a common practise?

Advices are welcome!

Cheers
Karim
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Using __ini__.py for common fonctions

2012-02-14 Thread Karim


Hello All,

I have 3 functions,  common utilities which I use several times in many 
modules of a main package.
I don't want to create an utilies.py  module in the package. Instead I 
declare it in the __init__.py of

the package. Then to use it I do the following:

from packe

Is it ok to do this? Is it a common practise?

Advices are welcome!

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using __ini__.py for common fonctions

2012-02-14 Thread Alan Gauld

On 14/02/12 19:08, Karim wrote:


Advices are welcome!


Asking the same question twice does not double your chances of getting a 
reply. It may even reduce them.


As to your question, it's not the most common way to do it, it's not 
even the way I'd recommend since what it does is hide your code by 
putting it somewhere a user is not likely to guess.


In Python explicit beats implicit. Put it in a module where we can see 
where it lives. It makes maintenance much easier later.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using __ini__.py for common fonctions

2012-02-14 Thread Karim



Le 14/02/2012 20:25, Alan Gauld a écrit :

On 14/02/12 19:08, Karim wrote:


Advices are welcome!


Asking the same question twice does not double your chances of getting 
a reply. It may even reduce them.


As to your question, it's not the most common way to do it, it's not 
even the way I'd recommend since what it does is hide your code by 
putting it somewhere a user is not likely to guess.


In Python explicit beats implicit. Put it in a module where we can see 
where it lives. It makes maintenance much easier later.




Sorry Alan,

I have an issue w/ thunderbird and I found my first email in the Trash bin !
I did not know if my email was sent or not as I don't receive my email 
back (Don't know why).


Thanks for your prompt answer.

Cheers
karim

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Learn Python The Hard Way, Ex19-3

2012-02-14 Thread amt
Hello! I managed in the end to have more than 10 ways of doing it,
moving now to Exercise 20.





Thank you so much for helping me out every time.



Regards,
amt
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] specific recommendation for a Python book, to move from baby-level to intermediate-level

2012-02-14 Thread Tamar Osher

Hello!  I have finished reading some Python tutorials.  My favorite tutorial is 
the official tutorial at Python.org.

I
 am hoping to find a professionally designed, serious, university level book 
(with exercises, with 
a learning disc, and answers, and an elaborately helpful website) that will 
carefully and surely guide me through 
learning computer programming with Python version 3.  I want to be lifted up 
from a baby-level to an intermediate 
level.

I
 don't want to spend a lot of time casually browsing through the 
websites, trying out different things.  I am in a rush to become a 
Python expert, I need a job!  I enjoy computer programming.  Python is my only 
programming language.

A note to Python Teachers:
 I downloaded Python version 3.2.2 on my computer.  Most Python books and 
tutorials are several years old, for older, outdated versions.  My learning 
Python got off to a slow start: Initially, I had spent over a week trying to 
figure out the (version 2) tutorial for Hello, World!, and the print/print() 
situation.
 Today, there is a huge and growing number of online Python tutorials and 
websites.  My request is that the list of recommended tutorials be revised and 
updated.  There is a sizable amount of learning and tutorial info at Python.org 
that seems to be valuable historical information rather than 
urgent-read-now-tutorials for new beginning programmers.  For instance, there 
are some very well written Python tutorials from years 2009, 2007, and 2005.  
An idea: Delete all references to tutorials that are not version 2 or 3.  And 
clearly label all the well-written version 2 tutorials, as being outdated 
version 2.
 For me, learning computer programming is easy, so far.  What is difficult 
is finding the proper tutorials, and learning how to manage the difference 
between version 3.2.2 and older versions.  For someone new to programming, the 
difference between version 3.2.2 and the older versions is enormous.  (I have a 
background as a professional classroom teacher.)

I am very eager to get kind help and wise counsel from others.  If I need to 
install install Python version 2, buy a version 2 university-level book, read 
some version 2 tutorials, and do some version 2 exercises, please let me know.  
I want to quickly move myself from a baby-level to a capable, 
intermediate-level Python programmer.

Please contact me when you have time.  I am eager to connect with everyone and 
hear each person's comments.  Have a GREAT day!
 
From Your Friend: Tamar Osher
Skype: tamarosher
Email: emeraldoff...@hotmail.com
Message Phone: 011- 1- 513-252-2936
www.HowToBeGifted.com - marketing communication, web design, and much more





  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor