Fix update_node_formatters to accept string keys matching NodeType values#8212
Open
r266-tech wants to merge 1 commit intopymc-devs:v6from
Open
Fix update_node_formatters to accept string keys matching NodeType values#8212r266-tech wants to merge 1 commit intopymc-devs:v6from
r266-tech wants to merge 1 commit intopymc-devs:v6from
Conversation
…lues The documented examples in model_to_graphviz and model_to_networkx show users passing string keys like 'Free Random Variable' and 'Observed Random Variable', but update_node_formatters only accepted NodeType enum members, raising ValueError. This fix converts string keys that match a NodeType.value to the corresponding NodeType member before validation. Fixes pymc-devs#8091
|
|
Documentation build overview
Show files changed (15 files in total): 📝 15 modified | ➕ 0 added | ➖ 0 deleted
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Fixes #8091
The function in validates keys against the enum, but the documented examples in and show users passing string keys like
"Free Random Variable"and"Observed Random Variable".Since these strings match
NodeType.valuebut are notNodeTypeenum members, the validation raises aValueError.This fix converts string keys that match a
NodeType.valueto the correspondingNodeTypemember before validation. This also makes the existing teststest_custom_node_formatting_networkxandtest_custom_node_formatting_graphvizpass, which already use string keys.Changes
update_node_formattersto convert string keys matchingNodeType.valuetoNodeTypeenum members before merging with defaults and validating.