| 1729 | # when squeezing |
| 1730 | |
| 1731 | class OldSqueeze(np.ndarray): |
| 1732 | |
| 1733 | def __new__(cls, |
| 1734 | input_array): |
| 1735 | obj = np.asarray(input_array).view(cls) |
| 1736 | return obj |
| 1737 | |
| 1738 | # it is perfectly reasonable that prior |
| 1739 | # to numpy version 1.7.0 a subclass of ndarray |
| 1740 | # might have been created that did not expect |
| 1741 | # squeeze to have an axis argument |
| 1742 | # NOTE: this example is somewhat artificial; |
| 1743 | # it is designed to simulate an old API |
| 1744 | # expectation to guard against regression |
| 1745 | def squeeze(self): |
| 1746 | return super().squeeze() |
| 1747 | |
| 1748 | oldsqueeze = OldSqueeze(np.array([[1],[2],[3]])) |
| 1749 |
no outgoing calls