Skip to content

Commit

Permalink
Make Cell.dependencies accept keyword args (#218)
Browse files Browse the repository at this point in the history
And fix error log bug.

Signed-off-by: Lucas Heitzmann Gabrielli <[email protected]>
  • Loading branch information
heitzmann committed Dec 1, 2023
1 parent a73f605 commit 5bf1aa2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gdstk/gdstk.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Cell:
deep_copy: bool = True,
) -> Cell: ...
def delete_property(self, name: str) -> Self: ...
def dependencies(self, recursive: bool) -> Sequence[Self | RawCell]: ...
def dependencies(self, recursive: bool = True) -> Sequence[Self | RawCell]: ...
def filter(
self,
spec: Iterable[tuple[int, int]],
Expand Down
11 changes: 7 additions & 4 deletions python/cell_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,9 +968,12 @@ static PyObject* cell_object_remap(CellObject* self, PyObject* args, PyObject* k
return (PyObject*)self;
}

static PyObject* cell_object_dependencies(CellObject* self, PyObject* args) {
int recursive;
if (!PyArg_ParseTuple(args, "p:dependencies", &recursive)) return NULL;
static PyObject* cell_object_dependencies(CellObject* self, PyObject* args, PyObject* kwds) {
int recursive = 1;
const char* keywords[] = {"recursive", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "p:dependencies", (char**)keywords, &recursive))
return NULL;

Map<Cell*> cell_map = {};
Map<RawCell*> rawcell_map = {};
self->cell->get_dependencies(recursive > 0, cell_map);
Expand Down Expand Up @@ -1038,7 +1041,7 @@ static PyMethodDef cell_object_methods[] = {
{"filter", (PyCFunction)cell_object_filter, METH_VARARGS | METH_KEYWORDS,
cell_object_filter_doc},
{"remap", (PyCFunction)cell_object_remap, METH_VARARGS | METH_KEYWORDS, cell_object_remap_doc},
{"dependencies", (PyCFunction)cell_object_dependencies, METH_VARARGS,
{"dependencies", (PyCFunction)cell_object_dependencies, METH_VARARGS | METH_KEYWORDS,
cell_object_dependencies_doc},
{"set_property", (PyCFunction)cell_object_set_property, METH_VARARGS, object_set_property_doc},
{"get_property", (PyCFunction)cell_object_get_property, METH_VARARGS, object_get_property_doc},
Expand Down
2 changes: 1 addition & 1 deletion python/docstrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2696,7 +2696,7 @@ Remap layers and data/text types for all elements in this cell.
over them with `get_dependencies`. To remap a whole libarry, use
`Library.remap`.)!");

PyDoc_STRVAR(cell_object_dependencies_doc, R"!(dependencies(recursive) -> list
PyDoc_STRVAR(cell_object_dependencies_doc, R"!(dependencies(recursive=True) -> list
List of cells and raw cells that are referenced by this cell.
Expand Down
10 changes: 6 additions & 4 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,12 @@ void convex_hull(const Array<Vec2> points, Array<Vec2>& result) {
qh_freeqhull(&qh, !qh_ALL); /* free long memory */
qh_memfreeshort(&qh, &curlong, &totlong); /* free short memory and memory allocator */
if (curlong || totlong) {
fprintf(
error_logger,
"[GDSTK] Qhull internal warning: did not free %d bytes of long memory (%d pieces)\n",
totlong, curlong);
if (error_logger) {
fprintf(
error_logger,
"[GDSTK] Qhull internal warning: did not free %d bytes of long memory (%d pieces)\n",
totlong, curlong);
}
}
#endif
}
Expand Down

0 comments on commit 5bf1aa2

Please sign in to comment.