Fun Python Function Discovery

Status
You're currently viewing only dockeen's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

dockeen

Ars Tribunus Militum
1,600
I was playing around with doing some functional work with
a Python program I wrote to look at some infrared image
data, and I made an interesting discovery...or maybe I was
just dim before.

I found that I can pass an array to a function with no fuss
or muss. Just pass it, like any other variable. It appears
to pass by reference.

Interesting.

Wayne
 

dockeen

Ars Tribunus Militum
1,600
Yes, it is. What was a little suprising for me is that
a lot of the support for arrays is pulled in through
the Numerical Python module, it is not really an inherent
part of Python, so I was suprised that I was able to
use the array as an argument in such a straight-foward
fashion. I even did an experiement in which I returned
an array out of the function.

This is a measure of what a boring person I am, discovering
this constitutes big excitement on a weekend.

:rolleyes: :rolleyes: :rolleyes:

Wayne
 

dockeen

Ars Tribunus Militum
1,600
A reccomendation based on my use for the last year or two.
I like VPython. It is an add-on to regular Python. I like
it because

(a) You get a pretty good IDE
(b) It brings Numpy in with it.
(c) The graphics, including neat 3D stuff are easy.

The attribute of VPython / Python have made it my new
"gun to my head, gotta do something quick" language for
most things. I do a LOT of data analysis with it.

Here is the link:
http://www.vpython.org/

One other module you might want to add, again mostly
from the plotting angle is DISLIN

http://www.linmpi.mpg.de/dislin/

Wayne
 

dockeen

Ars Tribunus Militum
1,600
Actually, a lot of the higher level support for arrays
do in fact come from Numpy. When I was first picking up Python, I remeber what a pain it was to do some of the things that I wanted to do through the regular Python methods. The Numpy stuff in a lot of ways looks like array functions from Matlab, which, again, learning in a screwy order, I learned after the fact.

Its actually sort of funny, a number of my Python books
kind of avoid serious discussion of arrays, but spend a
lot of time of lists. I guess my interests are less...
well..interesting.

I know you can return a variety of data from a function,
I just thought it was a neat contrast in the clean way
you can return an array versus, say C++. Minimum knowlege
and intelligence needed, perfectly suited to an intellectually
challenged physicist.

I definitely fit under the category of easily impressed.

Wayne
 

dockeen

Ars Tribunus Militum
1,600
Actually, I can cross numeric types and not generate an exception. If possible, the language will recast. Try the same thing in Ada and it won't compile. Heck, in Ada, I can have two defined types which are fundamentally the same type, and have the same problem. Now, that is my definition of strong typing. Probably not correct, but that is how a weirdo like me things about it.

In a related unrelated note, I made the classic mistake the other day, I was dividing one integer by another, and was wondering why I was getting zero. Took me a while to realize I was dealing with integers (numerator smaller than denominator). When I did, I hit myself on the head. Still hurts.

Wayne
 

dockeen

Ars Tribunus Militum
1,600
OK, so you're not saying there's something wrong with Cygwin's Python, just that there are better tools/environments/implementations out there. OK. Cool.

I believe that because, well, you saw my recommendation for VPython.
:). I don't even use the Cygwin version of Python because of it.

I only brought up Cygwin because I have run into people who use it regularly, but don't know that they have Perl and Python with it.

Wayne
 

dockeen

Ars Tribunus Militum
1,600
Biologist...hmmm...my Disseration, among other things, looked at the effects of radiation on single crystals of an analogue of a DNA base, 6MeMPR...work that I'm sure no-one has read except me and my Ph.D committee. I worked in the wrong kind (non-commercial) of magnetic resonance, Electron Spin Resonance...not even smart enough to work with protons...

;-)

So there is a biological connection in there some where...

Good to meet you,

Wayne
 
Status
You're currently viewing only dockeen's posts. Click here to go back to viewing the entire thread.
Not open for further replies.