[Tutor] calling a method within a function
John
washakie at gmail.com
Wed Dec 8 09:38:52 CET 2010
I understand... but don't blame me if it hurts your head ;)
The class is here:
http://python.pastebin.com/gPpep50Y
The function is here:
http://python.pastebin.com/faK0vZ8U
The issue is with the 'reflectance' method of the FlightData class
(line 76). You can see in the class definition I now just add
reflectance to self, but before I was trying to return it, and in the
function (line 38-40) I was calling the method to get the array.
On Ipython it worked fine to call the method and get a refl array. The
array worked as expected (ie. refl.max(), refl.min() returned floats).
But when I passed the same FlightData object to the function and
called it inside it would not work. It would still return a
numpy.ma.core.MaskedArray, but the max and min methods on the array
returned empty values, which caused my function to crash.
On Wed, Dec 8, 2010 at 2:18 AM, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
> "John" <washakie at gmail.com> wrote
>
>> I have a strange problem with a piece of code I've written. It's a bit
>> overly complicated to make an example with, but the gist is below. But
>> in the example below, it works. However, in my example, when I call
>> the method from within the function, it returns something other than
>> what I expect.
>
> Care to give us a clue?
>
> What did you expect?
> What did you get?
> What does the real code look like?
>
> Its a bit hard to diagnose your problem based on a bit of code that
> works and a loose description of your dissapointment with another
> bit of code that may or may not work - depending on what you
> expected!
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
--
Configuration
``````````````````````````
Plone 2.5.3-final,
CMF-1.6.4,
Zope (Zope 2.9.7-final, python 2.4.4, linux2),
Python 2.6
PIL 1.1.6
Mailman 2.1.9
Postfix 2.4.5
Procmail v3.22 2001/09/10
Basemap: 1.0
Matplotlib: 1.0.0
More information about the Tutor
mailing list