|
12 | 12 | from opencosmo.dataset.state import DatasetState
|
13 | 13 | from opencosmo.dataset.visit import visit_dataset
|
14 | 14 | from opencosmo.header import OpenCosmoHeader
|
15 |
| -from opencosmo.index import ChunkedIndex, DataIndex, SimpleIndex |
| 15 | +from opencosmo.index import ChunkedIndex, DataIndex |
16 | 16 | from opencosmo.io.schemas import DatasetSchema
|
17 | 17 | from opencosmo.parameters import HaccSimulationParameters
|
18 | 18 | from opencosmo.spatial import check
|
@@ -569,44 +569,7 @@ def take_range(self, start: int, end: int) -> Table:
|
569 | 569 | self.__tree,
|
570 | 570 | )
|
571 | 571 |
|
572 |
| - def take_rows(self, indices: np.ndarray, size: Optional[np.ndarray] = None): |
573 |
| - """ |
574 |
| - Create a new dataset with the rows specified by the arguments. This method allows for |
575 |
| - two different types of input |
576 |
| -
|
577 |
| - 1. A single array, representing the indices of the rows to take |
578 |
| - 2. Two arrays. The first representing the start of a set of row chunks, and the second representing |
579 |
| - their size |
580 |
| -
|
581 |
| - Parameters |
582 |
| - ---------- |
583 |
| - indices: np.ndarray[int] |
584 |
| - The rows to take, or the beginnings of the row chunks |
585 |
| -
|
586 |
| - size: np.ndarray[int], optional |
587 |
| - The size of the row chunks |
588 |
| -
|
589 |
| - Returns |
590 |
| - ------- |
591 |
| - dataset : opencosmo.Dataset |
592 |
| - The new dataset with only the selected rows. |
593 |
| -
|
594 |
| - """ |
595 |
| - if np.any(indices < 0): |
596 |
| - raise ValueError("Row indices cannot be negative!") |
597 |
| - |
598 |
| - size_ = 0 if size is None else size |
599 |
| - if np.any(indices + size_) > len(self): |
600 |
| - raise ValueError( |
601 |
| - "Row indices cannot be larger than the length of this dataset!" |
602 |
| - ) |
603 |
| - |
604 |
| - index: DataIndex |
605 |
| - if size is None: |
606 |
| - index = SimpleIndex(indices) |
607 |
| - else: |
608 |
| - index = ChunkedIndex(indices, size) |
609 |
| - |
| 572 | + def with_index(self, index: DataIndex): |
610 | 573 | new_state = self.__state.with_index(index)
|
611 | 574 | return Dataset(self.__handler, self.__header, new_state, self.__tree)
|
612 | 575 |
|
|
0 commit comments