Skip to content

Commit

Permalink
fix: fix typo in error message
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreminger committed Sep 28, 2024
1 parent c84f306 commit b075278
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions public/dimensional_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,14 +1129,15 @@ def _imp_(arg1: float):
if arg1.is_integer() and arg1 >= 0.0:
return math.factorial(int(arg1))
else:
raise ValueError("The factorial function can only be evaluated a nonnegative integer")
raise ValueError("The factorial function can only be evaluated on a nonnegative integer")

def _eval_evalf(self, prec):
if self.args[0].is_number:
if not (self.args[0].is_real and
cast(ExprWithAssumptions, self.args[0]).is_finite and
cast(ExprWithAssumptions, self.args[0]).is_integer and cast(int, self.args[0]) >= 0):
raise ValueError("The factorial function can only be evaluated a nonnegative integer")
if not (self.args[0].is_real and
cast(ExprWithAssumptions, self.args[0]).is_finite and
cast(ExprWithAssumptions, self.args[0]).is_integer and
cast(int, self.args[0]) >= 0):
raise ValueError("The factorial function can only be evaluated on a nonnegative integer")
return factorial(self.args[0])._eval_evalf(prec) # type: ignore

# case of symbolic input
Expand Down
4 changes: 2 additions & 2 deletions tests/test_basic.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1784,15 +1784,15 @@ test('Test factorial error check for non integer input', async () => {

await page.waitForSelector('text=Updating...', {state: 'detached'});

await expect(page.locator('text=The factorial function can only be evaluated a nonnegative integer')).toBeVisible();
await expect(page.locator('text=The factorial function can only be evaluated on a nonnegative integer')).toBeVisible();
});

test('Test factorial error check for negative input', async () => {
await page.setLatex(0, String.raw`-1!=`);

await page.waitForSelector('text=Updating...', {state: 'detached'});

await expect(page.locator('text=The factorial function can only be evaluated a nonnegative integer')).toBeVisible();
await expect(page.locator('text=The factorial function can only be evaluated on a nonnegative integer')).toBeVisible();
});

test('Test factorial error check for input with units', async () => {
Expand Down

0 comments on commit b075278

Please sign in to comment.