I want to implement a similar function, and want to accept an array or number that I pass to numpy.ones
.
Specifically, I want to do this:
def halfs(shape):
shape = numpy.concatenate([2], shape)
return 0.5 * numpy.ones(shape)
Example input-output pairs:
# default
In [5]: beta_jeffreys()
Out[5]: array([-0.5, -0.5])
# scalar
In [5]: beta_jeffreys(3)
Out[3]:
array([[-0.5, -0.5, -0.5],
[-0.5, -0.5, -0.5]])
# vector (1)
In [3]: beta_jeffreys((3,))
Out[3]:
array([[-0.5, -0.5, -0.5],
[-0.5, -0.5, -0.5]])
# vector (2)
In [7]: beta_jeffreys((2,3))
Out[7]:
array([[[-0.5, -0.5, -0.5],
[-0.5, -0.5, -0.5]],
[[-0.5, -0.5, -0.5],
[-0.5, -0.5, -0.5]]])