|
| 1 | +--- |
| 2 | +name: np-tests |
| 3 | +description: Write and migrate numpy tests for NumSharp functions. Use when adding tests for np.* methods, migrating numpy test suites, or battletesting NumSharp implementations against numpy 2.4.2. |
| 4 | +--- |
| 5 | + |
| 6 | +We are looking to test numpy's np.* implementations to the fullest. we are aligning with numpy 2.4.2 as source of truth and are to validate exact same behavior as numpy does. |
| 7 | +This session we focusing on: """$ARGUMENTS""" |
| 8 | +Your job is around writing tests for np.* functions (no more than a few. more than one ONLY if they are closely related). |
| 9 | + |
| 10 | +To interact/develop/create tests for np.* functions, high-level development cycle is as follows: |
| 11 | +1. Find and read numpy's tests for the function/s you are about to test. Tests are in K:\source\NumSharp\src\numpy under numpy/_core/tests/, numpy/lib/tests/, etc. Remember, numpy is the source of truth. |
| 12 | +Definition of Done: |
| 13 | +- At the end of this step you understand 100% what numpy tests: inputs, outputs, edge cases, error conditions, dtype behaviors. |
| 14 | +- You have identified all test files and test methods related to your function. |
| 15 | +2. Migrate numpy's tests to C# following TUnit framework patterns in test/NumSharp.UnitTest. Match numpy's test structure and assertions exactly. |
| 16 | +Definition of Done: |
| 17 | + - Every numpy test case has a corresponding C# test. |
| 18 | + - We cover all dtypes NumSharp supports (Boolean, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Char, Single, Double, Decimal). |
| 19 | + - Test names reflect what they test (e.g., Test_Sort_Axis0_Int32). |
| 20 | + - Assertions match numpy's expected values exactly. |
| 21 | +3. Battletest to find gaps. Run python and dotnet side-by-side to discover edge cases numpy handles that we might miss. |
| 22 | +Definition of Done: |
| 23 | + - All numpy tests pass in NumSharp. |
| 24 | + - Additional edge cases discovered via battletesting are covered. |
| 25 | + - Any bugs found are reported to implementation teammate or fixed on the spot. |
| 26 | +4. Review test coverage: empty arrays, scalar inputs, negative axis, broadcasting, NaN/Inf handling, dtype promotion, error conditions. |
| 27 | +5. Commit and report completion. |
| 28 | + |
| 29 | +## Tools: |
| 30 | +### Battletesting |
| 31 | +Use battletesting to validate behavior matches numpy: 'dotnet run << 'EOF'' and 'python << 'EOF'' side-by-side comparison. |
| 32 | + |
| 33 | +### Test Patterns |
| 34 | +```csharp |
| 35 | +[Test] |
| 36 | +public async Task FunctionName_Scenario_Dtype() |
| 37 | +{ |
| 38 | + // Arrange |
| 39 | + var input = np.array(new[] { 3, 1, 2 }); |
| 40 | + |
| 41 | + // Act |
| 42 | + var result = np.sort(input); |
| 43 | + |
| 44 | + // Assert - values from running actual numpy |
| 45 | + Assert.That(result.IsContiguous, Is.True); |
| 46 | + Assert.That(result.GetAtIndex<int>(0), Is.EqualTo(1)); |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +## Instructions to Team Leader |
| 51 | +- Create at-least 4 users if the task can be parallelised to that level and if not then use less |
| 52 | + - Do not wait for other teammates to complete, always have N teammates developing until all the work is completed by definition of done. |
| 53 | + - If user asked for 1 of something there there is only a reason to launch one teammate and not five. |
| 54 | +- When the teammate have completed development all the way to last step and all definition of done: finish and shutdown the teammate. |
0 commit comments