Skip to content

test(transforms): Refactor tensor ops#261

Merged
javiermtorres merged 4 commits intomainfrom
156-partition-tests
Feb 16, 2026
Merged

test(transforms): Refactor tensor ops#261
javiermtorres merged 4 commits intomainfrom
156-partition-tests

Conversation

@javiermtorres
Copy link
Contributor

Each operation or group of operations has been separated into its own file, including its tests. If these files again grow too much, further refinement can be done.

Closes #156

@javiermtorres javiermtorres marked this pull request as ready for review February 5, 2026 18:54
@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 99.23077% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
encoderfile/src/transforms/tensor/ops/mean_pool.rs 96.80% 3 Missing ⚠️
...ncoderfile/src/transforms/tensor/ops/properties.rs 97.52% 3 Missing ⚠️
...ncoderfile/src/transforms/tensor/ops/layer_norm.rs 98.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
encoderfile/src/transforms/tensor/mod.rs 95.65% <100.00%> (-1.93%) ⬇️
encoderfile/src/transforms/tensor/ops/arithm.rs 100.00% <100.00%> (ø)
encoderfile/src/transforms/tensor/ops/axes.rs 100.00% <100.00%> (ø)
encoderfile/src/transforms/tensor/ops/clamp.rs 100.00% <100.00%> (ø)
encoderfile/src/transforms/tensor/ops/fold_axis.rs 100.00% <100.00%> (ø)
...oderfile/src/transforms/tensor/ops/lp_normalize.rs 100.00% <100.00%> (ø)
encoderfile/src/transforms/tensor/ops/map_axis.rs 100.00% <100.00%> (ø)
encoderfile/src/transforms/tensor/ops/softmax.rs 100.00% <100.00%> (ø)
encoderfile/src/transforms/tensor/ops/sum_axis.rs 100.00% <100.00%> (ø)
encoderfile/src/transforms/tensor/ops/transpose.rs 100.00% <100.00%> (ø)
... and 4 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@javiermtorres
Copy link
Contributor Author

@besaleli the linter growls: https://github.com/mozilla-ai/encoderfile/actions/runs/21724072599/job/62661358316?pr=261
do I add this method? Thanks in advance 🙂

@besaleli
Copy link
Member

besaleli commented Feb 9, 2026

@besaleli the linter growls: https://github.com/mozilla-ai/encoderfile/actions/runs/21724072599/job/62661358316?pr=261 do I add this method? Thanks in advance 🙂

sure why not @javiermtorres

Copy link
Member

@besaleli besaleli left a comment

Choose a reason for hiding this comment

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

one formatting thing, otherwise looks beautiful!

Ok(Tensor(new))
}

#[cfg(test)]
Copy link
Member

Choose a reason for hiding this comment

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

put these all in a mod tests {}

Copy link
Member

Choose a reason for hiding this comment

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

then, write #[test] as decorator of each test function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Macros already use the test tag, defined with the same name but on a different module (after grouping into tests as suggested). For example, cargo test test_tensor results in these tests being run:

TowoMoz:156-partition-tests ⇒ cargo test test_tensor
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.69s
     Running unittests src/lib.rs (target/debug/deps/encoderfile-58a353167a97c36b)

running 8 tests
test transforms::engine::tests::test_tensor_function_is_only_safe_binding ... ok
test transforms::tensor::ops::arithm::tests::test_multiplication::test_tensor ... ok
test transforms::tensor::ops::arithm::tests::test_subtraction::test_tensor ... ok
test transforms::tensor::ops::arithm::tests::test_addition::test_tensor ... ok
test transforms::tensor::ops::arithm::tests::test_division::test_tensor ... ok
test transforms::engine::tests::test_tensor_return_type ... ok
test transforms::engine::tests::test_tensor_methods_chain_twice ... ok
test transforms::engine::tests::test_tensor_metatable_preserved ... ok

But maybe you'd prefer some other organization, like adding the op name into the test name instead of making specific modules.

BTW, maybe I could factor out the broadcast tests using a table of values, as well. Not really necessary, but compacts things a bit. Wdyt?

}
}

#[test]
Copy link
Member

Choose a reason for hiding this comment

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

mod tests!!

@javiermtorres
Copy link
Contributor Author

BTW, I think I didn't group into mod tests for most of the modules :-/ I'll do that for all the modules, let me know if that's ok.

@besaleli besaleli changed the title Refactor tensor ops test(transforms): Refactor tensor ops Feb 16, 2026
@javiermtorres javiermtorres merged commit f4df2f0 into main Feb 16, 2026
3 checks passed
@javiermtorres javiermtorres deleted the 156-partition-tests branch February 16, 2026 18:21
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.

Make tensor unit tests a little less insane

3 participants