PyElastica icon indicating copy to clipboard operation
PyElastica copied to clipboard

Avoid having randomized unittest

Open skim0119 opened this issue 1 year ago • 17 comments

  • This issue came up on one of the github-action.
  • Instead of random test, we should have pre-generated set of test cases and known solution.
  • Precision should be specified.
  • Best to include corner cases and negative cases (fail case)

https://github.com/GazzolaLab/PyElastica/blob/d12107a2d3ad7228a2893ad55de5da89a9bab87b/tests/test_math/test_timestepper.py#L401-L408

skim0119 avatar Feb 20 '24 02:02 skim0119

Hi, I love to work on this issue, Can you please assign me ??

vikas-chaudhary-2802 avatar Feb 23 '24 22:02 vikas-chaudhary-2802

@vikas-chaudhary-2802 the issue has been assigned, please follow these guidelines when working on the issue.

bhosale2 avatar Feb 23 '24 22:02 bhosale2

@vikas-chaudhary-2802 I included some more explanation above.

skim0119 avatar Feb 23 '24 22:02 skim0119

@skim0119 I have made few changes and i wanted to test whether those are working. Do i need to build the project and then run the test using 'make test' command? If yes, how can i build it?

vikas-chaudhary-2802 avatar Feb 27 '24 15:02 vikas-chaudhary-2802

@vikas-chaudhary-2802 Repository can be installed using pip or poetry.

skim0119 avatar Feb 28 '24 03:02 skim0119

@skim0119 whether I need to build after I make the changes or not ?

vikas-chaudhary-2802 avatar Feb 28 '24 06:02 vikas-chaudhary-2802

@vikas-chaudhary-2802 If you have made changes within the tests directory, it won't be necessary to reinstall.

skim0119 avatar Feb 28 '24 16:02 skim0119

@skim0119 i added logging line to check the datatype but the logs are not getting printed on the shell when i run - make tests....could you please suggest any other way to debug ?

vikas-chaudhary-2802 avatar Mar 05 '24 16:03 vikas-chaudhary-2802

@vikas-chaudhary-2802 You can directly run pytest -s on repository to capture stdout/stderr

skim0119 avatar Mar 06 '24 05:03 skim0119

@skim0119 @bhosale2 I'm facing difficulties with certain test cases and despite my attempts, I haven't been able to resolve them. Could you please provide assistance with these specific issues? Screenshot 2024-03-18 at 9 50 05 AM

vikas-chaudhary-2802 avatar Mar 18 '24 06:03 vikas-chaudhary-2802

@vikas-chaudhary-2802 Could you commit your code in your fork that reproduces this error?

skim0119 avatar Mar 18 '24 16:03 skim0119

@skim0119 yeah, I am able to commit Screenshot 2024-03-19 at 5 33 11 PM

vikas-chaudhary-2802 avatar Mar 19 '24 12:03 vikas-chaudhary-2802

@skim0119 @bhosale2 I Create a PR, Can you please suggest me the changes that i have to do ...so that the failed test cases will resolve and then i will commit the changes again

vikas-chaudhary-2802 avatar Mar 19 '24 21:03 vikas-chaudhary-2802

@vikas-chaudhary-2802 I went over your code. The directors passed to the timestepper need to be orthogonal. I think that is why the analytical solution is breaking. Please correct the directors and try to run the test again.

Also, try to format the script before commiting. You can run make format-codestyle.

skim0119 avatar Mar 23 '24 09:03 skim0119

Hi, @skim0119 Thank You for your suggestion. I will make the changes as soon as possible

vikas-chaudhary-2802 avatar Mar 24 '24 05:03 vikas-chaudhary-2802

Hi, @skim0119 @bhosale2 Now the directors passed to the timestepper is orthogonal but still the same test cases failed.... i will attached the changes ....please review it and tell me what i have to do next to pass the test cases as soon as possible

Screenshot 2024-03-27 at 12 45 47 AM

vikas-chaudhary-2802 avatar Mar 26 '24 19:03 vikas-chaudhary-2802

@vikas-chaudhary-2802 I would appreciate it if you could attach the actual code, or link the forked script to re-run. I can't help out just looking at the image file. Same for the error message.

Few comments:

  • I am not sure how you are initializing random_directors. Please re-write them readable and clean. Quickly looking at it, it looks wrong implementation. The final dimension needs to be 3x3xN where N is the number of test cases.
  • Don't use QR decomposition to orthogonalize them. The whole point of this issue and avoiding randomized unit-test is to test if the code can handle largely expected cases (and corner cases if any). Your approach, in the end, has the same issue as the original implementation: don't know why the test passes or fails.

skim0119 avatar Mar 26 '24 23:03 skim0119

Fixed in update-0.3.3

skim0119 avatar Aug 09 '25 03:08 skim0119