mitodl / mitx-grading-library

The MITx Grading Library, a python grading library for edX
https://edge.edx.org/courses/course-v1:MITx+grading-library+examples/
BSD 3-Clause "New" or "Revised" License
14 stars 9 forks source link

Functions and IdentityMultiple #102

Closed ChristopherChudzicki closed 6 years ago

ChristopherChudzicki commented 6 years ago

The Issue

In MatrixGrader problems, if IdentityMultiple instances are passed to functions, students currently receive unhelpful generic error messages:

from mitxgraders import FormulaGrader

grader = MatrixGrader(answers='1')
grader(None, 'sin(I)'
# raises:
# StudentFacingError: Invalid Input: Could not check input 'sin(I)'

This is bad.

(The actual cause of this error is an isinf check in calc.py's eval_function parse action. However: I suggest that this issue should be for discussing the intended behavior, not the source of the bug.)

Original motivation of IdentityMultiple

My thinking with IdentityMultiple originally was:

Resolutions

Shape is a bit more important for the identity matrix than I originally realized. In particular, I see no way to handle trace and norm for generic-dimensional identity operators.

I'm not sure what the best approach to resolve this is. Two ideas:

I am personally rather fond of IdentityMultiple, but I am actually leaning toward Idea B.

jolyonb commented 6 years ago

Note that det is also dependent on the dimensionality.

I too am quite fond of IdentityMultiple, but I think you're right that Idea B is probably the better way to go. Being explicit about what something is will ultimately lead to less confusion than having a clever but ill-defined construct.

I propose that in addition to exposing a helper function Identity(n), we have an additional key like identity_dim (default None) that will populate I with the identity of the appropriate dimension. This reduces the author load just that little bit.

jolyonb commented 6 years ago

Resolved by #105.