expr-codegen 0.13.0__tar.gz → 0.13.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.13.0 → expr_codegen-0.13.2}/PKG-INFO +9 -1
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/README.md +8 -0
- expr_codegen-0.13.2/expr_codegen/_version.py +1 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/codes.py +25 -1
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/polars/template.py.j2 +1 -0
- expr_codegen-0.13.0/expr_codegen/_version.py +0 -1
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/.gitignore +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/LICENSE +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/__init__.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/dag.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/expr.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/latex/__init__.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/latex/printer.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/model.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/pandas/__init__.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/pandas/code.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/pandas/helper.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/pandas/printer.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/pandas/ta.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/pandas/template.py.j2 +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/polars/__init__.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/polars/code.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/polars/printer.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/sql/__init__.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/sql/code.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/sql/printer.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/sql/template.sql.j2 +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/expr_codegen/tool.py +0 -0
- {expr_codegen-0.13.0 → expr_codegen-0.13.2}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: expr_codegen
|
|
3
|
-
Version: 0.13.
|
|
3
|
+
Version: 0.13.2
|
|
4
4
|
Summary: symbol expression to polars expression tool
|
|
5
5
|
Author-email: wukan <wu-kan@163.com>
|
|
6
6
|
License: BSD 3-Clause License
|
|
@@ -94,6 +94,13 @@ def _code_block_2():
|
|
|
94
94
|
# talib在模板中没有默认导入。这种写法可实现在生成的代码中导入
|
|
95
95
|
from polars_ta.prefix.talib import ts_LINEARREG_SLOPE # noqa
|
|
96
96
|
|
|
97
|
+
# 还支持def和class的原样导入
|
|
98
|
+
def cs_rank_if(condition, factor):
|
|
99
|
+
return cs_rank(if_else(condition, factor, None))
|
|
100
|
+
|
|
101
|
+
class Clazz:
|
|
102
|
+
pass
|
|
103
|
+
|
|
97
104
|
# 1. 下划线开头的变量只是中间变量,会被自动更名,最终输出时会被剔除
|
|
98
105
|
# 2. 下划线开头的变量可以重复使用。多个复杂因子多行书写时有重复中间变时不再冲突
|
|
99
106
|
_avg = ts_mean(corr, 20)
|
|
@@ -268,6 +275,7 @@ X3 = (ts_returns(CLOSE, 3)).over(_ASSET_, order_by=_DATE_),
|
|
|
268
275
|
C = unpack(_x_0, 2)
|
|
269
276
|
```
|
|
270
277
|
11. 单行注释支持参数输入,如:`# --over_null`、`# --over_null=order_by`、`# --over_null=partition_by`
|
|
278
|
+
12. 代码块中,对`import`、`def`、`class`三种语法,自动原样插入到生成的代码中
|
|
271
279
|
|
|
272
280
|
## 下划线开头的变量
|
|
273
281
|
|
|
@@ -44,6 +44,13 @@ def _code_block_2():
|
|
|
44
44
|
# talib在模板中没有默认导入。这种写法可实现在生成的代码中导入
|
|
45
45
|
from polars_ta.prefix.talib import ts_LINEARREG_SLOPE # noqa
|
|
46
46
|
|
|
47
|
+
# 还支持def和class的原样导入
|
|
48
|
+
def cs_rank_if(condition, factor):
|
|
49
|
+
return cs_rank(if_else(condition, factor, None))
|
|
50
|
+
|
|
51
|
+
class Clazz:
|
|
52
|
+
pass
|
|
53
|
+
|
|
47
54
|
# 1. 下划线开头的变量只是中间变量,会被自动更名,最终输出时会被剔除
|
|
48
55
|
# 2. 下划线开头的变量可以重复使用。多个复杂因子多行书写时有重复中间变时不再冲突
|
|
49
56
|
_avg = ts_mean(corr, 20)
|
|
@@ -218,6 +225,7 @@ X3 = (ts_returns(CLOSE, 3)).over(_ASSET_, order_by=_DATE_),
|
|
|
218
225
|
C = unpack(_x_0, 2)
|
|
219
226
|
```
|
|
220
227
|
11. 单行注释支持参数输入,如:`# --over_null`、`# --over_null=order_by`、`# --over_null=partition_by`
|
|
228
|
+
12. 代码块中,对`import`、`def`、`class`三种语法,自动原样插入到生成的代码中
|
|
221
229
|
|
|
222
230
|
## 下划线开头的变量
|
|
223
231
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.13.2"
|
|
@@ -121,6 +121,18 @@ class SyntaxTransformer(ast.NodeTransformer):
|
|
|
121
121
|
self.generic_visit(node)
|
|
122
122
|
return node
|
|
123
123
|
|
|
124
|
+
def visit_FunctionDef(self, node):
|
|
125
|
+
return node
|
|
126
|
+
|
|
127
|
+
def visit_ClassDef(self, node):
|
|
128
|
+
return node
|
|
129
|
+
|
|
130
|
+
def visit_Import(self, node):
|
|
131
|
+
return node
|
|
132
|
+
|
|
133
|
+
def visit_ImportFrom(self, node):
|
|
134
|
+
return node
|
|
135
|
+
|
|
124
136
|
|
|
125
137
|
class RenameTransformer(ast.NodeTransformer):
|
|
126
138
|
"""改名处理。改名前需要语法规范"""
|
|
@@ -308,6 +320,18 @@ class RenameTransformer(ast.NodeTransformer):
|
|
|
308
320
|
self.generic_visit(node)
|
|
309
321
|
return node
|
|
310
322
|
|
|
323
|
+
def visit_FunctionDef(self, node):
|
|
324
|
+
return node
|
|
325
|
+
|
|
326
|
+
def visit_ClassDef(self, node):
|
|
327
|
+
return node
|
|
328
|
+
|
|
329
|
+
def visit_Import(self, node):
|
|
330
|
+
return node
|
|
331
|
+
|
|
332
|
+
def visit_ImportFrom(self, node):
|
|
333
|
+
return node
|
|
334
|
+
|
|
311
335
|
|
|
312
336
|
def source_replace(source: str) -> str:
|
|
313
337
|
# 三元表达式转换成 错误版if( )else,一定得在Transformer中修正
|
|
@@ -382,7 +406,7 @@ def sources_to_asts(*sources, convert_xor: bool):
|
|
|
382
406
|
assigns.append(node)
|
|
383
407
|
continue
|
|
384
408
|
# TODO 是否要把其它语句也加入?是否有安全问题?
|
|
385
|
-
if isinstance(node, (ast.Import, ast.ImportFrom)):
|
|
409
|
+
if isinstance(node, (ast.Import, ast.ImportFrom, ast.FunctionDef, ast.ClassDef)):
|
|
386
410
|
raw.append(node)
|
|
387
411
|
continue
|
|
388
412
|
if isinstance(node, ast_comments.Comment):
|
|
@@ -18,6 +18,7 @@ from polars_ta.prefix.tdx import * # noqa
|
|
|
18
18
|
from polars_ta.prefix.ta import * # noqa
|
|
19
19
|
from polars_ta.prefix.wq import * # noqa
|
|
20
20
|
from polars_ta.prefix.cdl import * # noqa
|
|
21
|
+
from polars_ta.prefix.vec import * # noqa
|
|
21
22
|
|
|
22
23
|
DataFrame = TypeVar('DataFrame', _pl_LazyFrame, _pl_DataFrame)
|
|
23
24
|
# ===================================
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.13.0"
|
|
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
|