Skip to content

Commit 071c106

Browse files
committed
Add some tests using N[,Method]
1 parent 07d5552 commit 071c106

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

mathics/builtin/constants.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def mp_constant(fn: str, d=None) -> mpmath.ctx_mp_python.mpf:
2929
if d is None:
3030
return getattr(mpmath, fn)()
3131
else:
32-
# TODO: In some function like Pi, you can
32+
# TODO: In some functions like Pi, you can
3333
# ask for a certain number of digits, but the
3434
# accuracy will be less than that. Figure out
3535
# what's up and compensate somehow.
@@ -434,7 +434,19 @@ class Pi(MPMathConstant, SympyConstant):
434434
435435
>> N[Pi]
436436
= 3.14159
437-
>> N[Pi, 50]
437+
438+
Force using the value given from numpy to compute Pi.
439+
>> N[Pi, Method->"numpy"]
440+
= 3.14159
441+
442+
Force using the value given from sympy to compute Pi to 3 places,
443+
two places after the decimal point.
444+
445+
Note that sympy is the default method.
446+
>> N[Pi, 3, Method->"sympy"]
447+
= 3.14
448+
449+
>> N[Pi, 50]
438450
= 3.1415926535897932384626433832795028841971693993751
439451
>> Attributes[Pi]
440452
= {Constant, Protected, ReadProtected}

0 commit comments

Comments
 (0)