Repository navigation
Conversation
normalize_list() computed batch = min(len(texts), batch_size), which is 0 for an empty list, and range(0, 0, 0) raised "ValueError: range() arg 3 must not be zero". inverse_normalize_list() and the normalize.py and inverse_normalize.py scripts with an empty --input_file failed the same way. Return [] for empty input. normalize_manifest() had the same batch computation and failed the same way for an empty manifest. Use a batch size of at least 1, so an empty manifest gives an empty output file. Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do ?
normalize_list([]),inverse_normalize_list([])andnormalize_manifeston an empty manifest now return[]/ write an empty output file instead of raisingValueError: range() arg 3 must not be zero.Fixes #534
Changes
normalize_list: return[]for empty input. This also coversinverse_normalize_listand thenormalize.py/inverse_normalize.pyscripts with an empty--input_file.normalize_manifest: usebatch = max(1, min(len(lines), batch_size)), so an empty manifest gives an empty output file.tests/nemo_text_processing/en/test_cardinal.py:test_normalize_list_emptyandtest_normalize_manifest_empty.Testing (macOS arm64, Python 3.11, pynini 2.1.6.post1)
pytest --cpu tests/nemo_text_processing/en/test_cardinal.py -k empty: 2 failed on main (ValueError: range() arg 3 must not be zeroat normalize.py:271 and :541), 2 passed with this change.pytest --cpu tests/nemo_text_processing/en/test_{cardinal,money,ordinal,decimal}.py: 580 passed.--input_filewrite an empty output file instead of raising.-l 119 -S) and isort report no changes for the two files.Before your PR is "Ready for review"
Pre checks:
git commit -sto sign.pytestor (if your machine does not have GPU)pytest --cpufrom the root folder (given you marked your test cases accordingly@pytest.mark.run_only_on('CPU')).bash tools/text_processing_deployment/export_grammars.sh --MODE=test ...pytestand Sparrowhawk here.__init__.pyfor every folder and subfolder, includingdatafolder which has .TSV files?Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.to all newly added Python files?Copyright 2015 and onwards Google, Inc.. See an example here.try import: ... except: ...) if not already done.I ran the tests listed above, not the full
pytest --cpusuite, and not the Sparrowhawk tests (the change is in the Python batching code, not in the grammars). The other unchecked items do not apply (no new feature, files, language or import guards).PR Type:
This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.