(original_array, new_array)
| 23 | |
| 24 | |
| 25 | def _maybe_view_as_subclass(original_array, new_array): |
| 26 | if type(original_array) is not type(new_array): |
| 27 | # if input was an ndarray subclass and subclasses were OK, |
| 28 | # then view the result as that subclass. |
| 29 | new_array = new_array.view(type=type(original_array)) |
| 30 | # Since we have done something akin to a view from original_array, we |
| 31 | # should let the subclass finalize (if it has it implemented, i.e., is |
| 32 | # not None). |
| 33 | if new_array.__array_finalize__: |
| 34 | new_array.__array_finalize__(original_array) |
| 35 | return new_array |
| 36 | |
| 37 | |
| 38 | @set_module("numpy.lib.stride_tricks") |
no test coverage detected
searching dependent graphs…