summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBaruch Sterin <baruchs@gmail.com>2012-02-23 11:09:57 -0800
committerBaruch Sterin <baruchs@gmail.com>2012-02-23 11:09:57 -0800
commitb879786e73220e835aed1673ff9f9abaadf73d4e (patch)
treeaaf223a00672a6972d6345c8b9396902cee7ee29 /src
parent1d25ae3b1a197a15cdba6c8c206bcd050608a4f0 (diff)
downloadabc-b879786e73220e835aed1673ff9f9abaadf73d4e.tar.gz
abc-b879786e73220e835aed1673ff9f9abaadf73d4e.tar.bz2
abc-b879786e73220e835aed1673ff9f9abaadf73d4e.zip
pyabc: added a function pyabc.iso_eq_classes() that retrieves the results of the "&iso" command
Diffstat (limited to 'src')
-rw-r--r--src/python/pyabc.i40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/python/pyabc.i b/src/python/pyabc.i
index a4c8c347..37501a75 100644
--- a/src/python/pyabc.i
+++ b/src/python/pyabc.i
@@ -252,6 +252,44 @@ int _cex_get_frame(Abc_Cex_t* pCex)
return pCex->iFrame;
}
+static PyObject* VecInt_To_PyList(Vec_Int_t* v)
+{
+ PyObject* pylist = PyList_New( Vec_IntSize(v) );
+
+ int elem, i;
+
+ Vec_IntForEachEntry( v, elem, i)
+ {
+ PyList_SetItem( pylist, i, PyInt_FromLong(elem) );
+ }
+
+ return pylist;
+}
+
+PyObject* iso_eq_classes()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ Vec_Ptr_t *vPoEquivs = Abc_FrameReadPoEquivs(pAbc);
+
+ PyObject* eq_classes;
+ Vec_Int_t* pEntry;
+ int i;
+
+ if( ! vPoEquivs )
+ {
+ Py_RETURN_NONE;
+ }
+
+ eq_classes = PyList_New( Vec_PtrSize(vPoEquivs) );
+
+ Vec_PtrForEachEntry( Vec_Int_t*, vPoEquivs, pEntry, i )
+ {
+ PyList_SetItem( eq_classes, i, VecInt_To_PyList(pEntry) );
+ }
+
+ return eq_classes;
+}
+
static PyObject* pyabc_internal_python_command_callback = 0;
void pyabc_internal_set_command_callback( PyObject* callback )
@@ -571,6 +609,8 @@ int _cex_n_pis(Abc_Cex_t* pCex);
int _cex_get_po(Abc_Cex_t* pCex);
int _cex_get_frame(Abc_Cex_t* pCex);
+PyObject* iso_eq_classes();
+
void pyabc_internal_set_command_callback( PyObject* callback );
void pyabc_internal_register_command( char * sGroup, char * sName, int fChanges );