Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Fix tensor.nonzero() function overload warning #4644

Merged
merged 3 commits into from
Sep 16, 2020

Conversation

nelson-liu
Copy link
Contributor

When running the CRF, I currently get this warning (reproduced it in py.test, too):

========================================== warnings summary ===========================================
tests/modules/conditional_random_field_test.py::TestConditionalRandomField::test_viterbi_tags
  /home/nfliu/git/allennlp/tests/modules/conditional_random_field_test.py:1: UserWarning: This overload of nonzero is deprecated:
  	nonzero()
  Consider using one of the following signatures instead:
  	nonzero(*, bool as_tuple) (Triggered internally at  /pytorch/torch/csrc/utils/python_arg_parser.cpp:766.)
    import itertools

-- Docs: https://docs.pytest.org/en/stable/warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! _pytest.outcomes.Exit: Quitting debugger !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================ 2 passed, 951 deselected, 1 warning in 13.40s ============================

The fix is pretty simple--just provide the as_tuple keyword explicitly (and keep it at its default value, False)

Copy link
Member

@epwalsh epwalsh left a comment

Choose a reason for hiding this comment

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

LGTM!

@nelson-liu nelson-liu merged commit de5d68b into allenai:master Sep 16, 2020
@nelson-liu nelson-liu deleted the nonzero_warning branch September 16, 2020 18:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants