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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description = "Evaluate Lidar-Inertial Odometry on public datasets"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"asteval>=1.0.6",
"distinctipy>=1.3.4",
"gdown>=5.2.0",
"joblib>=1.5.2",
Expand Down
10 changes: 3 additions & 7 deletions python/evalio/cli/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from rich import box

from evalio import types as ty, stats

import numpy as np
import typer

import distinctipy
Expand Down Expand Up @@ -290,11 +288,9 @@ def evaluate_typer(
if filter_str is None:
filter_method = lambda r: True # noqa: E731
else:
filter_method = lambda r: eval( # noqa: E731
filter_str,
{"__builtins__": None},
{"np": np, **r},
)
from asteval import Interpreter

filter_method = lambda r: Interpreter(user_symbols=r).eval(filter_str)

original_filter = filter_method
if only_complete:
Expand Down
73 changes: 73 additions & 0 deletions python/typings/asteval/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""
This type stub file was generated by pyright.
"""

from typing import Any, Iterable, Optional

class Interpreter:
"""create an asteval Interpreter: a restricted, simplified interpreter
of mathematical expressions using Python syntax.

Parameters
----------
symtable : dict or `None`
dictionary or SymbolTable to use as symbol table (if `None`, one will be created).
nested_symtable : bool, optional
whether to use a new-style nested symbol table instead of a plain dict [False]
user_symbols : dict or `None`
dictionary of user-defined symbols to add to symbol table.
writer : file-like or `None`
callable file-like object where standard output will be sent.
err_writer : file-like or `None`
callable file-like object where standard error will be sent.
use_numpy : bool
whether to use functions from numpy.
max_statement_length : int
maximum length of expression allowed [50,000 characters]
readonly_symbols : iterable or `None`
symbols that the user can not assign to
builtins_readonly : bool
whether to blacklist all symbols that are in the initial symtable
minimal : bool
create a minimal interpreter: disable many nodes (see Note 1).
config : dict
dictionay listing which nodes to support (see note 2))

Notes
-----
1. setting `minimal=True` is equivalent to setting a config with the following
nodes disabled: ('import', 'importfrom', 'if', 'for', 'while', 'try', 'with',
'functiondef', 'ifexp', 'listcomp', 'dictcomp', 'setcomp', 'augassign',
'assert', 'delete', 'raise', 'print')
2. by default 'import' and 'importfrom' are disabled, though they can be enabled.
"""
def __init__(
self,
symtable: dict[Any, Any] = ...,
nested_symtable: bool = ...,
user_symbols: dict[Any, Any] = ...,
writer: Optional[Any] = ...,
err_writer: Optional[Any] = ...,
use_numpy: bool = ...,
max_statement_length: int = ...,
minimal: bool = ...,
readonly_symbols: Optional[Iterable[str]] = ...,
builtins_readonly: bool = ...,
config: dict[str, Any] = ...,
**kws: dict[Any, Any],
) -> None:
pass

def eval(
self,
expr: str,
lineno: int = ...,
show_errors: bool = ...,
raise_errors: bool = ...,
) -> Any:
"""Evaluate a single statement."""
...

__all__ = [
"Interpreter",
]
11 changes: 11 additions & 0 deletions uv.lock

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