Skip to content

is_equiv rates different equations as equivalent: _strip_string drops any left-hand side of two characters or fewer #35

Open

Description

@damienen

_strip_string in modeling/math_equivalence.py has this rule, commented as "get rid of e.g. "k = " or "q = " at beginning":

if len(string.split("=")) == 2:
    if len(string.split("=")[0]) <= 2:
        string = string.split("=")[1]

It applies to every equation with a short left side, not just stray prefixes. x=7 and y=7 both become 7, so is_equiv treats them as the same answer. For problems whose answer is an equation, the right-hand side alone decides the grade.

A real case is test/precalculus/323: the problem asks for the image of the line y = 2x + 1 in the form "y = mx + b", and the gold answer is y = 2x + 3. A completion ending in \boxed{x=2x+3} (a different equation) is graded correct. I checked that with a one-problem run using the public problem and gold text; that run gave a score of 1/1 where 0/1 is expected.

Reproduction

Standard library only. Run with SRC set to a checkout of the repo.

import os, sys, importlib.util
p = os.path.join(os.environ["SRC"], "modeling", "math_equivalence.py")
s = importlib.util.spec_from_file_location("me", p)
m = importlib.util.module_from_spec(s)
s.loader.exec_module(m)
# The last pair is test/precalculus/323: gold "y = 2x + 3", model answer "x=2x+3".
pairs = [("x=7", "y=7"), ("z=2x+3", "y=2x+3"), ("x=2x+3", "y = 2x + 3")]
bad = 0
for pred, gold in pairs:
    r = m.is_equiv(pred, gold)
    print(f"is_equiv({pred!r},{gold!r}) observed={r} expected=False")
    bad += r
if bad:
    print("REPRODUCED")
    sys.exit(1)

Expected: observed=False for all three pairs.
Actual on main:

is_equiv('x=7','y=7') observed=True expected=False
is_equiv('z=2x+3','y=2x+3') observed=True expected=False
is_equiv('x=2x+3','y = 2x + 3') observed=True expected=False
REPRODUCED

(exit code 1.) I did not count how many MATH answers are equations with a short left-hand side.

Reproduces on main at 985bdc1696e88e8643f081a0ff4719da39f2ae2a.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions