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

[Python] FixedShapeTensorType.ToString() should print the type's parameters #35623

Closed
spenczar opened this issue May 16, 2023 · 1 comment · Fixed by #36496
Closed

[Python] FixedShapeTensorType.ToString() should print the type's parameters #35623

spenczar opened this issue May 16, 2023 · 1 comment · Fixed by #36496

Comments

@spenczar
Copy link
Contributor

Describe the enhancement requested

Earlier today, I ran into this confusing error message:
ArrowTypeError: Casting from 'extension<arrow.fixed_shape_tensor>' to different extension type 'extension<arrow.fixed_shape_tensor>' not permitted. One can first cast to the storage type, then to the extension type.

Those look like the same extension type to me, what is going on?

In truth, they had different shapes. One was shaped (6, 6) while the other was shaped (36,).

It would have been clearer if I had an error message like this:

ArrowTypeError: Casting from 'extension<arrow.fixed_shape_tensor<shape=[6,6],type=float64>' to different extension type 'extension<arrow.fixed_shape_tensor<shape=[36],type=float64>' not permitted. One can first cast to the storage type, then to the extension type.

That bit I'm suggesting should change appears to be coming from __str__: https://github.com/apache/arrow/blob/505a2e4519ba8d4983da6caa1c56ecae8d063e84/python/pyarrow/types.pxi#LL220C39-L220C39. It would be nice if FixedShapeTensorType had a custom __str__ implementation which revealed its parameters.

Component(s)

Python

@AlenkaF
Copy link
Member

AlenkaF commented Jun 19, 2023

@spenczar would you be interested in submitting a PR?

@AlenkaF AlenkaF self-assigned this Jul 5, 2023
@AlenkaF AlenkaF modified the milestones: 13.0.0, 14.0.0 Jul 6, 2023
AlenkaF added a commit that referenced this issue Oct 9, 2023
…the type's parameters (#36496)

### Rationale for this change

The string representation of two different `FixedShapeTensorType` objects is currently the same: `extension<arrow.fixed_shape_tensor>`.

### What changes are included in this PR?

Override general type `ToString()` method for `FixedShapeTensorType`. The string representation of a tensor in this PR is proposed as follows:

``` 
extension<arrow.fixed_shape_tensor[value_type=*, shape=[*]]
```
### Are these changes tested?

Yes, in Python and in C++.

### Are there any user-facing changes?

No.
* Closes: #35623

Lead-authored-by: AlenkaF <frim.alenka@gmail.com>
Co-authored-by: Alenka Frim <AlenkaF@users.noreply.github.com>
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Signed-off-by: AlenkaF <frim.alenka@gmail.com>
JerAguilon pushed a commit to JerAguilon/arrow that referenced this issue Oct 23, 2023
…print the type's parameters (apache#36496)

### Rationale for this change

The string representation of two different `FixedShapeTensorType` objects is currently the same: `extension<arrow.fixed_shape_tensor>`.

### What changes are included in this PR?

Override general type `ToString()` method for `FixedShapeTensorType`. The string representation of a tensor in this PR is proposed as follows:

``` 
extension<arrow.fixed_shape_tensor[value_type=*, shape=[*]]
```
### Are these changes tested?

Yes, in Python and in C++.

### Are there any user-facing changes?

No.
* Closes: apache#35623

Lead-authored-by: AlenkaF <frim.alenka@gmail.com>
Co-authored-by: Alenka Frim <AlenkaF@users.noreply.github.com>
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Signed-off-by: AlenkaF <frim.alenka@gmail.com>
loicalleyne pushed a commit to loicalleyne/arrow that referenced this issue Nov 13, 2023
…print the type's parameters (apache#36496)

### Rationale for this change

The string representation of two different `FixedShapeTensorType` objects is currently the same: `extension<arrow.fixed_shape_tensor>`.

### What changes are included in this PR?

Override general type `ToString()` method for `FixedShapeTensorType`. The string representation of a tensor in this PR is proposed as follows:

``` 
extension<arrow.fixed_shape_tensor[value_type=*, shape=[*]]
```
### Are these changes tested?

Yes, in Python and in C++.

### Are there any user-facing changes?

No.
* Closes: apache#35623

Lead-authored-by: AlenkaF <frim.alenka@gmail.com>
Co-authored-by: Alenka Frim <AlenkaF@users.noreply.github.com>
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Signed-off-by: AlenkaF <frim.alenka@gmail.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…print the type's parameters (apache#36496)

### Rationale for this change

The string representation of two different `FixedShapeTensorType` objects is currently the same: `extension<arrow.fixed_shape_tensor>`.

### What changes are included in this PR?

Override general type `ToString()` method for `FixedShapeTensorType`. The string representation of a tensor in this PR is proposed as follows:

``` 
extension<arrow.fixed_shape_tensor[value_type=*, shape=[*]]
```
### Are these changes tested?

Yes, in Python and in C++.

### Are there any user-facing changes?

No.
* Closes: apache#35623

Lead-authored-by: AlenkaF <frim.alenka@gmail.com>
Co-authored-by: Alenka Frim <AlenkaF@users.noreply.github.com>
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Signed-off-by: AlenkaF <frim.alenka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants