Convert the decimal numbers expressed in a `numpy.ndarray` into a matrix representing elements in fractional form
Cousin Stanley
cousinstanley at gmail.com
Mon May 23 15:20:29 EDT 2022
> hongy... wrote ....
>
> This method doesn't work, as shown below:
>
? b ....
>
> [0.0, -1.0, 0.0, 0.25]
> [1.0, 0.0, 0.0, 0.25]
> [0.0, 0.0, 1.0, 0.25]
> [0.0, 0.0, 0.0, 1.0]
>
> a ....
>
> 0 0 0 1
>
# -----------------------------------
Using ....
debian 11.3 bullseye
python 3.9
numpy 1,21,5
Code as I posted in my reply dated 2022-05-18
$ python3 np_array_to_fractions_2.py
b ....
[0.0, -1.0, 0.0, 0.25]
[1.0, 0.0, 0.0, 0.25]
[0.0, 0.0, 1.0, 0.25]
[0.0, 0.0, 0.0, 1.0]
a ....
0 -1 0 1/4
1 0 0 1/4
0 0 1 1/4
0 0 0 1
--
Stanley C. Kitching
Human Being
Phoenix, Arizona
More information about the Python-list
mailing list