Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mathics/builtin/vectors/math_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class Curl(SympyFunction):
"""

attributes = A_PROTECTED

# Set checking that the number of arguments required is two or three.
eval_error = Builtin.generic_argument_error
expected_args = (2, 3)

rules = {
"Curl[{f1_, f2_}, {x1_, x2_}]": " D[f2, x1] - D[f1, x2]",
"Curl[{f1_, f2_, f3_}, {x1_, x2_, x3_}]": """{
Expand Down
1 change: 1 addition & 0 deletions test/builtin/vectors/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
32 changes: 31 additions & 1 deletion test/builtin/vectors/test_mathops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"""
Unit tests for mathics.builtin.vectors.math_ops

In particular, Norm[].
In particular, Curl[] and Norm[].
"""

from test.helper import check_evaluation

import pytest


def test_norm():
for str_expr, expected_message in (
Expand Down Expand Up @@ -48,3 +50,31 @@ def test_norm():
),
):
check_evaluation(str_expr=str_expr, str_expected=str_expected)


@pytest.mark.parametrize(
("str_expr", "msgs", "assert_fail_msg"),
[
(
"Curl[a]",
["Curl called with 1 argument; 2 or 3 arguments are expected."],
"Curl with one argument",
),
(
"Curl[a, b, c, d]",
["Curl called with 4 arguments; 2 or 3 arguments are expected."],
"Curl with more than three arguments",
),
],
)
def test_wrong_number_of_arguments(str_expr, msgs, assert_fail_msg):
""" """
check_evaluation(
str_expr,
str_expr,
to_string_expr=True,
to_string_expected=True,
hold_expected=True,
failure_message=assert_fail_msg,
expected_messages=msgs,
)
Loading