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

Function test_array_from_numpy_ascii

python/pyarrow/tests/test_array.py:2800–2829  ·  view source on GitHub ↗
(binary_type)

Source from the content-addressed store, hash-verified

2798 pa.large_binary(),
2799 pa.binary_view()])
2800def test_array_from_numpy_ascii(binary_type):
2801 # Default when no type is specified should be binary
2802 expected_type = binary_type or pa.binary()
2803
2804 arr = np.array(['abcde', 'abc', ''], dtype='|S5')
2805
2806 arrow_arr = pa.array(arr, binary_type)
2807 assert arrow_arr.type == expected_type
2808 expected = pa.array(['abcde', 'abc', ''], type=expected_type)
2809 assert arrow_arr.equals(expected)
2810
2811 mask = np.array([False, True, False])
2812 arrow_arr = pa.array(arr, binary_type, mask=mask)
2813 expected = pa.array(['abcde', None, ''], type=expected_type)
2814 assert arrow_arr.equals(expected)
2815
2816 # Strided variant
2817 arr = np.array(['abcde', 'abc', ''] * 5, dtype='|S5')[::2]
2818 mask = np.array([False, True, False] * 5)[::2]
2819 arrow_arr = pa.array(arr, binary_type, mask=mask)
2820
2821 expected = pa.array(['abcde', '', None, 'abcde', '', None, 'abcde', ''],
2822 type=expected_type)
2823 assert arrow_arr.equals(expected)
2824
2825 # 0 itemsize
2826 arr = np.array(['', '', ''], dtype='|S0')
2827 arrow_arr = pa.array(arr, binary_type)
2828 expected = pa.array(['', '', ''], type=expected_type)
2829 assert arrow_arr.equals(expected)
2830
2831
2832def test_interval_array_from_timedelta():

Callers

nothing calls this directly

Calls 2

equalsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected