Re: any python module to calculate sin, cos, arctan?

2005-11-08 Thread Matt Feinstein
On Tue, 08 Nov 2005 12:30:35 GMT, Raymond L. Buvel
[EMAIL PROTECTED] wrote:

Shi Mu wrote:
 any python module to calculate sin, cos, arctan?

The other answers in this thread point you to the standard modules.  If
you need arbitrary precision floating point versions of these functions
check out:

http://calcrpnpy.sourceforge.net/clnumManual.html

Unless you're using Windows.

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: any python module to calculate sin, cos, arctan?

2005-11-08 Thread Matt Feinstein
On Tue, 08 Nov 2005 06:43:51 -0800, Robert Kern
[EMAIL PROTECTED] wrote:

Matt Feinstein wrote:
 On Tue, 08 Nov 2005 12:30:35 GMT, Raymond L. Buvel
 [EMAIL PROTECTED] wrote:

http://calcrpnpy.sourceforge.net/clnumManual.html
 
 Unless you're using Windows.

Why? Have you tried compiling it and failed?

Copied from the linked site:

Windows is not supported but it may be possible to get this module to
work. You will need to use the GNU tools and figure out how to build
the CLN library. Then you need to figure out how to compile and link
the clnum extension module for the standard Python. If anyone gets
this to work and wants to contribute the results, contact me at
rlbuvel at gmail dot com.

Note: may be possible, you need to figure out, if anyone gets
this to work.

The message seems clear to me-- 'If you want this capability, you can
either-- 1) install all the development tools, 2) compile all the
relevant libraries, and then 3) link and compile the Python extension
module at your own risk and on your own (or on your company's) time--
or, use Linux. Personally, I'd use Linux. On the other hand, not
everyone has that option,  it seems reasonable to me to point out
that there's a non-trivial difficulty here.

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Python at Work

2005-10-17 Thread Matt Feinstein
On 17 Oct 2005 08:12:35 -0700, Nikola [EMAIL PROTECTED]
wrote:

I'm currently learning Python for my own use.
I'm considering installing it on a work laptop, knowing that it is
non-licensed, distributable software.

However, does it access communication ports?  I know the company checks
their ports regularly for activity.

I won't be doing anything very serious; I'm just trying out Python,
learning the basics from 'Learning Python' by O'Reilly.

Python installations are pretty benign. Note, however, that when you
install additional modules, you are trusting the module writer.

For locality, you can do a completely local Python installation in
Linux, and generally speaking, additional modules can be installed
locally as well. Under win32, the standard binary installer makes a
registry entry which is checked when additional (binary) modules are
installed. I don't think there's any other 'non-local' behavior.

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Learning Python

2005-10-10 Thread Matt Feinstein
On Mon, 10 Oct 2005 12:50:18 -0400, Paul DiRezze [EMAIL PROTECTED]
wrote:

I'm spending the next two weeks off and I'm looking to take a crack at 
learning how to program in Python.  Here's a list of the places I've 
bookmarked:

http://www.python.org/doc/ and more specifically
http://wiki.python.org/moin/
http://wiki.python.org/moin/BeginnersGuide
http://www.python.org/doc/Intros.html
http://www.python.org/topics/

I'm looking for additional resources (links, names of books, 
whatever...) that you think may help me out.

I'm a hobby programmer using mostly BASIC(s) and some Java.  I know 
procedural programming and I know what encapsulation, inheritance and 
polymorphism are but I have very little experience in using them as I've 
written just a few Java programs (i.e., I guess I could use a primer in 
OO programming).

Any ideas?

http://diveintopython.org/


Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Newbie

2005-10-05 Thread Matt Feinstein
On 5 Oct 2005 08:38:44 -0700, [EMAIL PROTECTED] wrote:

Hi,

I'm learning Python now and I'm really pleased with everything so far,
however,  at some point I'll want to develop a Windows application (no
other OS at this point).  The question are:
1. What toolkit is best for Windows development?
2. Which toolkits can I exclude from consideration?
3. What toolkit is most popular for Windows development?
4. Are there any impartial reviews of these packages anywhere?

You have to give us a clue about what you mean by 'best'. 

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Processing an image with numarray.nd image

2005-10-04 Thread Matt Feinstein
On Tue, 04 Oct 2005 11:56:51 +0200, Raphaƫl MARC
[EMAIL PROTECTED] wrote:

Hello,

Can anyone tell me how to open an image
and transform it into a list so that
the functions of the multi dimensionnal module of
numarray (numarray.nd image) can process it ?

Do I have to use PIL ?

So I would code something like :
import Image
im = Image.open(Python.jpg)
data = list(im.getdata())
import numarray.nd image as ti
ti.median filter(data,...)

I've been doing something like that...

from numarray import  *
import numarray.nd_image as Filter
import PIL.Image as Image

im = Image.open(file_name)
array_dat = reshape(array(list(im.getdata())), im.size)
filt_array_dat = Filter.correlate(array_dat, my_filter)

et cetera...

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: morphological image processing in Python

2005-10-03 Thread Matt Feinstein
On Mon, 3 Oct 2005 14:23:11 + (UTC), Alexandre Fayolle
[EMAIL PROTECTED] wrote:

Hello,

I'm about to start a project which will involve some greyscale image
processing using morphological operators (erosion, dilation, distance
transforms...), and I was wondering if these operators were available in
Python through some open source libraries. 

A quick google search returned pymorphpro[1], which is unfortunately not
free software, and there also seem to be something available in ITK [2].
Unless I'm mistaken, the PIL does not provide these operations, nore do
Numeric/numarray/scipy. 

Have I missed the one true Python mathematical morphology toolbox?

Thanks in advance for any advice.

Actually, numarray does support morphological array operations. See
the chapter on 'Multi-dimensional image processing' in the numarray
docs.


Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Off-screen rendering in PyOpenGL?

2005-08-17 Thread Matt Feinstein
Poking around in the PyOpenGL tarball... I can see that the wrapper
for the WGL pixel format function includes flags for rendering to a
bitmap and for hardware acceleration... so maybe I could get
hardware-accelerated off-screen rendering under win32.. but what about
linux?

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Gotchas in user-space matplotlib install?

2005-08-15 Thread Matt Feinstein

If you do a --prefix=~/usr for all 'configure' and 'python setup.py
install' commands, and set your PATH, C_INCLUDE_PATH,
CPLUS_INCLUDE_PATH, LIBRARY_PATH, and LD_LIBRARY_PATH variables
accordingly, and set the MATPLOTLIBDATA environment variable to point
to ~/usr/share/matplotlib, it should work.

When debugging your setup, you might want to run your test
matplotlib/pylab script with 

   python myscript.py --verbose-helpful

OR

   python myscript.py --verbose-debug

to get extra information about where matplotlib is looking for things.

For the record, I persuaded the sysadmin to install current levels of
the tcl, tcl-devel, tk, and tk-devel libraries-- my argument was that
you couldn't get a useful installation of Python without them.

Since I used /usr/people/mrf/python24 for my home Python directory,
there were a few tweaks needed to get the matplotlib installer to find
stuff. To get access to the freetype and Numeric libraries and
what-have-you, adding /usr/people/mrf/python24/lib/python2.4 and
/usr/people/mrf/Numeric-23.8 to the basedir dictionary in setext.py
seemed to work. In addition, I think I had to copy the Numeric include
directory into an additional location. There was also a little
fiddling with PYTHONPATH to insure that the installer found both
numarray and Numeric. Didn't seem to need MATPLOTLIBDATA, but that
would have been my next try.

With a working version of Tcl/Tk, the need for other widget sets
became somewhat academic. For GTK, Fedora Core 1 is apparently so far
behind current levels of GTK that it is pointless to complain. Wx is
still a possibility.

All in all, not actually excruciating-- and now I have a working
version of matplotlib!
Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Gotchas in user-space matplotlib install?

2005-08-15 Thread Matt Feinstein
On Mon, 15 Aug 2005 09:02:57 -0500, John Hunter
[EMAIL PROTECTED] wrote:

 Matt == Matt Feinstein [EMAIL PROTECTED] writes:

Matt All in all, not actually excruciating-- and now I have a
Matt working version of matplotlib!  Matt Feinstein

Great!  While this is all fresh in your mind, would you be able to add
a wiki entry at
http://www.scipy.org/wikis/topical_software/MatplotlibCookbook

Thanks,

I'm making notes on it now. The only thing that the installation
really stumbled over was some includes-- the Python installation left
me with a '/usr/people/mrf/python24/include' directory, which at the
matplotlib installation had 'python' and 'python2.4' subdirectories--
numarray put its includes into the 'python2.4' subdirectory, while
Numeric put its includes into the 'python' subdirectory. The
matplotlib installer found the numarray includes but not the Numeric
includes-- copying the Numeric includes into the 'python2.4'
subdirectory got the ball rolling again.

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Gotchas in user-space matplotlib install?

2005-08-09 Thread Matt Feinstein
Hi all--

I'm planning to try to do a completely local install of matplotlib (in
Fedora Core 1)-- the system administrator isn't going to stop me-- but
he isn't going to cooperate either. I've got the tarballs for python,
numeric, numarray, matplotlib,  ipython, wxpython and freetype-- which
I think covers the various pre-requisites and post-requisites. One
semi-obvious question is where to put the freetype library (the system
version in FC1 is not up to the required level)-- but I can only
wonder what other trouble I'm going to get into. Any advice before I
take the plunge would be appreciated. TIA...


Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Matt Feinstein
On 27 Jun 2005 20:16:12 -0700, BORT [EMAIL PROTECTED]
wrote:

Please forgive me if this is TOO newbie-ish.

I am toying with the idea of teaching my ten year old a little about
programming.  I started my search with something like best FREE
programming language for kids.  After MUCH clicking and high-level
scanning, I am looking at Python and Forth.  Both have advocates that
say each is a great approach to learning computers.

FORTH is 'way outside the mainstream of current programming, while
Python is, if anything, excessively buzz-word compliant. If you want
to teach your kid something that will a basis for learning anything
about current practices in programming, teach him Python.
Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem with 'struct' module

2005-06-14 Thread Matt Feinstein
Using the 'struct' module (Win32, python version 2.4.1)--

The library documentation says that 'no alignment is required for any
type'. However,  struct.calcsize('fd') gives 16 while
struct.calcsize('df') gives 12, implying that double precision data
has to start on a double-word boundary. 

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


PIL and GeoTIFF

2005-06-09 Thread Matt Feinstein
Hi all--

I've succeeded in using the PIL (Python Imaging Library) to read a
simple GeoTIFF file and to extract data from the file's GeoTIFF key--
but I'd also like to write GeoTIFFs, and there doesn't appear to be a
one-step way of doing that.

I suspect, first, that -writing- a GeoTIFF file with PIL means poking
around in the PIL TIFF plugin file which I'm a little wary of doing.
Also, I don't see any clear description in the PIL documentation on
how to add specified TIFF keys to a saved file. Any words of wisdom
about either of these questions would be much appreciated.


Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Unhappy with numarray docs

2005-06-01 Thread Matt Feinstein
I spent all day yesterday trying to figure out how to do file IO in
the numarray module-- I -did- (I think) figure it all out, eventually,
but it's left me in a rather sour mood.

1. The basic functions and methods: fromfile, fromstring, tofile, and
tostring, are buried, in non-alphabetical order, in two chapters that
list -all- the functions and methods. This is not user-friendly. The
explanations themselves, once I found them, are OK, but a line or two
of sample code is always nice. File IO is a real-world necessity in an
environment where most people use Matlab and/or IDL. And is it
obvious, btw, that reading data should be a function? What if I want
to read into a buffer?

2. The memmap documentation is screwed up in a more serious fashion. I
was able to deduce relatively rapidly that

from numarray.memmap import *

was needed for some of the example code. But I didn't immediately have
the degree of clairvoyance needed to figure out that

import numarray.numarryall as num

was required for the critical step of associating an array with a
MemmapSlice. Grr.

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unhappy with numarray docs

2005-06-01 Thread Matt Feinstein
On Wed, 01 Jun 2005 08:11:36 -0700, Scott David Daniels
[EMAIL PROTECTED] wrote:

Propose some fixes to the documents that will make this easier for
the next one in line.  You don't even need to get it exactly right;
the person after you can fix the mistakes you make.  This is the
process we use for this.  See this as an opportunity to contribute,
not simply a frustration about how much you overpaid for the product.

Which is why I was specific about what I didn't like about the
documentation and why I didn't like it. Seriously, what more should I
do? It's plainly inappropriate for me to write documentation for a
module that I'm still struggling to learn.

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unhappy with numarray docs

2005-06-01 Thread Matt Feinstein
On Wed, 01 Jun 2005 09:55:14 -0600, Fernando Perez
[EMAIL PROTECTED] wrote:

Just a suggestion: post your message on the numeric discussion list (where
numarray is also discussed).  Most of the num* developers only check c.l.py on
occasion, so it's very easy that your message will be simply missed by the
appropriate people, which would be a shame.  They are generally very
responsive to user requests and constructive criticism.

Done. Thanks for the suggestion.

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Applying a function to a 2-D numarray

2005-05-16 Thread Matt Feinstein
Is there an optimal way to apply a function to the elements of a two-d
array?

What I'd like to do is define some function:

def plone(x):
 return x+1

and then apply it elementwise to a 2-D numarray. I intend to treat the
function as a variable, so ufuncs are probably not appropriate-- I
realize that  what I'm looking for won't be terrifically efficient,
but I'd like to avoid doing it in the -worst- possible way.

Some things I've looked at include things like

def applyfun(m,f):
 elist = [f(e) for e in m]
 return reshape(elist,m.shape)

however, I can see that this looks neat but probably generates several
copies of the array, which is not so neat.

Is there a better way?

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Applying a function to a 2-D numarray

2005-05-16 Thread Matt Feinstein
On Mon, 16 May 2005 11:07:06 -0600, Steven Bethard
[EMAIL PROTECTED] wrote:



I must be missing something, because the simplest possible thing seems 
to work for me:

py import numarray as na
py def plus1(arr):
... return arr + 1
...
py def apply_func(arr, f):
... return f(arr)
...
py a = na.arange(20, shape=(4, 5))
py a
array([[ 0,  1,  2,  3,  4],
[ 5,  6,  7,  8,  9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19]])
py apply_func(a, plus1)
array([[ 1,  2,  3,  4,  5],
[ 6,  7,  8,  9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20]])

Is this not what you wanted?

The problem is that I chose an example function that's too simple.
Non-trivial functions aren't so polymorphic, unfortunately.

Sorry for the confusion.

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Applying a function to a 2-D numarray

2005-05-16 Thread Matt Feinstein
On Mon, 16 May 2005 12:03:24 -0600, Steven Bethard
[EMAIL PROTECTED] wrote:

Can you give an example of what you really want to do?  Probably there 
are numarray functions that you can use.  In general, you'll do better 
applying a sequence of numarray functions than operating element-wise on 
an array and converting it from a list back to an array...

Well, for example, suppose I want to modify the elements of the matrix
in some fashion. However, I'm not entirely sure how I want to do it.
As a strawman, I generate a function with a Boolean test in it that
multiplies by one factor if the matrix element is in an interval and
by a different factor if it is outside the interval

def genfunc(xmin, xmax, f_in, f_out):
 def booltest(x):
 in_interval = x  xmin and x  xmax
 if in_interval:
  return x*f_in
else:
 return x*f_out
return booltest
   
Generating the function in this way gives me great flexibility in
deciding exactly what function I apply to the matrix. It's why I want
to use Python for this analysis. The part of the function  I vary and
play around with is localized in one place in the 'genfunc' function--
I can change that and everything else stays the same. However, I
realize that the gain in flexibility means a loss in efficiency. I'm
limited to not-so-efficient ways of. For this work, it's OK-- I just
want to know the best not-so-efficient way of doing the calculation.

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Numarray question

2005-05-13 Thread Matt Feinstein
If I try

 2  array([1,2,3])

I get:

array([0, 0, 1], type=Bool)

which is pretty slick, However if I set

 q = 2  array([1,2,3])
 q and q

I get a runtime error: An array doesn't make sense as a truth value.

So..  why not? It seems to me that if I could vectorize logical
expressions (a la Matlab), it would be a lot easier to write functions
that will take either scalar or vector input values. Am I missing
something?

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which IDE is recommended?

2005-04-27 Thread Matt Feinstein
On Wed, 27 Apr 2005 21:16:29 +0800, monkey [EMAIL PROTECTED] wrote:

Read through python site for programming tool, really plenty of choices :-)
(For c++, I just can't breath with very very limited choices)

Tried Spe, it come with wxGlade built-in very nice(is Spe still actively
develop?). But seem that Boa Constructor and PyDev(the plug-in for Eclipse)
also worth looking. Actually which one are you guys using? and why? I think
it is also valuable for those who are new to python as me.

If you intend to use Python for Matlab-like calculations with
numerical arrays and plotting with Matplotlib, then ipython is the
right choice-- it has a special 'pylab' mode that is Matplotlib-aware,
allowing you to make plots interactively (as well as various other
useful features).

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


New versions of numarray?

2005-04-25 Thread Matt Feinstein
Hi--
I notice that there are some new versions of numarray available for
download-- is there any documentation on what's new/fixed/broken?

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: goto statement

2005-04-20 Thread Matt Feinstein
On Wed, 20 Apr 2005 10:23:58 +0100 (BST), praba kar
[EMAIL PROTECTED] wrote:

Dear All,

   In Python what is equivalent to goto statement

I'd like to that implemented in an interpreted language. Requires some
time travel.

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


My stupid newbie mistake

2005-04-11 Thread Matt Feinstein
I named a file 'try.py' and then was stumped, for a while, when

 import try

gave a syntax error... So, how about a
'YouAreUsingAReservedWordStupid' exception ?

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list