Skip to content

Commit

Permalink
MAI: improve error message and documentation
Browse files Browse the repository at this point in the history
The error about requested memory did not
explain how to select the requested memory
when instantiating the class `dd.cudd.BDD`.
  • Loading branch information
johnyf committed Oct 10, 2020
1 parent c042cf1 commit 22536e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dd/cudd.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,17 @@ cdef class BDD(object):
if memory_estimate is None:
memory_estimate = default_memory
if memory_estimate >= total_memory:
print(
print((
'Error in `dd.cudd`: '
'total physical memory is {t} bytes, '
'but requested {r} bytes').format(
'but requested {r} bytes. '
'Please pass an amount of memory to '
'the `BDD` constructor to avoid this error. '
'For example, by instantiating '
'the `BDD` manager as `BDD({q})`.').format(
t=total_memory,
r=memory_estimate)
r=memory_estimate,
q=round(total_memory / 2)))
assert memory_estimate < total_memory, (
memory_estimate, total_memory)
if initial_cache_size is None:
Expand Down
3 changes: 3 additions & 0 deletions doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,9 @@ heuristics for deciding *when* to invoke reordering.
CUDD is initialized with a `memory_estimate` of 1 GB. If the machine has les
RAM, then `cudd.BDD` will raise an error. In this case, pass a smaller initial
memory estimate, for example `cudd.BDD(memory_estimate=0.5 * 2**30)`.
The package [`humanize`](https://pypi.org/project/humanize/) is useful for
reading memory sizes, for example `humanize.naturalsize(1073741824, gnu=True)`
returns `'1.0G'`.


### Functions
Expand Down

0 comments on commit 22536e1

Please sign in to comment.