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

Revise some spatial tests to pytest style; avoids numercial issues due to float comparisons #2657

Merged
merged 2 commits into from
Apr 11, 2023

Conversation

heplesser
Copy link
Contributor

The main motivation for this PR is that tests from two modules failed on Apple silicon after upgrading to macOS 13.3.1 and XCode 14.3 because some distance values returned by NEST differ in the last decimal (mantissa bit). The difference occurs with Apple Clang 14.0.3 and GCC 12.2.0; it does not occur on Intel silicon.

All comparisons (except where exact zero is expected) now use pytest.approx(). The tests are also restructured in PyTest form and grouped in two classes according to the network setup they require.

The tests could probably be revised further, but this is a bug fix and should therefore not be delayed.

@heplesser heplesser added T: Bug Wrong statements in the code or documentation S: High Should be handled next I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) labels Apr 10, 2023
Copy link
Member

@nicolossus nicolossus left a comment

Choose a reason for hiding this comment

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

The bug fix looks good to me, thanks!

Copy link
Contributor

@med-ayssar med-ayssar left a comment

Choose a reason for hiding this comment

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

Most of the tests in test_SynapseCollection_distance might be split into 3 parts:

  • Using Grid
  • Using Free distribution (include randomness)
  • Mixed: Both variants

Each of those has the same pattern:

  1. Create Nodes
  2. Connect
  3. GetConnections
  4. Get distance
  5. assert

So I think we can have one function for each of the three variants mentioned above and use pytest decorators to parametrize the function to avoid code repetition.

@med-ayssar
Copy link
Contributor

med-ayssar commented Apr 11, 2023

The tests could probably be revised further, but this is a bug fix and should therefore not be delayed.

@heplesser: Otherwise regarding the bug, the changes look fine. If you want to consider my suggestions, I will wait and approve later, otherwise if you think that they should belong to a different PR, then I will approve immediately.

Co-authored-by: med-ayssar <med.ayssar@gmail.com>
Copy link
Contributor

@med-ayssar med-ayssar left a comment

Choose a reason for hiding this comment

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

Perfect!

@heplesser heplesser merged commit c241033 into nest:master Apr 11, 2023
6 checks passed
@heplesser heplesser deleted the fix-py311-numerics-issues branch September 15, 2023 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: High Should be handled next T: Bug Wrong statements in the code or documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants