You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tustvold (via GitHub)" <gi...@apache.org> on 2023/05/09 15:30:49 UTC

[GitHub] [arrow-rs] tustvold commented on a diff in pull request #4180: feat: Float16 cast

tustvold commented on code in PR #4180:
URL: https://github.com/apache/arrow-rs/pull/4180#discussion_r1188781408


##########
arrow-cast/src/cast.rs:
##########
@@ -6399,6 +6644,110 @@ mod tests {
         );
     }
 
+    #[test]
+    fn test_cast_from_f16() {
+        let f16_values: Vec<f16> = vec![
+            f16::from_f32(i32::MIN as f32),
+            f16::from_f32(i32::MIN as f32),
+            f16::from_f32(i16::MIN as f32),
+            f16::from_f32(i8::MIN as f32),
+            f16::from_f32(0_f32),
+            f16::from_f32(u8::MAX as f32),
+            f16::from_f32(u16::MAX as f32),
+            f16::from_f32(u32::MAX as f32),
+            f16::from_f32(u32::MAX as f32),
+        ];
+        let f16_array: ArrayRef = Arc::new(Float16Array::from(f16_values));
+
+        let f64_expected = vec![
+            "-inf", "-inf", "-32768.0", "-128.0", "0.0", "255.0", "inf", "inf", "inf",

Review Comment:
   -inf seems off here, unless the original value was f16::NEG_INFINITY ?



##########
arrow-cast/src/cast.rs:
##########
@@ -6399,6 +6644,110 @@ mod tests {
         );
     }
 
+    #[test]
+    fn test_cast_from_f16() {

Review Comment:
   I think this test would be clearer if it used f16::Inf, instead of relying on i32::MIN overflowing (which is what I think is going on)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org