I think you must have just confused yourself because of the fact that typing new code and then calling the function again does nothing: it just runs the old code again. You have to actually click “Shift-Enter” on the changed cell before you call it again in order to run the new code.
Watch this:
np.random.seed(42)
A = np.random.randn(1,4)
dist = np.linalg.norm(A)
print(f"type(dist) = {type(dist)}")
fdist = float(dist)
print(f"type(fdist) = {type(fdist)}")
type(dist) = <class 'numpy.float64'>
type(fdist) = <class 'float'>
So you get a scalar float in either case.
I’ll bet that the previous code which failed with the error about ufunc 'isfinite' looked like this:
dist = np.linalg.norm(A, axis = -1)
print(f"type(dist) = {type(dist)}")
type(dist) = <class 'numpy.ndarray'>
We’ve seen this a number of times before, e.g. on this recent thread.