Recently I have reported problems with using results of stats() as scalars.
Today I found that another of my scripts, that used to work in older PDL
versions, is failing. The problem is very similar, using one-element
piddles in scalar context gives almost random results. Here it is:

pdl> $x = floor(1.3)
pdl> p $x
1
pdl> $x += 0.1
pdl> p $x
1.1

pdl> $x = floor(1)
pdl> p $x
1
pdl> $x += 0.1
pdl> p $x
1

when taking floor() of an integer number, I cannot increment it afterwards.
No problems when I take floor() of a non-integer. I think in this
particular case the problem is with the type:

pdl> $x = floor(1.1); p $x->info
PDL: Double D []
pdl> $x = floor(1); p $x->info
PDL: Byte D []

Suddenly, the type is changed and I suppose 'Byte' doesn't take +=0.1. This
is a bit random, unexpected and unpredictable. In particular, there is
inconsistency:

pdl> $x = floor(1); p $x->info
PDL: Byte D []
pdl> $y = pdl(1); p $y->info
PDL: Double D []

Has something been changed in the recent months (or even years, as we used
to use quite old version of PDL for years and only recently upgraded to
2.007) in the way types are converted and one-element piddles are treated
in the scalar context? I'm just discovering more and more of my scripts
doing weird things...

Cheers,
Marek
------------------------------------------------------------------------------
_______________________________________________
pdl-devel mailing list
pdl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel

Reply via email to