Skip to content

Commit d22b540

Browse files
committed
Corrected bug where upper cased functions would not register as functions
1 parent 03829e7 commit d22b540

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="shunting-yard",
8-
version="1.0.8",
8+
version="1.0.9",
99
author="Paul 'charon25' Kern",
1010
description="Compute any math expression",
1111
long_description=long_description,
@@ -14,5 +14,5 @@
1414
url="https://www.github.com/charon25/ShuntingYard",
1515
license="MIT",
1616
packages=['shunting_yard'],
17-
download_url="https://github.com/charon25/ShuntingYard/archive/refs/tags/v1.0.8.tar.gz"
17+
download_url="https://github.com/charon25/ShuntingYard/archive/refs/tags/v1.0.9.tar.gz"
1818
)

shunting_yard/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from string import ascii_lowercase, digits
1+
from string import ascii_lowercase, ascii_uppercase, digits
22

33

44
UNARY_OPERATORS = '+-'
55
UNARY_OPERATORS_SYMBOLS = ('-u', '+u')
66
BASE_OPERATORS = '+-*/^'
77
NUMBER_CHARS = digits + '.'
88
# functions cannot start with a number
9-
FUNCTION_FIRST_CHARS = ascii_lowercase + '_'
9+
FUNCTION_FIRST_CHARS = ascii_lowercase + ascii_uppercase + '_'
1010
FUNCTION_CHARS = FUNCTION_FIRST_CHARS + NUMBER_CHARS
1111

1212
SEPARATORS_NO_CLOSING_BRACKET = '(,;'

shunting_yard/rpn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import math
12
from operator import add, mul, neg, pos, sub, truediv
23
from typing import Any, Callable, Optional, Union
3-
import math
44

55
from shunting_yard.constants import NUMBER_CHARS
66

shunting_yard/shunting_yard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from enum import Enum
2-
from typing import Optional
32
import math
43
import re
4+
from typing import Optional
55

66
from shunting_yard.tokenize import tokenize
77
from shunting_yard.constants import BASE_OPERATORS, NUMBER_CHARS, FUNCTION_CHARS, SEPARATORS, SEPARATORS_NO_CLOSING_BRACKET, UNARY_OPERATORS_SYMBOLS

tests/test_tokenize.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ def test_function_unary_in_function(self):
7373
def test_digits_in_function_name(self):
7474
self.assertListEqual(list(tokenize('min3(1, 2)')), ['min3', '(', '1', ',', '2', ')'])
7575

76+
def test_upper_case_functions(self):
77+
self.assertListEqual(list(tokenize('Sin(x)')), ['Sin', '(', 'x', ')'])
78+
self.assertListEqual(list(tokenize('sIN(x)')), ['sIN', '(', 'x', ')'])
79+
self.assertListEqual(list(tokenize('SIN(x)')), ['SIN', '(', 'x', ')'])
80+
7681

7782
class TestRemoveImplicitMultiplication(unittest.TestCase):
7883

0 commit comments

Comments
 (0)