File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -1033,23 +1033,16 @@ Lookup specified var (obs) ids in $idv ($ido) (see B<rtable>) and return indices
10331033
10341034sub which_id {
10351035 my ($id, $id_s) = @_;
1036-
1037- my %ind;
1038- @ind{ @$id } = ( 0 .. $#$id );
1039-
1040- my @ind_select;
1041- for (@$id_s) {
1042- defined( $ind{$_} ) and push @ind_select, $ind{$_};
1043- }
1044- return pdl @ind_select;
1036+ my %ind; @ind{ @$id } = (0 .. $#$id);
1037+ pdl grep defined, map $ind{$_}, @$id_s;
10451038}
10461039
1040+ my %code_bad = map +($_=>1), '', 'BAD';
10471041sub code_ivs {
10481042 my ($var_ref) = @_;
10491043 $var_ref = [ $var_ref->list ] if UNIVERSAL::isa($var_ref, 'PDL');
1050- my ($l, @filtered, %level) = (0,
1051- map defined($_) && $_ ne '' && $_ ne 'BAD' ? $_ : undef, @$var_ref);
1052- $level{$_} //= $l++ for grep defined, @filtered;
1044+ my @filtered = map !defined($_) || $code_bad{$_} ? undef : $_, @$var_ref;
1045+ my ($l, %level) = 0; $level{$_} //= $l++ for grep defined, @filtered;
10531046 my $pdl = pdl(map defined($_) ? $level{$_} : -1, @filtered)->setvaltobad(-1);
10541047 $pdl->check_badflag;
10551048 wantarray ? ($pdl, \%level) : $pdl;
You can’t perform that action at this time.
0 commit comments