Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typing in multiple places #7333

Merged
merged 2 commits into from
May 24, 2024
Merged

Conversation

michaelosthege
Copy link
Member

@michaelosthege michaelosthege commented May 23, 2024

Description

Fixes to type hints, mostly in printing.py and logprob/order.py.

Checklist

Type of change

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

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

Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a small discussion point on naming conventions

@@ -28,7 +28,7 @@
from pytensor import tensor as pt
from pytensor.compile.builders import OpFromGraph
from pytensor.graph import FunctionGraph, clone_replace, node_rewriter
from pytensor.graph.basic import Node, Variable, io_toposort
from pytensor.graph.basic import Apply, Variable, io_toposort
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only comment: it's a bit awkward to have variables called node typed as Apply instead of Node. I was thinking you could do an alias here: from pytensor.graph.basic import Apply as ApplyNode to make the type hints a bit more obvious? Or maybe that's a name change that we should consider at the pytensor level @ricardoV94 . It would match Variable -> TensorVariable that way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node is a bit of useless baseclass for Apply and Variable. The only thing shared between the two is the get_parents. We definitely like to call Apply(Node) nodes in the codebase, and never corresponding Variable(Node) nodes, or variable nodes. I think this gives us so little that we could remove the shared base class and only have Variables and Nodes (although I understand why they wanted to call a Variable a node as well). Anyway that should be a discussion on the PyTensor side, I don't think PyMC should invent new names here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree, I'll raise an issue on the pytensor side about typing generally. @michaelosthege please ignore my comment, PR looks good to go

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. I agree that things should be improved on the PyTensor side. The type hinting is a bit of a mess down there too.

@michaelosthege michaelosthege merged commit a197b19 into pymc-devs:main May 24, 2024
20 checks passed
@michaelosthege michaelosthege deleted the type-fixes branch May 24, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants