Skip to content

Allow specializing shape of predefined tensor types #1355

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

Merged

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Apr 9, 2025

The following is now allowed

import pytensor.tensor as pt

pt.dmatrix(shape=(3, 4))

Whereas before only the generic matrix function allowed it. The reason we didn't make dmatrix and alike just helper functions like matrix was that they are used to parametrize itypes/otypes of Ops without make_node, and they need to be PyTensor types for that.


📚 Documentation preview 📚: https://pytensor--1355.org.readthedocs.build/en/1355/

@ricardoV94 ricardoV94 added the enhancement New feature or request label Apr 9, 2025
@ricardoV94 ricardoV94 changed the title Allow specializing shape of predefined tensors types Allow specializing shape of predefined tensor types Apr 9, 2025
@ricardoV94 ricardoV94 force-pushed the allow_defining_shape_of_dtyped_tensors branch from 95af427 to 5da3d0c Compare April 9, 2025 12:18
@ricardoV94 ricardoV94 force-pushed the allow_defining_shape_of_dtyped_tensors branch from 5da3d0c to 800a9bf Compare April 9, 2025 12:21
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.

Great PR, long overdue

Copy link

codecov bot commented Apr 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.04%. Comparing base (3c66aa6) to head (800a9bf).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1355   +/-   ##
=======================================
  Coverage   82.04%   82.04%           
=======================================
  Files         203      203           
  Lines       48837    48844    +7     
  Branches     8689     8691    +2     
=======================================
+ Hits        40067    40074    +7     
  Misses       6619     6619           
  Partials     2151     2151           
Files with missing lines Coverage Δ
pytensor/tensor/type.py 94.61% <100.00%> (+0.08%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ricardoV94 ricardoV94 merged commit 9578bd3 into pymc-devs:main Apr 9, 2025
73 checks passed
@ricardoV94 ricardoV94 deleted the allow_defining_shape_of_dtyped_tensors branch April 9, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants