Skip to content

Commit

Permalink
Address testing feedback
Browse files Browse the repository at this point in the history
NaNs are still excluded from `randFloat16`, as this matches the native
float equivalents
  • Loading branch information
benibus committed Oct 31, 2023
1 parent 7690928 commit e414709
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 3 additions & 4 deletions go/parquet/internal/testutils/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,9 @@ func randFloat64(r *rand.Rand) float64 {
// to better spread the values out and ensure we do not return any NaN or Inf values.
func randFloat16(r *rand.Rand) float16.Num {
for {
f16 := float16.FromBits(uint16(r.Uint64n(math.MaxUint16 + 1)))
f64 := float64(f16.Float32())
if !math.IsNaN(f64) && !math.IsInf(f64, 0) {
return f16
f := float16.FromBits(uint16(r.Uint64n(math.MaxUint16 + 1)))
if !f.IsNaN() {
return f
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions go/parquet/schema/reflection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func ExampleNewSchemaFromStruct_logicaltypes() {
BSON []byte `parquet:"logical=BSON"`
UUID [16]byte `parquet:"logical=uuid"`
Float16 [2]byte `parquet:"logical=float16"`
Float16Optional *[2]byte `parquet:"logical=float16"`
}

sc, err := schema.NewSchemaFromStruct(LogicalTypes{})
Expand Down Expand Up @@ -182,6 +183,7 @@ func ExampleNewSchemaFromStruct_logicaltypes() {
// required byte_array field_id=-1 BSON (BSON);
// required fixed_len_byte_array field_id=-1 UUID (UUID);
// required fixed_len_byte_array field_id=-1 Float16 (Float16);
// optional fixed_len_byte_array field_id=-1 Float16Optional (Float16);
// }
}

Expand Down

0 comments on commit e414709

Please sign in to comment.