expr-codegen 0.15.1__tar.gz → 0.15.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/PKG-INFO +1 -1
- expr_codegen-0.15.2/expr_codegen/_version.py +1 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/expr.py +8 -41
- expr_codegen-0.15.1/expr_codegen/_version.py +0 -1
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/.gitignore +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/LICENSE +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/README.md +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/__init__.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/codes.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/dag.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/latex/__init__.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/latex/printer.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/model.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/pandas/__init__.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/pandas/code.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/pandas/helper.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/pandas/printer.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/pandas/ta.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/pandas/template.py.j2 +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/polars/__init__.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/polars/code.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/polars/printer.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/polars/template.py.j2 +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/sql/__init__.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/sql/code.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/sql/printer.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/sql/template.sql.j2 +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/expr_codegen/tool.py +0 -0
- {expr_codegen-0.15.1 → expr_codegen-0.15.2}/pyproject.toml +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.15.2"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from functools import reduce
|
|
2
2
|
|
|
3
3
|
from sympy import Mul, preorder_traversal, symbols, Function, simplify, Add, Basic, Symbol, sympify, FunctionClass
|
|
4
|
+
from loguru import logger
|
|
4
5
|
|
|
5
6
|
# 预定义前缀,算子用前缀进行区分更方便。
|
|
6
7
|
# 当然也可以用是否在某容器中进行分类
|
|
@@ -329,7 +330,7 @@ def _replace__ts_sum__to__ts_mean(e):
|
|
|
329
330
|
if node.args[1].args[1] == node.args[0].q and node.args[0].p == 1:
|
|
330
331
|
replacements.append((node, ts_mean(node.args[1].args[0], node.args[1].args[1])))
|
|
331
332
|
for node, replacement in replacements:
|
|
332
|
-
|
|
333
|
+
logger.debug("{} -> {}", node, replacement)
|
|
333
334
|
e = e.xreplace({node: replacement})
|
|
334
335
|
return e
|
|
335
336
|
|
|
@@ -353,7 +354,7 @@ def _replace__repeat(e):
|
|
|
353
354
|
if node_name in ('cs_rank', 'sign', 'Abs', 'abs_'):
|
|
354
355
|
replacements.append((node, node.args[0]))
|
|
355
356
|
for node, replacement in replacements:
|
|
356
|
-
|
|
357
|
+
logger.debug("{} -> {}", node, replacement)
|
|
357
358
|
e = e.xreplace({node: replacement})
|
|
358
359
|
return e
|
|
359
360
|
|
|
@@ -372,7 +373,7 @@ def _replace__one_mul(e):
|
|
|
372
373
|
else:
|
|
373
374
|
replacements.append((node, node.args[1]))
|
|
374
375
|
for node, replacement in replacements:
|
|
375
|
-
|
|
376
|
+
logger.debug("{} -> {}", node, replacement)
|
|
376
377
|
e = e.xreplace({node: replacement})
|
|
377
378
|
return e
|
|
378
379
|
|
|
@@ -391,12 +392,10 @@ def _replace__ts_xxx_1(e):
|
|
|
391
392
|
try:
|
|
392
393
|
if node.args[1] <= 1:
|
|
393
394
|
replacements.append((node, node.args[0]))
|
|
394
|
-
except:
|
|
395
|
-
|
|
396
|
-
print(e)
|
|
397
|
-
raise
|
|
395
|
+
except Exception as ex:
|
|
396
|
+
logger.warning("{} | {}: {}", e, node_name, ex)
|
|
398
397
|
for node, replacement in replacements:
|
|
399
|
-
|
|
398
|
+
logger.debug("{} -> {}", node, replacement)
|
|
400
399
|
e = e.xreplace({node: replacement})
|
|
401
400
|
return e
|
|
402
401
|
|
|
@@ -436,38 +435,6 @@ def _replace__ts_delay__to__ts_delta(e):
|
|
|
436
435
|
if len(tmp_args.args) < len(new_args):
|
|
437
436
|
replacements.append((node, tmp_args))
|
|
438
437
|
for node, replacement in replacements:
|
|
439
|
-
|
|
438
|
+
logger.debug("{} -> {}", node, replacement)
|
|
440
439
|
e = e.xreplace({node: replacement})
|
|
441
440
|
return e
|
|
442
|
-
|
|
443
|
-
# def is_meaningless(e):
|
|
444
|
-
# if _meaningless__ts_xxx_1(e):
|
|
445
|
-
# return True
|
|
446
|
-
# if _meaningless__xx_xx(e):
|
|
447
|
-
# return True
|
|
448
|
-
# return False
|
|
449
|
-
#
|
|
450
|
-
#
|
|
451
|
-
# def _meaningless__ts_xxx_1(e):
|
|
452
|
-
# """ts_xxx部分函数如果参数为1,可直接丢弃"""
|
|
453
|
-
# for node in preorder_traversal(e):
|
|
454
|
-
# if len(node.args) >= 2:
|
|
455
|
-
# node_name = get_node_name(node)
|
|
456
|
-
# if node_name in ('ts_delay', 'ts_delta'):
|
|
457
|
-
# if not node.args[1].is_Integer:
|
|
458
|
-
# return True
|
|
459
|
-
# if node_name.startswith('ts_'):
|
|
460
|
-
# if not node.args[-1].is_Number:
|
|
461
|
-
# return True
|
|
462
|
-
# if node.args[-1] <= 1:
|
|
463
|
-
# return True
|
|
464
|
-
# return False
|
|
465
|
-
#
|
|
466
|
-
#
|
|
467
|
-
# def _meaningless__xx_xx(e):
|
|
468
|
-
# """部分函数如果两参数完全一样,可直接丢弃"""
|
|
469
|
-
# for node in preorder_traversal(e):
|
|
470
|
-
# if len(node.args) >= 2:
|
|
471
|
-
# if node.args[0] == node.args[1]:
|
|
472
|
-
# return True
|
|
473
|
-
# return False
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.15.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|