when using the unique function for a 2D array I need it to stop swapping values for the sub arrays:
array([[ 0. , 0. ],
[-0.25049165, 3.99214904],
[-3.99214904, -0.25049165],
…,
[ 3.99214904, 0.25049165],
[ 0.25049165, -3.99214904],
[ 0. , 0. ]])
using:
np.array(np.unique(np.sort(solution, axis=1), axis=0))
before I rounded to 4 dp for the first column and 5 to the second:
array([[-3.99215, -0.2505 ],
[-3.99215, 0.2505 ],
[-3.9921 , -0.25049],
[-3.9921 , 0.25049],
[-0.2505 , 3.99215],
[-0.25049, 3.9921 ],
[ 0. , 0. ],
[ 0.25049, 3.9921 ],
[ 0.2505 , 3.99215]])
but as we can see some of the first column is to 5dp because it swaps as it needs to be 8 unique combos of +/- 0.25.. and +/- 3.99.. , and 0,0 as a residue to the code, how do i stop the swap?
submitted by /u/Hung003
[link] [comments]
r/learnpython when using the unique function for a 2D array I need it to stop swapping values for the sub arrays: array([[ 0. , 0. ], [-0.25049165, 3.99214904], [-3.99214904, -0.25049165], …, [ 3.99214904, 0.25049165], [ 0.25049165, -3.99214904], [ 0. , 0. ]]) using: np.array(np.unique(np.sort(solution, axis=1), axis=0)) before I rounded to 4 dp for the first column and 5 to the second: array([[-3.99215, -0.2505 ], [-3.99215, 0.2505 ], [-3.9921 , -0.25049], [-3.9921 , 0.25049], [-0.2505 , 3.99215], [-0.25049, 3.9921 ], [ 0. , 0. ], [ 0.25049, 3.9921 ], [ 0.2505 , 3.99215]]) but as we can see some of the first column is to 5dp because it swaps as it needs to be 8 unique combos of +/- 0.25.. and +/- 3.99.. , and 0,0 as a residue to the code, how do i stop the swap? submitted by /u/Hung003 [link] [comments]
when using the unique function for a 2D array I need it to stop swapping values for the sub arrays:
array([[ 0. , 0. ],
[-0.25049165, 3.99214904],
[-3.99214904, -0.25049165],
…,
[ 3.99214904, 0.25049165],
[ 0.25049165, -3.99214904],
[ 0. , 0. ]])
using:
np.array(np.unique(np.sort(solution, axis=1), axis=0))
before I rounded to 4 dp for the first column and 5 to the second:
array([[-3.99215, -0.2505 ],
[-3.99215, 0.2505 ],
[-3.9921 , -0.25049],
[-3.9921 , 0.25049],
[-0.2505 , 3.99215],
[-0.25049, 3.9921 ],
[ 0. , 0. ],
[ 0.25049, 3.9921 ],
[ 0.2505 , 3.99215]])
but as we can see some of the first column is to 5dp because it swaps as it needs to be 8 unique combos of +/- 0.25.. and +/- 3.99.. , and 0,0 as a residue to the code, how do i stop the swap?
submitted by /u/Hung003
[link] [comments]