2

I am trying to use the python package autograd and I want to use values of an autograd arraybox in an interpolation

np.interp(x, x_values, y_values)

where y_values are store in an autograd arraybox. This leads to an error

TypeError: Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe'

which is connected to the fact the y_values is an autograd arraybox. I don't understand why I get this error, since I thought that autograd should work with numpy? But ok if I can convert the autograd arraybox into a numpy array I can work with that, but that does not seem to work either?

floats = [float(x) for x in y_values]

leads to

TypeError: float() argument must be a string or a number, not 'ArrayBox'
carl
  • 4,216
  • 9
  • 55
  • 103

1 Answers1

3

I did:

myvariable._value

and I got an array with the values inside the ArrayBox, which then I could manipulate.

I figured it out after checking the attributes of the ArrayBox using call(myvariable). Looks it is not documented anywhere. Hope it helps