atleast_2d_pad
full name: tenpy.tools.misc.atleast_2d_pad
parent module:
tenpy.tools.misc
type: function
- tenpy.tools.misc.atleast_2d_pad(a, pad_item=0)[source]
Transform a into a 2D array, filling missing places with pad_item.
Given a list of lists, turn it to a 2D array (pad with 0), or turn a 1D list to 2D.
- Parameters:
a (list of lists) – to be converted into ad 2D array.
- Returns:
a_2D – a converted into a numpy array.
- Return type:
2D ndarray
Examples
>>> atleast_2d_pad([3, 4, 0]) array([[3, 4, 0]])
>>> atleast_2d_pad([[3, 4], [1, 6, 7]]) array([[3., 4., 0.], [1., 6., 7.]])