code: def test_astype_category(self, name, dtype_ordered, index_ordered):
      # GH#18630
      index = CategoricalIndex(
          list("aabbca"), categories=list("cab"), ordered=index_ordered
      )
      if name:
          index = index.rename(name)
  
      # standard categories
      dtype = CategoricalDtype(ordered=dtype_ordered)
      result = index.astype(dtype)
      expected = CategoricalIndex(
          index.tolist(),
          name=name,
          categories=index.categories,
          ordered=dtype_ordered,
      )
      tm.assert_index_equal(result, expected)
  
      # non-standard categories
      dtype = CategoricalDtype(
          index.unique().tolist()[:-1], dtype_ordered
      )
      result = index.astype(dtype)
      expected = CategoricalIndex(
          index.tolist(), name=name, dtype=dtype
      )
      tm.assert_index_equal(result, expected)
  
      if dtype_ordered is False:
          # dtype='category' can't specify ordered, so only test once
          result = index.astype("category")
          expected = index
          tm.assert_index_equal(result, expected)
  
file_path: pandas/pandas/tests/indexes/categorical/test_astype.py
imports: from datetime import date
  import numpy
  import pytest
  from pandas import Categorical, CategoricalDtype, CategoricalIndex, Index, IntervalIndex
  import pandas._testing
label_desc: Use image node_id 2 for calling the TestAstype obj's underlying member method code with example usage: obj.test_astype_category(name, dtype_ordered, index_ordered) without return types