Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage consulting of this library: Rust backend panicked with exception: assertion failed: !res.contains(&format!(\" {prim} \")) #8

Open
bofei5675 opened this issue Oct 27, 2023 · 0 comments

Comments

@bofei5675
Copy link

I write a simple python program to compress my program dataset. I'd like to iteratively reduce my library such that I don't need to wait too long for intermediate result.

This is an example of my script.

from stitch_core import compress, rewrite
import json
import pandas as pd
import numpy as np

def process():
    epoch = 100
    df = pd.read_csv('dataset.csv')
    programs = df['programs'].tolist()
    avg_length = np.mean([len(i) for i in programs])
    print('compress result avg length:',avg_length)
    for i in range(epoch):
        res = compress(programs, iterations=10, max_arity=2, slient=False)
        # print(res)
        # print(res.json)
        print('-' * 100)
        n_abst = len(res.abstractions)
        print('total abstraction', n_abst)
        print('rewrite')
        programs_rewrite = rewrite(programs, res.abstractions)
        programs = programs_rewrite.rewritten
        print('rewrite programs', len(programs))
        with open(f'output/result_epoch_{i}.json', 'w') as f:
            json.dump(programs_rewrite.json, f, indent=4)
        avg_length = np.mean([len(i) for i in programs])
        print('compress result avg length:',avg_length)

This loop executes well in the beginning and throw error when epoch=19:

Traceback (most recent call last):
  File "/home/bofei-zhang/miniconda3/envs/plcn/lib/python3.9/site-packages/stitch_core/__init__.py", line 303, in compress
    res = compress_backend(
pyo3_runtime.PanicException: assertion failed: !res.contains(&format!(\" {prim} \"))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/bofei-zhang/Documents/Project/Projects/concept_learning/pl-cn/experiments/stitch_pl/process.py", line 142, in <module>
    process()
  File "/home/bofei-zhang/Documents/Project/Projects/concept_learning/pl-cn/experiments/stitch_pl/process.py", line 125, in process
    res = compress(programs, iterations=10, max_arity=2, slient=False)
  File "/home/bofei-zhang/miniconda3/envs/plcn/lib/python3.9/site-packages/stitch_core/__init__.py", line 311, in compress
    raise StitchException(f"Rust backend panicked with exception: {e}")
stitch_core.StitchException: Rust backend panicked with exception: assertion failed: !res.contains(&format!(\" {prim} \"))

Please kindly advise how to address this issue.

@bofei5675 bofei5675 changed the title Usage consulting of this library Usage consulting of this library: Rust backend panicked with exception: assertion failed: !res.contains(&format!(\" {prim} \")) Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant