Skip to content

Commit 75c7f4a

Browse files
committed
Restore the float cast test of Widen
The cast conformance suite casts an integer array only to integer types, so this test is the only one that covers the cast rule declining a float target, including the integer guard for unsigned values. It keeps one signed and one unsigned case. Signed-off-by: Connor Tsui <[email protected]>
1 parent c304543 commit 75c7f4a

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

‎vortex-array/src/arrays/widen/tests/compute.rs‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,32 @@ fn test_cast_preserves_checked_nullability() -> VortexResult<()> {
161161
Ok(())
162162
}
163163

164+
/// The cast rule of `Widen` declines a float target, so canonical execution casts the values. The
165+
/// cast conformance suite casts an integer array only to integer types, so this test covers the
166+
/// decline. The unsigned case checks the integer guard of the rule, because its signedness check
167+
/// alone accepts a float target for unsigned values.
168+
#[rstest]
169+
#[case::signed_to_f64(signed(), PType::F64)]
170+
#[case::unsigned_to_f32(unsigned(), PType::F32)]
171+
fn test_cast_to_float_matches_canonical(
172+
#[case] array: WidenArray,
173+
#[case] target: PType,
174+
) -> VortexResult<()> {
175+
let mut ctx = SESSION.create_execution_ctx();
176+
let target = DType::Primitive(target, array.dtype().nullability());
177+
let canonical = array
178+
.clone()
179+
.into_array()
180+
.execute::<PrimitiveArray>(&mut ctx)?;
181+
182+
let cast = array.into_array().cast(target.clone())?;
183+
184+
let expected = canonical.into_array().cast(target)?;
185+
assert_arrays_eq!(cast, expected, &mut ctx);
186+
187+
Ok(())
188+
}
189+
164190
#[rstest]
165191
#[case::non_nullable_fill(
166192
Scalar::primitive(2i64, Nullability::NonNullable),

0 commit comments

Comments
 (0)