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

Make input mismatch TypeError in make_node more readable #655

Merged
merged 1 commit into from
Nov 15, 2021

Conversation

ricardoV94
Copy link
Contributor

@ricardoV94 ricardoV94 commented Nov 4, 2021

import aesara
import aesara.tensor as at

class MyOp(aesara.graph.op.Op):
    itypes = [at.dvector, at.dvector, at.dvector]
    otypes = [at.dscalar]
    def perform(self, node, inputs, outputs):
        pass
    
MyOp()(at.vector(), at.scalar(), at.vector())

Before:

Traceback (most recent call last):
  File "/home/ricardo/Documents/Projects/aesara/venv/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3441, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-c79d16f9907a>", line 10, in <module>
    MyOp()(at.vector(), at.scalar(), at.dvector())
  File "/home/ricardo/Documents/Projects/aesara/aesara/graph/op.py", line 275, in __call__
    node = self.make_node(*inputs, **kwargs)
  File "/home/ricardo/Documents/Projects/aesara/aesara/graph/op.py", line 227, in make_node
    raise TypeError(
TypeError: We expected inputs of types '[TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, vector)]' but got types '[TensorType(float64, vector), TensorType(float64, scalar), TensorType(float64, vector)]'

After:

Traceback (most recent call last):
  File "/home/ricardo/Documents/Projects/aesara/venv/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3441, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-ddfd178ce0c4>", line 13, in <module>
    MyOp()(at.vector(), at.scalar(), at.vector())
  File "/home/ricardo/Documents/Projects/aesara/aesara/graph/op.py", line 284, in __call__
    node = self.make_node(*inputs, **kwargs)
  File "/home/ricardo/Documents/Projects/aesara/aesara/graph/op.py", line 228, in make_node
    raise TypeError(
TypeError: Invalid input types for Op MyOp:
Input 2/3: Expected TensorType(float64, vector), got TensorType(float64, scalar)

@ricardoV94 ricardoV94 force-pushed the better_msg branch 2 times, most recently from 111b46a to 13ffb0a Compare November 4, 2021 15:06
@codecov
Copy link

codecov bot commented Nov 4, 2021

Codecov Report

Merging #655 (327bd1e) into main (620edab) will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #655   +/-   ##
=======================================
  Coverage   77.15%   77.16%           
=======================================
  Files         156      156           
  Lines       47007    47007           
  Branches    10281    10281           
=======================================
+ Hits        36269    36271    +2     
+ Misses       8151     8150    -1     
+ Partials     2587     2586    -1     
Impacted Files Coverage Δ
aesara/graph/op.py 68.37% <ø> (+0.42%) ⬆️

@brandonwillard brandonwillard added enhancement New feature or request refactor This issue involves refactoring labels Nov 4, 2021
aesara/graph/op.py Outdated Show resolved Hide resolved
Copy link
Member

@brandonwillard brandonwillard left a comment

Choose a reason for hiding this comment

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

The Codecov annotation says that these changes are being tested (I also don't see a test for this in tests.graph.test_basic). If that's true, we need a test; otherwise, this is good to merge.

aesara/graph/op.py Outdated Show resolved Hide resolved
Copy link
Member

@brandonwillard brandonwillard left a comment

Choose a reason for hiding this comment

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

Looks like the regex pattern needs adjustment.

@ricardoV94
Copy link
Contributor Author

Looks like the regex pattern needs adjustment.

Weird. It was passing locally... Will have a look

@ricardoV94
Copy link
Contributor Author

It was a float32 test thing... Should be fixed now

@brandonwillard brandonwillard merged commit cbf9112 into aesara-devs:main Nov 15, 2021
@ricardoV94 ricardoV94 deleted the better_msg branch November 22, 2021 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor This issue involves refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants