Skip to content

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

Merged
swahtz merged 2 commits into
openvdb:mainfrom
mvanhorn:fix/260-silence-syntaxwarning-and-tensor-copy-construct-us
Jun 1, 2026
Merged

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

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

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

@swahtz swahtz left a comment

Copy link
Copy Markdown
Contributor

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
Contributor 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
Contributor Author

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

@swahtz swahtz added the tests label Jun 1, 2026
@swahtz swahtz merged commit 8644816 into openvdb:main Jun 1, 2026
39 checks passed
@mvanhorn

mvanhorn commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Appreciate the merge @swahtz. Silencing the SyntaxWarning and fixing the tensor copy-construct should quiet some noise for users.

@mvanhorn

mvanhorn commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging the warning cleanup @swahtz, the SyntaxWarning and tensor copy-construct noise is gone from the import path.

@mvanhorn

mvanhorn commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Much appreciated @swahtz, good to have the SyntaxWarning and tensor copy-construct noise gone.

@mvanhorn

mvanhorn commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Appreciate the merge, @swahtz. Should be quieter test runs now without the SyntaxWarning and tensor copy-construct noise.

@swahtz swahtz added this to the v0.5 milestone Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Warnings in fvdb-core pytests

3 participants