Bugs item #1869760, was opened at 2008-01-11 17:56
Message generated for change (Comment added) made by lambd
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=100612&aid=1869760&group_id=612

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: other
Group: None
>Status: Closed
>Resolution: Duplicate
Priority: 6
Private: No
Submitted By: Derek Lamb (lambd)
Assigned to: Nobody/Anonymous (nobody)
Summary: uniqvec fails with input of only identical vectors

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Derek Lamb (lambd)
Date: 2008-01-13 11:39

Message:
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!

----------------------------------------------------------------------

Comment By: Derek Lamb (lambd)
Date: 2008-01-13 11:39

Message:
Logged In: YES 
user_id=1357170
Originator: YES

Bug fixed in CVS.
Thanks for reporting the problem!


----------------------------------------------------------------------

Comment By: Chris Marshall (marshallch)
Date: 2008-01-12 18:54

Message:
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);
 ...

The line should read $srt->slice("(0),:")->mv(0,-1) instead.

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.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=100612&aid=1869760&group_id=612

_______________________________________________
PDL-porters mailing list
PDL-porters@jach.hawaii.edu
http://mailman.jach.hawaii.edu/mailman/listinfo/pdl-porters

Reply via email to