JErnestoMtz / rapl

Rank Polymorphic array library for Rust.
103 stars 3 forks source link

Remove ability to `.reshape()` via tuples #29

Closed DeliciousHair closed 1 year ago

DeliciousHair commented 1 year ago

Using an array works great and is very flexible. Using a tuple on the other hand runs into obstacles if the dimension is greater than 4 at present. Given that using tuples requires additional implementations for each dimension, using tuples represents code bloat and a point of confusion as a user--which one should I use and why?

My thinking is that removing tuples altogether makes thing easier for the user (only arrays work) as well as keeps the code bloat to a minimum.

JErnestoMtz commented 1 year ago

Issue solved in https://github.com/JErnestoMtz/rapl/commit/09a0df5f37079e4e7d5cff020ac3ff569a669424#diff-f686acba59f5e44ba9e3177784a8c42d45806e266474c5540305fd33dad01f40.

Make sense to remove Tuples it just add noise. Now you can reshape with arrays up to length 20 i.e. Ndarras of 20 dimensions, that would probably take care off 99% of the use-cases. But for the other 1% it is also possible to do higher dimensions by first initializing your own Dim object:

 // for Dim<R> where R > 20 
        use typenum::U24;
        let dim_24 = Dim::<U24>::new(&vec![2;24]).unwrap();
        //2^24 = 16777216
        let arr_dim24 = Ndarr::from(0..16777216).reshape(&dim_24).unwrap();