Is there an alternative to numpy.atleast_2d() in Julia.
The python function can be found on this link: https://www.geeksforgeeks.org/numpy-atleast_2d-in-python/
Is there an alternative to numpy.atleast_2d() in Julia.
The python function can be found on this link: https://www.geeksforgeeks.org/numpy-atleast_2d-in-python/
Looking at the Python Numpy docs this needs to be defined as:
atleast_2d(a) = fill(a,1,1)
atleast_2d(a::AbstractArray) = ndims(a) == 1 ? reshape(a, :, 1) : a
Testing:
julia> atleast_2d(3)
1×1 Matrix{Int64}:
3
julia> atleast_2d([4,5])
2×1 Matrix{Int64}:
4
5