From 6f9fbb490573a741787d49646d0bd263fb1e1be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?sonata=20=C2=ABpath=C3=A9tique=C2=BB?= Date: Wed, 18 Nov 2020 21:21:29 -0800 Subject: [PATCH 1/2] some kind of attempt at adding phi? yes i know i missed at least something and i do not care --- mathbot/calculator/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathbot/calculator/parser.py b/mathbot/calculator/parser.py index bd62e725..6267474d 100644 --- a/mathbot/calculator/parser.py +++ b/mathbot/calculator/parser.py @@ -704,7 +704,7 @@ def tokenizer(original_string, ttypes, source_name = '__unknown__'): ('string', r'"(?:\\.|[^\\"])*"'), ('string', r'“(?:\\.|[^\\”])*”'), ('glyph', r';\\.|;[^\\]'), - ('word', r'π|τ|∞|[a-zA-Z_][a-zA-Z0-9_]*'), + ('word', r'π|τ|∞|φ|ϕ|[a-zA-Z_][a-zA-Z0-9_]*'), # ('die_op', r'd'), ('pow_op', r'\^'), ('superscript', r'[⁰¹²³⁴⁵⁶⁷⁸⁹]+'), From 594d38f90126d7df8f3b6879f5af8973a6204378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?sonata=20=C2=ABpath=C3=A9tique=C2=BB?= Date: Wed, 18 Nov 2020 21:30:01 -0800 Subject: [PATCH 2/2] etc --- mathbot/calculator/runtime.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mathbot/calculator/runtime.py b/mathbot/calculator/runtime.py index 4af83230..d45b8bd4 100644 --- a/mathbot/calculator/runtime.py +++ b/mathbot/calculator/runtime.py @@ -151,6 +151,10 @@ def reduce_to_float(value): 'π': sympy.pi, 'τ': sympy.pi * 2, 'tau': sympy.pi * 2, + 'φ': sympy.S.GoldenRatio, + 'phi': sympy.S.GoldenRatio, + 'ϕ': (1 - math.sqrt(5)) / 2, + 'phiconj': (1 - math.sqrt(5)) / 2, 'true': True, 'false': False } @@ -159,8 +163,12 @@ def reduce_to_float(value): FIXED_VALUES_EXPORTABLE = { 'π': math.pi, 'τ': math.pi * 2, + 'φ': (1 + math.sqrt(5)) / 2, + 'ϕ': (1 - math.sqrt(5)) / 2, 'pi': math.pi, 'tau': math.pi * 2, + 'phi': (1 + math.sqrt(5)) / 2, + 'phiconj': (1 - math.sqrt(5)) / 2, 'true': True, 'false': False }