Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## #174 uniqvec fails with input of only identical vectors

closed-duplicate
nobody
6
2008-01-13
2008-01-12
Derek Lamb
No

If all the vectors in a piddle are identical, then uniqvec gets confused about which dimensions to run over, and returns an incorrect result. If one of the vectors is different, then uniqvec returns the correct result.

perldl> \$a = pdl([[0,1]]); perldl> \$b = \$a->glue(1,\$a,\$a); perldl> print \$b;
[
[0 1]
[0 1]
[0 1]
]
perldl> print \$b->uniqvec;
[0 0 0]
# not correct, should return
# [
# [0 1]
# ]
# but if one vector is different, the result is OK

perldl> \$b = \$a->glue(1,\$a,2*\$a); perldl> print \$b;
[
[0 1]
[0 1]
[0 2]
] perldl> print \$b->uniqvec;
[
[0 1]
[0 2]
]

The docs for uniqvec say "The 0th dimension of the input PDL is treated as a dimensional index within each vector, and the 1st and any higher dimensions are taken to run across vectors." So I think I'm correct in my interpretation.

Some more rigorous testing of uniqvec in t/primitive.t would be useful.

## Discussion

• Chris Marshall
2008-01-13

Logged In: YES
user_id=44920
Originator: NO

Line 766 of ./Basic/Primitive/Primitive.pm is the problem here:
...
763 my \$uniq = (\$srt != \$srt->rotate(-1)) -> mv(0,-1) -> orover->which;
764
765 return \$uniq->nelem==0 ?
766 \$srt->slice(":,(0)")->mv(0,-1) :
767 \$srt->dice(\$uniq)->mv(0,-1);
...

A test needs to be added for this case and the code modified
as above. I'll get to it next week if no one gets to it by
then. Thanks for the problem report. Regards, Chris M.

• Derek Lamb
2008-01-13

Logged In: YES
user_id=1357170
Originator: YES

This duplicated bug #1544352, which was resolved by CHM patch #1548824, but never uploaded to CVS. Thanks for the pointer!

• Derek Lamb
2008-01-13

• status: open --> closed-duplicate

• Derek Lamb
2008-01-13

Logged In: YES
user_id=1357170
Originator: YES

Bug fixed in CVS.
Thanks for reporting the problem!