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
11 changes: 8 additions & 3 deletions dltype/_lib/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,14 @@ def _tokenize_string_expr( # noqa: C901, PLR0912
assert isinstance(character, str)
for op in _DLTypeOperator:
if tuple(expression[idx : idx + len(op.value)]) == tuple(op.value):
second_pass_return_list[idx - offset] = op
offset += len(op.value) - 1
found_operator = True
# we might have an operator, but if the operator is functional we need to check for a ( next
if (
op not in _functional_operators
or expression[idx + len(op.value)] == _DLTypeGroupToken.LPAREN.value
):
second_pass_return_list[idx - offset] = op
offset += len(op.value) - 1
found_operator = True
break
if not found_operator:
for spec in _DLTypeSpecifier:
Expand Down
5 changes: 5 additions & 0 deletions dltype/tests/parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
("max(3^x,min(3-y,99))", {"x": 2, "y": 4}, 9),
("min(3^x,3-y)", {"x": 2, "y": 4}, -1),
("variable_name_with_underscores", {"variable_name_with_underscores": 1}, 1),
("max_variable_starts_with_operator", {"max_variable_starts_with_operator": 1}, 1),
("isqrt(5)", {}, 2),
("isqrt(16)", {}, 4),
("isqrt(x-y)", {"x": 20, "y": 5}, 3),
Expand Down Expand Up @@ -93,6 +94,10 @@ def test_parse_expression(
("min()", {}),
("a=b=2", {}),
("isqrt(*)", {}),
("+_variable_name", {}),
("max(", {}),
("a_max(", {}),
("a_max()", {}),
("dim+", {}),
("dim%", {}),
("dim?", {}),
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ license-files = ["LICENSE"]
name = "dltype"
readme = "README.md"
requires-python = ">=3.10"
version = "0.16.0"
version = "0.17.0"

[project.optional-dependencies]
jax = ["jax>=0.6.2"]
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading