Skip to content

Instantly share code, notes, and snippets.

@microprediction
Last active February 17, 2023 03:43
Show Gist options
  • Save microprediction/3d97ab7896dc5f6e1739deab76180a1a to your computer and use it in GitHub Desktop.
Save microprediction/3d97ab7896dc5f6e1739deab76180a1a to your computer and use it in GitHub Desktop.
Force numpy array to be column or row
def at_least_2d_column(x):
return at_least_2d_row(x).T
def at_least_2d_row(x):
return np.atleast_2d(np.ravel(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment