# SF#390 scalar PDL with badvalue always compares BAD with perl scalars #124

Closed
opened this Issue Jun 17, 2015 · 3 comments

Projects
None yet
1 participant
Member

### zmughal commented Jun 17, 2015

 This problem was reported by as user summarized in this message: https://sourceforge.net/p/pdl/mailman/message/34211884/ as shown in this sample program: use PDL; use PDL::NiceSlice; my \$x = pdl(1, 2, 3, 0); \$x->badflag(1); \$x->badvalue(0); print "x = \$x\n"; my (\$m, \$s) = stats(\$x); print "m = \$m, s = \$s\n"; print "s greater than zero\n" if \$s > 0; print "s less than zero\n" if \$s < 0; print "s equals zero\n" if \$s == 0; In fact, other comparisons of a scalar PDL value with the badflag set show the same error: pdl> \$s = pdl(0) pdl> \$s->badflag(1) pdl> p \$s 0 pdl> p \$s>3 0 pdl> p \$s->badvalue(0) 0 pdl> p \$s>3 BAD pdl> \$s .= 2 pdl> p \$s 2 pdl> p \$s>3 BAD pdl> p \$s->badvalue(35) 35 pdl> p \$s>3 0 pdl> p \$s->badvalue(2) 2 pdl> p \$s>3 BAD Given the weird and not yet understood behavior, I have marked this as highest priority.

### zmughal added a commit that referenced this issue Jun 21, 2015

test comparisons between scalars and 0-dim PDLs with badflag == 1
This is to elucidate the issues with stat() and per-PDL badvalues
brought up by Marek Gierliński in SF#390
<http://sourceforge.net/p/pdl/bugs/390/>,
<#124>.

Merged

Member

### zmughal added a commit that referenced this issue Jun 21, 2015

test comparisons between scalars and 0-dim PDLs with badflag == 1
This is to elucidate the issues with stat() and per-PDL badvalues
brought up by Marek Gierliński in SF#390
<http://sourceforge.net/p/pdl/bugs/390/>,
<#124>.

### zmughal added a commit that referenced this issue Jun 21, 2015

test comparisons between scalars and 0-dim PDLs with badflag == 1
This is to elucidate the issues with stat() and per-PDL badvalues
brought up by Marek Gierliński in SF#390
<http://sourceforge.net/p/pdl/bugs/390/>,
<#124>.
Member

### zmughal commented Jun 27, 2015

 I wanted to know if this bug was a regression or not, so I used a tool I wrote (in the devops repository on GitHub) and it appears that this bug has been around since at least 2008.

### zmughal added a commit that referenced this issue Jul 25, 2015

throw a warning when using comparison operator and badval is in {0, 1}
When using a comparison operator, inconsistent results can appear when a
badvalue is either 0 or 1. This is because {0, 1} is the range of all
operators that return a logical PDL. This means that if the input PDL
result of computing the operator *and* logical values at the same time.

This is a continuation of the work addressing the problem brought up in
<http://sourceforge.net/p/pdl/bugs/390/>, <#124>.

### zmughal added a commit that referenced this issue Jul 28, 2015

test comparisons between scalars and 0-dim PDLs with badflag == 1
This is to elucidate the issues with stat() and per-PDL badvalues
brought up by Marek Gierliński in SF#390
<http://sourceforge.net/p/pdl/bugs/390/>,
<#124>.

When testing the scalar comparison, test across several values on either
side of bad value so that it is clear which case is failing.

### zmughal added a commit that referenced this issue Jul 28, 2015

throw a warning when using comparison operator and badval is in {0, 1}
When using a comparison operator, inconsistent results can appear when a
badvalue is either 0 or 1. This is because {0, 1} is the range of all
operators that return a logical PDL. This means that if the input PDL
result of computing the operator *and* logical values at the same time.

This is a continuation of the work addressing the problem brought up in
<http://sourceforge.net/p/pdl/bugs/390/>, <#124>.

### zmughal added a commit that referenced this issue Jul 28, 2015

test comparisons between scalars and 0-dim PDLs with badflag == 1
This is to elucidate the issues with stat() and per-PDL badvalues
brought up by Marek Gierliński in SF#390
<http://sourceforge.net/p/pdl/bugs/390/>,
<#124>.

When testing the scalar comparison, test across several values on either
side of bad value so that it is clear which case is failing.

### zmughal added a commit that referenced this issue Jul 28, 2015

throw a warning when using comparison operator and badval is in {0, 1}
When using a comparison operator, inconsistent results can appear when a
badvalue is either 0 or 1. This is because {0, 1} is the range of all
operators that return a logical PDL. This means that if the input PDL
result of computing the operator *and* logical values at the same time.

This is a continuation of the work addressing the problem brought up in
<http://sourceforge.net/p/pdl/bugs/390/>, <#124>.

Member

### zmughal commented Aug 11, 2015

 This will be in the next full release: PDL v2.013.