Skip to content

Commit

Permalink
Merge 30236e2 into 26d88e0
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherChudzicki committed Jul 1, 2018
2 parents 26d88e0 + 30236e2 commit 19d3fb8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 37 deletions.
4 changes: 2 additions & 2 deletions mitxgraders/formulagrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,9 @@ def log_sample_info(self, index, varlist, funclist, student_eval,
header = self.debug_appendix_header_template.format(
grader=self.__class__.__name__,
# The regexp replaces memory locations, e.g., 0x10eb1e848 -> 0x...
functions_allowed=pp.pformat({f: funclist['f'] for f in funclist
functions_allowed=pp.pformat({f: funclist[f] for f in funclist
if f in self.permitted_functions}),
functions_disallowed=pp.pformat({f: funclist['f'] for f in funclist
functions_disallowed=pp.pformat({f: funclist[f] for f in funclist
if f not in self.permitted_functions}),
)
self.log(re.sub(r"0x[0-9a-fA-F]+", "0x...", header))
Expand Down
Binary file modified python_lib.zip
Binary file not shown.
74 changes: 39 additions & 35 deletions tests/test_formulagrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,10 @@ def test_fg_debug_log():
'z': ComplexRectangle()
},
blacklist=['sin', 'cos'],
user_functions={'f': RandomFunction()},
user_functions={
'f': RandomFunction(),
'square': lambda x: x**2
},
samples=2,
debug=True
)
Expand All @@ -507,42 +510,43 @@ def test_fg_debug_log():
"FormulaGrader Debug Info<br/>\n"
"==============================================================<br/>\n"
"Functions available during evaluation and allowed in answer:<br/>\n"
"{{ 'abs': <function f at 0x...>,<br/>\n"
" 'arccos': <function f at 0x...>,<br/>\n"
" 'arccosh': <function f at 0x...>,<br/>\n"
" 'arccot': <function f at 0x...>,<br/>\n"
" 'arccoth': <function f at 0x...>,<br/>\n"
" 'arccsc': <function f at 0x...>,<br/>\n"
" 'arccsch': <function f at 0x...>,<br/>\n"
" 'arcsec': <function f at 0x...>,<br/>\n"
" 'arcsech': <function f at 0x...>,<br/>\n"
" 'arcsin': <function f at 0x...>,<br/>\n"
" 'arcsinh': <function f at 0x...>,<br/>\n"
" 'arctan': <function f at 0x...>,<br/>\n"
" 'arctanh': <function f at 0x...>,<br/>\n"
" 'conj': <function f at 0x...>,<br/>\n"
" 'cosh': <function f at 0x...>,<br/>\n"
" 'cot': <function f at 0x...>,<br/>\n"
" 'coth': <function f at 0x...>,<br/>\n"
" 'csc': <function f at 0x...>,<br/>\n"
" 'csch': <function f at 0x...>,<br/>\n"
" 'exp': <function f at 0x...>,<br/>\n"
"{{ 'abs': <ufunc 'absolute'>,<br/>\n"
" 'arccos': <function arccos at 0x...>,<br/>\n"
" 'arccosh': <ufunc 'arccosh'>,<br/>\n"
" 'arccot': <function arccot at 0x...>,<br/>\n"
" 'arccoth': <function arccoth at 0x...>,<br/>\n"
" 'arccsc': <function arccsc at 0x...>,<br/>\n"
" 'arccsch': <function arccsch at 0x...>,<br/>\n"
" 'arcsec': <function arcsec at 0x...>,<br/>\n"
" 'arcsech': <function arcsech at 0x...>,<br/>\n"
" 'arcsin': <function arcsin at 0x...>,<br/>\n"
" 'arcsinh': <ufunc 'arcsinh'>,<br/>\n"
" 'arctan': <ufunc 'arctan'>,<br/>\n"
" 'arctanh': <function arctanh at 0x...>,<br/>\n"
" 'conj': <ufunc 'conjugate'>,<br/>\n"
" 'cosh': <ufunc 'cosh'>,<br/>\n"
" 'cot': <function cot at 0x...>,<br/>\n"
" 'coth': <function coth at 0x...>,<br/>\n"
" 'csc': <function csc at 0x...>,<br/>\n"
" 'csch': <function csch at 0x...>,<br/>\n"
" 'exp': <ufunc 'exp'>,<br/>\n"
" 'f': <function f at 0x...>,<br/>\n"
" 'fact': <function f at 0x...>,<br/>\n"
" 'factorial': <function f at 0x...>,<br/>\n"
" 'im': <function f at 0x...>,<br/>\n"
" 'ln': <function f at 0x...>,<br/>\n"
" 'log10': <function f at 0x...>,<br/>\n"
" 'log2': <function f at 0x...>,<br/>\n"
" 're': <function f at 0x...>,<br/>\n"
" 'sec': <function f at 0x...>,<br/>\n"
" 'sech': <function f at 0x...>,<br/>\n"
" 'sinh': <function f at 0x...>,<br/>\n"
" 'sqrt': <function f at 0x...>,<br/>\n"
" 'tan': <function f at 0x...>,<br/>\n"
" 'tanh': <function f at 0x...>}}<br/>\n"
" 'fact': <built-in function factorial>,<br/>\n"
" 'factorial': <built-in function factorial>,<br/>\n"
" 'im': <function <lambda> at 0x...>,<br/>\n"
" 'ln': <function log at 0x...>,<br/>\n"
" 'log10': <function log10 at 0x...>,<br/>\n"
" 'log2': <function log2 at 0x...>,<br/>\n"
" 're': <function <lambda> at 0x...>,<br/>\n"
" 'sec': <function sec at 0x...>,<br/>\n"
" 'sech': <function sech at 0x...>,<br/>\n"
" 'sinh': <ufunc 'sinh'>,<br/>\n"
" 'sqrt': <function sqrt at 0x...>,<br/>\n"
" 'square': <function <lambda> at 0x...>,<br/>\n"
" 'tan': <ufunc 'tan'>,<br/>\n"
" 'tanh': <ufunc 'tanh'>}}<br/>\n"
"Functions available during evaluation and disallowed in answer:<br/>\n"
"{{ 'cos': <function f at 0x...>, 'sin': <function f at 0x...>}}<br/>\n"
"{{ 'cos': <ufunc 'cos'>, 'sin': <ufunc 'sin'>}}<br/>\n"
"<br/>\n"
"<br/>\n"
"==========================================<br/>\n"
Expand Down

0 comments on commit 19d3fb8

Please sign in to comment.