Skip to content

Commit 827aa78

Browse files
authored
Fix/revert factorial (#233)
* Revert "Merge pull request #232 from lambda-feedback/fix/git-install" This reverts commit d22647c, reversing changes made to d89371f. * Revert "Merge pull request #231 from lambda-feedback/fix/python-version" This reverts commit d89371f, reversing changes made to 896bc51. * Revert "Merge pull request #227 from lambda-feedback/bug/fix-inappropriate-symbol-and-!-for-factorial" This reverts commit 896bc51, reversing changes made to 51708f8.
1 parent d22647c commit 827aa78

File tree

8 files changed

+14
-56
lines changed

8 files changed

+14
-56
lines changed

.github/workflows/test-and-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: [3.12]
18+
python-version: [3.8]
1919

2020
defaults:
2121
run:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Once the code passes all these tests, it will then be uploaded to AWS and will b
5353
## Pre-requisites
5454
Although all programming can be done through the GitHub interface, it is recommended you do this locally on your machine. To do this, you must have installed:
5555

56-
- Python 3.12 or higher.
56+
- Python 3.8 or higher.
5757

5858
- GitHub Desktop or the `git` CLI.
5959

app/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Base image that bundles AWS Lambda Python 3.12 image with some middleware functions
1+
# Base image that bundles AWS Lambda Python 3.8 image with some middleware functions
22
# FROM base-eval-tmp
33
# FROM rabidsheep55/python-base-eval-layer
4-
FROM ghcr.io/lambda-feedback/baseevalutionfunctionlayer:main-3.12
4+
FROM ghcr.io/lambda-feedback/baseevalutionfunctionlayer:main-3.8
55

6-
RUN dnf install -y git
6+
RUN yum install -y git
77

88
WORKDIR /app
99

app/evaluation.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,6 @@ def evaluation_function(response, answer, params, include_test_data=False) -> di
288288
if "!" in response:
289289
evaluation_result.add_feedback(("NOTATION_WARNING_FACTORIAL", symbolic_comparison_internal_messages("NOTATION_WARNING_FACTORIAL")(dict())))
290290

291-
if "!!!" in response:
292-
evaluation_result.add_feedback(
293-
("NOTATION_WARNING_TRIPLE_FACTORIAL", symbolic_comparison_internal_messages("NOTATION_WARNING_TRIPLE_FACTORIAL")(dict())))
294-
295291
reserved_expressions_success, reserved_expressions = parse_reserved_expressions(reserved_expressions_strings, parameters, evaluation_result)
296292
if reserved_expressions_success is False:
297293
return evaluation_result.serialise(include_test_data)

app/feedback/symbolic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"PARSE_ERROR": f"`{inputs.get('x','')}` could not be parsed as a valid mathematical expression. Ensure that correct codes for input symbols are used, correct notation is used, that the expression is unambiguous and that all parentheses are closed.",
2222
"NOTATION_WARNING_EXPONENT": "Note that `^` cannot be used to denote exponentiation, use `**` instead.",
2323
"NOTATION_WARNING_FACTORIAL": "Note that `!` cannot be used to denote factorial, use `factorial(...)` instead.",
24-
"NOTATION_WARNING_TRIPLE_FACTORIAL": "Note that `!!!` is not supported.",
2524
"EXPRESSION_NOT_EQUALITY": "The response was an expression but was expected to be an equality.",
2625
"EQUALITY_NOT_EXPRESSION": "The response was an equality but was expected to be an expression.",
2726
"EQUALITIES_EQUIVALENT": None,

app/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pydot
22
typing_extensions
33
mpmath==1.2.1
4-
sympy==1.14
4+
sympy==1.12
55
antlr4-python3-runtime==4.7.2
66
git+https://github.com/lambda-feedback/latex2sympy.git@master#egg=latex2sympy2

app/tests/symbolic_evaluation_tests.py

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,10 @@ def test_warning_inappropriate_symbol(self):
775775
'(0,002*6800*v)/1,2',
776776
'(0.002*6800*v)/1.2'
777777
),
778+
(
779+
'-∞',
780+
'-inf'
781+
),
778782
(
779783
'x.y',
780784
'x*y'
@@ -1861,52 +1865,15 @@ def test_sum_in_answer(self, response, answer, value):
18611865
result = evaluation_function(response, answer, params)
18621866
assert result["is_correct"] is value
18631867

1864-
@pytest.mark.parametrize(
1865-
"response, answer, value",
1866-
[
1867-
("3!", "factorial(3)", True),
1868-
("(n+1)!", "factorial(n+1)", True),
1869-
("n!", "factorial(n)", True),
1870-
("a!=b", "factorial(3)", False),
1871-
("2*n!", "2*factorial(n)", True),
1872-
("3!", "3!", True),
1873-
("3*sin(n)!", "3*factorial(sin(n))", True)
1874-
]
1875-
)
1876-
def test_exclamation_mark_for_factorial(self, response, answer, value):
1877-
params = {
1878-
"strict_syntax": False,
1879-
"elementary_functions": True,
1880-
}
1881-
result = evaluation_function(response, answer, params)
1882-
assert result["is_correct"] is value
1883-
1884-
@pytest.mark.parametrize(
1885-
"response, answer, value",
1886-
[
1887-
("3!!", "factorial2(3)", True),
1888-
("(n+1)!!", "factorial2(n+1)", True),
1889-
("n!!", "factorial2(n)", True),
1890-
("a!=b", "factorial2(3)", False),
1891-
("2*n!!", "2*factorial2(n)", True),
1892-
("3!!", "3!!", True),
1893-
]
1894-
)
1895-
def test_double_exclamation_mark_for_factorial(self, response, answer, value):
1868+
def test_exclamation_mark_for_factorial(self):
1869+
response = "3!"
1870+
answer = "factorial(3)"
18961871
params = {
18971872
"strict_syntax": False,
18981873
"elementary_functions": True,
18991874
}
19001875
result = evaluation_function(response, answer, params)
1901-
assert result["is_correct"] is value
1902-
1903-
def test_warning_for_triple_factorial(self):
1904-
answer = '2^4!'
1905-
response = '2^4!!!'
1906-
params = {'strict_syntax': False}
1907-
result = evaluation_function(response, answer, params, include_test_data=True)
1908-
assert result["is_correct"] is False
1909-
assert "NOTATION_WARNING_TRIPLE_FACTORIAL" in result["tags"]
1876+
assert result["is_correct"] is True
19101877

19111878
def test_alternatives_to_input_symbols_takes_priority_over_elementary_function_alternatives(self):
19121879
answer = "Ef*exp(x)"

app/utility/expression_utilities.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,20 +691,17 @@ def parse_expression(expr_string, parsing_params):
691691
substitutions.sort(key=substitutions_sort_key)
692692
if parsing_params["elementary_functions"] is True:
693693
substitutions += protect_elementary_functions_substitutions(expr)
694-
695694
substitutions = list(set(substitutions))
696695
substitutions.sort(key=substitutions_sort_key)
697696
expr = substitute(expr, substitutions)
698697
expr = " ".join(expr.split())
699-
700698
can_split = lambda x: False if x in unsplittable_symbols else _token_splittable(x)
701699
if strict_syntax is True:
702700
transformations = parser_transformations[0:4]+extra_transformations
703701
else:
704702
transformations = parser_transformations[0:5, 6]+extra_transformations+(split_symbols_custom(can_split),)+parser_transformations[8, 9]
705703
if parsing_params.get("rationalise", False):
706704
transformations += parser_transformations[11]
707-
708705
if "=" in expr:
709706
expr_parts = expr.split("=")
710707
lhs = parse_expr(expr_parts[0], transformations=transformations, local_dict=symbol_dict)
@@ -716,7 +713,6 @@ def parse_expression(expr_string, parsing_params):
716713
parsed_expr = parsed_expr.simplify()
717714
else:
718715
parsed_expr = parse_expr(expr, transformations=transformations, local_dict=symbol_dict, evaluate=False)
719-
720716
if not isinstance(parsed_expr, Basic):
721717
raise ValueError(f"Failed to parse Sympy expression `{expr}`")
722718
parsed_expr_set.add(parsed_expr)

0 commit comments

Comments
 (0)