Skip to content

Copy-edit the integration tests for simplicity #281

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

Merged
merged 1 commit into from
Mar 8, 2022

Conversation

adamreichold
Copy link
Member

No description provided.

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

👍 From a very quick glance, looks reasonable and good tidy ups.

Might be worth checking why the coverage number reports a drop? Maybe a couple extra tests may be wanted.

@adamreichold
Copy link
Member Author

adamreichold commented Mar 3, 2022

Might be worth checking why the coverage number reports a drop?

It seems the drop was mostly due to not formatting the expected errors. The old code would print them but not check the error messages which I adjusted and thereby found incorrect error messages like invalid length: 2, but expected 2 created by PyArray::from_vec2/3 which I fixed.

The other loss is PyArray::from_array which however just safely forwards to ToPyArray::to_pyarray (and has a doc test) so I think this should be fine (it didn't have a test, it was just called incidentally).

Maybe a couple extra tests may be wanted.

I think that is definitely the case. My plan here is to do more copy editing to become more familiar with the details of the code base and after that work on improving the tests (and adding benchmarks if appropriate). (With the amount of unsafe code it would really be nice to run Miri in CI, but I guess this is impossible due to that unsafe interacting with C code.)

Copy link
Member

@kngwyu kngwyu left a comment

Choose a reason for hiding this comment

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

Thank you!

Comment on lines +1176 to +1178
for v in v {
if v.len() != len2 {
return Err(FromVecError::new(v.len(), len2));
Copy link
Member

Choose a reason for hiding this comment

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

Oops, this is a nice catch, thank you.

for elem in iter {
*elem *= 2.0;
*elem *= 2;
Copy link
Member

Choose a reason for hiding this comment

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

I prefer to note the decimal to clarify that *elem is a float, but I'm not sure about the community's preference or best practices.

Copy link
Member Author

Choose a reason for hiding this comment

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

The type of elem was changed to i32 by

let arr = pyarray![py, [0, 1], [2, 3], [4, 5]];

I changed all tests (where that does not affect their meaning) to work with integers as this avoids having to do tricks like assert_approx_eq! to check for equality against expectations. With integers, I can for example just use assert_eq! to compare the exact sums.

@adamreichold adamreichold merged commit 3a614fe into main Mar 8, 2022
@adamreichold adamreichold deleted the tests-copy-editing branch March 8, 2022 10:12
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