For testing, I installed PDL v2.012_01 in an Ubuntu VM. Here it is what
happens when I run my original test:

pdl> $x = pdl(1, 2, 3, 0);
pdl> $x->badflag(1); $x->badvalue(0);
pdl> ($m, $s) = stats($x)
pdl> p $m > 0
Badvalue is set to 0 or 1. This will cause data loss when using badvalues
for comparison operators. at (eval 86) line 4, <STDIN> line 47.
main::__ANON__() called at perldl line 719
eval {...} called at perldl line 719
main::eval_and_report('p $m > 0\x{a}') called at perldl line 655
main::process_input() called at perldl line 675
eval {...} called at perldl line 675
1

This is a new behaviour. Clearly, using 0 or 1 for bad values is a bad
idea... Trying again:

pdl> $x->badvalue(-2.3123123e231)
pdl> p $m > 0
1
pdl> p $m < 0
0
pdl> p $m->badflag()
0

This is certainly better. I might need to change some of my scripts where I
use 0 for bad values, but this is not a problem.

Then, I tried this:

pdl> $x = $x->setbadif($x > -1)
pdl> p $x
[BAD BAD BAD BAD]
pdl> ($m, $s) = stats($x)
pdl> p $m
BAD
pdl> p $m->badflag
1
pdl> p $m > 0
BAD

This seems very logical.

Thanks everyone involved for your help!

Marek


On Sun, 2 Aug 2015 at 06:13 Zakariyya Mughal <zaki.mug...@gmail.com> wrote:

> On 2015-06-16 at 11:04:07 +0000, Marek Gierliński wrote:
> > I have recently encountered a weird problem with stats (or statsover)
> using
> > bad values. The resulting numbers have a strange property, they always
> > return true in comparisons.
>
> There is now a possible fix for this in a dev release of PDL
> (v2.012_01). If you can, try installing that by running cpanminus
>
>     cpanm --dev PDL
>
> or using cpan
>
>     cpan CHM/PDL-2.012_01.tar.gz
>
> Please let me know if that helps!
>
> Cheers,
> - Zaki Mughal
>
> >
> > Marek
>
> >
> ------------------------------------------------------------------------------
>
> > _______________________________________________
> > pdl-general mailing list
> > pdl-gene...@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/pdl-general
>
> --
Dr Marek Gierliński
The Data Analysis Group
The Barton Group
Computational Biology and GRE
School of Life Sciences
University of Dundee, Dundee, Scotland, UK.
Tel: +44 1382 386427
www.compbio.dundee.ac.uk/dag.html
------------------------------------------------------------------------------
_______________________________________________
pdl-devel mailing list
pdl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel

Reply via email to