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

Function test_min_max

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

as_pyMethod · 0.80
TakeOptionsMethod · 0.80

Tested by

no test coverage detected