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

disallow multiplication of 3+ vectors w/o parens #123

Closed ChristopherChudzicki closed 6 years ago

ChristopherChudzicki commented 6 years ago

Resolves #108

Error message is potentially confusing in large expressions. Would be great if parse_results included the original string so we could show students what string caused the error. One day, maybe... !

jolyonb commented 6 years ago

Looks fine to me.

jolyonb commented 6 years ago

Ah. I've had second thoughts... We shouldn't give this message for vecv/2/pi...

ChristopherChudzicki commented 6 years ago

We don't, but I think I see what you mean. Currently:

from mitxgraders.helpers.calc import evaluator, MathArray

variables = {
    'i': MathArray([1, 0]),
    'j': MathArray([0, 1]),
}

result = evaluator("i/i*i", variables)[0]
# raises
# Multiplying three or more vectors is ambiguous. Please place parentheses around vector multiplications.
# but should raise
# something above not dividing vectors.

raises an error, but it should just give MathArray([1, 0, 0])

raises the wrong error.

jolyonb commented 6 years ago

Haha, ok ;-)