Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor BasicType with documentation and exception improvements #532

Merged
merged 1 commit into from
Jun 7, 2019
Merged

Refactor BasicType with documentation and exception improvements #532

merged 1 commit into from
Jun 7, 2019

Conversation

abelbriggs1
Copy link
Collaborator

Fixes #531.

This PR:

  • makes a distinction between usage of RuntimeException and UnsupportedOperationException - RuntimeException is still used in functions like toString(), where the type could possibly be in an invalid state. RuntimeException has been replaced by UnsupportedOperationException when the user can potentially (and realistically) misuse a function (sending invalid arguments or using an unintended type). Additionally, UnsupportedOperationException is thrown instead of asserting when an error state is realistically possible.

  • adds Javadoc comments to functions that throw UnsupportedOperationException.

  • replaces usage of static allTypes().contains(type) calls with the corresponding isType() call when the current scope is not static.

Copy link
Contributor

@afd afd left a comment

Choose a reason for hiding this comment

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

Looks good.

Please see comment about a follow-up issue and PR to get rid of the static numColumns (or we should figure out if there's actually some need for that version of the method, though I cannot see one).

I also wonder about having more "is" methods (e.g. isScalar()) and going over the code base more generally to replace lots of the code that does "if(BasicType.allMatrixTypes().contains(...))" to use "isMatrix", similar for "isScalar", etc.

@@ -344,26 +344,44 @@ public boolean isBoolean() {
BVEC4));
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, not sure why we have this static method at all. It looks like numColumns(mat) is the same as mat.getNumColumns().

Can you open an issue for us to delete the static method and change all code that used it to use the instance version?

@afd afd merged commit 4316319 into google:dev Jun 7, 2019
@abelbriggs1 abelbriggs1 deleted the basictype-unsupported-ops branch June 10, 2019 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants