Skip to content

Fix update_node_formatters to accept string keys matching NodeType values#8212

Open
r266-tech wants to merge 1 commit intopymc-devs:v6from
r266-tech:fix-update-node-formatters-string-keys
Open

Fix update_node_formatters to accept string keys matching NodeType values#8212
r266-tech wants to merge 1 commit intopymc-devs:v6from
r266-tech:fix-update-node-formatters-string-keys

Conversation

@r266-tech
Copy link
Copy Markdown

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.value but are not NodeType enum members, the validation raises a ValueError.

This fix converts string keys that match a NodeType.value to the corresponding NodeType member before validation. This also makes the existing tests test_custom_node_formatting_networkx and test_custom_node_formatting_graphviz pass, which already use string keys.

Changes

  • Modified update_node_formatters to convert string keys matching NodeType.value to NodeType enum members before merging with defaults and validating.

…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
@welcome
Copy link
Copy Markdown

welcome bot commented Mar 23, 2026

Thank You Banner]
💖 Thanks for opening this pull request! 💖 The PyMC community really appreciates your time and effort to contribute to the project. Please make sure you have read our Contributing Guidelines and filled in our pull request template to the best of your ability.

@github-actions github-actions bot added the bug label Mar 23, 2026
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 pymc | 🛠️ Build #31931602 | 📁 Comparing 45adb7a against latest (8a1896b)


🔍 Preview build

Show files changed (15 files in total): 📝 15 modified | ➕ 0 added | ➖ 0 deleted
File Status
glossary.html 📝 modified
_modules/pymc/model_graph.html 📝 modified
api/generated/pymc.draw.html 📝 modified
api/generated/pymc.icdf.html 📝 modified
api/generated/pymc.logcdf.html 📝 modified
api/generated/pymc.logp.html 📝 modified
api/generated/pymc.sample_posterior_predictive.html 📝 modified
api/generated/pymc.sample_prior_predictive.html 📝 modified
_modules/pymc/distributions/distribution.html 📝 modified
_modules/pymc/logprob/basic.html 📝 modified
_modules/pymc/model/core.html 📝 modified
_modules/pymc/sampling/forward.html 📝 modified
_modules/pymc/smc/sampling.html 📝 modified
api/distributions/generated/classmethods/pymc.SymbolicRandomVariable.update.html 📝 modified
api/model/generated/classmethods/pymc.model.core.Model.compile_fn.html 📝 modified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: update_node_formatters rejects documented string keys in pymc/model_graph.py

1 participant