Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property-based testing of matrix transposition #65

Merged
merged 5 commits into from
Jan 3, 2022

Conversation

xcapaldi
Copy link
Contributor

Rather than just testing the self-inverse property of matrix transposition, use property-based testing to check if transposition is correct and meets the self-inverse (involutory) property.

Similarly test unraveling and reraveling of matrices.

We still check that the transposition is performed in the Little Endian-sense with another test.

Rather than just testing the self-inverse property of matrix
transposition, use property-based testing to check if transposition
is correct and meets the self-inverse (involutory) property.

Similarly test unraveling and reraveling of matrices.

We still check that the transposition is performed in the Little
Endian-sense with another test.
@xcapaldi xcapaldi self-assigned this Dec 20, 2021
internal/util/bits.go Outdated Show resolved Hide resolved
internal/util/bitvect_test.go Outdated Show resolved Hide resolved
internal/util/bitvect_test.go Outdated Show resolved Hide resolved
* Add `bitVectWidth` as a constant to use instead of 512 everywhere
* Move `isBitSetUint64` to `bitvect_test.go` as it is only used for
  testing
* Rename variables in tests
@jvsg jvsg requested a review from juanli16 December 21, 2021 21:06
internal/util/bitvect_test.go Outdated Show resolved Hide resolved
We take the default time-seeded randomness from Quick and use it
when generating our matrices. In addition, matrices are generated
with a random length such that the max size in 5 blocks of 512 by
512 bits.
Based on review comments on property-based on testing of matrix
transposition, realized that the testing of the bit utils had
similar flaws. Ensure the randomness from Quick (time-seeded) is
passed to bitset generation and also create sets of truly random
length.
// 512 rows.
func (tallMatrix) Generate(r *rand.Rand, unusedSizeHint int) reflect.Value {
var tall tallMatrix
size := 1 + r.Intn(31*bitVectWidth) // a max of 32 blocks
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
size := 1 + r.Intn(31*bitVectWidth) // a max of 32 blocks
size := r.Intn(unusedSizeHint*bitVectWidth) // a max of 32 blocks

Generate up to 32 - 512x512 blocks for property-based testing.
Copy link
Contributor

@juanli16 juanli16 left a comment

Choose a reason for hiding this comment

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

LGTM

@xcapaldi xcapaldi merged commit dd14e34 into main Jan 3, 2022
@xcapaldi xcapaldi deleted the property-test-transpose branch January 3, 2022 15:54
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.

3 participants