expr-codegen 0.10.1__tar.gz → 0.10.3__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.
Files changed (34) hide show
  1. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/PKG-INFO +3 -1
  2. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/README.md +2 -0
  3. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/__init__.py +1 -0
  4. expr_codegen-0.10.3/expr_codegen/_version.py +1 -0
  5. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/codes.py +3 -1
  6. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/expr.py +4 -1
  7. {expr_codegen-0.10.1/expr_codegen/polars_over → expr_codegen-0.10.3/expr_codegen/polars_group}/template.py.j2 +8 -7
  8. {expr_codegen-0.10.1/expr_codegen/polars_group → expr_codegen-0.10.3/expr_codegen/polars_over}/template.py.j2 +8 -7
  9. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/tool.py +9 -4
  10. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen.egg-info/PKG-INFO +3 -1
  11. expr_codegen-0.10.1/expr_codegen/_version.py +0 -1
  12. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/LICENSE +0 -0
  13. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/dag.py +0 -0
  14. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/latex/__init__.py +0 -0
  15. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/latex/printer.py +0 -0
  16. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/model.py +0 -0
  17. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/pandas/__init__.py +0 -0
  18. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/pandas/code.py +0 -0
  19. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/pandas/helper.py +0 -0
  20. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/pandas/printer.py +0 -0
  21. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/pandas/ta.py +0 -0
  22. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/pandas/template.py.j2 +0 -0
  23. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/polars_group/__init__.py +0 -0
  24. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/polars_group/code.py +0 -0
  25. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/polars_group/printer.py +0 -0
  26. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/polars_over/__init__.py +0 -0
  27. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/polars_over/code.py +0 -0
  28. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen/polars_over/printer.py +0 -0
  29. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen.egg-info/SOURCES.txt +0 -0
  30. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen.egg-info/dependency_links.txt +0 -0
  31. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen.egg-info/requires.txt +0 -0
  32. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/expr_codegen.egg-info/top_level.txt +0 -0
  33. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/pyproject.toml +0 -0
  34. {expr_codegen-0.10.1 → expr_codegen-0.10.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: expr_codegen
3
- Version: 0.10.1
3
+ Version: 0.10.3
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
@@ -119,6 +119,8 @@ df = codegen_exec(df, _code_block_1, _code_block_2, output_file=sys.stdout) #
119
119
  df = codegen_exec(df, _code_block_1, _code_block_2, output_file="output.py") # 保存到文件
120
120
  df = codegen_exec(df, _code_block_1, _code_block_2) # 只执行,不保存代码
121
121
 
122
+ df = codegen_exec(df.lazy(), _code_block_1, _code_block_2).collect() # Lazy CPU
123
+ df = codegen_exec(df.lazy(), _code_block_1, _code_block_2).collect(engine="gpu") # Lazy GPU
122
124
  ```
123
125
 
124
126
  ## 目录结构
@@ -69,6 +69,8 @@ df = codegen_exec(df, _code_block_1, _code_block_2, output_file=sys.stdout) #
69
69
  df = codegen_exec(df, _code_block_1, _code_block_2, output_file="output.py") # 保存到文件
70
70
  df = codegen_exec(df, _code_block_1, _code_block_2) # 只执行,不保存代码
71
71
 
72
+ df = codegen_exec(df.lazy(), _code_block_1, _code_block_2).collect() # Lazy CPU
73
+ df = codegen_exec(df.lazy(), _code_block_1, _code_block_2).collect(engine="gpu") # Lazy GPU
72
74
  ```
73
75
 
74
76
  ## 目录结构
@@ -1 +1,2 @@
1
1
  from expr_codegen._version import __version__
2
+ from expr_codegen.tool import codegen_exec
@@ -0,0 +1 @@
1
+ __version__ = "0.10.3"
@@ -2,7 +2,7 @@ import ast
2
2
  import re
3
3
  from ast import expr
4
4
 
5
- from sympy import Add, Mul, Pow, Eq
5
+ from sympy import Add, Mul, Pow, Eq, Not, Xor
6
6
 
7
7
  from expr_codegen.expr import register_symbols, dict_to_exprs
8
8
 
@@ -372,6 +372,8 @@ def _add_default_type(globals_):
372
372
  globals_['Mul'] = Mul
373
373
  globals_['Pow'] = Pow
374
374
  globals_['Eq'] = Eq
375
+ globals_['Not'] = Not
376
+ globals_['Xor'] = Xor
375
377
  return globals_
376
378
 
377
379
 
@@ -1,6 +1,6 @@
1
1
  from functools import reduce
2
2
 
3
- from sympy import Mul, preorder_traversal, symbols, Function, simplify, Add, Basic, Symbol, sympify
3
+ from sympy import Mul, preorder_traversal, symbols, Function, simplify, Add, Basic, Symbol, sympify, FunctionClass
4
4
 
5
5
  # 预定义前缀,算子用前缀进行区分更方便。
6
6
  # 当然也可以用是否在某容器中进行分类
@@ -23,6 +23,9 @@ def is_symbol(x, globals_):
23
23
  if type(s) is type:
24
24
  # Eq
25
25
  return issubclass(s, Basic)
26
+ if isinstance(s, FunctionClass):
27
+ # Not
28
+ return True
26
29
  return False
27
30
 
28
31
 
@@ -1,13 +1,13 @@
1
1
  # this code is auto generated by the expr_codegen
2
2
  # https://github.com/wukan1986/expr_codegen
3
3
  # 此段代码由 expr_codegen 自动生成,欢迎提交 issue 或 pull request
4
+ from typing import TypeVar
4
5
 
5
- import numpy as np # noqa
6
- import pandas as pd # noqa
7
6
  import polars as pl # noqa
8
7
  import polars.selectors as cs # noqa
9
- from loguru import logger # noqa
10
-
8
+ # from loguru import logger # noqa
9
+ from polars import DataFrame as _pl_DataFrame
10
+ from polars import LazyFrame as _pl_LazyFrame
11
11
  # ===================================
12
12
  # 导入优先级,例如:ts_RSI在ta与talib中都出现了,优先使用ta
13
13
  # 运行时,后导入覆盖前导入,但IDE智能提示是显示先导入的
@@ -18,6 +18,7 @@ from polars_ta.prefix.ta import * # noqa
18
18
  from polars_ta.prefix.wq import * # noqa
19
19
  from polars_ta.prefix.cdl import * # noqa
20
20
 
21
+ DataFrame = TypeVar('DataFrame', _pl_LazyFrame, _pl_DataFrame)
21
22
  # ===================================
22
23
 
23
24
  {{ syms1 }}
@@ -38,7 +39,7 @@ def unpack(x: Expr, idx: int = 0) -> Expr:
38
39
  {% endfor %}
39
40
 
40
41
  {% for key, value in funcs.items() %}
41
- def {{ key }}(df: pl.DataFrame) -> pl.DataFrame:
42
+ def {{ key }}(df: DataFrame) -> DataFrame:
42
43
  {{ value }}
43
44
  return df
44
45
  {% endfor %}
@@ -56,7 +57,7 @@ def {{ key }}(df: pl.DataFrame) -> pl.DataFrame:
56
57
  """
57
58
 
58
59
 
59
- def main(df: pl.DataFrame) -> pl.DataFrame:
60
+ def main(df: DataFrame) -> DataFrame:
60
61
  # logger.info("start...")
61
62
  {% for key, value in groupbys.items() %}
62
63
  {{ value-}}
@@ -68,7 +69,7 @@ def main(df: pl.DataFrame) -> pl.DataFrame:
68
69
 
69
70
  # shrink
70
71
  df = df.select(cs.all().shrink_dtype())
71
- df = df.shrink_to_fit()
72
+ # df = df.shrink_to_fit()
72
73
 
73
74
  # logger.info('done')
74
75
 
@@ -1,13 +1,13 @@
1
1
  # this code is auto generated by the expr_codegen
2
2
  # https://github.com/wukan1986/expr_codegen
3
3
  # 此段代码由 expr_codegen 自动生成,欢迎提交 issue 或 pull request
4
+ from typing import TypeVar
4
5
 
5
- import numpy as np # noqa
6
- import pandas as pd # noqa
7
6
  import polars as pl # noqa
8
7
  import polars.selectors as cs # noqa
9
- from loguru import logger # noqa
10
-
8
+ # from loguru import logger # noqa
9
+ from polars import DataFrame as _pl_DataFrame
10
+ from polars import LazyFrame as _pl_LazyFrame
11
11
  # ===================================
12
12
  # 导入优先级,例如:ts_RSI在ta与talib中都出现了,优先使用ta
13
13
  # 运行时,后导入覆盖前导入,但IDE智能提示是显示先导入的
@@ -18,6 +18,7 @@ from polars_ta.prefix.ta import * # noqa
18
18
  from polars_ta.prefix.wq import * # noqa
19
19
  from polars_ta.prefix.cdl import * # noqa
20
20
 
21
+ DataFrame = TypeVar('DataFrame', _pl_LazyFrame, _pl_DataFrame)
21
22
  # ===================================
22
23
 
23
24
  {{ syms1 }}
@@ -38,7 +39,7 @@ def unpack(x: Expr, idx: int = 0) -> Expr:
38
39
  {% endfor %}
39
40
 
40
41
  {% for key, value in funcs.items() %}
41
- def {{ key }}(df: pl.DataFrame) -> pl.DataFrame:
42
+ def {{ key }}(df: DataFrame) -> DataFrame:
42
43
  {{ value }}
43
44
  return df
44
45
  {% endfor %}
@@ -56,7 +57,7 @@ def {{ key }}(df: pl.DataFrame) -> pl.DataFrame:
56
57
  """
57
58
 
58
59
 
59
- def main(df: pl.DataFrame) -> pl.DataFrame:
60
+ def main(df: DataFrame) -> DataFrame:
60
61
  # logger.info("start...")
61
62
  {% for key, value in groupbys.items() %}
62
63
  {{ value-}}
@@ -68,7 +69,7 @@ def main(df: pl.DataFrame) -> pl.DataFrame:
68
69
 
69
70
  # shrink
70
71
  df = df.select(cs.all().shrink_dtype())
71
- df = df.shrink_to_fit()
72
+ # df = df.shrink_to_fit()
72
73
 
73
74
  # logger.info('done')
74
75
 
@@ -19,10 +19,12 @@ except ImportError:
19
19
 
20
20
  try:
21
21
  from polars import DataFrame as _pl_DataFrame
22
+ from polars import LazyFrame as _pl_LazyFrame
22
23
  except ImportError:
23
24
  _pl_DataFrame = None
25
+ _pl_LazyFrame = None
24
26
 
25
- DataFrame = TypeVar('DataFrame', _pl_DataFrame, _pd_DataFrame)
27
+ DataFrame = TypeVar('DataFrame', _pl_LazyFrame, _pl_DataFrame, _pd_DataFrame)
26
28
 
27
29
  # ===============================
28
30
  # TypeError: expecting bool or Boolean, not `ts_delay(X, 3)`.
@@ -127,11 +129,12 @@ class ExprTool:
127
129
 
128
130
  exprs_dict = {}
129
131
 
130
- # 不做改动,直接生成
132
+ # cse前简化一次,cse后不再简化
133
+ # (~开盘涨停 & 昨收涨停) | (~收盘涨停 & 最高涨停)
131
134
  for variable, expr in repl:
132
- exprs_dict[variable] = simplify2(expr)
135
+ exprs_dict[variable] = expr
133
136
  for variable, expr in redu:
134
- exprs_dict[variable] = simplify2(expr)
137
+ exprs_dict[variable] = expr
135
138
 
136
139
  return exprs_dict
137
140
 
@@ -322,6 +325,8 @@ def codegen_exec(df: Optional[DataFrame],
322
325
  ^ 转成异或还是乘方
323
326
  style: str
324
327
  代码风格。可选值 'pandas', 'polars_group', 'polars_over'
328
+ - polars_group: 不支持Lazy
329
+ - pandas: 不支持struct
325
330
  template_file: str
326
331
  代码模板
327
332
  date: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: expr_codegen
3
- Version: 0.10.1
3
+ Version: 0.10.3
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
@@ -119,6 +119,8 @@ df = codegen_exec(df, _code_block_1, _code_block_2, output_file=sys.stdout) #
119
119
  df = codegen_exec(df, _code_block_1, _code_block_2, output_file="output.py") # 保存到文件
120
120
  df = codegen_exec(df, _code_block_1, _code_block_2) # 只执行,不保存代码
121
121
 
122
+ df = codegen_exec(df.lazy(), _code_block_1, _code_block_2).collect() # Lazy CPU
123
+ df = codegen_exec(df.lazy(), _code_block_1, _code_block_2).collect(engine="gpu") # Lazy GPU
122
124
  ```
123
125
 
124
126
  ## 目录结构
@@ -1 +0,0 @@
1
- __version__ = "0.10.1"
File without changes
File without changes