[SciPy-Dev] Ticket #995, All scipy.constants.constants functions "choke" on non-array sequence input

Ryan May rmay31@gmail....
Thu Jun 17 15:10:01 CDT 2010


On Thu, Jun 17, 2010 at 2:30 PM, Benjamin Root <ben.root@ou.edu> wrote:
> On Thu, Jun 17, 2010 at 2:24 PM, Skipper Seabold <jsseabold@gmail.com>
> wrote:
>>
>> On Thu, Jun 17, 2010 at 3:23 PM, Vincent Davis <vincent@vincentdavis.net>
>> wrote:
>> > On Thu, Jun 17, 2010 at 1:18 PM, Vincent Davis
>> > <vincent@vincentdavis.net> wrote:
>> >> The problem is that for example C2F is
>> >>
>> >> def C2F(C):
>> >>     return 1.8 * C + 32
>> >> So array_like (list, tuple...) does not work.
>> >>
>> >> What is the preferred solution?
>> >>
>> >> 1, Change the docs to say "scalar or array" and return a warning if C
>> >> is not a scalar or array
>> >> 2, Ad the ability to handle all array_like.
>> >>
>> > def C2F(C):
>> >     return np.add(np.multilpy(1.8, C), 32)
>> >
>> > I think that accepts array-like and scaler and returns the same
>>
>> Or just C = np.asarray(C)
>>
>> This is quite often what is done.
>>
> What about masked arrays?  Should np.asanyarray() be used?

I'd say (emphatically) yes.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma


More information about the SciPy-Dev mailing list