[AstroPy] Summing an array

Rudolf Baer rbaer25 at gmail.com
Tue Jul 12 04:13:34 EDT 2022


Hi Derek
In a new jupyter notebook it works !!!
Thank you   v e r y  much
Do you think I should update numpy? if yes to  version  1.21.6?

with kind regards
Rudolf

import numpy as np
import matplotlib.pyplot as plt

print(np.version.version)
print(np.sum.__class__)
print(np.sum.__name__)
print(np.sum.__module__)

object=str('361')
path='Gaia/''BASS'+object+'_107.6252849 59.13899216.csv'
rpflux=
np.genfromtxt(path,delimiter=',',dtype="float64",autostrip=True,skip_header=137,skip_footer=0,
usecols=(19))
print(rpflux)
print('sum', np.nansum(rpflux))

1.18.5
<class 'function'>
sum
numpy
[3140.   nan 2770. 3080. 3170. 3050. 3060. 3100. 2990. 3120. 3060. 9670.
 3100. 3070. 3020.   nan 3200. 3150. 3350. 2990. 2910. 2920. 3030. 3000.
 2800. 2980. 2860. 2840. 2610. 2650. 2610. 2650. 2490. 2490. 2540. 2510.
 2470.]
sum 108450.0




On Mon, Jul 11, 2022 at 6:10 PM Homeier, Derek <dhomeie at gwdg.de> wrote:

> Hi Rudolf,
>
>
> print(np.version.version) 1.18.5
>
>
> That’s kind of old (Python 3.7 is supported by up to 1.21.6), but the
> interface really has not changed
> notably since then.
>
> class 'numpy.ndarray
>
>    1 print(np.version.version)      2 print(np.sum.__class__)----> 3 print(np.sum.__name__)      4 print(np.sum.__module__)
> AttributeError: 'numpy.ndarray' object has no attribute '__name__'
>
>
> 2 print(np.sum.__class__)      3 #print(np.sum.__name__)----> 4 print(np.sum.__module__)
> AttributeError: 'numpy.ndarray' object has no attribute ‘__module__'
>
>
> Really looks like a polluted namespace (meaning some methods like
> `np.sum`, `np.nansum` have been
> overwritten by some other operation).
>
> As Eric suggested, could you provide a standalone example as a script
> including in particular everything from the
>
> import numpy as np
>
> statement in a fresh Python session onwards (I am assuming you are seeing
> the same error with
>
> rpflux = np.array([3140.,   2770. ,    3080.  ,   3170. ,    3050.,
> 3060.])
> np.sum(rpflux)
>
> so no need to include your actual data file in that case).
>
> Cheers,
> Derek
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/astropy/attachments/20220712/5ffcdfc0/attachment-0001.html>


More information about the AstroPy mailing list