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

Function test_generated_docstrings

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

Source from the content-addressed store, hash-verified

867
868
869def test_generated_docstrings():
870 # With options
871 assert pc.min_max.__doc__ == textwrap.dedent("""\
872 Compute the minimum and maximum values of a numeric array.
873
874 Null values are ignored by default.
875 This can be changed through ScalarAggregateOptions.
876
877 Parameters
878 ----------
879 array : Array-like
880 Argument to compute function.
881 skip_nulls : bool, default True
882 Whether to skip (ignore) nulls in the input.
883 If False, any null in the input forces the output to null.
884 min_count : int, default 1
885 Minimum number of non-null values in the input. If the number
886 of non-null values is below `min_count`, the output is null.
887 options : pyarrow.compute.ScalarAggregateOptions, optional
888 Alternative way of passing options.
889 memory_pool : pyarrow.MemoryPool, optional
890 If not passed, will allocate memory from the default memory pool.
891
892 Examples
893 --------
894 >>> import pyarrow as pa
895 >>> import pyarrow.compute as pc
896 >>> arr1 = pa.array([1, 1, 2, 2, 3, 2, 2, 2])
897 >>> pc.min_max(arr1)
898 <pyarrow.StructScalar: [('min', 1), ('max', 3)]>
899
900 Using ``skip_nulls`` to handle null values.
901
902 >>> arr2 = pa.array([1.0, None, 2.0, 3.0])
903 >>> pc.min_max(arr2)
904 <pyarrow.StructScalar: [('min', 1.0), ('max', 3.0)]>
905 >>> pc.min_max(arr2, skip_nulls=False)
906 <pyarrow.StructScalar: [('min', None), ('max', None)]>
907
908 Using ``ScalarAggregateOptions`` to control minimum number of non-null values.
909
910 >>> arr3 = pa.array([1.0, None, float("nan"), 3.0])
911 >>> pc.min_max(arr3)
912 <pyarrow.StructScalar: [('min', 1.0), ('max', 3.0)]>
913 >>> pc.min_max(arr3, options=pc.ScalarAggregateOptions(min_count=3))
914 <pyarrow.StructScalar: [('min', 1.0), ('max', 3.0)]>
915 >>> pc.min_max(arr3, options=pc.ScalarAggregateOptions(min_count=4))
916 <pyarrow.StructScalar: [('min', None), ('max', None)]>
917
918 This function also works with string values.
919
920 >>> arr4 = pa.array(["z", None, "y", "x"])
921 >>> pc.min_max(arr4)
922 <pyarrow.StructScalar: [('min', 'x'), ('max', 'z')]>
923 """)
924 # Without options
925 assert pc.add.__doc__ == textwrap.dedent("""\
926 Add the arguments element-wise.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected