Skip to content

tensorflow: Tensor.__bool__'s signature is incorrect for one element tensors #13365

@hoel-bagard

Description

@hoel-bagard

CurrentlyTensor.__bool__'s signature is as follows:

class Tensor:
    def __bool__(self) -> NoReturn: ...

It suggests that the method should never be called, however the following is valid code:

import tensorflow as tf

bool(tf.constant([1]))

Since this depends on the shape of the tensor, I don't know if this can be fixed, but it would be nice to have.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions