Hi guys im just a rookie in python (even in programming) so my question might sound very basic but i have a hard time to understand this.
Why is the selective behavior on arithmetics on 'float object'?
import numpy as np
a = np.random.normal(size=10)
a = np.abs(a)
b = np.array(a, dtype=object)
np.square(a) # this works
np.square(b) # this works
np.sqrt(a) # this works
np.sqrt(b) # AttributeError: 'float' object has no attribute 'sqrt'
The image link is my run result in local jupyter notebook:
Appreciate useful insights! thanks
edit 050418 09:53 --add a link that i think is similar issue Numpy AttributeError: 'float' object has no attribute 'exp'

numpydelegates the calculation to the elements (sort of like a list comprehension). The result is that some calculations work, others don't. You have found a pair that illustrate this. Both are compiled, so it isn't easy to see how the delegation is different. - hpauljipythondouble question mark:??As a general rule, don't count on doing math on object dtype arrays. It's hit and miss. And even when it works, it is slower than with numeric dtypes. - hpauljsquareknows that it can delegate the operation to the object's__mul__method, if it has one, which a Pythonfloatobject does. If an object has asqrtmethod,numpy.sqrtwill delegate to that. The Pythonfloatdoesn't have asqrtmethod. - Warren Weckesser