I'm trying to create a numpy scalar of a specified dtype. I know I could do, say, x = numpy.int16(3), but I don't know the dtype in advance.
If I were to want an array then
dtype = int
x = numpy.array(3, dtype=dtype)
would do it, so I had high hopes for
x = numpy.generic(3, dtype=dtype)
but one cannot create an instance of numpy.generic.
Any ideas?