FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: tensor equals type raises exception by JohannesMessner · Pull Request #1739 · docarray/docarray · GitHub

fix: tensor equals type raises exception - #1739

Merged
JoanFM merged 4 commits into
mainfrom
fix-tensor-equals-type
Jul 31, 2023
Merged

fix: tensor equals type raises exception#1739
JoanFM merged 4 commits into
mainfrom
fix-tensor-equals-type

Conversation

Copy link
Copy Markdown
Member

Currently the following raises and exception:

from docarray.typing import TorchTensor

TorchTensor == type
Traceback (most recent call last):
  File "/home/johannes/.config/JetBrains/PyCharmCE2023.2/scratches/scratch_183.py", line 3, in <module>
    TorchTensor == type
  File "/home/johannes/Documents/jina/docarrayv2/docarray/typing/tensor/abstract_tensor.py", line 101, in __eq__
    if cls._equals_special_case(other):
  File "/home/johannes/Documents/jina/docarrayv2/docarray/typing/tensor/abstract_tensor.py", line 62, in _equals_special_case
    is_tensor = is_type and AbstractTensor in other.mro()
TypeError: descriptor 'mro' of 'type' object needs an argument

This fixes that

Signed-off-by: Johannes Messner <messnerjo@gmail.com>
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
Signed-off-by: Johannes Messner <messnerjo@gmail.com>

codecov Bot commented Jul 31, 2023
edited
Loading

Copy link
Copy Markdown

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (7be038c) 84.45% compared to head (55ba014) 84.46%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1739      +/-   ##
==========================================
+ Coverage   84.45%   84.46%   +0.01%     
==========================================
  Files         134      134              
  Lines        8840     8840              
==========================================
+ Hits         7466     7467       +1     
+ Misses       1374     1373       -1     
Flag Coverage Δ
docarray 84.46% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
docarray/typing/tensor/abstract_tensor.py 91.41% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

)
return any(issubclass(candidate, cls) for candidate in type(instance).mro())
return any(
issubclass(candidate, cls) for candidate in type(instance).__mro__

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

us safe version of is_subclass please

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

i am not sure if we want that here. This implements the "normal" isinstance() call, so i don't think it should work with non-class inputs. For example, the following also raises an exception:

isinstance(3, List[int])
TypeError: Subscripted generics cannot be used with class and instance checks

So I would not catch such things here

Signed-off-by: Johannes Messner <messnerjo@gmail.com>

Copy link
Copy Markdown

📝 Docs are deployed on https://ft-fix-tensor-equals-type--jina-docs.netlify.app 🎉

JoanFM merged commit d2c82d4 into main Jul 31, 2023
JoanFM deleted the fix-tensor-equals-type branch July 31, 2023 15:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL