Skip to main content

Useful tools for parsing Python programs for algorithm design.

Project description

Useful tools for parsing Python programs for algorithm design


This repo aims to help develop more powerful Large Language Models for Algorithm Design (LLM4AD) applications.

More tools will be provided soon.


The figure demonstrates how a Python program is parsed into PyScript, PyFunction, PyClass, and PyProgram via adtools.

pycode


Installation

[!TIP]

It is recommended to use Python >= 3.10.

Run the following instructions to install adtools.

pip install git+https://github.com/RayZhhh/adtool.git

Usage

Parse your code (in string) into Python code instances.

from adtools import PyProgram

code = r'''
import ast
import numpy as np

def func():
    a = 5
    return a + a

class A(B):
    a=1
    
    @yes()
    @deco()
    def __init__(self):
        pass

    def method(self):
        pass
    
    b=2
'''

p = PyProgram.from_text(code)
print(p)
print(f'-------------------------------------')
print(p.classes[0].functions[0].decorator)
print(f'-------------------------------------')
print(p.functions[0].name)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_adtools-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_adtools-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file py_adtools-0.1.0.tar.gz.

File metadata

  • Download URL: py_adtools-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for py_adtools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 456829c9466fa65cb24ccbe9e276f51cdf439f8bf38af81a4f800ec22d04a08a
MD5 0bef15166472b895d2250a7567175211
BLAKE2b-256 2fe9f4c28ad9ddddec58d79eefcdb1bd8acc6a3995e7ed1ebd862df94f595b85

See more details on using hashes here.

File details

Details for the file py_adtools-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_adtools-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for py_adtools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1f5bf4244e8262aaa57227463fde7a7eff146d717e4c10b78f99234284ac57a
MD5 204c0235a4ef6d0b3b3e30dab94c70b1
BLAKE2b-256 365e463f4a2ad397cb59006b8db8c4d29e094f59e6ce831c50b45cc8a2600a36

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page