#8 pdl constructor barfs on scalar pdl dim?

closed-fixed
None
5
2001-01-18
2000-08-24
No

Loaded PDL v2.003
perldl> use PDL::Math;

perldl> p $test = ceil(9.5);
10
perldl> p zeroes(double(),$test);
PDL barfed: Trying to use piddle as dimensions?
Caught at file (eval 18), line 3, pkg main

perldl> $test = ($test->list())[0];
PDL barfed: Trying to use piddle as dimensions?
Caught at file (eval 18), line 3, pkg main

perldl> p zeroes(double(),$test);
[0 0 0 0 0 0 0 0 0 0]

The work-around, I guess, is to insert
$test = ($test->list())[0];
before using $test as a Perl scalar, but this is UGLY....

By the way, did you notice the double barfing above (after
a non-offending source line was entered)?
Is this just me? (Perl version 5.005_03 built for i386-linux, Mandrake Linux 7.0)

<Digression>
Having used Yorick rather extensively for numerical work,
I can't help but observe that the PDL project seems to be
faced with some difficult choices about how to integrate
and inter-convert PDL objects with those already present
in Perl. The builders of NumPy would seem to have an
easier time of it in this regard (although they are not as
far along, in some other ways).
</Digression>

Discussion

  • Hi keith
    I tried your example. I dont see the "bug".
    the first barf occurs because ceil returns a type PDL and thus the error message is indeed correct. I

    I do not get the second barf when I try to reproduce your expression.

    However I do get an interesting error message when I type

    perldl> use PDL::Math
    Prototype mismatch: sub main::ceil vs (;@) at (eval 27) line 3

    It also seems odd to me to me that ceil should be overloaded to return a type PDL rather than a type SCALAR when used with a scalar arg.

    charlie strauss

     
    • assigned_to: nobody --> csopen
    • status: open --> closed-fixed
     
  • This should now work (PDL 2.2). Note, however, the documentation of
    PDL::new_from_specification. Basically,

    zeroes $pdl

    will not do what you want but

    zeroes double, $pdl

    will.