Skip to content

Conversation

@jolyonb
Copy link
Collaborator

@jolyonb jolyonb commented Dec 7, 2018

This PR introduces a flag to MatrixGrader that completely suppresses all matrix error messages. This is useful when variables are secretly being used as matrices due to their noncommutativity, but matrix error messages would be confusing to students. Includes code, tests, documentation and course example.

@jolyonb jolyonb force-pushed the suppressmatrixerrors branch from b4cffd9 to 04bbba5 Compare March 12, 2019 06:33
@jolyonb jolyonb changed the title Introducing flag to suppress matrix error messages [WIP] Introducing flag to suppress matrix error messages Mar 12, 2019
@ChristopherChudzicki
Copy link
Collaborator

Do you think suppress_shape_messages would be too verbose? Otherwise, this all looks good.

@jolyonb
Copy link
Collaborator Author

jolyonb commented Mar 12, 2019

That sounds reasonable, and more intuitive, given that it's only suppressing matrix-related messages. I'll go and make the change.

@jolyonb
Copy link
Collaborator Author

jolyonb commented Mar 12, 2019

Updated the flag name.

@ChristopherChudzicki
Copy link
Collaborator

ChristopherChudzicki commented Mar 19, 2019

Note that right now suppress_matrix_messages does not suppress all matrix-related errors, just the shape errors. In particular:

from mitxgraders import *
grader = MatrixGrader(
    variables=['A'],
    sample_from={
        'A': RealMatrices()
    },
    max_array_dim=0,
    suppress_messages=True, 
)

# below raises MathArrayError "Cannot raise a matrix to non-integer powers."
result = grader('A', 'A^1.3')

# below raises a DomainError
# (DomainError is not an instance of MathArrayError, but this is matrix-related)
result = grader('A', 'sin(A)')

@jolyon Maybe you should catch MathArrayError instead of ShapeErrors? This would still expose DomainError messages, but those are harder to suppress. Also, see #183 for ideas about an alternative approach.

(Note: the idea in #183 works for customizing DomainError messages, too.)

@jolyonb
Copy link
Collaborator Author

jolyonb commented Mar 22, 2019

Hmm. I can definitely catch MathArrayErrors and suppress those too. Domain errors ... can also be caught, I think... Let me see what I can do.

@jolyonb jolyonb force-pushed the suppressmatrixerrors branch from e017f47 to cf50b73 Compare March 22, 2019 00:54
@jolyonb jolyonb force-pushed the suppressmatrixerrors branch from cf50b73 to ac362c3 Compare March 22, 2019 00:56
@jolyonb
Copy link
Collaborator Author

jolyonb commented Mar 22, 2019

Ok, I've had a go at fixing things. Let me know what you think. I'm not terribly happy with the outcome, as it's somewhat kludgy, but it's a quick and dirty way to get noncommuting "scalars". I updated the documentation with a warning that taking functions of these "scalars" will be problematic. I'll go and comment on #183 now.

@ChristopherChudzicki ChristopherChudzicki merged commit 26d8190 into master Mar 22, 2019
@jolyonb jolyonb deleted the suppressmatrixerrors branch March 22, 2019 20:44
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