Skip to content

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

Open
@hoel-bagard

Description

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

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions