When I check my value of J with print(J) it outputs [13.67072581] so the function seems to be computing the right value. The data type of J is float64, which I think is okay?
Has anyone else ran into this issue? Any advice would be greatly appreciated!
It’s a practice to study the error message. By the arrow, it happened in the print line when converting the numeric J into a string of this formatting 0.2f. According to the message, it sees J as a numpy.ndarray, and it is erroneous because it can’t convert an array to a string that satisfies the formatting string. That formatting string 0.2f expects a number, not an array. That’s the problem.
So, as asked by the DocString:
J is supposed to be a float, but yours is not. This is where you can start looking into. You are given many ndarray as inputs, and through your code, it finally becomes another ndarray. You need to figure out at which step you can expect it to be a scalar but it remains as an array.