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 stack type hints #205

Merged
merged 1 commit into from
Feb 5, 2023
Merged

Conversation

covertg
Copy link
Contributor

@covertg covertg commented Feb 3, 2023

Seeking to address #193, making type hints for pt.stack more accurate.

Implementation details

I chose to type hint as TensorLike, defined here as Variable | Sequence[Variable] | npt.ArrayLike. I hope this will address all cases that mypy was complaining about. I also updated the docs and errors accordingly.

Lastly, because there was a case that coerces a list of zero-dim Variables into MakeVector, I also allowed a parallel case of zero-dim numpy arrays to use MakeVector rather than Join and updated a test to cover this case.

Checklist

Major / Breaking Changes

  • na

New features

  • pt.stack([np.array(1), np.array(2)]) will use MakeVector rather than Join

Bugfixes

  • More accurate type hints

Documentation

  • ...

Maintenance

  • ...

Please let me know if you have any feedback!

@codecov-commenter
Copy link

Codecov Report

Merging #205 (548e94f) into main (a6e7722) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #205   +/-   ##
=======================================
  Coverage   80.06%   80.06%           
=======================================
  Files         170      170           
  Lines       45185    45185           
  Branches     9608     9608           
=======================================
+ Hits        36176    36178    +2     
+ Misses       6794     6793    -1     
+ Partials     2215     2214    -1     
Impacted Files Coverage Δ
pytensor/tensor/basic.py 90.62% <100.00%> (+0.13%) ⬆️

@michaelosthege michaelosthege added the enhancement New feature or request label Feb 5, 2023
Copy link
Member

@michaelosthege michaelosthege left a comment

Choose a reason for hiding this comment

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

Thanks, @covertg this is looking good.

When upgrading PyMC to the next PyTensor release we can then revert part of pymc-devs/pymc@e062237

@michaelosthege michaelosthege changed the title Type updates for stack (addresses #193) Fix pt.stack type hints Feb 5, 2023
@michaelosthege michaelosthege merged commit 5628ab1 into pymc-devs:main Feb 5, 2023
@ricardoV94 ricardoV94 added maintenance and removed enhancement New feature or request labels Feb 15, 2023
@ricardoV94 ricardoV94 changed the title Fix pt.stack type hints Fix stack type hints Feb 15, 2023
michaelosthege added a commit to ricardoV94/pymc that referenced this pull request Feb 18, 2023
ricardoV94 pushed a commit to ricardoV94/pymc that referenced this pull request Feb 21, 2023
ricardoV94 pushed a commit to ricardoV94/pymc that referenced this pull request Feb 21, 2023
ricardoV94 pushed a commit to ricardoV94/pymc that referenced this pull request Feb 27, 2023
ricardoV94 pushed a commit to pymc-devs/pymc that referenced this pull request Feb 28, 2023
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.

4 participants