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

empty Fsas and RaggedTensors are truthy #1195

Open
svandiekendialpad opened this issue May 11, 2023 · 0 comments
Open

empty Fsas and RaggedTensors are truthy #1195

svandiekendialpad opened this issue May 11, 2023 · 0 comments

Comments

@svandiekendialpad
Copy link

svandiekendialpad commented May 11, 2023

I encountered a case where best_paths = k2.shortest_path(fsa, use_double_scores=True) can return an emtpy Fsa and was surprised that bool(best_paths) returns True.
Is this by design or would you consider adding something like:

class Fsa(object):
    [...]
    def __bool__(self) -> bool:
        return self.num_arcs > 0
    [...]

I noticed the same behaviour for RaggedTensor where bool(k2.RaggedTensor([], dtype=torch.int32)) returns True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant