MCPcopy Create free account
hub / github.com/apache/arrow / test_min_max

Function test_min_max

python/pyarrow/tests/test_compute.py:780–811  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

778
779
780def test_min_max():
781 # An example generated function wrapper with possible options
782 data = [4, 5, 6, None, 1]
783 s = pc.min_max(data)
784 assert s.as_py() == {'min': 1, 'max': 6}
785 s = pc.min_max(data, options=pc.ScalarAggregateOptions())
786 assert s.as_py() == {'min': 1, 'max': 6}
787 s = pc.min_max(data, options=pc.ScalarAggregateOptions(skip_nulls=True))
788 assert s.as_py() == {'min': 1, 'max': 6}
789 s = pc.min_max(data, options=pc.ScalarAggregateOptions(skip_nulls=False))
790 assert s.as_py() == {'min': None, 'max': None}
791
792 # Options as dict of kwargs
793 s = pc.min_max(data, options={'skip_nulls': False})
794 assert s.as_py() == {'min': None, 'max': None}
795 # Options as named functions arguments
796 s = pc.min_max(data, skip_nulls=False)
797 assert s.as_py() == {'min': None, 'max': None}
798
799 # Both options and named arguments
800 with pytest.raises(TypeError):
801 s = pc.min_max(
802 data, options=pc.ScalarAggregateOptions(), skip_nulls=False)
803
804 # Wrong options type
805 options = pc.TakeOptions()
806 with pytest.raises(TypeError):
807 s = pc.min_max(data, options=options)
808
809 # Missing argument
810 with pytest.raises(TypeError, match="min_max takes 1 positional"):
811 s = pc.min_max()
812
813
814def test_any():

Callers

nothing calls this directly

Calls 3

as_pyMethod · 0.80
TakeOptionsMethod · 0.80

Tested by

no test coverage detected