Skip to content

Commit 6a813e2

Browse files
authored
fix: remove inconsistent handling of low-rank inputs of unbytes (#825)
1 parent 030d069 commit 6a813e2

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/algorithm/encode.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -461,19 +461,13 @@ impl Value {
461461
}
462462
};
463463
let mut new_shape = bytes.shape;
464-
if new_shape.is_empty() {
465-
new_shape.push(1);
466-
}
467-
if new_shape.len() > 1 {
468-
let last_dim = new_shape.pop().unwrap();
464+
if let Some(last_dim) = new_shape.pop() {
469465
if last_dim != elem_size {
470466
return Err(env.error(format!(
471467
"Bytes shape has last axis size {last_dim}, \
472468
which does not match format {format}"
473469
)));
474470
}
475-
} else {
476-
new_shape[0] = (new_shape[0] / elem_size).max(1);
477471
}
478472
let mut data = eco_vec![0.0; new_shape.elements()];
479473
let slice = data.make_mut();

tests/dyadic.ua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,10 @@ F ← ⊂0 [⊙⊙∘]
312312
⍤⤙≍ ¯3 ∨ 3 ¯∞
313313

314314
# Bytes
315-
⍤⤙≍ ⊃⋅¤⍜bytes∘ "u32" 6
316-
⍤⤙≍ ⊃⋅¤⍜bytes∘ "f64" 6
315+
⍤⤙≍ ⍜bytes∘ "u32" 6
316+
⍤⤙≍ ⍜bytes∘ "f64" 6
317317
⍤⤙≍ ⤙⍜bytes∘ "u32" [6]
318318
⍤⤙≍ ⤙⍜bytes∘ "f64" [6]
319319
⍤⤙≍ ⤙⍜bytes∘ "u32" [1 2 3]
320-
⍤⤙≍ [1 2 3 4] ⌝bytes "u32" [1 0 0 0 2 0 0 0 3 0 0 0 4 0 0 0]
320+
⍤⤙≍ [1 2 3 4] ⌝bytes "u32" [[1 0 0 0] [2 0 0 0] [3 0 0 0] [4 0 0 0]]
321+
⍤⤙≍ 6 ⌝bytes "f64" [0 0 0 0 0 0 24 64]

0 commit comments

Comments
 (0)