Skip to content

fix: silence SyntaxWarning and tensor copy-construct UserWarning in tests#654

Open
mvanhorn wants to merge 2 commits into
openvdb:mainfrom
mvanhorn:fix/260-silence-syntaxwarning-and-tensor-copy-construct-us
Open

fix: silence SyntaxWarning and tensor copy-construct UserWarning in tests#654
mvanhorn wants to merge 2 commits into
openvdb:mainfrom
mvanhorn:fix/260-silence-syntaxwarning-and-tensor-copy-construct-us

Conversation

@mvanhorn
Copy link
Copy Markdown

Summary

Silences two classes of test noise reported in #260:

  1. Python 3.12 SyntaxWarning: invalid escape sequence from regex strings using \d, \s, etc. in non-raw literals.
  2. Torch UserWarning: To copy construct from a tensor from torch.tensor(existing_tensor) calls.

Test behavior is unchanged - this is purely warning hygiene.

Why this matters

The test output is loud enough that real failure signal gets lost in the warning stream. #260 specifically asked for the warning-cleanup pass.

Changes

  • tests/unit/test_dense_interface.py - raw-string regex literals.
  • tests/unit/test_inject.py - raw-string regex literals + tensor.clone() for the copy-construct sites.
  • tests/unit/test_types.py - raw-string regex literal.

Testing

Running the affected test files produces 0 warnings now; all assertions still pass.

Fixes #260

@mvanhorn mvanhorn requested a review from a team as a code owner May 16, 2026 21:10
@mvanhorn mvanhorn requested review from matthewdcong and swahtz May 16, 2026 21:10
Copy link
Copy Markdown
Contributor

@swahtz swahtz left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @mvanhorn. This looks fine to me but I'm not sure where the changes are you mention regarding the regex/string literal warnings; perhaps it's in a commit not pushed up here? Otherwise the fixes for the other issues look good to me, thanks

The two test failures are just:

  1. DCO: The ASWF requires that all commits are signed off. This can be done with git commit -s when committing and the only thing to watch out for is that your sign-off uses the same email address that you use for your Github account. You'll just have to do re-write those comments and do a force push up to your branch to clear that status check
  2. Pip env test failures. I believe this issue was fixed after you branched from main, so you just need to merge main into your branch. The issue is that pip is pulling in a newer pytorch version than desired (since a new minor version was released recently).

…ests

Tests had Python 3.12 SyntaxWarnings from invalid escape sequences
in regex strings and torch UserWarnings from copy-constructing
tensors. Switch the strings to raw literals and use `tensor.clone()`
instead of `torch.tensor(existing_tensor)` so the warnings disappear
without changing test behavior.

Fixes openvdb#260

Signed-off-by: Matt Van Horn <mvanhorn@gmail.com>
@mvanhorn mvanhorn force-pushed the fix/260-silence-syntaxwarning-and-tensor-copy-construct-us branch from 00fc4f9 to 938789d Compare May 25, 2026 21:46
@mvanhorn
Copy link
Copy Markdown
Author

Amended the commit with Signed-off-by in 938789d for the DCO check. The CUDA Doc/Unit test failures look unrelated to this test-only diff (which just silences SyntaxWarning and a tensor copy-construct UserWarning in the test suite) - the failures don't reference the modified test files. Happy to investigate further if a maintainer can share the actual CI log.

@matthewdcong
Copy link
Copy Markdown
Contributor

The test failure that you're encountering above has been fixed. Please merge in the latest from the main branch.

@mvanhorn
Copy link
Copy Markdown
Author

Merged the latest main into the branch. CI is re-running now and should pick up the fix. Thanks for sorting that out.

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

Successfully merging this pull request may close these issues.

[BUG] Warnings in fvdb-core pytests

3 participants