提交 7d738cf2 编写于 作者: HansBug's avatar HansBug 😆

dev(hansbug): add support for treevalue[potc]

上级 588c5366
......@@ -32,7 +32,16 @@ You can simply install it with `pip` command line from the official PyPI site.
pip install treevalue
```
For more information about installation, you can refer to [Installation](https://opendilab.github.io/treevalue/main/tutorials/installation/index.html#).
If you want to link with the [potc](https://github.com/potc-dev/potc) package so that treevalue can support source code conversion, you can use the following command to install it.
```shell
pip install treevalue[potc]
```
For more information about installation, you can refer to
* [Installation](https://opendilab.github.io/treevalue/main/tutorials/installation/index.html)
* [Potc Plugin Installation](https://opendilab.github.io/treevalue/main/tutorials/plugins/index.html#potc-support)
## Documentation
......
......@@ -19,6 +19,7 @@ structure processing when the calculation is tree-based.
tutorials/basic_usage/index
tutorials/advanced_usage/index
tutorials/cli_usage/index
tutorials/plugins/index
.. toctree::
......
Plugins
===============
Potc support
---------------------
`Potc <https://github.com/potc-dev/potc>`_ is a package that can convert any object into executable source code.
For ``treevalue``, potc can support the source code transformation of treevalue objects through
the installation of additional plugins. So we can execute the following installation command
.. code:: shell
pip install treevalue[potc]
After this installation, you will be able to directly convert treevalue to an object without any additional operations.
Such as
.. literalinclude:: ./potc_demo.demo.py
:language: python
:linenos:
The output should be
.. literalinclude:: ./potc_demo.demo.py.txt
:language: text
:linenos:
Also, you can use the following CLI command to get the same output results as above.
.. code:: shell
potc export -v 'test_simple.t' -v 'test_simple.st' -v 'test_simple.r'
For further information, you can refer to
* `potc-dev/potc <https://github.com/potc-dev/potc>`_
* `potc-dev/potc-treevalue <https://github.com/potc-dev/potc-treevalue>`_
from potc import transvars
from treevalue import FastTreeValue, raw
r = raw({'a': 1, 'b': 2, 'c': [3, 4]})
t = FastTreeValue({
'a': 1, 'b': 'this is a string',
'c': [], 'd': {
'x': raw({'a': 1, 'b': (None, Ellipsis)}),
'y': {3, 4, 5}
}
})
st = t._detach()
if __name__ == '__main__':
_code = transvars(
{'t': t, 'st': t._detach(), 'r': r},
reformat='pep8'
)
print(_code)
......@@ -8,4 +8,5 @@ sphinx-multiversion~=0.2.4
where~=1.0.2
numpy>=1.19,<2
easydict>=1.7,<2
scikit-learn>=0.24.2
\ No newline at end of file
scikit-learn>=0.24.2
potc-treevalue>=0.0.1
\ No newline at end of file
potc-treevalue>=0.0.1
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册