def test_pa_to_rt_unsigned(self, num_cats, dtype, ordered: bool, output_writable: bool, have_nulls: bool) -> None:
        # Create a numpy array containing `num_cats` distinct strings.
        cat_labels = np.array([f"x{i}" for i in range(0, num_cats)])
        indices = np.arange(num_cats, dtype=dtype)

        # Create the pyarrow dict-encoded array.
        if have_nulls:
            # pyarrow uses an INvalid mask (where True means null/NA).
            invalid_mask = indices % 7 == 3
            pa_indices = pa.array(indices, mask=invalid_mask)
            pa_arr = pa.DictionaryArray.from_arrays(pa_indices, cat_labels, ordered=ordered)
        else:
            pa_arr = pa.DictionaryArray.from_arrays(indices, cat_labels, ordered=ordered)

        assert len(pa_arr.dictionary) == num_cats

        # Create the Categorical from the pyarrow array.
        result_cat = rt.Categorical.from_arrow(pa_arr, zero_copy_only=False, writable=output_writable)

        if have_nulls:
            result_invalid_mask = result_cat.isfiltered()
            assert_array_equal(result_invalid_mask, invalid_mask)
 def test_roundtrip_rt_pa_rt(self, rt_tsp_arr: rt.Date) -> None:
     """Test round-tripping from rt.Date to pyarrow.Array and back."""
     result_pa_arr = rt_tsp_arr.to_arrow()
     result_tsp_arr = rt.TimeSpan.from_arrow(result_pa_arr, zero_copy_only=False)
     assert_array_equal(rt_tsp_arr, result_tsp_arr)
 def test_roundtrip_rt_pa_rt(self, rt_farr: rt.FastArray) -> None:
     """Test round-tripping from rt.FastArray to pyarrow.Array and back."""
     result_pa_arr = rt_farr.to_arrow()
     result_farr = rt.FastArray.from_arrow(result_pa_arr, zero_copy_only=False)
     assert_array_equal(rt_farr, result_farr)