Skip to content

Commit

Permalink
start on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Dec 11, 2024
1 parent a165f1c commit 8b1ff63
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
10 changes: 10 additions & 0 deletions python/pyarrow/tests/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@
pa.float32(),
pa.float64()
])
decimal32_type = st.builds(
pa.decimal32,
precision=st.integers(min_value=1, max_value=9),
scale=st.integers(min_value=1, max_value=9)
)
decimal64_type = st.builds(
pa.decimal64,
precision=st.integers(min_value=1, max_value=18),
scale=st.integers(min_value=1, max_value=18)
)
decimal128_type = st.builds(
pa.decimal128,
precision=st.integers(min_value=1, max_value=38),
Expand Down
4 changes: 3 additions & 1 deletion python/pyarrow/tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,9 @@ def test_fsl_to_fsl_cast(value_type):
FloatToDecimalCase = namedtuple('FloatToDecimalCase',
('precision', 'scale', 'float_val'))

decimal_type_traits = [DecimalTypeTraits('decimal128', pa.decimal128, 38),
decimal_type_traits = [DecimalTypeTraits('decimal32', pa.decimal32, 8),
DecimalTypeTraits('decimal64', pa.decimal64, 18),
DecimalTypeTraits('decimal128', pa.decimal128, 38),
DecimalTypeTraits('decimal256', pa.decimal256, 76)]


Expand Down
10 changes: 5 additions & 5 deletions python/pyarrow/tests/test_convert_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ def test_sequence_mixed_types_with_specified_type_fails():

def test_sequence_decimal():
data = [decimal.Decimal('1234.183'), decimal.Decimal('8094.234')]
for type in [pa.decimal128, pa.decimal256]:
for type in [pa.decimal32, pa.decimal64, pa.decimal128, pa.decimal256]:
arr = pa.array(data, type=type(precision=7, scale=3))
assert arr.to_pylist() == data

Expand All @@ -1601,28 +1601,28 @@ def test_sequence_decimal_different_precisions():
data = [
decimal.Decimal('1234234983.183'), decimal.Decimal('80943244.234')
]
for type in [pa.decimal128, pa.decimal256]:
for type in [pa.decimal64, pa.decimal128, pa.decimal256]:
arr = pa.array(data, type=type(precision=13, scale=3))
assert arr.to_pylist() == data


def test_sequence_decimal_no_scale():
data = [decimal.Decimal('1234234983'), decimal.Decimal('8094324')]
for type in [pa.decimal128, pa.decimal256]:
for type in [pa.decimal64, pa.decimal128, pa.decimal256]:
arr = pa.array(data, type=type(precision=10))
assert arr.to_pylist() == data


def test_sequence_decimal_negative():
data = [decimal.Decimal('-1234.234983'), decimal.Decimal('-8.094324')]
for type in [pa.decimal128, pa.decimal256]:
for type in [pa.decimal64, pa.decimal128, pa.decimal256]:
arr = pa.array(data, type=type(precision=10, scale=6))
assert arr.to_pylist() == data


def test_sequence_decimal_no_whole_part():
data = [decimal.Decimal('-.4234983'), decimal.Decimal('.0103943')]
for type in [pa.decimal128, pa.decimal256]:
for type in [pa.decimal32, pa.decimal64, pa.decimal128, pa.decimal256]:
arr = pa.array(data, type=type(precision=7, scale=7))
assert arr.to_pylist() == data

Expand Down
2 changes: 2 additions & 0 deletions python/pyarrow/tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ def test_set_timezone_db_path_non_windows():
pa.Time32Type,
pa.Time64Type,
pa.TimestampType,
pa.Decimal32Type,
pa.Decimal64Type,
pa.Decimal128Type,
pa.Decimal256Type,
pa.DictionaryType,
Expand Down
2 changes: 2 additions & 0 deletions python/pyarrow/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ def test_type_schema_pickling(pickle_module):
pa.date64(),
pa.timestamp('ms'),
pa.timestamp('ns'),
pa.decimal32(9, 3),
pa.decimal64(11, 4),
pa.decimal128(12, 2),
pa.decimal256(76, 38),
pa.field('a', 'string', metadata={b'foo': b'bar'}),
Expand Down

0 comments on commit 8b1ff63

Please sign in to comment.