Skip to content

Conversation

@bradley-solliday-skydio
Copy link
Contributor

This is done by adding sym.util.check_matrix_size_and_numpify and calling it on the matrix inputs (when use_numba=False and reshape_vectors=True). This function converts list arguments to ndarrays and checks that the shape is what is expected.

Note, numpy only raises a deprecation warning if a ragged nested list is passed in.

If use_numba=True, just performs an inline check on the shape of the input, raising an IndexError if it is not what was expected. It never performs a reshape on matrix arguments.

Also adds the type alias sym.util.MatrixType and sym.util.VectorType. This is to make the type annotations less verbose.

This is done by adding `sym.util.check_matrix_size_and_numpify` and
calling it on the matrix inputs (when `use_numba=False` and
`reshape_vectors=True`). This function converts list arguments to
ndarrays and checks that the shape is what is expected.

Note, numpy only raises a deprecation warning if a ragged nested list is
passed in.

If `use_numba=True`, just performs an inline check on the shape of the
input, raising an `IndexError` if it is not what was expected. It never
performs a reshape on matrix arguments.

Also adds the type alias `sym.util.MatrixType` and
`sym.util.VectorType`. This is to make the type annotations less
verbose.
Copy link
Member

@aaron-skydio aaron-skydio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment about the type aliases, otherwise looks good

# -----------------------------------------------------------------------------

import typing as T

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typing is not a builtin package in python 2. We could add it as a depenency of sym or something, but that seems like a bummer. I'm not actually sure what a good approach would be here - maybe @eric-skydio has ideas? For context we have this mildly-complicated type that we'd like an alias for, but ideally we don't add a runtime dependency on typing from this module (sym)

Noting that the import is actually added here, although it isn't necessary at runtime in that PR.

)
)

return array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants