Ensure we have a valid array to pass to _simple_new.
(cls, data, dtype, copy: bool)
| 593 | |
| 594 | @classmethod |
| 595 | def _ensure_array(cls, data, dtype, copy: bool): |
| 596 | """ |
| 597 | Ensure we have a valid array to pass to _simple_new. |
| 598 | """ |
| 599 | if data.ndim > 1: |
| 600 | # GH#13601, GH#20285, GH#27125 |
| 601 | raise ValueError("Index data must be 1-dimensional") |
| 602 | elif dtype == np.float16: |
| 603 | # float16 not supported (no indexing engine) |
| 604 | raise NotImplementedError("float16 indexes are not supported") |
| 605 | |
| 606 | if copy: |
| 607 | # asarray_tuplesafe does not always copy underlying data, |
| 608 | # so need to make sure that this happens |
| 609 | data = data.copy() |
| 610 | return data |
| 611 | |
| 612 | @final |
| 613 | @classmethod |