dpilger26 / NumCpp

C++ implementation of the Python Numpy library
https://dpilger26.github.io/NumCpp
MIT License
3.55k stars 550 forks source link

index on shape object #195

Closed TorokLev closed 1 year ago

TorokLev commented 1 year ago

With this one can say

    NdArray<double> obj;
    auto rows=obj.shape()[0] ;
    auto cols=obj.shape()[1] ;

for greater compatibility with numpy

dpilger26 commented 1 year ago

The rows and cols members on Shape were chosen to be more clear/concise than list indexing. This also eliminates the possibility of needing to handle exceptions or UB (asserts are generally compiled out in release mode) from an operator[]. This was an active decision to deviate from NumPy. Closing this PR as a "not going to incorporate".