is_scalar bug

Hi,

I believe that the cbook.is_scalar function has a bug:

In [19]: cbook.is_scalar('abc')
Out[19]: 1

I believe it should be:

def is_scalar(obj):
    'return true if *obj* is not string like and is not iterable'
    return not is_string_like(obj) and not iterable(obj)

Cheers,
David

···

--
**********************************
David M. Kaplan
Charge de Recherche 1
Institut de Recherche pour le Developpement
Centre de Recherche Halieutique Mediterraneenne et Tropicale
av. Jean Monnet
B.P. 171
34203 Sete cedex
France

Phone: +33 (0)4 99 57 32 27
Fax: +33 (0)4 99 57 32 95
http://www.ur097.ird.fr/team/dkaplan/index.html
**********************************

Yep, good catch. I committed this fix to 5822

JDH

···

On Wed, Jul 23, 2008 at 4:04 AM, David Kaplan <David.Kaplan@...622...> wrote:

Hi,

I believe that the cbook.is_scalar function has a bug:

In [19]: cbook.is_scalar('abc')
Out[19]: 1

I believe it should be:

def is_scalar(obj):
   'return true if *obj* is not string like and is not iterable'
   return not is_string_like(obj) and not iterable(obj)

Hi,

Almost:

In [3]: cbook.is_scalar((0,1))
Out[3]: True

That should be an "and" not an "or".

Cheers,
David

···

On Wed, 2008-07-23 at 08:16 -0500, John Hunter wrote:

On Wed, Jul 23, 2008 at 4:04 AM, David Kaplan <David.Kaplan@...622...> wrote:
> Hi,
>
> I believe that the cbook.is_scalar function has a bug:
>
> In [19]: cbook.is_scalar('abc')
> Out[19]: 1
>
> I believe it should be:
>
> def is_scalar(obj):
> 'return true if *obj* is not string like and is not iterable'
> return not is_string_like(obj) and not iterable(obj)

Yep, good catch. I committed this fix to 5822

JDH

--
**********************************
David M. Kaplan
Charge de Recherche 1
Institut de Recherche pour le Developpement
Centre de Recherche Halieutique Mediterraneenne et Tropicale
av. Jean Monnet
B.P. 171
34203 Sete cedex
France

Phone: +33 (0)4 99 57 32 27
Fax: +33 (0)4 99 57 32 95
http://www.ur097.ird.fr/team/dkaplan/index.html
**********************************

OK, I'll leave the final fix to you.....

JDH

···

On Wed, Jul 23, 2008 at 8:53 AM, David Kaplan <David.Kaplan@...622...> wrote:

That should be an "and" not an "or"