Skip to content

Conversation

@osyuksel
Copy link
Contributor

@osyuksel osyuksel commented Jul 17, 2025

Description

This change:

  • Replaces VarName type with built-in str
  • Updates get_var_name to have it work without getattr

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pymc--7855.org.readthedocs.build/en/7855/

@osyuksel
Copy link
Contributor Author

osyuksel commented Jul 17, 2025

I also attempted to address the second point re. getattr(variable, "name") in the issue with this commit, however, making an explicit attribute reference (i.e. calling var.name instead of getattr) causes the tests to fail, so I assume there must be some variables where the attribute is not present.

==================================== ERRORS ====================================
__________________ ERROR collecting tests/test_model_graph.py __________________
tests/test_model_graph.py:467: in <module>
    class TestVariableSelection:
tests/test_model_graph.py:499: in TestVariableSelection
    ModelGraph(model_with_different_descendants()).vars_to_plot(),
pymc/model_graph.py:238: in __init__
    self._all_var_names = get_default_varnames(self.model.named_vars, include_transformed=False)
pymc/util.py:212: in get_default_varnames
    return [var for var in var_iterator if not is_transformed_name(get_var_name(var))]
pymc/util.py:217: in get_var_name
    return str(var.name if var.name is not None else var)
E   AttributeError: 'str' object has no attribute 'name'

@osyuksel osyuksel changed the title Remove VarName for codebase Replace VarName with built-in str Jul 17, 2025
@osyuksel osyuksel marked this pull request as ready for review July 17, 2025 12:07
@ricardoV94
Copy link
Member

That should check explicitly if the input is a string, instead of trying to call var.name on it

@osyuksel
Copy link
Contributor Author

Makes sense, missed that var could be str. Updated PR.

@codecov
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.48%. Comparing base (3a0186e) to head (32445d1).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7855   +/-   ##
=======================================
  Coverage   91.47%   91.48%           
=======================================
  Files         116      116           
  Lines       18947    18946    -1     
=======================================
  Hits        17332    17332           
+ Misses       1615     1614    -1     
Files with missing lines Coverage Δ
pymc/model/core.py 93.30% <100.00%> (ø)
pymc/model_graph.py 84.53% <100.00%> (ø)
pymc/util.py 81.11% <100.00%> (-0.09%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ricardoV94 ricardoV94 added the major Include in major changes release notes section label Jul 27, 2025
@ricardoV94 ricardoV94 merged commit b131236 into pymc-devs:main Nov 8, 2025
26 checks passed
@ricardoV94
Copy link
Member

This got forgotten but thanks @osyuksel

@ricardoV94 ricardoV94 mentioned this pull request Nov 10, 2025
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance major Include in major changes release notes section

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove VarName from codebase

2 participants