Re: Plotting Images

2007-07-31 Thread Andr
On Jul 31, 8:41 am, Pei-Yu CHAO <[EMAIL PROTECTED]> wrote:
> Hi ALL:
>
> I have only been switched from matlab to python few
> months ago. I having trouble of plotting images from a
> matrix size of 8x1 (unfortunately that is the size
> of my data.)
>
> for example,
> x = rand(8,1)
> inshow(x)
>
> I have tried to use matplotlib function imshow(), but
> all i get is a long thin line (unable to see the color
> display and the my matrix information).
>
What is the screen size of your image?  If it's scaled down so that
the largest dimension is 1000px, then the smaller dimension will be
reduced to 1px.

Try breaking your image into various "strips".

HTH,
Andr 

> i think imshow() has the same problem in matlab, but i
> think there is a alternative in matlab, imagesc().
>
> I did search on web about plt.imagesc().but when i
> try to run the example code, python just tell me
> cannot find module plt.
>
> >>>from scipy import plt
>
> ImportError: cannot import name plt
>
> I have installed scipy, wxpython2.6and it still
> seem not to work!
>
> is there some alternitive? or what have i done wrong?
> Thank you
>
> Pei
>
>   
> 
> 想及時通知通訊錄裡的所有親朋好友好消息,就來 
> Yahoo!奇摩電子信箱發簡訊!http://tw.mobile.yahoo.com/texts/mail.php


-- 
http://mail.python.org/mailman/listinfo/python-list

Linguistic challenge: name this program

2004-12-05 Thread Andr? Roberge
In 1981, Richard Pattis wrote a delightful little book titled "Karel
the Robot, a Gentle Introduction to the Art of Programming." Pattis's
"Karel the Robot" was named after the author Karel Capek, who
popularized the word "robot" in his play "Rossum's Universal Robots".
Pattis's approach was to introduce a robot who could follow 5 basic
instructions and be taught to accomplish tasks of increasing
complexity.

A few years ago, a first implementation of "Karel the Robot" in Python
was created and called PyKarel. A second, newer implementation is
called Guido van Robot (GvR for short), and is available at
gvr.sourceforge.net. Work is currently underway by the developpers of
GvR to produce a new-and-improved version.

I have been working on my own (better ;-) version (sometimes
collaborating with the GvR folks) in order to learn Python. It is now
90% finished. It is meant to be a complete environment to learn about
programming concepts, from simple sequences of instruction to OOP.

Given the origin of Pattis's name (Rossum's Universal Robot) and the
name of Python's BDFL, I find it difficult to think of a better name
than Guido van Robot to name a programming environment in which one
uses Python to teach a robot new tricks! (Hat's off to Steve Howell
for this one). Yet, I want a "clever" name for my version.

Any suggestions?

Andre Roberge
-- 
http://mail.python.org/mailman/listinfo/python-list


exec and global puzzle

2004-12-05 Thread Andr? Roberge
I have the following two files:

#--testexec.py--
def exec_code(co):
try:
exec co
except:
print "error"

#-- test.py--
import thread
import testexec
import time

code = "def a():\n print 'a'\n\n" +\
   "def c():\n a()\n\nc()"

code2 = "def a():\n print 'a'\n\n" +\
   "def c():\n global a\n a()\n\nc()"

print " exec code - no global"
exec code
print " exec from thread - no global"
thread.start_new(testexec.exec_code, (code,))
time.sleep(1)
print "\n exec code2 - with global"
exec code2
print " exec from thread - with global"
thread.start_new(testexec.exec_code, (code2,))
#---

Here's the output when I execute test.py:

 exec code - no global
a
 exec from thread - no global
error

 exec code2 - with global
a
 exec from thread - with global
a
#-
Without the global statement, I get an error when trying to execute
the code.
I don't understand why I need to use the global statement within the
definition of c() in order for it to know what a() is.  If I define
exec_code() within test.py and use it there, I do not get any error,
with or without the use of a global statement.

Andre
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Version 0.9 of RUR-PLE

2005-05-31 Thread =?ISO-8859-1?Q?Andr=E9_Roberge?=
Version 0.9 of RUR: a Python Learning Environment has been released.
Information about RUR-PLE can be obtained at
http://rur-ple.sourceforge.net

Note that the project website is slightly out of date.

Among the changes in this new version:

***Spanish translation added.*

Changed image for language selection to reflect addition.

Changed directory structure of lessons.

Fixed "non-existent file" problem when changing language
with unstranslated lesson file open in browser; the
browser will open the default file in the chosen language
instead.

Changed dialogs (beepers to robot and resize world)
to use GridBagSizer for layout as opposed to specific
coordinates.

Added parameter  wx.BUFFER_VIRTUAL_AREA in
dc = wx.BufferedPaintDC(self, self.buffer, wx.BUFFER_VIRTUAL_AREA)
in world_display.py; this is required to get proper scrolling
since wxPython 2.5.4.1.

Added SetFocus() when positioning sizer on "Robot: code and learn"
page.  This gets rid of the unwanted grey background.

Changed list of beepers that can be placed at an intersection from
0 ... 15, 16, 17, 18, 19, 20  to
0 ... 15, 20, 40, 60, 80, 99.

Removed the "from __future__ import division" command to the interpreter.
Since this is not likely to be the default version for a *long* time, it 
seems
a better idea to revert to the default behaviour for the interpreter.
TODO: The lesson needs to be updated to reflect this change.

World redrawn immediately after selecting a new language, so that
the words "streets" and "avenues" are updated right away.

Corrected tooltip language setting on speed selection slider.

Added possibility to change background colour of robot world
through user program.  This is to be used in the random maze escape lesson.

Changed the 20 robot images so that their background
is transparent.

Removed obsolete self-testing code in various files as well as
redundant import statements.

Fixed problem with seemingly random
"invalid world file" error.  This occured when
a robot was removed from the world, and an
attempt was made at resetting the world.

Added SetFocus() to WorldGui.OnLeftDown().  Somehow,
the WorldGUI (i.e. robot world) would no longer get focus
as a matter of course when left-clicked.  This meant that it
was no longer possible to position the robot using the cursor keys.
This problem has appeared since I made the switch to
wxPython 2.6.

-- 
http://mail.python.org/mailman/listinfo/python-list