Hello all. I believe that over the years there were multiple proposals to replace the linspace formula start + n *(stop - start) / (npoints - 1) with a * start + b * end with a, b linearly spaced between 0 and 1 with npoints. Concretely, a = n / (npoints - 1), b = 1 - a. Here, 0 <= n < npoints. I believe this would fix the issue here among many others. However, it was always rejected due to backward-incompatibility concerns. Perhaps it’s time to revisit this issue. Best regards, Hameer Abbasi
Am 10.01.2022 um 12:59 schrieb alejandro.giacometti@gmail.com:
I see what you mean, there is, however, some inconsistency on how this is handled, and it's not entirely intuitive
``` _type=np.int8 N=8 np.linspace( start=np.iinfo(_type).min, stop=np.iinfo(_type).max, num=N, dtype=_type, ) => array([-128, -92, -56, -19, 17, 54, 90, 127], dtype=int8)
_type=np.float16 np.linspace( start=np.finfo(_type).min, stop=np.finfo(_type).max, num=N, dtype=_type, ) => array([-65504., -46784., -28080., -9360., 9360., 28080., 46784., 65504.], dtype=float16)
_type=np.float32 np.linspace( start=np.finfo(_type).min, stop=np.finfo(_type).max, num=N, dtype=_type, ) => array([-3.4028235e+38, -2.4305882e+38, -1.4583529e+38, -4.8611764e+37, 4.8611764e+37, 1.4583529e+38, 2.4305882e+38, 3.4028235e+38], dtype=float32)
_type=np.float64 np.linspace( start=np.finfo(_type).min, stop=np.finfo(_type).max, num=N, dtype=_type, ) => array([ nan, inf, inf, inf, inf, inf, inf, 1.79769313e+308])
_type=np.float64 np.linspace( start=0, stop=np.finfo(_type).max, num=N, dtype=_type, ) => array([0.00000000e+000, 2.56813305e+307, 5.13626610e+307, 7.70439915e+307, 1.02725322e+308, 1.28406652e+308, 1.54087983e+308, 1.79769313e+308])
_type=np.float64 np.linspace( start=-1e291, stop=np.finfo(_type).max, num=N, dtype=_type, ) => array([-1.00000000e+291, 2.56813305e+307, 5.13626610e+307, 7.70439915e+307, 1.02725322e+308, 1.28406652e+308, 1.54087983e+308, 1.79769313e+308])
_type=np.float64 np.linspace( start=-1e292, stop=np.finfo(_type).max, num=N, dtype=_type, ) => array([ nan, inf, inf, inf, inf, inf, inf, 1.79769313e+308])
_type=np.float16 np.logspace( start=np.finfo(_type).minexp, stop=np.finfo(_type).maxexp, num=N, dtype=_type, base=2, ) => array([6.104e-05, 1.190e-03, 2.322e-02, 4.529e-01, 8.836e+00, 1.722e+02, 3.360e+03, inf], dtype=float16)
_type=np.float16 np.logspace( start=np.finfo(_type).minexp, stop=np.finfo(_type).maxexp, num=N, dtype=_type, base=2, endpoint=False, ) => array([6.104e-05, 8.211e-04, 1.105e-02, 1.487e-01, 2.000e+00, 2.691e+01, 3.620e+02, 4.872e+03], dtype=float16)
_type=np.float64 np.logspace( start=np.finfo(_type).minexp, stop=np.finfo(_type).maxexp, num=N, dtype=_type, base=2, endpoint=False, ) => array([2.22507386e-308, 2.16653556e-231, 2.10953732e-154, 2.05403862e-077, 2.00000000e+000, 1.94738306e+077, 1.89615038e+154, 1.84626556e+231]) ``` _______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-leave@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: einstein.edison@gmail.com