Skip to content

Commit 2b52394

Browse files
committed
fix a bug in length dedup optimization
1 parent 3e182f6 commit 2b52394

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/algorithm/monadic/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,9 @@ impl<T: ArrayValue> Array<T> {
15471547
}
15481548
/// Count the number of unique rows in the array
15491549
pub fn count_unique(&self) -> usize {
1550+
if self.element_count() == 0 && self.row_count() > 0 {
1551+
return 1;
1552+
}
15501553
let mut seen = HashSet::new();
15511554
self.row_slices()
15521555
.filter(|row| seen.insert(ArrayCmpSlice(row)))

tests/optimized.ua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ F ← /◇⊂
129129
⍤⤙≍ ⊃(⧻∘⊚|⧻⊚) [1 0 3]
130130
⍤⤙≍ ⊃(⧻∘⊚|⧻⊚) [1 0 1 0 1 0 1]
131131

132+
# Count unique
133+
⍤⤙≍ ⊃(⧻∘◴|⧻◴) °△ 1_0
134+
132135
# Depth deshape
133136
⍤⤙≍ ⊃≡(♭∘)≡♭ °△2_2_3_3
134137
⍤⤙≍ ⊃≡(♭₀∘)≡♭₀ °△2_2_3_3

0 commit comments

Comments
 (0)