-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: support roots as
dict
in JSON interface
Dump roots of BDD to JSON from a `dict`, in `dd._copy.dump_json()`. Load roots of BDD from JSON into a `dict`, in `dd._copy.load_json()`. This change is motivated by readability, and that reference by name is more accessible to humans than reference by index. The previous interface used lists of root nodes of BDDs. Therefore, each root was identified by its index in a `list`. This way of referring to nodes is equivalent to having a dictionary that maps integers to root nodes. This view enables comparing to the new interface (implemented by this commit). String names as keys are more readable by humans, and memorable, than indices. This is especially so for data persistence, because the intention for storing a BDD to a (JSON) file may be archiving. So the BDD may be accessed again years later, and possibly by others. Having a string as name for each root of the BDD, instead of an integer, can communicate more information about what the BDD and its roots mean. Using strings, instead of positions (i.e., indices) also could help catch bugs when reloading the BDDs. Those bugs would be effectively implicit when lists are used, and pass without getting noticed. Explicit is better than implicit. Errors should never pass silently. In any case, the previous interface of `roots` as `list` is still supported, for any cases when a `list` would suffice, and for backward compatibility. - REF: move typing information from the docstring of the function `dd._copy._load_json()` to its signature, as type hint.
- Loading branch information
Showing
3 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters