diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index 84067e37f..09d1f3c73 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -345,8 +345,7 @@ dotnet build -v q --nologo "-clp:NoSummary;ErrorsOnly" -p:WarningLevel=0 ### Running Tests -Tests use **TUnit** framework with source-generated test discovery. -- `dotnet_test_tunit --filter "..."`: MSTest-style filter for TUnit (Category=, Name~, ClassName~, FullyQualifiedName~) +Tests use **MSTest v3** framework with source-generated test discovery. ```bash # Run from test directory @@ -356,10 +355,19 @@ cd test/NumSharp.UnitTest dotnet test --no-build # Exclude OpenBugs (CI-style - only real failures) -dotnet test --no-build -- --treenode-filter "/*/*/*/*[Category!=OpenBugs]" +dotnet test --no-build --filter "TestCategory!=OpenBugs" # Run ONLY OpenBugs tests -dotnet test --no-build -- --treenode-filter "/*/*/*/*[Category=OpenBugs]" +dotnet test --no-build --filter "TestCategory=OpenBugs" + +# Exclude multiple categories +dotnet test --no-build --filter "TestCategory!=OpenBugs&TestCategory!=HighMemory" + +# Run specific test class +dotnet test --no-build --filter "ClassName~BinaryOpTests" + +# Run specific test method +dotnet test --no-build --filter "Name~Add_Int32_SameType" ``` ### Output Formatting @@ -369,10 +377,10 @@ dotnet test --no-build -- --treenode-filter "/*/*/*/*[Category=OpenBugs]" dotnet test --no-build 2>&1 | grep -E "^(failed|skipped|Test run| total:| failed:| succeeded:| skipped:| duration:)" # Results with messages (no stack traces) -dotnet test --no-build 2>&1 | grep -v "^ at " | grep -v "^ at " | grep -v "^ ---" | grep -v "^ from K:" | sed 's/TUnit.Engine.Exceptions.TestFailedException: //' | sed 's/AssertFailedException: //' +dotnet test --no-build 2>&1 | grep -v "^ at " | grep -v "^ at " | grep -v "^ ---" | grep -v "^ from K:" | sed 's/AssertFailedException: //' -# Detailed output (shows passed tests too) -dotnet test --no-build -- --output Detailed +# Verbose output (shows passed tests too) +dotnet test --no-build -v normal ``` ## Test Categories @@ -383,36 +391,38 @@ Tests use typed category attributes defined in `TestCategory.cs`. Adding new bug |----------|-----------|---------|-------------| | `OpenBugs` | `[OpenBugs]` | Known-failing bug reproductions. Remove when fixed. | **EXCLUDED** via filter | | `Misaligned` | `[Misaligned]` | Documents NumSharp vs NumPy behavioral differences. | Runs (tests pass) | -| `WindowsOnly` | `[WindowsOnly]` | Requires GDI+/System.Drawing.Common | Runtime platform check | +| `WindowsOnly` | `[WindowsOnly]` | Requires GDI+/System.Drawing.Common | Excluded on non-Windows | +| `HighMemory` | `[HighMemory]` | Requires 8GB+ RAM | **EXCLUDED** via filter | -### How CI Excludes OpenBugs +### How CI Excludes Categories -The CI pipeline (`.github/workflows/build-and-release.yml`) uses TUnit's `--treenode-filter` to exclude `OpenBugs`: +The CI pipeline (`.github/workflows/build-and-release.yml`) uses MSTest's `--filter` to exclude categories: ```yaml - name: Test (net10.0) run: | - dotnet run --project test/NumSharp.UnitTest/NumSharp.UnitTest.csproj \ + dotnet test test/NumSharp.UnitTest/NumSharp.UnitTest.csproj \ --configuration Release --no-build --framework net10.0 \ - -- --treenode-filter '/*/*/*/*[Category!=OpenBugs]' + --filter "TestCategory!=OpenBugs&TestCategory!=HighMemory" ``` -This filter excludes all tests with `[OpenBugs]` attribute from CI runs. Tests pass locally when the bug is fixed — then remove the `[OpenBugs]` attribute. +This filter excludes all tests with `[OpenBugs]` or `[HighMemory]` attributes from CI runs. Tests pass locally when the bug is fixed — then remove the `[OpenBugs]` attribute. ### Usage ```csharp // Class-level (all tests in class) +[TestClass] [OpenBugs] public class BroadcastBugTests { ... } // Method-level -[Test] +[TestMethod] [OpenBugs] -public async Task BroadcastWriteCorruptsData() { ... } +public void BroadcastWriteCorruptsData() { ... } // Documenting behavioral differences (NOT excluded from CI) -[Test] +[TestMethod] [Misaligned] public void BroadcastSlice_MaterializesInNumSharp() { ... } ``` @@ -421,13 +431,16 @@ public void BroadcastSlice_MaterializesInNumSharp() { ... } ```bash # Exclude OpenBugs (same as CI) -dotnet test -- --treenode-filter "/*/*/*/*[Category!=OpenBugs]" +dotnet test --filter "TestCategory!=OpenBugs" # Run ONLY OpenBugs tests (to verify fixes) -dotnet test -- --treenode-filter "/*/*/*/*[Category=OpenBugs]" +dotnet test --filter "TestCategory=OpenBugs" # Run ONLY Misaligned tests -dotnet test -- --treenode-filter "/*/*/*/*[Category=Misaligned]" +dotnet test --filter "TestCategory=Misaligned" + +# Combine multiple exclusions +dotnet test --filter "TestCategory!=OpenBugs&TestCategory!=HighMemory&TestCategory!=WindowsOnly" ``` **OpenBugs files**: `OpenBugs.cs` (general), `OpenBugs.Bitmap.cs` (bitmap), `OpenBugs.ApiAudit.cs` (API audit), `OpenBugs.ILKernelBattle.cs` (IL kernel). @@ -599,10 +612,10 @@ A: Core ops (`dot`, `matmul`) in `LinearAlgebra/`. Advanced decompositions (`inv ## Q&A - Development **Q: What's in the test suite?** -A: TUnit framework in `test/NumSharp.UnitTest/`. Many tests adapted from NumPy's own test suite. Decent coverage but gaps in edge cases. Uses source-generated test discovery (no special flags needed). +A: MSTest v3 framework in `test/NumSharp.UnitTest/`. Many tests adapted from NumPy's own test suite. Decent coverage but gaps in edge cases. Uses source-generated test discovery (no special flags needed). **Q: What .NET version is targeted?** -A: Library multi-targets `net8.0` and `net10.0`. Tests require .NET 9+ runtime (TUnit requirement). +A: Library multi-targets `net8.0` and `net10.0`. Tests also multi-target both frameworks. **Q: What are the main dependencies?** A: No external runtime dependencies. `System.Memory` and `System.Runtime.CompilerServices.Unsafe` (previously NuGet packages) are built into the .NET 8+ runtime. diff --git a/.claude/skills/np-tests/SKILL.md b/.claude/skills/np-tests/SKILL.md index 7c4359ed6..fade72443 100644 --- a/.claude/skills/np-tests/SKILL.md +++ b/.claude/skills/np-tests/SKILL.md @@ -12,7 +12,7 @@ To interact/develop/create tests for np.* functions, high-level development cycl Definition of Done: - At the end of this step you understand 100% what numpy tests: inputs, outputs, edge cases, error conditions, dtype behaviors. - You have identified all test files and test methods related to your function. -2. Migrate numpy's tests to C# following TUnit framework patterns in test/NumSharp.UnitTest. Match numpy's test structure and assertions exactly. +2. Migrate numpy's tests to C# following MSTest v3 framework patterns in test/NumSharp.UnitTest. Match numpy's test structure and assertions exactly. Definition of Done: - Every numpy test case has a corresponding C# test. - We cover all dtypes NumSharp supports (Boolean, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Char, Single, Double, Decimal). @@ -32,8 +32,8 @@ Use battletesting to validate behavior matches numpy: 'dotnet run << 'EOF'' and ### Test Patterns ```csharp -[Test] -public async Task FunctionName_Scenario_Dtype() +[TestMethod] +public void FunctionName_Scenario_Dtype() { // Arrange var input = np.array(new[] { 3, 1, 2 }); @@ -42,8 +42,8 @@ public async Task FunctionName_Scenario_Dtype() var result = np.sort(input); // Assert - values from running actual numpy - Assert.That(result.IsContiguous, Is.True); - Assert.That(result.GetAtIndex(0), Is.EqualTo(1)); + Assert.IsTrue(result.IsContiguous); + Assert.AreEqual(1, result.GetAtIndex(0)); } ``` diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000..ea952afa6 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,11 @@ +# TUnit to MSTest v3 attribute migration +ac020336 + +# TUnit assertions to AwesomeAssertions migration +b1d1d543 + +# Add [TestClass] attributes for MSTest discovery +e0db3c3e + +# Convert async Task to void for sync test methods +4eea9644 diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 1adf28ded..285c9a591 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -43,26 +43,39 @@ jobs: - name: Build run: dotnet build test/NumSharp.UnitTest/NumSharp.UnitTest.csproj --configuration Release -p:NoWarn=${{ env.DOTNET_NOWARN }} - # NOTE: Test project currently only targets net10.0. See TODO in NumSharp.UnitTest.csproj - # to re-enable net8.0 when TUnit compatibility is resolved. - # # Test filtering: # - OpenBugs: excluded (known-failing bug reproductions) # - HighMemory: excluded (requires 8GB+ RAM, too much for CI runners) - # - WindowsOnly: auto-skipped at runtime via [SkipOnNonWindows] attribute + # - WindowsOnly: excluded on non-Windows runners + - name: Test (net8.0) + shell: bash + timeout-minutes: 10 + run: | + echo "Starting test run (net8.0)..." + echo "dotnet version: $(dotnet --version)" + echo "Available memory: $(free -h 2>/dev/null || echo 'N/A')" + FILTER="TestCategory!=OpenBugs&TestCategory!=HighMemory" + if [[ "$RUNNER_OS" != "Windows" ]]; then + FILTER="$FILTER&TestCategory!=WindowsOnly" + fi + dotnet test test/NumSharp.UnitTest/NumSharp.UnitTest.csproj \ + --configuration Release --no-build --framework net8.0 \ + --filter "$FILTER" --logger "trx" + - name: Test (net10.0) shell: bash timeout-minutes: 10 run: | - echo "Starting test run..." + echo "Starting test run (net10.0)..." echo "dotnet version: $(dotnet --version)" echo "Available memory: $(free -h 2>/dev/null || echo 'N/A')" - # Note: TUnit --treenode-filter doesn't seem to exclude class-level categories. - # The HighMemory filter was attempted but didn't reduce test count. - # Ubuntu failures are allowed via continue-on-error while investigating. - dotnet run --project test/NumSharp.UnitTest/NumSharp.UnitTest.csproj \ + FILTER="TestCategory!=OpenBugs&TestCategory!=HighMemory" + if [[ "$RUNNER_OS" != "Windows" ]]; then + FILTER="$FILTER&TestCategory!=WindowsOnly" + fi + dotnet test test/NumSharp.UnitTest/NumSharp.UnitTest.csproj \ --configuration Release --no-build --framework net10.0 \ - -- --treenode-filter '/*/*/*/*[Category!=OpenBugs]' --report-trx + --filter "$FILTER" --logger "trx" - name: Upload Test Results uses: actions/upload-artifact@v4 diff --git a/docs/MSTEST_FILTER_GUIDE.md b/docs/MSTEST_FILTER_GUIDE.md new file mode 100644 index 000000000..ab946286b --- /dev/null +++ b/docs/MSTEST_FILTER_GUIDE.md @@ -0,0 +1,173 @@ +# MSTest `--filter` Guide + +## Filter Syntax + +MSTest uses a simple property-based filter syntax: + +``` +--filter "Property=Value" +--filter "Property!=Value" +--filter "Property~Value" # Contains +--filter "Property!~Value" # Does not contain +``` + +Combine with `&` (AND) or `|` (OR): +``` +--filter "Property1=A&Property2=B" # AND +--filter "Property1=A|Property2=B" # OR +``` + +## Available Properties + +| Property | Description | Example | +|----------|-------------|---------| +| `TestCategory` | Category attribute | `TestCategory=OpenBugs` | +| `ClassName` | Test class name | `ClassName~BinaryOpTests` | +| `Name` | Test method name | `Name~Add_Int32` | +| `FullyQualifiedName` | Full namespace.class.method | `FullyQualifiedName~Backends.Kernels` | + +## 5 Concrete Examples + +### 1. Exclude OpenBugs (CI-style run) + +```bash +dotnet test --no-build --filter "TestCategory!=OpenBugs" +``` + +Runs all tests EXCEPT those marked `[OpenBugs]`. This is what CI uses. + +### 2. Run ONLY OpenBugs (verify bug fixes) + +```bash +dotnet test --no-build --filter "TestCategory=OpenBugs" +``` + +Runs only failing bug reproductions to check if your fix works. + +### 3. Run single test class + +```bash +dotnet test --no-build --filter "ClassName~CountNonzeroTests" +``` + +Runs all tests in classes containing `CountNonzeroTests`. + +### 4. Run single test method + +```bash +dotnet test --no-build --filter "Name=Add_TwoNumbers_ReturnsSum" +``` + +Runs only the test named exactly `Add_TwoNumbers_ReturnsSum`. + +### 5. Run tests by namespace pattern + +```bash +dotnet test --no-build --filter "FullyQualifiedName~Backends.Kernels" +``` + +Runs all tests in the `Backends.Kernels` namespace. + +## Quick Reference + +| Goal | Filter | +|------|--------| +| Exclude category | `TestCategory!=OpenBugs` | +| Include category only | `TestCategory=OpenBugs` | +| Single class (exact) | `ClassName=BinaryOpTests` | +| Class contains | `ClassName~BinaryOp` | +| Method contains | `Name~Add_` | +| Namespace contains | `FullyQualifiedName~Backends.Kernels` | +| Multiple categories (AND) | `TestCategory!=OpenBugs&TestCategory!=WindowsOnly` | +| Multiple categories (OR) | `TestCategory=OpenBugs\|TestCategory=Misaligned` | + +## Operators + +| Op | Meaning | Example | +|----|---------|---------| +| `=` | Equals | `TestCategory=Unit` | +| `!=` | Not equals | `TestCategory!=Slow` | +| `~` | Contains | `Name~Integration` | +| `!~` | Does not contain | `ClassName!~Legacy` | +| `&` | AND | `TestCategory!=A&TestCategory!=B` | +| `\|` | OR | `TestCategory=A\|TestCategory=B` | + +**Important:** +- Use `\|` (escaped pipe) for OR in bash +- Parentheses are NOT needed for combining filters +- Filter values are case-sensitive + +## NumSharp Categories + +| Category | Purpose | CI Behavior | +|----------|---------|-------------| +| `OpenBugs` | Known-failing bug reproductions | **Excluded** | +| `HighMemory` | Requires 8GB+ RAM | **Excluded** | +| `Misaligned` | NumSharp vs NumPy differences (tests pass) | Runs | +| `WindowsOnly` | Requires GDI+/System.Drawing | Excluded on Linux/macOS | +| `LongIndexing` | Tests > int.MaxValue elements | Runs | + +## Useful Commands + +```bash +# Stop on first failure (MSTest v3) +dotnet test --no-build -- --fail-on-failure + +# Verbose output (see passed tests too) +dotnet test --no-build -v normal + +# List tests without running +dotnet test --no-build --list-tests + +# CI-style: exclude OpenBugs and HighMemory +dotnet test --no-build --filter "TestCategory!=OpenBugs&TestCategory!=HighMemory" + +# Windows CI: full exclusion list +dotnet test --no-build --filter "TestCategory!=OpenBugs&TestCategory!=HighMemory" + +# Linux/macOS CI: also exclude WindowsOnly +dotnet test --no-build --filter "TestCategory!=OpenBugs&TestCategory!=HighMemory&TestCategory!=WindowsOnly" +``` + +## Advanced Filter Examples + +### Example A: Specific Test Method + +```bash +dotnet test --no-build --filter "FullyQualifiedName=NumSharp.UnitTest.Backends.Kernels.VarStdComprehensiveTests.Var_2D_Axis0" +``` + +**Result:** 1 test + +### Example B: Pattern Matching Multiple Classes + +```bash +dotnet test --no-build --filter "ClassName~Comprehensive&Name~_2D_" +``` + +**Result:** Tests in `*Comprehensive*` classes with `_2D_` in method name + +### Example C: Namespace + Category Filter + +```bash +dotnet test --no-build --filter "FullyQualifiedName~Backends.Kernels&TestCategory!=OpenBugs" +``` + +**Result:** All Kernels tests except OpenBugs + +### Example D: Multiple Categories (OR) + +```bash +dotnet test --no-build --filter "TestCategory=OpenBugs|TestCategory=Misaligned" +``` + +**Result:** Tests that have EITHER `[OpenBugs]` OR `[Misaligned]` attribute + +## Migration from TUnit + +| TUnit Filter | MSTest Filter | +|--------------|---------------| +| `--treenode-filter "/*/*/*/*[Category!=X]"` | `--filter "TestCategory!=X"` | +| `--treenode-filter "/*/*/ClassName/*"` | `--filter "ClassName~ClassName"` | +| `--treenode-filter "/*/*/*/MethodName"` | `--filter "Name=MethodName"` | +| `--treenode-filter "/*/Namespace/*/*"` | `--filter "FullyQualifiedName~Namespace"` | diff --git a/docs/TUNIT_FILTER_GUIDE.md b/docs/TUNIT_FILTER_GUIDE.md deleted file mode 100644 index 00c0aa8a8..000000000 --- a/docs/TUNIT_FILTER_GUIDE.md +++ /dev/null @@ -1,188 +0,0 @@ -# TUnit `--treenode-filter` Guide - -## Filter Path Structure - -``` -////[Property] -``` - -Use `*` as wildcard. Properties filter by `[Category(...)]` attributes. - -## 5 Concrete Examples - -### 1. Exclude OpenBugs (CI-style run) - -```bash -dotnet test --no-build -- --treenode-filter "/*/*/*/*[Category!=OpenBugs]" -``` - -Runs all tests EXCEPT those marked `[OpenBugs]`. This is what CI uses. - -### 2. Run ONLY OpenBugs (verify bug fixes) - -```bash -dotnet test --no-build -- --treenode-filter "/*/*/*/*[Category=OpenBugs]" -``` - -Runs only failing bug reproductions to check if your fix works. - -### 3. Run single test class - -```bash -dotnet test --no-build -- --treenode-filter "/*/*/CountNonzeroTests/*" -``` - -Runs all tests in `CountNonzeroTests` class regardless of namespace. - -### 4. Run single test method - -```bash -dotnet test --no-build -- --treenode-filter "/*/*/*/Add_TwoNumbers_ReturnsSum" -``` - -Runs only the test named `Add_TwoNumbers_ReturnsSum`. - -### 5. Run tests by namespace pattern - -```bash -dotnet test --no-build -- --treenode-filter "/*/NumSharp.UnitTest.Backends.Kernels/*/*" -``` - -Runs all tests in the `NumSharp.UnitTest.Backends.Kernels` namespace. - -## Quick Reference - -| Goal | Filter | -|------|--------| -| Exclude category | `/*/*/*/*[Category!=OpenBugs]` | -| Include category only | `/*/*/*/*[Category=OpenBugs]` | -| Single class | `/*/*/ClassName/*` | -| Single method | `/*/*/*/MethodName` | -| Namespace | `/*/Full.Namespace.Path/*/*` | -| Multiple categories (AND) | `/*/*/*/*[(Category!=OpenBugs)&(Category!=WindowsOnly)]` | -| Multiple categories (OR) | `/*/*/*/*[(Category=OpenBugs)\|(Category=Misaligned)]` | -| Multiple classes | Use wildcards: `/*/*/*Comprehensive*/*` | - -## Operators - -| Op | Meaning | Where | Example | -|----|---------|-------|---------| -| `*` | Wildcard | Path & Properties | `*Tests*`, `[Category=Open*]` | -| `=` | Equals | Properties | `[Category=Unit]` | -| `!=` | Not equals | Properties | `[Category!=Slow]` | -| `&` | AND | Properties | `[(Category=A)&(Priority=High)]` | -| `\|` | OR | **Properties ONLY** | `[(Category=A)\|(Category=B)]` | - -**Important:** -- OR (`|`) only works for property filters, NOT for path segments -- AND (`&`) requires outer brackets: `[(A)&(B)]` not `[A]&[B]` - -## NumSharp Categories - -| Category | Purpose | CI Behavior | -|----------|---------|-------------| -| `OpenBugs` | Known-failing bug reproductions | **Excluded** | -| `Misaligned` | NumSharp vs NumPy differences (tests pass) | Runs | -| `WindowsOnly` | Requires GDI+/System.Drawing | Excluded on Linux/macOS | - -## Useful Flags - -```bash -# Stop on first failure -dotnet test --no-build -- --fail-fast --treenode-filter "..." - -# Detailed output (see passed tests too) -dotnet test --no-build -- --output Detailed --treenode-filter "..." - -# List tests without running -dotnet test --no-build -- --list-tests - -# Combine: detailed + fail-fast + filter (exclude OpenBugs and WindowsOnly) -dotnet test --no-build -- --output Detailed --fail-fast \ - --treenode-filter "/*/*/*/*[(Category!=OpenBugs)&(Category!=WindowsOnly)]" -``` - -## Advanced Filter Examples (Tested & Working) - -### Example A: All Path Parameters Specified - -```bash -dotnet test --no-build -- --treenode-filter "/*/NumSharp.UnitTest.Backends.Kernels/VarStdComprehensiveTests/Var_2D_Axis0" -``` - -**Result:** 1 test ✅ - -| Part | Value | -|------|-------| -| Assembly | `*` (wildcard - assembly name varies) | -| Namespace | `NumSharp.UnitTest.Backends.Kernels` | -| Class | `VarStdComprehensiveTests` | -| Method | `Var_2D_Axis0` | - -### Example B: All Path Parameters with Wildcards - -```bash -dotnet test --no-build -- --treenode-filter "/*/*.Backends.*/*Comprehensive*/*_2D_*" -``` - -**Result:** 29 tests ✅ - -| Part | Pattern | Matches | -|------|---------|---------| -| Assembly | `*` | Any | -| Namespace | `*.Backends.*` | Contains `.Backends.` | -| Class | `*Comprehensive*` | Contains `Comprehensive` | -| Method | `*_2D_*` | Contains `_2D_` | - -### Example C: Multiple Classes via Wildcard Pattern - -```bash -dotnet test --no-build -- --treenode-filter "/*/*/VarStd*/*" -``` - -**Result:** 77 tests ✅ - -Matches `VarStdComprehensiveTests` and any other class starting with `VarStd`. - -**Note:** OR (`|`) does NOT work for path segments. Use wildcards instead. - -### Example D: OR for Multiple Categories (Properties) - -```bash -dotnet test --no-build -- --treenode-filter "/*/*/*/*[(Category=OpenBugs)|(Category=Misaligned)]" -``` - -**Result:** 277 tests ✅ - -Runs tests that have EITHER `[OpenBugs]` OR `[Misaligned]` attribute. - -### Example E: Combined - Wildcards + Property Filters (AND) - -```bash -dotnet test --no-build -- --treenode-filter "/*/*.Backends*/*/*[(Category!=OpenBugs)&(Category!=WindowsOnly)]" -``` - -**Result:** 1877 tests ✅ - -| Part | Pattern | Effect | -|------|---------|--------| -| Assembly | `*` | Any | -| Namespace | `*.Backends*` | Backend tests only | -| Class | `*` | All classes | -| Method | `*` | All methods | -| Properties | `[(Category!=OpenBugs)&(Category!=WindowsOnly)]` | Exclude both categories | - -**Note:** Wrap AND conditions in outer brackets: `[(A)&(B)]` - -## What Works vs What Doesn't - -| Pattern Type | Works? | Example | -|--------------|--------|---------| -| Path wildcards | ✅ | `/*/*/Var*/*` | -| Property equals | ✅ | `[Category=OpenBugs]` | -| Property not equals | ✅ | `[Category!=OpenBugs]` | -| Property AND (with brackets) | ✅ | `[(A=1)&(B=2)]` | -| Property OR | ✅ | `[(A=1)\|(B=2)]` | -| Property AND without brackets | ❌ | `[A=1]&[B=2]` → 0 matches | -| Path OR `(A)\|(B)` | ❌ | Does not match | -| `~=` contains | ❌ | Not supported | diff --git a/global.json b/global.json deleted file mode 100644 index 3140116df..000000000 --- a/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "test": { - "runner": "Microsoft.Testing.Platform" - } -} diff --git a/test/NumSharp.UnitTest/APIs/CountNonzeroTests.cs b/test/NumSharp.UnitTest/APIs/CountNonzeroTests.cs index fdf58dd2b..4ce625209 100644 --- a/test/NumSharp.UnitTest/APIs/CountNonzeroTests.cs +++ b/test/NumSharp.UnitTest/APIs/CountNonzeroTests.cs @@ -1,10 +1,6 @@ using System; -using System.Threading.Tasks; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; @@ -12,155 +8,156 @@ namespace NumSharp.UnitTest.APIs; /// Tests for np.count_nonzero. /// NumPy: np.count_nonzero([0, 1, 0, 2]) = 2 /// +[TestClass] public class CountNonzeroTests { #region Element-wise (No Axis) - [Test] - public async Task CountNonzero_1D_ReturnsCount() + [TestMethod] + public void CountNonzero_1D_ReturnsCount() { // NumPy: np.count_nonzero([0, 1, 0, 2]) = 2 var a = np.array(new int[] { 0, 1, 0, 2 }); var result = np.count_nonzero(a); - await Assert.That(result).IsEqualTo(2); + result.Should().Be(2); } - [Test] - public async Task CountNonzero_1D_AllZero_ReturnsZero() + [TestMethod] + public void CountNonzero_1D_AllZero_ReturnsZero() { // NumPy: np.count_nonzero([0, 0, 0]) = 0 var a = np.array(new int[] { 0, 0, 0 }); var result = np.count_nonzero(a); - await Assert.That(result).IsEqualTo(0); + result.Should().Be(0); } - [Test] - public async Task CountNonzero_1D_AllNonzero_ReturnsSize() + [TestMethod] + public void CountNonzero_1D_AllNonzero_ReturnsSize() { // NumPy: np.count_nonzero([1, 2, 3]) = 3 var a = np.array(new int[] { 1, 2, 3 }); var result = np.count_nonzero(a); - await Assert.That(result).IsEqualTo(3); + result.Should().Be(3); } - [Test] - public async Task CountNonzero_2D_ReturnsTotal() + [TestMethod] + public void CountNonzero_2D_ReturnsTotal() { // NumPy: np.count_nonzero([[0, 1], [2, 0]]) = 2 var a = np.array(new int[,] { { 0, 1 }, { 2, 0 } }); var result = np.count_nonzero(a); - await Assert.That(result).IsEqualTo(2); + result.Should().Be(2); } - [Test] - public async Task CountNonzero_Empty_ReturnsZero() + [TestMethod] + public void CountNonzero_Empty_ReturnsZero() { // NumPy: np.count_nonzero([]) = 0 var a = np.array(new int[0]); var result = np.count_nonzero(a); - await Assert.That(result).IsEqualTo(0); + result.Should().Be(0); } #endregion #region Boolean Arrays - [Test] - public async Task CountNonzero_Boolean_TrueIsNonzero() + [TestMethod] + public void CountNonzero_Boolean_TrueIsNonzero() { // NumPy: np.count_nonzero([False, True, False, True]) = 2 var a = np.array(new bool[] { false, true, false, true }); var result = np.count_nonzero(a); - await Assert.That(result).IsEqualTo(2); + result.Should().Be(2); } #endregion #region Float Arrays - [Test] - public async Task CountNonzero_Float_ZeroIsExact() + [TestMethod] + public void CountNonzero_Float_ZeroIsExact() { // NumPy: np.count_nonzero([0.0, 1.0, 0.0, 2.0]) = 2 var a = np.array(new double[] { 0.0, 1.0, 0.0, 2.0 }); var result = np.count_nonzero(a); - await Assert.That(result).IsEqualTo(2); + result.Should().Be(2); } - [Test] - public async Task CountNonzero_Float_NaN_IsNonzero() + [TestMethod] + public void CountNonzero_Float_NaN_IsNonzero() { // NumPy: np.count_nonzero([0.0, nan, 0.0]) = 1 var a = np.array(new double[] { 0.0, double.NaN, 0.0 }); var result = np.count_nonzero(a); - await Assert.That(result).IsEqualTo(1); + result.Should().Be(1); } #endregion #region Axis Reduction - [Test] - public async Task CountNonzero_2D_Axis0() + [TestMethod] + public void CountNonzero_2D_Axis0() { // NumPy: np.count_nonzero([[0, 1, 2], [3, 0, 0]], axis=0) = [1, 1, 1] var a = np.array(new int[,] { { 0, 1, 2 }, { 3, 0, 0 } }); var result = np.count_nonzero(a, axis: 0); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(1L); - await Assert.That(result.GetInt64(2)).IsEqualTo(1L); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(1L); + result.GetInt64(2).Should().Be(1L); } - [Test] - public async Task CountNonzero_2D_Axis1() + [TestMethod] + public void CountNonzero_2D_Axis1() { // NumPy: np.count_nonzero([[0, 1, 2], [3, 0, 0]], axis=1) = [2, 1] var a = np.array(new int[,] { { 0, 1, 2 }, { 3, 0, 0 } }); var result = np.count_nonzero(a, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 2 }); - await Assert.That(result.GetInt64(0)).IsEqualTo(2L); - await Assert.That(result.GetInt64(1)).IsEqualTo(1L); + result.shape.Should().BeEquivalentTo(new long[] { 2 }); + result.GetInt64(0).Should().Be(2L); + result.GetInt64(1).Should().Be(1L); } - [Test] - public async Task CountNonzero_2D_Axis0_Keepdims() + [TestMethod] + public void CountNonzero_2D_Axis0_Keepdims() { // NumPy: np.count_nonzero([[0, 1, 2], [3, 0, 0]], axis=0, keepdims=True) = [[1, 1, 1]] (shape 1,3) var a = np.array(new int[,] { { 0, 1, 2 }, { 3, 0, 0 } }); var result = np.count_nonzero(a, axis: 0, keepdims: true); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 1, 3 }); + result.shape.Should().BeEquivalentTo(new long[] { 1, 3 }); // Access via 2D indexing since keepdims preserves dimensions - await Assert.That(result.GetAtIndex(0)).IsEqualTo(1L); - await Assert.That(result.GetAtIndex(1)).IsEqualTo(1L); - await Assert.That(result.GetAtIndex(2)).IsEqualTo(1L); + result.GetAtIndex(0).Should().Be(1L); + result.GetAtIndex(1).Should().Be(1L); + result.GetAtIndex(2).Should().Be(1L); } - [Test] - public async Task CountNonzero_2D_NegativeAxis() + [TestMethod] + public void CountNonzero_2D_NegativeAxis() { // NumPy: np.count_nonzero([[0, 1, 2], [3, 0, 0]], axis=-1) = [2, 1] var a = np.array(new int[,] { { 0, 1, 2 }, { 3, 0, 0 } }); var result = np.count_nonzero(a, axis: -1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 2 }); - await Assert.That(result.GetInt64(0)).IsEqualTo(2L); - await Assert.That(result.GetInt64(1)).IsEqualTo(1L); + result.shape.Should().BeEquivalentTo(new long[] { 2 }); + result.GetInt64(0).Should().Be(2L); + result.GetInt64(1).Should().Be(1L); } - [Test] - public async Task CountNonzero_3D_Axis1() + [TestMethod] + public void CountNonzero_3D_Axis1() { // 3D array with shape (2, 2, 3) reduced along axis 1 gives shape (2, 3) var a = np.zeros(new Shape(2, 2, 3), NPTypeCode.Int32); @@ -171,41 +168,41 @@ public async Task CountNonzero_3D_Axis1() var result = np.count_nonzero(a, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 2, 3 }); + result.shape.Should().BeEquivalentTo(new long[] { 2, 3 }); // [0,0]: sum axis 1 of [0,:,0] = [1,0] -> 1 nonzero // [0,1]: sum axis 1 of [0,:,1] = [0,1] -> 1 nonzero // [0,2]: sum axis 1 of [0,:,2] = [0,0] -> 0 nonzero - await Assert.That(result.GetAtIndex(0)).IsEqualTo(1L); - await Assert.That(result.GetAtIndex(1)).IsEqualTo(1L); - await Assert.That(result.GetAtIndex(2)).IsEqualTo(0L); + result.GetAtIndex(0).Should().Be(1L); + result.GetAtIndex(1).Should().Be(1L); + result.GetAtIndex(2).Should().Be(0L); } #endregion #region Empty Array Axis Reduction - [Test] - public async Task CountNonzero_Empty2D_Axis0_ReturnsZeros() + [TestMethod] + public void CountNonzero_Empty2D_Axis0_ReturnsZeros() { // NumPy: np.count_nonzero(np.zeros((0, 3)), axis=0) = [0, 0, 0] var a = np.zeros(new Shape(0, 3), NPTypeCode.Int32); var result = np.count_nonzero(a, axis: 0); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That(result.GetInt64(0)).IsEqualTo(0L); - await Assert.That(result.GetInt64(1)).IsEqualTo(0L); - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + result.GetInt64(0).Should().Be(0L); + result.GetInt64(1).Should().Be(0L); + result.GetInt64(2).Should().Be(0L); } - [Test] - public async Task CountNonzero_Empty2D_Axis1_ReturnsEmpty() + [TestMethod] + public void CountNonzero_Empty2D_Axis1_ReturnsEmpty() { // NumPy: np.count_nonzero(np.zeros((0, 3)), axis=1) = [] (shape (0,)) var a = np.zeros(new Shape(0, 3), NPTypeCode.Int32); var result = np.count_nonzero(a, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 0 }); - await Assert.That(result.size).IsEqualTo(0); + result.shape.Should().BeEquivalentTo(new long[] { 0 }); + result.size.Should().Be(0); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np.can_cast.BattleTest.cs b/test/NumSharp.UnitTest/APIs/np.can_cast.BattleTest.cs index 055c6f3b8..36854d3a6 100644 --- a/test/NumSharp.UnitTest/APIs/np.can_cast.BattleTest.cs +++ b/test/NumSharp.UnitTest/APIs/np.can_cast.BattleTest.cs @@ -1,248 +1,245 @@ using System; -using System.Threading.Tasks; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; /// /// Battle tests for np.can_cast - comprehensive coverage of type casting rules. /// +[TestClass] public class NpCanCastBattleTests { #region Safe Casting - Type to Type - [Test] - public async Task CanCast_SameType_AlwaysTrue() + [TestMethod] + public void CanCast_SameType_AlwaysTrue() { - await Assert.That(np.can_cast(NPTypeCode.Int32, NPTypeCode.Int32)).IsTrue(); - await Assert.That(np.can_cast(NPTypeCode.Double, NPTypeCode.Double)).IsTrue(); - await Assert.That(np.can_cast(NPTypeCode.Boolean, NPTypeCode.Boolean)).IsTrue(); + np.can_cast(NPTypeCode.Int32, NPTypeCode.Int32).Should().BeTrue(); + np.can_cast(NPTypeCode.Double, NPTypeCode.Double).Should().BeTrue(); + np.can_cast(NPTypeCode.Boolean, NPTypeCode.Boolean).Should().BeTrue(); } - [Test] - public async Task CanCast_BoolToIntegers_Safe() + [TestMethod] + public void CanCast_BoolToIntegers_Safe() { - await Assert.That(np.can_cast(NPTypeCode.Boolean, NPTypeCode.Byte)).IsTrue(); - await Assert.That(np.can_cast(NPTypeCode.Boolean, NPTypeCode.Int32)).IsTrue(); - await Assert.That(np.can_cast(NPTypeCode.Boolean, NPTypeCode.Int64)).IsTrue(); + np.can_cast(NPTypeCode.Boolean, NPTypeCode.Byte).Should().BeTrue(); + np.can_cast(NPTypeCode.Boolean, NPTypeCode.Int32).Should().BeTrue(); + np.can_cast(NPTypeCode.Boolean, NPTypeCode.Int64).Should().BeTrue(); } - [Test] - public async Task CanCast_BoolToFloats_Safe() + [TestMethod] + public void CanCast_BoolToFloats_Safe() { - await Assert.That(np.can_cast(NPTypeCode.Boolean, NPTypeCode.Single)).IsTrue(); - await Assert.That(np.can_cast(NPTypeCode.Boolean, NPTypeCode.Double)).IsTrue(); + np.can_cast(NPTypeCode.Boolean, NPTypeCode.Single).Should().BeTrue(); + np.can_cast(NPTypeCode.Boolean, NPTypeCode.Double).Should().BeTrue(); } - [Test] - public async Task CanCast_ByteUpcast_Safe() + [TestMethod] + public void CanCast_ByteUpcast_Safe() { - await Assert.That(np.can_cast(NPTypeCode.Byte, NPTypeCode.Int16)).IsTrue(); - await Assert.That(np.can_cast(NPTypeCode.Byte, NPTypeCode.Int32)).IsTrue(); - await Assert.That(np.can_cast(NPTypeCode.Byte, NPTypeCode.Double)).IsTrue(); + np.can_cast(NPTypeCode.Byte, NPTypeCode.Int16).Should().BeTrue(); + np.can_cast(NPTypeCode.Byte, NPTypeCode.Int32).Should().BeTrue(); + np.can_cast(NPTypeCode.Byte, NPTypeCode.Double).Should().BeTrue(); } - [Test] - public async Task CanCast_Int32ToInt64_Safe() + [TestMethod] + public void CanCast_Int32ToInt64_Safe() { - await Assert.That(np.can_cast(NPTypeCode.Int32, NPTypeCode.Int64)).IsTrue(); + np.can_cast(NPTypeCode.Int32, NPTypeCode.Int64).Should().BeTrue(); } - [Test] - public async Task CanCast_Int64ToInt32_NotSafe() + [TestMethod] + public void CanCast_Int64ToInt32_NotSafe() { - await Assert.That(np.can_cast(NPTypeCode.Int64, NPTypeCode.Int32)).IsFalse(); + np.can_cast(NPTypeCode.Int64, NPTypeCode.Int32).Should().BeFalse(); } - [Test] - public async Task CanCast_Float32ToFloat64_Safe() + [TestMethod] + public void CanCast_Float32ToFloat64_Safe() { - await Assert.That(np.can_cast(NPTypeCode.Single, NPTypeCode.Double)).IsTrue(); + np.can_cast(NPTypeCode.Single, NPTypeCode.Double).Should().BeTrue(); } - [Test] - public async Task CanCast_Float64ToFloat32_NotSafe() + [TestMethod] + public void CanCast_Float64ToFloat32_NotSafe() { - await Assert.That(np.can_cast(NPTypeCode.Double, NPTypeCode.Single)).IsFalse(); + np.can_cast(NPTypeCode.Double, NPTypeCode.Single).Should().BeFalse(); } - [Test] - public async Task CanCast_FloatToInt_NotSafe() + [TestMethod] + public void CanCast_FloatToInt_NotSafe() { - await Assert.That(np.can_cast(NPTypeCode.Double, NPTypeCode.Int32)).IsFalse(); + np.can_cast(NPTypeCode.Double, NPTypeCode.Int32).Should().BeFalse(); } #endregion #region Casting Modes - [Test] - public async Task CanCast_NoMode_OnlySameType() + [TestMethod] + public void CanCast_NoMode_OnlySameType() { - await Assert.That(np.can_cast(NPTypeCode.Int32, NPTypeCode.Int32, "no")).IsTrue(); - await Assert.That(np.can_cast(NPTypeCode.Int32, NPTypeCode.Int64, "no")).IsFalse(); + np.can_cast(NPTypeCode.Int32, NPTypeCode.Int32, "no").Should().BeTrue(); + np.can_cast(NPTypeCode.Int32, NPTypeCode.Int64, "no").Should().BeFalse(); } - [Test] - public async Task CanCast_SameKindMode_AllowsDowncastWithinKind() + [TestMethod] + public void CanCast_SameKindMode_AllowsDowncastWithinKind() { - await Assert.That(np.can_cast(NPTypeCode.Int32, NPTypeCode.Int16, "same_kind")).IsTrue(); - await Assert.That(np.can_cast(NPTypeCode.Double, NPTypeCode.Single, "same_kind")).IsTrue(); + np.can_cast(NPTypeCode.Int32, NPTypeCode.Int16, "same_kind").Should().BeTrue(); + np.can_cast(NPTypeCode.Double, NPTypeCode.Single, "same_kind").Should().BeTrue(); } - [Test] - public async Task CanCast_SameKindMode_RejectsCrossKind() + [TestMethod] + public void CanCast_SameKindMode_RejectsCrossKind() { - await Assert.That(np.can_cast(NPTypeCode.Int32, NPTypeCode.Single, "same_kind")).IsFalse(); + np.can_cast(NPTypeCode.Int32, NPTypeCode.Single, "same_kind").Should().BeFalse(); } - [Test] - public async Task CanCast_UnsafeMode_AllowsAnything() + [TestMethod] + public void CanCast_UnsafeMode_AllowsAnything() { - await Assert.That(np.can_cast(NPTypeCode.Double, NPTypeCode.Int32, "unsafe")).IsTrue(); - await Assert.That(np.can_cast(NPTypeCode.Int64, NPTypeCode.Byte, "unsafe")).IsTrue(); + np.can_cast(NPTypeCode.Double, NPTypeCode.Int32, "unsafe").Should().BeTrue(); + np.can_cast(NPTypeCode.Int64, NPTypeCode.Byte, "unsafe").Should().BeTrue(); } - [Test] - public async Task CanCast_InvalidMode_Throws() + [TestMethod] + public void CanCast_InvalidMode_Throws() { - await Assert.That(() => np.can_cast(NPTypeCode.Int32, NPTypeCode.Int64, "invalid")).ThrowsException(); + new Action(() => np.can_cast(NPTypeCode.Int32, NPTypeCode.Int64, "invalid")).Should().Throw(); } #endregion #region Scalar Value Tests - [Test] - public async Task CanCast_IntScalar_FitsInByte() + [TestMethod] + public void CanCast_IntScalar_FitsInByte() { - await Assert.That(np.can_cast(0, NPTypeCode.Byte)).IsTrue(); - await Assert.That(np.can_cast(255, NPTypeCode.Byte)).IsTrue(); + np.can_cast(0, NPTypeCode.Byte).Should().BeTrue(); + np.can_cast(255, NPTypeCode.Byte).Should().BeTrue(); } - [Test] - public async Task CanCast_IntScalar_ExceedsByte() + [TestMethod] + public void CanCast_IntScalar_ExceedsByte() { - await Assert.That(np.can_cast(256, NPTypeCode.Byte)).IsFalse(); - await Assert.That(np.can_cast(-1, NPTypeCode.Byte)).IsFalse(); + np.can_cast(256, NPTypeCode.Byte).Should().BeFalse(); + np.can_cast(-1, NPTypeCode.Byte).Should().BeFalse(); } - [Test] - public async Task CanCast_BooleanBoundaries() + [TestMethod] + public void CanCast_BooleanBoundaries() { - await Assert.That(np.can_cast(0, NPTypeCode.Boolean)).IsTrue(); - await Assert.That(np.can_cast(1, NPTypeCode.Boolean)).IsTrue(); - await Assert.That(np.can_cast(2, NPTypeCode.Boolean)).IsFalse(); + np.can_cast(0, NPTypeCode.Boolean).Should().BeTrue(); + np.can_cast(1, NPTypeCode.Boolean).Should().BeTrue(); + np.can_cast(2, NPTypeCode.Boolean).Should().BeFalse(); } - [Test] - public async Task CanCast_LongScalar_FitsInInt32() + [TestMethod] + public void CanCast_LongScalar_FitsInInt32() { - await Assert.That(np.can_cast((long)int.MaxValue, NPTypeCode.Int32)).IsTrue(); + np.can_cast((long)int.MaxValue, NPTypeCode.Int32).Should().BeTrue(); } - [Test] - public async Task CanCast_LongScalar_ExceedsInt32() + [TestMethod] + public void CanCast_LongScalar_ExceedsInt32() { - await Assert.That(np.can_cast((long)int.MaxValue + 1, NPTypeCode.Int32)).IsFalse(); + np.can_cast((long)int.MaxValue + 1, NPTypeCode.Int32).Should().BeFalse(); } #endregion #region Generic Overload Tests - [Test] - public async Task CanCast_Generic_IntToLong() + [TestMethod] + public void CanCast_Generic_IntToLong() { - await Assert.That(np.can_cast()).IsTrue(); + np.can_cast().Should().BeTrue(); } - [Test] - public async Task CanCast_Generic_LongToInt() + [TestMethod] + public void CanCast_Generic_LongToInt() { - await Assert.That(np.can_cast()).IsFalse(); + np.can_cast().Should().BeFalse(); } - [Test] - public async Task CanCast_Generic_FloatToDouble() + [TestMethod] + public void CanCast_Generic_FloatToDouble() { - await Assert.That(np.can_cast()).IsTrue(); + np.can_cast().Should().BeTrue(); } - [Test] - public async Task CanCast_Generic_SameKind() + [TestMethod] + public void CanCast_Generic_SameKind() { - await Assert.That(np.can_cast("same_kind")).IsTrue(); + np.can_cast("same_kind").Should().BeTrue(); } #endregion #region Primitive Type Overloads - [Test] - public async Task CanCast_ByteOverload() + [TestMethod] + public void CanCast_ByteOverload() { - await Assert.That(np.can_cast((byte)100, NPTypeCode.Int32)).IsTrue(); + np.can_cast((byte)100, NPTypeCode.Int32).Should().BeTrue(); } - [Test] - public async Task CanCast_ShortOverload() + [TestMethod] + public void CanCast_ShortOverload() { - await Assert.That(np.can_cast((short)-100, NPTypeCode.Byte)).IsFalse(); + np.can_cast((short)-100, NPTypeCode.Byte).Should().BeFalse(); } - [Test] - public async Task CanCast_ULongOverload() + [TestMethod] + public void CanCast_ULongOverload() { - await Assert.That(np.can_cast(ulong.MaxValue, NPTypeCode.Int64)).IsFalse(); + np.can_cast(ulong.MaxValue, NPTypeCode.Int64).Should().BeFalse(); } - [Test] - public async Task CanCast_FloatOverload() + [TestMethod] + public void CanCast_FloatOverload() { - await Assert.That(np.can_cast(1.0f, NPTypeCode.Double)).IsTrue(); + np.can_cast(1.0f, NPTypeCode.Double).Should().BeTrue(); } - [Test] - public async Task CanCast_BoolOverload() + [TestMethod] + public void CanCast_BoolOverload() { - await Assert.That(np.can_cast(true, NPTypeCode.Int32)).IsTrue(); + np.can_cast(true, NPTypeCode.Int32).Should().BeTrue(); } #endregion #region NDArray Tests - [Test] - public async Task CanCast_NDArray_ToLargerType() + [TestMethod] + public void CanCast_NDArray_ToLargerType() { var arr = np.array(new int[] { 1, 2, 3 }); - await Assert.That(np.can_cast(arr, NPTypeCode.Int64)).IsTrue(); + np.can_cast(arr, NPTypeCode.Int64).Should().BeTrue(); } - [Test] - public async Task CanCast_NDArray_ToSmallerType() + [TestMethod] + public void CanCast_NDArray_ToSmallerType() { var arr = np.array(new int[] { 1, 2, 3 }); - await Assert.That(np.can_cast(arr, NPTypeCode.Int16)).IsFalse(); + np.can_cast(arr, NPTypeCode.Int16).Should().BeFalse(); } #endregion #region Type Overload Tests - [Test] - public async Task CanCast_Type_IntToLong() + [TestMethod] + public void CanCast_Type_IntToLong() { - await Assert.That(np.can_cast(typeof(int), typeof(long))).IsTrue(); + np.can_cast(typeof(int), typeof(long)).Should().BeTrue(); } - [Test] - public async Task CanCast_Type_LongToInt() + [TestMethod] + public void CanCast_Type_LongToInt() { - await Assert.That(np.can_cast(typeof(long), typeof(int))).IsFalse(); + np.can_cast(typeof(long), typeof(int)).Should().BeFalse(); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np.common_type.BattleTest.cs b/test/NumSharp.UnitTest/APIs/np.common_type.BattleTest.cs index 084f7cde5..1a574c3c5 100644 --- a/test/NumSharp.UnitTest/APIs/np.common_type.BattleTest.cs +++ b/test/NumSharp.UnitTest/APIs/np.common_type.BattleTest.cs @@ -1,133 +1,130 @@ using System; -using System.Threading.Tasks; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; /// /// Battle tests for np.common_type - comprehensive coverage. /// +[TestClass] public class NpCommonTypeBattleTests { #region Integer Arrays - Always Return Double - [Test] - public async Task CommonType_Int32Array_ReturnsDouble() + [TestMethod] + public void CommonType_Int32Array_ReturnsDouble() { var arr = np.array(new int[] { 1, 2, 3 }); - await Assert.That(np.common_type_code(arr)).IsEqualTo(NPTypeCode.Double); + np.common_type_code(arr).Should().Be(NPTypeCode.Double); } - [Test] - public async Task CommonType_ByteArray_ReturnsDouble() + [TestMethod] + public void CommonType_ByteArray_ReturnsDouble() { var arr = np.array(new byte[] { 1, 2, 3 }); - await Assert.That(np.common_type_code(arr)).IsEqualTo(NPTypeCode.Double); + np.common_type_code(arr).Should().Be(NPTypeCode.Double); } - [Test] - public async Task CommonType_BoolArray_ReturnsDouble() + [TestMethod] + public void CommonType_BoolArray_ReturnsDouble() { var arr = np.array(new bool[] { true, false }); - await Assert.That(np.common_type_code(arr)).IsEqualTo(NPTypeCode.Double); + np.common_type_code(arr).Should().Be(NPTypeCode.Double); } #endregion #region Float Arrays - [Test] - public async Task CommonType_Float32Array_ReturnsSingle() + [TestMethod] + public void CommonType_Float32Array_ReturnsSingle() { var arr = np.array(new float[] { 1.0f, 2.0f }); - await Assert.That(np.common_type_code(arr)).IsEqualTo(NPTypeCode.Single); + np.common_type_code(arr).Should().Be(NPTypeCode.Single); } - [Test] - public async Task CommonType_Float64Array_ReturnsDouble() + [TestMethod] + public void CommonType_Float64Array_ReturnsDouble() { var arr = np.array(new double[] { 1.0, 2.0 }); - await Assert.That(np.common_type_code(arr)).IsEqualTo(NPTypeCode.Double); + np.common_type_code(arr).Should().Be(NPTypeCode.Double); } #endregion #region Multiple Arrays - [Test] - public async Task CommonType_Float32AndFloat64_ReturnsDouble() + [TestMethod] + public void CommonType_Float32AndFloat64_ReturnsDouble() { var a = np.array(new float[] { 1.0f }); var b = np.array(new double[] { 1.0 }); - await Assert.That(np.common_type_code(a, b)).IsEqualTo(NPTypeCode.Double); + np.common_type_code(a, b).Should().Be(NPTypeCode.Double); } - [Test] - public async Task CommonType_AllFloat32_ReturnsSingle() + [TestMethod] + public void CommonType_AllFloat32_ReturnsSingle() { var a = np.array(new float[] { 1.0f }); var b = np.array(new float[] { 2.0f }); - await Assert.That(np.common_type_code(a, b)).IsEqualTo(NPTypeCode.Single); + np.common_type_code(a, b).Should().Be(NPTypeCode.Single); } #endregion #region NPTypeCode Overload - [Test] - public async Task CommonTypeCode_SingleInt_ReturnsDouble() + [TestMethod] + public void CommonTypeCode_SingleInt_ReturnsDouble() { - await Assert.That(np.common_type_code(NPTypeCode.Int32)).IsEqualTo(NPTypeCode.Double); + np.common_type_code(NPTypeCode.Int32).Should().Be(NPTypeCode.Double); } - [Test] - public async Task CommonTypeCode_SingleFloat_ReturnsSingle() + [TestMethod] + public void CommonTypeCode_SingleFloat_ReturnsSingle() { - await Assert.That(np.common_type_code(NPTypeCode.Single)).IsEqualTo(NPTypeCode.Single); + np.common_type_code(NPTypeCode.Single).Should().Be(NPTypeCode.Single); } #endregion #region Type Overload - [Test] - public async Task CommonType_Type_Int32_ReturnsDouble() + [TestMethod] + public void CommonType_Type_Int32_ReturnsDouble() { var arr = np.array(new int[] { 1, 2 }); var result = np.common_type(arr); - await Assert.That(result).IsEqualTo(typeof(double)); + result.Should().Be(typeof(double)); } - [Test] - public async Task CommonType_Type_Float32_ReturnsSingle() + [TestMethod] + public void CommonType_Type_Float32_ReturnsSingle() { var arr = np.array(new float[] { 1.0f, 2.0f }); var result = np.common_type(arr); - await Assert.That(result).IsEqualTo(typeof(float)); + result.Should().Be(typeof(float)); } #endregion #region Error Cases - [Test] - public async Task CommonType_Empty_Throws() + [TestMethod] + public void CommonType_Empty_Throws() { - await Assert.That(() => np.common_type_code(Array.Empty())).ThrowsException(); + new Action(() => np.common_type_code(Array.Empty())).Should().Throw(); } - [Test] - public async Task CommonType_Null_Throws() + [TestMethod] + public void CommonType_Null_Throws() { - await Assert.That(() => np.common_type_code((NDArray[])null!)).ThrowsException(); + new Action(() => np.common_type_code((NDArray[])null!)).Should().Throw(); } - [Test] - public async Task CommonTypeCode_Empty_Throws() + [TestMethod] + public void CommonTypeCode_Empty_Throws() { - await Assert.That(() => np.common_type_code(Array.Empty())).ThrowsException(); + new Action(() => np.common_type_code(Array.Empty())).Should().Throw(); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np.finfo.BattleTest.cs b/test/NumSharp.UnitTest/APIs/np.finfo.BattleTest.cs index f922fc95f..3e69cc86a 100644 --- a/test/NumSharp.UnitTest/APIs/np.finfo.BattleTest.cs +++ b/test/NumSharp.UnitTest/APIs/np.finfo.BattleTest.cs @@ -1,174 +1,171 @@ using System; -using System.Threading.Tasks; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; /// /// Battle tests for np.finfo - comprehensive coverage of all floating point types. /// +[TestClass] public class NpFInfoBattleTests { #region All Float Types Coverage - [Test] - public async Task FInfo_Single_AllProperties() + [TestMethod] + public void FInfo_Single_AllProperties() { var info = np.finfo(NPTypeCode.Single); - await Assert.That(info.bits).IsEqualTo(32); - await Assert.That(info.precision).IsEqualTo(6); - await Assert.That(info.maxexp).IsEqualTo(128); - await Assert.That(info.minexp).IsEqualTo(-125); + info.bits.Should().Be(32); + info.precision.Should().Be(6); + info.maxexp.Should().Be(128); + info.minexp.Should().Be(-125); // max/min are stored as double, so compare with tolerance - await Assert.That(info.max).IsGreaterThan(3.4e38); - await Assert.That(info.min).IsLessThan(-3.4e38); - await Assert.That(info.tiny).IsEqualTo(info.smallest_normal); + info.max.Should().BeGreaterThan(3.4e38); + info.min.Should().BeLessThan(-3.4e38); + info.tiny.Should().Be(info.smallest_normal); // smallest_subnormal for float is ~1.4e-45 - await Assert.That(info.smallest_subnormal).IsLessThan(1e-44); - await Assert.That(info.resolution).IsEqualTo(1e-6); + info.smallest_subnormal.Should().BeLessThan(1e-44); + info.resolution.Should().Be(1e-6); // eps for float32 ~ 1.19e-07 - await Assert.That(info.eps).IsGreaterThan(1e-7); - await Assert.That(info.eps).IsLessThan(2e-7); + info.eps.Should().BeGreaterThan(1e-7); + info.eps.Should().BeLessThan(2e-7); } - [Test] - public async Task FInfo_Double_AllProperties() + [TestMethod] + public void FInfo_Double_AllProperties() { var info = np.finfo(NPTypeCode.Double); - await Assert.That(info.bits).IsEqualTo(64); - await Assert.That(info.precision).IsEqualTo(15); - await Assert.That(info.maxexp).IsEqualTo(1024); - await Assert.That(info.minexp).IsEqualTo(-1021); - await Assert.That(info.max).IsEqualTo(double.MaxValue); - await Assert.That(info.min).IsEqualTo(-double.MaxValue); - await Assert.That(info.smallest_subnormal).IsEqualTo(double.Epsilon); - await Assert.That(info.resolution).IsEqualTo(1e-15); + info.bits.Should().Be(64); + info.precision.Should().Be(15); + info.maxexp.Should().Be(1024); + info.minexp.Should().Be(-1021); + info.max.Should().Be(double.MaxValue); + info.min.Should().Be(-double.MaxValue); + info.smallest_subnormal.Should().Be(double.Epsilon); + info.resolution.Should().Be(1e-15); // eps ~ 2.22e-16 - await Assert.That(info.eps).IsGreaterThan(2e-16); - await Assert.That(info.eps).IsLessThan(3e-16); + info.eps.Should().BeGreaterThan(2e-16); + info.eps.Should().BeLessThan(3e-16); } - [Test] - public async Task FInfo_Decimal_AllProperties() + [TestMethod] + public void FInfo_Decimal_AllProperties() { var info = np.finfo(NPTypeCode.Decimal); - await Assert.That(info.bits).IsEqualTo(128); - await Assert.That(info.precision).IsEqualTo(28); - await Assert.That(info.resolution).IsEqualTo(1e-28); + info.bits.Should().Be(128); + info.precision.Should().Be(28); + info.resolution.Should().Be(1e-28); } #endregion #region Error Cases - [Test] - public async Task FInfo_Int32_Throws() + [TestMethod] + public void FInfo_Int32_Throws() { - await Assert.That(() => np.finfo(NPTypeCode.Int32)).ThrowsException(); + new Action(() => np.finfo(NPTypeCode.Int32)).Should().Throw(); } - [Test] - public async Task FInfo_Boolean_Throws() + [TestMethod] + public void FInfo_Boolean_Throws() { - await Assert.That(() => np.finfo(NPTypeCode.Boolean)).ThrowsException(); + new Action(() => np.finfo(NPTypeCode.Boolean)).Should().Throw(); } - [Test] - public async Task FInfo_Byte_Throws() + [TestMethod] + public void FInfo_Byte_Throws() { - await Assert.That(() => np.finfo(NPTypeCode.Byte)).ThrowsException(); + new Action(() => np.finfo(NPTypeCode.Byte)).Should().Throw(); } - [Test] - public async Task FInfo_Empty_Throws() + [TestMethod] + public void FInfo_Empty_Throws() { - await Assert.That(() => np.finfo(NPTypeCode.Empty)).ThrowsException(); + new Action(() => np.finfo(NPTypeCode.Empty)).Should().Throw(); } - [Test] - public async Task FInfo_NullType_Throws() + [TestMethod] + public void FInfo_NullType_Throws() { - await Assert.That(() => np.finfo((Type)null!)).ThrowsException(); + new Action(() => np.finfo((Type)null!)).Should().Throw(); } - [Test] - public async Task FInfo_NullArray_Throws() + [TestMethod] + public void FInfo_NullArray_Throws() { - await Assert.That(() => np.finfo((NDArray)null!)).ThrowsException(); + new Action(() => np.finfo((NDArray)null!)).Should().Throw(); } - [Test] - public async Task FInfo_EmptyDtypeString_Throws() + [TestMethod] + public void FInfo_EmptyDtypeString_Throws() { - await Assert.That(() => np.finfo("")).ThrowsException(); + new Action(() => np.finfo("")).Should().Throw(); } - [Test] - public async Task FInfo_InvalidDtypeString_Throws() + [TestMethod] + public void FInfo_InvalidDtypeString_Throws() { - await Assert.That(() => np.finfo("int32")).ThrowsException(); + new Action(() => np.finfo("int32")).Should().Throw(); } #endregion #region Generic Overload Tests - [Test] - public async Task FInfo_Generic_Float() + [TestMethod] + public void FInfo_Generic_Float() { var info = np.finfo(); - await Assert.That(info.bits).IsEqualTo(32); - await Assert.That(info.precision).IsEqualTo(6); + info.bits.Should().Be(32); + info.precision.Should().Be(6); } - [Test] - public async Task FInfo_Generic_Double() + [TestMethod] + public void FInfo_Generic_Double() { var info = np.finfo(); - await Assert.That(info.bits).IsEqualTo(64); - await Assert.That(info.precision).IsEqualTo(15); + info.bits.Should().Be(64); + info.precision.Should().Be(15); } - [Test] - public async Task FInfo_Generic_Decimal() + [TestMethod] + public void FInfo_Generic_Decimal() { var info = np.finfo(); - await Assert.That(info.bits).IsEqualTo(128); + info.bits.Should().Be(128); } - [Test] - public async Task FInfo_Generic_Int_Throws() + [TestMethod] + public void FInfo_Generic_Int_Throws() { - await Assert.That(() => np.finfo()).ThrowsException(); + new Action(() => np.finfo()).Should().Throw(); } #endregion #region NDArray Overload Tests - [Test] - public async Task FInfo_NDArray_Float32() + [TestMethod] + public void FInfo_NDArray_Float32() { var arr = np.array(new float[] { 1.0f, 2.0f, 3.0f }); var info = np.finfo(arr); - await Assert.That(info.bits).IsEqualTo(32); + info.bits.Should().Be(32); } - [Test] - public async Task FInfo_NDArray_Float64() + [TestMethod] + public void FInfo_NDArray_Float64() { var arr = np.array(new double[] { 1.0, 2.0, 3.0 }); var info = np.finfo(arr); - await Assert.That(info.bits).IsEqualTo(64); + info.bits.Should().Be(64); } - [Test] - public async Task FInfo_NDArray_Int_Throws() + [TestMethod] + public void FInfo_NDArray_Int_Throws() { var arr = np.array(new int[] { 1, 2, 3 }); - await Assert.That(() => np.finfo(arr)).ThrowsException(); + new Action(() => np.finfo(arr)).Should().Throw(); } #endregion @@ -178,59 +175,59 @@ public async Task FInfo_NDArray_Int_Throws() // Note: np.dtype() uses type names like "float", "double", "single" // NumPy-style names like "float32", "float64" are not fully supported yet - [Test] - public async Task FInfo_String_Float() + [TestMethod] + public void FInfo_String_Float() { var info = np.finfo("float"); // defaults to float (single) - await Assert.That(info.bits).IsEqualTo(32); + info.bits.Should().Be(32); } - [Test] - public async Task FInfo_String_Single() + [TestMethod] + public void FInfo_String_Single() { var info = np.finfo("single"); - await Assert.That(info.bits).IsEqualTo(32); + info.bits.Should().Be(32); } - [Test] - public async Task FInfo_String_Double() + [TestMethod] + public void FInfo_String_Double() { var info = np.finfo("double"); - await Assert.That(info.bits).IsEqualTo(64); + info.bits.Should().Be(64); } #endregion #region Epsilon Verification - [Test] - public async Task FInfo_Double_EpsIsNextFloat() + [TestMethod] + public void FInfo_Double_EpsIsNextFloat() { var info = np.finfo(NPTypeCode.Double); double expected = Math.BitIncrement(1.0) - 1.0; - await Assert.That(info.eps).IsEqualTo(expected); + info.eps.Should().Be(expected); } - [Test] - public async Task FInfo_Single_EpsIsNextFloat() + [TestMethod] + public void FInfo_Single_EpsIsNextFloat() { var info = np.finfo(NPTypeCode.Single); // Must use MathF for float operations double expected = MathF.BitIncrement(1.0f) - 1.0f; - await Assert.That(info.eps).IsEqualTo(expected); + info.eps.Should().Be(expected); } #endregion #region ToString Tests - [Test] - public async Task FInfo_ToString_ContainsExpectedInfo() + [TestMethod] + public void FInfo_ToString_ContainsExpectedInfo() { var info = np.finfo(NPTypeCode.Double); var str = info.ToString(); - await Assert.That(str).Contains("resolution="); - await Assert.That(str).Contains("float64"); + str.Should().Contain("resolution="); + str.Should().Contain("float64"); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np.iinfo.BattleTest.cs b/test/NumSharp.UnitTest/APIs/np.iinfo.BattleTest.cs index 841fbb1ca..eab5891e3 100644 --- a/test/NumSharp.UnitTest/APIs/np.iinfo.BattleTest.cs +++ b/test/NumSharp.UnitTest/APIs/np.iinfo.BattleTest.cs @@ -1,232 +1,229 @@ using System; -using System.Threading.Tasks; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; /// /// Battle tests for np.iinfo - comprehensive coverage of all integer types and edge cases. /// +[TestClass] public class NpIInfoBattleTests { #region All Integer Types Coverage - [Test] - public async Task IInfo_Boolean_AllProperties() + [TestMethod] + public void IInfo_Boolean_AllProperties() { var info = np.iinfo(NPTypeCode.Boolean); - await Assert.That(info.bits).IsEqualTo(8); - await Assert.That(info.min).IsEqualTo(0); - await Assert.That(info.max).IsEqualTo(1); - await Assert.That(info.maxUnsigned).IsEqualTo(1UL); - await Assert.That(info.kind).IsEqualTo('b'); - await Assert.That(info.dtype).IsEqualTo(NPTypeCode.Boolean); + info.bits.Should().Be(8); + info.min.Should().Be(0); + info.max.Should().Be(1); + info.maxUnsigned.Should().Be(1UL); + info.kind.Should().Be('b'); + info.dtype.Should().Be(NPTypeCode.Boolean); } - [Test] - public async Task IInfo_Byte_AllProperties() + [TestMethod] + public void IInfo_Byte_AllProperties() { var info = np.iinfo(NPTypeCode.Byte); - await Assert.That(info.bits).IsEqualTo(8); - await Assert.That(info.min).IsEqualTo(0); - await Assert.That(info.max).IsEqualTo(255); - await Assert.That(info.maxUnsigned).IsEqualTo(255UL); - await Assert.That(info.kind).IsEqualTo('u'); + info.bits.Should().Be(8); + info.min.Should().Be(0); + info.max.Should().Be(255); + info.maxUnsigned.Should().Be(255UL); + info.kind.Should().Be('u'); } - [Test] - public async Task IInfo_Int16_AllProperties() + [TestMethod] + public void IInfo_Int16_AllProperties() { var info = np.iinfo(NPTypeCode.Int16); - await Assert.That(info.bits).IsEqualTo(16); - await Assert.That(info.min).IsEqualTo(short.MinValue); - await Assert.That(info.max).IsEqualTo(short.MaxValue); - await Assert.That(info.kind).IsEqualTo('i'); + info.bits.Should().Be(16); + info.min.Should().Be(short.MinValue); + info.max.Should().Be(short.MaxValue); + info.kind.Should().Be('i'); } - [Test] - public async Task IInfo_UInt16_AllProperties() + [TestMethod] + public void IInfo_UInt16_AllProperties() { var info = np.iinfo(NPTypeCode.UInt16); - await Assert.That(info.bits).IsEqualTo(16); - await Assert.That(info.min).IsEqualTo(0); - await Assert.That(info.max).IsEqualTo(ushort.MaxValue); - await Assert.That(info.kind).IsEqualTo('u'); + info.bits.Should().Be(16); + info.min.Should().Be(0); + info.max.Should().Be(ushort.MaxValue); + info.kind.Should().Be('u'); } - [Test] - public async Task IInfo_Int32_AllProperties() + [TestMethod] + public void IInfo_Int32_AllProperties() { var info = np.iinfo(NPTypeCode.Int32); - await Assert.That(info.bits).IsEqualTo(32); - await Assert.That(info.min).IsEqualTo(int.MinValue); - await Assert.That(info.max).IsEqualTo(int.MaxValue); - await Assert.That(info.kind).IsEqualTo('i'); + info.bits.Should().Be(32); + info.min.Should().Be(int.MinValue); + info.max.Should().Be(int.MaxValue); + info.kind.Should().Be('i'); } - [Test] - public async Task IInfo_UInt32_AllProperties() + [TestMethod] + public void IInfo_UInt32_AllProperties() { var info = np.iinfo(NPTypeCode.UInt32); - await Assert.That(info.bits).IsEqualTo(32); - await Assert.That(info.min).IsEqualTo(0); - await Assert.That(info.max).IsEqualTo(uint.MaxValue); - await Assert.That(info.kind).IsEqualTo('u'); + info.bits.Should().Be(32); + info.min.Should().Be(0); + info.max.Should().Be(uint.MaxValue); + info.kind.Should().Be('u'); } - [Test] - public async Task IInfo_Int64_AllProperties() + [TestMethod] + public void IInfo_Int64_AllProperties() { var info = np.iinfo(NPTypeCode.Int64); - await Assert.That(info.bits).IsEqualTo(64); - await Assert.That(info.min).IsEqualTo(long.MinValue); - await Assert.That(info.max).IsEqualTo(long.MaxValue); - await Assert.That(info.kind).IsEqualTo('i'); + info.bits.Should().Be(64); + info.min.Should().Be(long.MinValue); + info.max.Should().Be(long.MaxValue); + info.kind.Should().Be('i'); } - [Test] - public async Task IInfo_UInt64_AllProperties() + [TestMethod] + public void IInfo_UInt64_AllProperties() { var info = np.iinfo(NPTypeCode.UInt64); - await Assert.That(info.bits).IsEqualTo(64); - await Assert.That(info.min).IsEqualTo(0); - await Assert.That(info.max).IsEqualTo(long.MaxValue); // clamped - await Assert.That(info.maxUnsigned).IsEqualTo(ulong.MaxValue); - await Assert.That(info.kind).IsEqualTo('u'); + info.bits.Should().Be(64); + info.min.Should().Be(0); + info.max.Should().Be(long.MaxValue); // clamped + info.maxUnsigned.Should().Be(ulong.MaxValue); + info.kind.Should().Be('u'); } - [Test] - public async Task IInfo_Char_AllProperties() + [TestMethod] + public void IInfo_Char_AllProperties() { var info = np.iinfo(NPTypeCode.Char); - await Assert.That(info.bits).IsEqualTo(16); - await Assert.That(info.min).IsEqualTo(0); - await Assert.That(info.max).IsEqualTo(char.MaxValue); - await Assert.That(info.kind).IsEqualTo('u'); + info.bits.Should().Be(16); + info.min.Should().Be(0); + info.max.Should().Be(char.MaxValue); + info.kind.Should().Be('u'); } #endregion #region Error Cases - [Test] - public async Task IInfo_Single_Throws() + [TestMethod] + public void IInfo_Single_Throws() { - await Assert.That(() => np.iinfo(NPTypeCode.Single)).ThrowsException(); + new Action(() => np.iinfo(NPTypeCode.Single)).Should().Throw(); } - [Test] - public async Task IInfo_Double_Throws() + [TestMethod] + public void IInfo_Double_Throws() { - await Assert.That(() => np.iinfo(NPTypeCode.Double)).ThrowsException(); + new Action(() => np.iinfo(NPTypeCode.Double)).Should().Throw(); } - [Test] - public async Task IInfo_Decimal_Throws() + [TestMethod] + public void IInfo_Decimal_Throws() { - await Assert.That(() => np.iinfo(NPTypeCode.Decimal)).ThrowsException(); + new Action(() => np.iinfo(NPTypeCode.Decimal)).Should().Throw(); } - [Test] - public async Task IInfo_Empty_Throws() + [TestMethod] + public void IInfo_Empty_Throws() { - await Assert.That(() => np.iinfo(NPTypeCode.Empty)).ThrowsException(); + new Action(() => np.iinfo(NPTypeCode.Empty)).Should().Throw(); } - [Test] - public async Task IInfo_NullType_Throws() + [TestMethod] + public void IInfo_NullType_Throws() { - await Assert.That(() => np.iinfo((Type)null!)).ThrowsException(); + new Action(() => np.iinfo((Type)null!)).Should().Throw(); } - [Test] - public async Task IInfo_NullArray_Throws() + [TestMethod] + public void IInfo_NullArray_Throws() { - await Assert.That(() => np.iinfo((NDArray)null!)).ThrowsException(); + new Action(() => np.iinfo((NDArray)null!)).Should().Throw(); } - [Test] - public async Task IInfo_EmptyDtypeString_Throws() + [TestMethod] + public void IInfo_EmptyDtypeString_Throws() { - await Assert.That(() => np.iinfo("")).ThrowsException(); + new Action(() => np.iinfo("")).Should().Throw(); } - [Test] - public async Task IInfo_InvalidDtypeString_Throws() + [TestMethod] + public void IInfo_InvalidDtypeString_Throws() { - await Assert.That(() => np.iinfo("float32")).ThrowsException(); + new Action(() => np.iinfo("float32")).Should().Throw(); } #endregion #region Generic Overload Tests - [Test] - public async Task IInfo_Generic_Int() + [TestMethod] + public void IInfo_Generic_Int() { var info = np.iinfo(); - await Assert.That(info.bits).IsEqualTo(32); - await Assert.That(info.min).IsEqualTo(int.MinValue); - await Assert.That(info.max).IsEqualTo(int.MaxValue); + info.bits.Should().Be(32); + info.min.Should().Be(int.MinValue); + info.max.Should().Be(int.MaxValue); } - [Test] - public async Task IInfo_Generic_Byte() + [TestMethod] + public void IInfo_Generic_Byte() { var info = np.iinfo(); - await Assert.That(info.bits).IsEqualTo(8); - await Assert.That(info.max).IsEqualTo(255); + info.bits.Should().Be(8); + info.max.Should().Be(255); } - [Test] - public async Task IInfo_Generic_Long() + [TestMethod] + public void IInfo_Generic_Long() { var info = np.iinfo(); - await Assert.That(info.bits).IsEqualTo(64); + info.bits.Should().Be(64); } - [Test] - public async Task IInfo_Generic_Bool() + [TestMethod] + public void IInfo_Generic_Bool() { var info = np.iinfo(); - await Assert.That(info.bits).IsEqualTo(8); - await Assert.That(info.max).IsEqualTo(1); + info.bits.Should().Be(8); + info.max.Should().Be(1); } - [Test] - public async Task IInfo_Generic_Float_Throws() + [TestMethod] + public void IInfo_Generic_Float_Throws() { - await Assert.That(() => np.iinfo()).ThrowsException(); + new Action(() => np.iinfo()).Should().Throw(); } #endregion #region NDArray Overload Tests - [Test] - public async Task IInfo_NDArray_Int32() + [TestMethod] + public void IInfo_NDArray_Int32() { var arr = np.array(new int[] { 1, 2, 3 }); var info = np.iinfo(arr); - await Assert.That(info.bits).IsEqualTo(32); - await Assert.That(info.dtype).IsEqualTo(NPTypeCode.Int32); + info.bits.Should().Be(32); + info.dtype.Should().Be(NPTypeCode.Int32); } - [Test] - public async Task IInfo_NDArray_Byte() + [TestMethod] + public void IInfo_NDArray_Byte() { var arr = np.array(new byte[] { 1, 2, 3 }); var info = np.iinfo(arr); - await Assert.That(info.bits).IsEqualTo(8); + info.bits.Should().Be(8); } - [Test] - public async Task IInfo_NDArray_Float_Throws() + [TestMethod] + public void IInfo_NDArray_Float_Throws() { var arr = np.array(new float[] { 1.0f, 2.0f }); - await Assert.That(() => np.iinfo(arr)).ThrowsException(); + new Action(() => np.iinfo(arr)).Should().Throw(); } #endregion @@ -236,58 +233,58 @@ public async Task IInfo_NDArray_Float_Throws() // Note: np.dtype() uses size+type format (e.g., "i4" for int32) // NumPy-style names like "int32" are not fully supported yet - [Test] - public async Task IInfo_String_Int() + [TestMethod] + public void IInfo_String_Int() { var info = np.iinfo("int"); // defaults to int32 - await Assert.That(info.bits).IsEqualTo(32); + info.bits.Should().Be(32); } - [Test] - public async Task IInfo_String_I4() + [TestMethod] + public void IInfo_String_I4() { var info = np.iinfo("i4"); // int32 - await Assert.That(info.bits).IsEqualTo(32); + info.bits.Should().Be(32); } - [Test] - public async Task IInfo_String_I8() + [TestMethod] + public void IInfo_String_I8() { var info = np.iinfo("i8"); // int64 - await Assert.That(info.bits).IsEqualTo(64); + info.bits.Should().Be(64); } - [Test] - public async Task IInfo_String_Bool() + [TestMethod] + public void IInfo_String_Bool() { var info = np.iinfo("bool"); - await Assert.That(info.bits).IsEqualTo(8); + info.bits.Should().Be(8); } #endregion #region ToString Tests - [Test] - public async Task IInfo_ToString_ContainsExpectedInfo() + [TestMethod] + public void IInfo_ToString_ContainsExpectedInfo() { var info = np.iinfo(NPTypeCode.Int32); var str = info.ToString(); - await Assert.That(str).Contains("min="); - await Assert.That(str).Contains("max="); - await Assert.That(str).Contains("int32"); + str.Should().Contain("min="); + str.Should().Contain("max="); + str.Should().Contain("int32"); } #endregion #region UInt64 Max Value Edge Case - [Test] - public async Task IInfo_UInt64_MaxExceedsLongMaxValue() + [TestMethod] + public void IInfo_UInt64_MaxExceedsLongMaxValue() { var info = np.iinfo(NPTypeCode.UInt64); - await Assert.That(info.maxUnsigned).IsEqualTo(ulong.MaxValue); - await Assert.That(info.maxUnsigned).IsGreaterThan((ulong)info.max); + info.maxUnsigned.Should().Be(ulong.MaxValue); + info.maxUnsigned.Should().BeGreaterThan((ulong)info.max); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np.isreal_iscomplex.BattleTest.cs b/test/NumSharp.UnitTest/APIs/np.isreal_iscomplex.BattleTest.cs index 9bf9bfe1f..d04d539da 100644 --- a/test/NumSharp.UnitTest/APIs/np.isreal_iscomplex.BattleTest.cs +++ b/test/NumSharp.UnitTest/APIs/np.isreal_iscomplex.BattleTest.cs @@ -1,193 +1,190 @@ using System; -using System.Threading.Tasks; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; /// /// Battle tests for np.isreal, np.iscomplex, np.isrealobj, np.iscomplexobj. /// +[TestClass] public class NpIsRealIsComplexBattleTests { #region isreal Tests - [Test] - public async Task IsReal_IntArray_AllTrue() + [TestMethod] + public void IsReal_IntArray_AllTrue() { var arr = np.array(new int[] { 1, 2, 3 }); var result = np.isreal(arr); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] - public async Task IsReal_FloatArray_AllTrue() + [TestMethod] + public void IsReal_FloatArray_AllTrue() { var arr = np.array(new float[] { 1.0f, 2.0f, 3.0f }); var result = np.isreal(arr); - await Assert.That(result.GetBoolean(0)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); } - [Test] - public async Task IsReal_DoubleArray_AllTrue() + [TestMethod] + public void IsReal_DoubleArray_AllTrue() { var arr = np.array(new double[] { 1.0, 2.0, 3.0 }); var result = np.isreal(arr); - await Assert.That(result.GetBoolean(0)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); } - [Test] - public async Task IsReal_ShapeMatches() + [TestMethod] + public void IsReal_ShapeMatches() { var arr = np.array(new int[] { 1, 2, 3 }); var result = np.isreal(arr); - await Assert.That(result.shape).IsEquivalentTo(arr.shape); + result.shape.Should().BeEquivalentTo(arr.shape); } - [Test] - public async Task IsReal_Null_Throws() + [TestMethod] + public void IsReal_Null_Throws() { - await Assert.That(() => np.isreal(null!)).ThrowsException(); + new Action(() => np.isreal(null!)).Should().Throw(); } #endregion #region iscomplex Tests - [Test] - public async Task IsComplex_IntArray_AllFalse() + [TestMethod] + public void IsComplex_IntArray_AllFalse() { var arr = np.array(new int[] { 1, 2, 3 }); var result = np.iscomplex(arr); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeFalse(); } - [Test] - public async Task IsComplex_FloatArray_AllFalse() + [TestMethod] + public void IsComplex_FloatArray_AllFalse() { var arr = np.array(new float[] { 1.0f, 2.0f, 3.0f }); var result = np.iscomplex(arr); - await Assert.That(result.GetBoolean(0)).IsFalse(); + result.GetBoolean(0).Should().BeFalse(); } - [Test] - public async Task IsComplex_ShapeMatches() + [TestMethod] + public void IsComplex_ShapeMatches() { var arr = np.array(new int[] { 1, 2, 3 }); var result = np.iscomplex(arr); - await Assert.That(result.shape).IsEquivalentTo(arr.shape); + result.shape.Should().BeEquivalentTo(arr.shape); } - [Test] - public async Task IsComplex_Null_Throws() + [TestMethod] + public void IsComplex_Null_Throws() { - await Assert.That(() => np.iscomplex(null!)).ThrowsException(); + new Action(() => np.iscomplex(null!)).Should().Throw(); } #endregion #region isrealobj Tests - [Test] - public async Task IsRealObj_IntArray_True() + [TestMethod] + public void IsRealObj_IntArray_True() { var arr = np.array(new int[] { 1, 2, 3 }); - await Assert.That(np.isrealobj(arr)).IsTrue(); + np.isrealobj(arr).Should().BeTrue(); } - [Test] - public async Task IsRealObj_FloatArray_True() + [TestMethod] + public void IsRealObj_FloatArray_True() { var arr = np.array(new float[] { 1.0f, 2.0f }); - await Assert.That(np.isrealobj(arr)).IsTrue(); + np.isrealobj(arr).Should().BeTrue(); } - [Test] - public async Task IsRealObj_DoubleArray_True() + [TestMethod] + public void IsRealObj_DoubleArray_True() { var arr = np.array(new double[] { 1.0, 2.0 }); - await Assert.That(np.isrealobj(arr)).IsTrue(); + np.isrealobj(arr).Should().BeTrue(); } - [Test] - public async Task IsRealObj_AllTypes_True() + [TestMethod] + public void IsRealObj_AllTypes_True() { - await Assert.That(np.isrealobj(np.array(new bool[] { true }))).IsTrue(); - await Assert.That(np.isrealobj(np.array(new byte[] { 1 }))).IsTrue(); - await Assert.That(np.isrealobj(np.array(new short[] { 1 }))).IsTrue(); - await Assert.That(np.isrealobj(np.array(new int[] { 1 }))).IsTrue(); - await Assert.That(np.isrealobj(np.array(new long[] { 1 }))).IsTrue(); + np.isrealobj(np.array(new bool[] { true })).Should().BeTrue(); + np.isrealobj(np.array(new byte[] { 1 })).Should().BeTrue(); + np.isrealobj(np.array(new short[] { 1 })).Should().BeTrue(); + np.isrealobj(np.array(new int[] { 1 })).Should().BeTrue(); + np.isrealobj(np.array(new long[] { 1 })).Should().BeTrue(); } - [Test] - public async Task IsRealObj_Null_Throws() + [TestMethod] + public void IsRealObj_Null_Throws() { - await Assert.That(() => np.isrealobj(null!)).ThrowsException(); + new Action(() => np.isrealobj(null!)).Should().Throw(); } #endregion #region iscomplexobj Tests - [Test] - public async Task IsComplexObj_IntArray_False() + [TestMethod] + public void IsComplexObj_IntArray_False() { var arr = np.array(new int[] { 1, 2, 3 }); - await Assert.That(np.iscomplexobj(arr)).IsFalse(); + np.iscomplexobj(arr).Should().BeFalse(); } - [Test] - public async Task IsComplexObj_FloatArray_False() + [TestMethod] + public void IsComplexObj_FloatArray_False() { var arr = np.array(new float[] { 1.0f, 2.0f }); - await Assert.That(np.iscomplexobj(arr)).IsFalse(); + np.iscomplexobj(arr).Should().BeFalse(); } - [Test] - public async Task IsComplexObj_AllRealTypes_False() + [TestMethod] + public void IsComplexObj_AllRealTypes_False() { - await Assert.That(np.iscomplexobj(np.array(new bool[] { true }))).IsFalse(); - await Assert.That(np.iscomplexobj(np.array(new byte[] { 1 }))).IsFalse(); - await Assert.That(np.iscomplexobj(np.array(new int[] { 1 }))).IsFalse(); - await Assert.That(np.iscomplexobj(np.array(new double[] { 1.0 }))).IsFalse(); + np.iscomplexobj(np.array(new bool[] { true })).Should().BeFalse(); + np.iscomplexobj(np.array(new byte[] { 1 })).Should().BeFalse(); + np.iscomplexobj(np.array(new int[] { 1 })).Should().BeFalse(); + np.iscomplexobj(np.array(new double[] { 1.0 })).Should().BeFalse(); } - [Test] - public async Task IsComplexObj_Null_Throws() + [TestMethod] + public void IsComplexObj_Null_Throws() { - await Assert.That(() => np.iscomplexobj(null!)).ThrowsException(); + new Action(() => np.iscomplexobj(null!)).Should().Throw(); } #endregion #region Various Array Shapes - [Test] - public async Task IsReal_EmptyArray() + [TestMethod] + public void IsReal_EmptyArray() { var arr = np.array(new int[0]); var result = np.isreal(arr); - await Assert.That(result.size).IsEqualTo(0); + result.size.Should().Be(0); } - [Test] - public async Task IsComplex_EmptyArray() + [TestMethod] + public void IsComplex_EmptyArray() { var arr = np.array(new int[0]); var result = np.iscomplex(arr); - await Assert.That(result.size).IsEqualTo(0); + result.size.Should().Be(0); } - [Test] - public async Task IsRealObj_EmptyArray_True() + [TestMethod] + public void IsRealObj_EmptyArray_True() { var arr = np.array(new int[0]); - await Assert.That(np.isrealobj(arr)).IsTrue(); + np.isrealobj(arr).Should().BeTrue(); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np.issubdtype.BattleTest.cs b/test/NumSharp.UnitTest/APIs/np.issubdtype.BattleTest.cs index 5b9a79194..810a8dbc1 100644 --- a/test/NumSharp.UnitTest/APIs/np.issubdtype.BattleTest.cs +++ b/test/NumSharp.UnitTest/APIs/np.issubdtype.BattleTest.cs @@ -1,14 +1,11 @@ using System; -using System.Threading.Tasks; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; /// /// Battle tests for np.issubdtype - comprehensive coverage of type hierarchy. /// +[TestClass] public class NpIsSubdtypeBattleTests { private static readonly NPTypeCode[] AllTypes = new[] @@ -20,12 +17,12 @@ public class NpIsSubdtypeBattleTests #region Generic Category - [Test] - public async Task IsSubdtype_AllTypes_AreGeneric() + [TestMethod] + public void IsSubdtype_AllTypes_AreGeneric() { foreach (var type in AllTypes) { - await Assert.That(np.issubdtype(type, "generic")).IsTrue(); + np.issubdtype(type, "generic").Should().BeTrue(); } } @@ -33,133 +30,133 @@ public async Task IsSubdtype_AllTypes_AreGeneric() #region Number Category - [Test] - public async Task IsSubdtype_IntegersAreNumbers() + [TestMethod] + public void IsSubdtype_IntegersAreNumbers() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, "number")).IsTrue(); - await Assert.That(np.issubdtype(NPTypeCode.Byte, "number")).IsTrue(); + np.issubdtype(NPTypeCode.Int32, "number").Should().BeTrue(); + np.issubdtype(NPTypeCode.Byte, "number").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_FloatsAreNumbers() + [TestMethod] + public void IsSubdtype_FloatsAreNumbers() { - await Assert.That(np.issubdtype(NPTypeCode.Double, "number")).IsTrue(); + np.issubdtype(NPTypeCode.Double, "number").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_BoolNotNumber_NumPy2x() + [TestMethod] + public void IsSubdtype_BoolNotNumber_NumPy2x() { - await Assert.That(np.issubdtype(NPTypeCode.Boolean, "number")).IsFalse(); + np.issubdtype(NPTypeCode.Boolean, "number").Should().BeFalse(); } #endregion #region Integer Category - [Test] - public async Task IsSubdtype_IntegersAreInteger() + [TestMethod] + public void IsSubdtype_IntegersAreInteger() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, "integer")).IsTrue(); - await Assert.That(np.issubdtype(NPTypeCode.Byte, "integer")).IsTrue(); + np.issubdtype(NPTypeCode.Int32, "integer").Should().BeTrue(); + np.issubdtype(NPTypeCode.Byte, "integer").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_BoolNotInteger_NumPy2x() + [TestMethod] + public void IsSubdtype_BoolNotInteger_NumPy2x() { - await Assert.That(np.issubdtype(NPTypeCode.Boolean, "integer")).IsFalse(); + np.issubdtype(NPTypeCode.Boolean, "integer").Should().BeFalse(); } - [Test] - public async Task IsSubdtype_FloatNotInteger() + [TestMethod] + public void IsSubdtype_FloatNotInteger() { - await Assert.That(np.issubdtype(NPTypeCode.Double, "integer")).IsFalse(); + np.issubdtype(NPTypeCode.Double, "integer").Should().BeFalse(); } #endregion #region Signed/Unsigned Integer Categories - [Test] - public async Task IsSubdtype_SignedIntegers_AreSignedInteger() + [TestMethod] + public void IsSubdtype_SignedIntegers_AreSignedInteger() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, "signedinteger")).IsTrue(); - await Assert.That(np.issubdtype(NPTypeCode.Int64, "signedinteger")).IsTrue(); + np.issubdtype(NPTypeCode.Int32, "signedinteger").Should().BeTrue(); + np.issubdtype(NPTypeCode.Int64, "signedinteger").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_UnsignedIntegers_AreUnsignedInteger() + [TestMethod] + public void IsSubdtype_UnsignedIntegers_AreUnsignedInteger() { - await Assert.That(np.issubdtype(NPTypeCode.Byte, "unsignedinteger")).IsTrue(); - await Assert.That(np.issubdtype(NPTypeCode.UInt32, "unsignedinteger")).IsTrue(); + np.issubdtype(NPTypeCode.Byte, "unsignedinteger").Should().BeTrue(); + np.issubdtype(NPTypeCode.UInt32, "unsignedinteger").Should().BeTrue(); } #endregion #region Floating Category - [Test] - public async Task IsSubdtype_Floats_AreFloating() + [TestMethod] + public void IsSubdtype_Floats_AreFloating() { - await Assert.That(np.issubdtype(NPTypeCode.Single, "floating")).IsTrue(); - await Assert.That(np.issubdtype(NPTypeCode.Double, "floating")).IsTrue(); + np.issubdtype(NPTypeCode.Single, "floating").Should().BeTrue(); + np.issubdtype(NPTypeCode.Double, "floating").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_Integers_NotFloating() + [TestMethod] + public void IsSubdtype_Integers_NotFloating() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, "floating")).IsFalse(); + np.issubdtype(NPTypeCode.Int32, "floating").Should().BeFalse(); } #endregion #region NDArray Overload - [Test] - public async Task IsSubdtype_NDArray_String() + [TestMethod] + public void IsSubdtype_NDArray_String() { var arr = np.array(new int[] { 1, 2, 3 }); - await Assert.That(np.issubdtype(arr, "integer")).IsTrue(); - await Assert.That(np.issubdtype(arr, "floating")).IsFalse(); + np.issubdtype(arr, "integer").Should().BeTrue(); + np.issubdtype(arr, "floating").Should().BeFalse(); } - [Test] - public async Task IsSubdtype_NDArray_Null_Throws() + [TestMethod] + public void IsSubdtype_NDArray_Null_Throws() { - await Assert.That(() => np.issubdtype((NDArray)null!, "integer")).ThrowsException(); + new Action(() => np.issubdtype((NDArray)null!, "integer")).Should().Throw(); } #endregion #region Type Overloads - [Test] - public async Task IsSubdtype_Type_String() + [TestMethod] + public void IsSubdtype_Type_String() { - await Assert.That(np.issubdtype(typeof(int), "integer")).IsTrue(); - await Assert.That(np.issubdtype(typeof(double), "floating")).IsTrue(); + np.issubdtype(typeof(int), "integer").Should().BeTrue(); + np.issubdtype(typeof(double), "floating").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_Type_Type() + [TestMethod] + public void IsSubdtype_Type_Type() { // Same concrete types: returns True - await Assert.That(np.issubdtype(typeof(int), typeof(int))).IsTrue(); - await Assert.That(np.issubdtype(typeof(long), typeof(long))).IsTrue(); + np.issubdtype(typeof(int), typeof(int)).Should().BeTrue(); + np.issubdtype(typeof(long), typeof(long)).Should().BeTrue(); // Different concrete types: returns False (even if same kind) // This matches NumPy: np.issubdtype(np.int32, np.int64) == False - await Assert.That(np.issubdtype(typeof(int), typeof(long))).IsFalse(); - await Assert.That(np.issubdtype(typeof(float), typeof(double))).IsFalse(); + np.issubdtype(typeof(int), typeof(long)).Should().BeFalse(); + np.issubdtype(typeof(float), typeof(double)).Should().BeFalse(); } #endregion #region Invalid Category - [Test] - public async Task IsSubdtype_InvalidCategory_ReturnsFalse() + [TestMethod] + public void IsSubdtype_InvalidCategory_ReturnsFalse() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, "invalid_category")).IsFalse(); + np.issubdtype(NPTypeCode.Int32, "invalid_category").Should().BeFalse(); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np.load.Test.cs b/test/NumSharp.UnitTest/APIs/np.load.Test.cs index c7cf0f30b..e4786079e 100644 --- a/test/NumSharp.UnitTest/APIs/np.load.Test.cs +++ b/test/NumSharp.UnitTest/APIs/np.load.Test.cs @@ -4,14 +4,14 @@ using System.Collections.Generic; using System.Text; using System.Linq; -using TUnit.Core; namespace NumSharp.UnitTest.APIs { - [NotInParallel] + [DoNotParallelize] + [TestClass] public class NumpyLoad { - [Test] + [TestMethod] public void NumpyLoadTest() { int[] a = {1, 2, 3, 4, 5}; @@ -20,7 +20,7 @@ public void NumpyLoadTest() int[] b = np.Load(mem); } - [Test] + [TestMethod] public void NumpyLoad1DimTest() { int[] arr = np.Load(@"data/1-dim-int32_4_comma_empty.npy"); @@ -30,7 +30,7 @@ public void NumpyLoad1DimTest() Assert.IsTrue(arr[3] == 3); } - [Test] + [TestMethod] public void NumpyNPZRoundTripTest() { int[] arr = np.Load(@"data/1-dim-int32_4_comma_empty.npy"); diff --git a/test/NumSharp.UnitTest/APIs/np.min_scalar_type.BattleTest.cs b/test/NumSharp.UnitTest/APIs/np.min_scalar_type.BattleTest.cs index f3b3bee9d..27704554f 100644 --- a/test/NumSharp.UnitTest/APIs/np.min_scalar_type.BattleTest.cs +++ b/test/NumSharp.UnitTest/APIs/np.min_scalar_type.BattleTest.cs @@ -1,144 +1,141 @@ using System; -using System.Threading.Tasks; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; /// /// Battle tests for np.min_scalar_type - comprehensive coverage of scalar type inference. /// +[TestClass] public class NpMinScalarTypeBattleTests { #region Unsigned Integer Boundaries - [Test] - public async Task MinScalarType_Zero() + [TestMethod] + public void MinScalarType_Zero() { - await Assert.That(np.min_scalar_type(0)).IsEqualTo(NPTypeCode.Byte); + np.min_scalar_type(0).Should().Be(NPTypeCode.Byte); } - [Test] - public async Task MinScalarType_ByteMax() + [TestMethod] + public void MinScalarType_ByteMax() { - await Assert.That(np.min_scalar_type(255)).IsEqualTo(NPTypeCode.Byte); + np.min_scalar_type(255).Should().Be(NPTypeCode.Byte); } - [Test] - public async Task MinScalarType_ByteMaxPlus1() + [TestMethod] + public void MinScalarType_ByteMaxPlus1() { - await Assert.That(np.min_scalar_type(256)).IsEqualTo(NPTypeCode.UInt16); + np.min_scalar_type(256).Should().Be(NPTypeCode.UInt16); } - [Test] - public async Task MinScalarType_UInt16Max() + [TestMethod] + public void MinScalarType_UInt16Max() { - await Assert.That(np.min_scalar_type(65535)).IsEqualTo(NPTypeCode.UInt16); + np.min_scalar_type(65535).Should().Be(NPTypeCode.UInt16); } - [Test] - public async Task MinScalarType_UInt16MaxPlus1() + [TestMethod] + public void MinScalarType_UInt16MaxPlus1() { - await Assert.That(np.min_scalar_type(65536)).IsEqualTo(NPTypeCode.UInt32); + np.min_scalar_type(65536).Should().Be(NPTypeCode.UInt32); } - [Test] - public async Task MinScalarType_UInt32Max() + [TestMethod] + public void MinScalarType_UInt32Max() { - await Assert.That(np.min_scalar_type(uint.MaxValue)).IsEqualTo(NPTypeCode.UInt32); + np.min_scalar_type(uint.MaxValue).Should().Be(NPTypeCode.UInt32); } #endregion #region Signed Integer Boundaries - [Test] - public async Task MinScalarType_MinusOne() + [TestMethod] + public void MinScalarType_MinusOne() { - await Assert.That(np.min_scalar_type(-1)).IsEqualTo(NPTypeCode.Int16); + np.min_scalar_type(-1).Should().Be(NPTypeCode.Int16); } - [Test] - public async Task MinScalarType_Int16Min() + [TestMethod] + public void MinScalarType_Int16Min() { - await Assert.That(np.min_scalar_type(short.MinValue)).IsEqualTo(NPTypeCode.Int16); + np.min_scalar_type(short.MinValue).Should().Be(NPTypeCode.Int16); } - [Test] - public async Task MinScalarType_Int16MinMinus1() + [TestMethod] + public void MinScalarType_Int16MinMinus1() { - await Assert.That(np.min_scalar_type((int)short.MinValue - 1)).IsEqualTo(NPTypeCode.Int32); + np.min_scalar_type((int)short.MinValue - 1).Should().Be(NPTypeCode.Int32); } - [Test] - public async Task MinScalarType_Int32Min() + [TestMethod] + public void MinScalarType_Int32Min() { - await Assert.That(np.min_scalar_type(int.MinValue)).IsEqualTo(NPTypeCode.Int32); + np.min_scalar_type(int.MinValue).Should().Be(NPTypeCode.Int32); } #endregion #region Float Values - [Test] - public async Task MinScalarType_FloatValue() + [TestMethod] + public void MinScalarType_FloatValue() { - await Assert.That(np.min_scalar_type(1.0f)).IsEqualTo(NPTypeCode.Single); + np.min_scalar_type(1.0f).Should().Be(NPTypeCode.Single); } - [Test] - public async Task MinScalarType_DoubleLarge() + [TestMethod] + public void MinScalarType_DoubleLarge() { - await Assert.That(np.min_scalar_type(1e100)).IsEqualTo(NPTypeCode.Double); + np.min_scalar_type(1e100).Should().Be(NPTypeCode.Double); } - [Test] - public async Task MinScalarType_FloatNaN() + [TestMethod] + public void MinScalarType_FloatNaN() { - await Assert.That(np.min_scalar_type(float.NaN)).IsEqualTo(NPTypeCode.Single); + np.min_scalar_type(float.NaN).Should().Be(NPTypeCode.Single); } - [Test] - public async Task MinScalarType_FloatInfinity() + [TestMethod] + public void MinScalarType_FloatInfinity() { - await Assert.That(np.min_scalar_type(float.PositiveInfinity)).IsEqualTo(NPTypeCode.Single); + np.min_scalar_type(float.PositiveInfinity).Should().Be(NPTypeCode.Single); } #endregion #region Boolean - [Test] - public async Task MinScalarType_True() + [TestMethod] + public void MinScalarType_True() { - await Assert.That(np.min_scalar_type(true)).IsEqualTo(NPTypeCode.Boolean); + np.min_scalar_type(true).Should().Be(NPTypeCode.Boolean); } - [Test] - public async Task MinScalarType_False() + [TestMethod] + public void MinScalarType_False() { - await Assert.That(np.min_scalar_type(false)).IsEqualTo(NPTypeCode.Boolean); + np.min_scalar_type(false).Should().Be(NPTypeCode.Boolean); } #endregion #region Decimal - [Test] - public async Task MinScalarType_Decimal() + [TestMethod] + public void MinScalarType_Decimal() { - await Assert.That(np.min_scalar_type(1.0m)).IsEqualTo(NPTypeCode.Decimal); + np.min_scalar_type(1.0m).Should().Be(NPTypeCode.Decimal); } #endregion #region Error Cases - [Test] - public async Task MinScalarType_Null_Throws() + [TestMethod] + public void MinScalarType_Null_Throws() { - await Assert.That(() => np.min_scalar_type(null!)).ThrowsException(); + new Action(() => np.min_scalar_type(null!)).Should().Throw(); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np.promote_types.BattleTest.cs b/test/NumSharp.UnitTest/APIs/np.promote_types.BattleTest.cs index f948eb957..cbec1158b 100644 --- a/test/NumSharp.UnitTest/APIs/np.promote_types.BattleTest.cs +++ b/test/NumSharp.UnitTest/APIs/np.promote_types.BattleTest.cs @@ -1,14 +1,11 @@ using System; -using System.Threading.Tasks; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; /// /// Battle tests for np.promote_types - comprehensive coverage of type promotion. /// +[TestClass] public class NpPromoteTypesBattleTests { private static readonly NPTypeCode[] AllTypes = new[] @@ -20,12 +17,12 @@ public class NpPromoteTypesBattleTests #region Same Type - [Test] - public async Task PromoteTypes_SameType_ReturnsSame() + [TestMethod] + public void PromoteTypes_SameType_ReturnsSame() { foreach (var type in AllTypes) { - await Assert.That(np.promote_types(type, type)).IsEqualTo(type); + np.promote_types(type, type).Should().Be(type); } } @@ -33,8 +30,8 @@ public async Task PromoteTypes_SameType_ReturnsSame() #region Symmetric Property - [Test] - public async Task PromoteTypes_Symmetric() + [TestMethod] + public void PromoteTypes_Symmetric() { foreach (var t1 in AllTypes) { @@ -42,7 +39,7 @@ public async Task PromoteTypes_Symmetric() { var result1 = np.promote_types(t1, t2); var result2 = np.promote_types(t2, t1); - await Assert.That(result1).IsEqualTo(result2); + result1.Should().Be(result2); } } } @@ -51,52 +48,52 @@ public async Task PromoteTypes_Symmetric() #region Integer Promotion - [Test] - public async Task PromoteTypes_Int16Int32() + [TestMethod] + public void PromoteTypes_Int16Int32() { - await Assert.That(np.promote_types(NPTypeCode.Int16, NPTypeCode.Int32)).IsEqualTo(NPTypeCode.Int32); + np.promote_types(NPTypeCode.Int16, NPTypeCode.Int32).Should().Be(NPTypeCode.Int32); } - [Test] - public async Task PromoteTypes_Int32Int64() + [TestMethod] + public void PromoteTypes_Int32Int64() { - await Assert.That(np.promote_types(NPTypeCode.Int32, NPTypeCode.Int64)).IsEqualTo(NPTypeCode.Int64); + np.promote_types(NPTypeCode.Int32, NPTypeCode.Int64).Should().Be(NPTypeCode.Int64); } #endregion #region Float Promotion - [Test] - public async Task PromoteTypes_Float32Float64() + [TestMethod] + public void PromoteTypes_Float32Float64() { - await Assert.That(np.promote_types(NPTypeCode.Single, NPTypeCode.Double)).IsEqualTo(NPTypeCode.Double); + np.promote_types(NPTypeCode.Single, NPTypeCode.Double).Should().Be(NPTypeCode.Double); } #endregion #region Generic Overload - [Test] - public async Task PromoteTypes_Generic_IntLong() + [TestMethod] + public void PromoteTypes_Generic_IntLong() { - await Assert.That(np.promote_types()).IsEqualTo(NPTypeCode.Int64); + np.promote_types().Should().Be(NPTypeCode.Int64); } - [Test] - public async Task PromoteTypes_Generic_FloatDouble() + [TestMethod] + public void PromoteTypes_Generic_FloatDouble() { - await Assert.That(np.promote_types()).IsEqualTo(NPTypeCode.Double); + np.promote_types().Should().Be(NPTypeCode.Double); } #endregion #region Type Overload - [Test] - public async Task PromoteTypes_Type_IntLong() + [TestMethod] + public void PromoteTypes_Type_IntLong() { - await Assert.That(np.promote_types(typeof(int), typeof(long))).IsEqualTo(NPTypeCode.Int64); + np.promote_types(typeof(int), typeof(long)).Should().Be(NPTypeCode.Int64); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np.result_type.BattleTest.cs b/test/NumSharp.UnitTest/APIs/np.result_type.BattleTest.cs index 3059f87a8..72e35f5b6 100644 --- a/test/NumSharp.UnitTest/APIs/np.result_type.BattleTest.cs +++ b/test/NumSharp.UnitTest/APIs/np.result_type.BattleTest.cs @@ -1,121 +1,117 @@ using System; -using System.Threading.Tasks; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; /// /// Battle tests for np.result_type - comprehensive coverage of type promotion. /// +[TestClass] public class NpResultTypeBattleTests { #region Single Type - [Test] - public async Task ResultType_SingleType_ReturnsSame() + [TestMethod] + public void ResultType_SingleType_ReturnsSame() { - await Assert.That(np.result_type(NPTypeCode.Int32)).IsEqualTo(NPTypeCode.Int32); - await Assert.That(np.result_type(NPTypeCode.Double)).IsEqualTo(NPTypeCode.Double); + np.result_type(NPTypeCode.Int32).Should().Be(NPTypeCode.Int32); + np.result_type(NPTypeCode.Double).Should().Be(NPTypeCode.Double); } #endregion #region Two Types - Integer Promotion - [Test] - public async Task ResultType_Int32Int64_ReturnsInt64() + [TestMethod] + public void ResultType_Int32Int64_ReturnsInt64() { - await Assert.That(np.result_type(NPTypeCode.Int32, NPTypeCode.Int64)).IsEqualTo(NPTypeCode.Int64); + np.result_type(NPTypeCode.Int32, NPTypeCode.Int64).Should().Be(NPTypeCode.Int64); } - [Test] - public async Task ResultType_Int16Int32_ReturnsInt32() + [TestMethod] + public void ResultType_Int16Int32_ReturnsInt32() { - await Assert.That(np.result_type(NPTypeCode.Int16, NPTypeCode.Int32)).IsEqualTo(NPTypeCode.Int32); + np.result_type(NPTypeCode.Int16, NPTypeCode.Int32).Should().Be(NPTypeCode.Int32); } - [Test] - public async Task ResultType_SignedUnsigned_PromotesToContainBoth() + [TestMethod] + public void ResultType_SignedUnsigned_PromotesToContainBoth() { var result = np.result_type(NPTypeCode.UInt32, NPTypeCode.Int32); - await Assert.That(result).IsEqualTo(NPTypeCode.Int64); + result.Should().Be(NPTypeCode.Int64); } #endregion #region Two Types - Float Promotion - [Test] - public async Task ResultType_Float32Float64_ReturnsFloat64() + [TestMethod] + public void ResultType_Float32Float64_ReturnsFloat64() { - await Assert.That(np.result_type(NPTypeCode.Single, NPTypeCode.Double)).IsEqualTo(NPTypeCode.Double); + np.result_type(NPTypeCode.Single, NPTypeCode.Double).Should().Be(NPTypeCode.Double); } #endregion #region Error Cases - [Test] - public async Task ResultType_Empty_Throws() + [TestMethod] + public void ResultType_Empty_Throws() { - await Assert.That(() => np.result_type(Array.Empty())).ThrowsException(); + new Action(() => np.result_type(Array.Empty())).Should().Throw(); } - [Test] - public async Task ResultType_NullArray_Throws() + [TestMethod] + public void ResultType_NullArray_Throws() { - await Assert.That(() => np.result_type((NPTypeCode[])null!)).ThrowsException(); + new Action(() => np.result_type((NPTypeCode[])null!)).Should().Throw(); } #endregion #region Two-Arg Convenience Overloads - [Test] - public async Task ResultType_TwoArg_NPTypeCode() + [TestMethod] + public void ResultType_TwoArg_NPTypeCode() { - await Assert.That(np.result_type(NPTypeCode.Int32, NPTypeCode.Int64)).IsEqualTo(NPTypeCode.Int64); + np.result_type(NPTypeCode.Int32, NPTypeCode.Int64).Should().Be(NPTypeCode.Int64); } - [Test] - public async Task ResultType_TwoArg_Type() + [TestMethod] + public void ResultType_TwoArg_Type() { - await Assert.That(np.result_type(typeof(int), typeof(long))).IsEqualTo(NPTypeCode.Int64); + np.result_type(typeof(int), typeof(long)).Should().Be(NPTypeCode.Int64); } - [Test] - public async Task ResultType_TwoArg_NDArray() + [TestMethod] + public void ResultType_TwoArg_NDArray() { var a = np.array(new int[] { 1, 2 }); var b = np.array(new long[] { 1, 2 }); - await Assert.That(np.result_type(a, b)).IsEqualTo(NPTypeCode.Int64); + np.result_type(a, b).Should().Be(NPTypeCode.Int64); } - [Test] - public async Task ResultType_TwoArg_NDArray_NullFirst_Throws() + [TestMethod] + public void ResultType_TwoArg_NDArray_NullFirst_Throws() { var b = np.array(new int[] { 1, 2 }); - await Assert.That(() => np.result_type((NDArray)null!, b)).ThrowsException(); + new Action(() => np.result_type((NDArray)null!, b)).Should().Throw(); } - [Test] - public async Task ResultType_TwoArg_NDArray_NullSecond_Throws() + [TestMethod] + public void ResultType_TwoArg_NDArray_NullSecond_Throws() { var a = np.array(new int[] { 1, 2 }); - await Assert.That(() => np.result_type(a, (NDArray)null!)).ThrowsException(); + new Action(() => np.result_type(a, (NDArray)null!)).Should().Throw(); } #endregion #region Symmetry Property - [Test] - public async Task ResultType_Symmetric() + [TestMethod] + public void ResultType_Symmetric() { - await Assert.That(np.result_type(NPTypeCode.Int32, NPTypeCode.Int64)) - .IsEqualTo(np.result_type(NPTypeCode.Int64, NPTypeCode.Int32)); + np.result_type(NPTypeCode.Int32, NPTypeCode.Int64).Should().Be(np.result_type(NPTypeCode.Int64, NPTypeCode.Int32)); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np.tofromfile.Test.cs b/test/NumSharp.UnitTest/APIs/np.tofromfile.Test.cs index 45c3969cb..d30bf0e27 100644 --- a/test/NumSharp.UnitTest/APIs/np.tofromfile.Test.cs +++ b/test/NumSharp.UnitTest/APIs/np.tofromfile.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.APIs { + [TestClass] public class NumpyToFromFileTest : TestClass { - [Test] + [TestMethod] public void NumpyToFromFileTestByte1() { var testString = "Hallo World!"; @@ -27,7 +28,7 @@ public void NumpyToFromFileTestByte1() AssertAreEqual(rawData, loadedArray.Array); } - [Test] + [TestMethod] public void NumpyToFromFileTestUShort1() { var testString = "Hallo World!"; diff --git a/test/NumSharp.UnitTest/APIs/np.type_checks.BattleTest.cs b/test/NumSharp.UnitTest/APIs/np.type_checks.BattleTest.cs index ab2678844..22e2cc9c4 100644 --- a/test/NumSharp.UnitTest/APIs/np.type_checks.BattleTest.cs +++ b/test/NumSharp.UnitTest/APIs/np.type_checks.BattleTest.cs @@ -1,205 +1,202 @@ using System; -using System.Threading.Tasks; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; /// /// Battle tests for type checking functions: issctype, isdtype, sctype2char, maximum_sctype. /// +[TestClass] public class NpTypeChecksBattleTests { #region issctype Tests - [Test] - public async Task IsSctype_NPTypeCode_ValidTypes() + [TestMethod] + public void IsSctype_NPTypeCode_ValidTypes() { - await Assert.That(np.issctype(NPTypeCode.Int32)).IsTrue(); - await Assert.That(np.issctype(NPTypeCode.Double)).IsTrue(); - await Assert.That(np.issctype(NPTypeCode.Boolean)).IsTrue(); + np.issctype(NPTypeCode.Int32).Should().BeTrue(); + np.issctype(NPTypeCode.Double).Should().BeTrue(); + np.issctype(NPTypeCode.Boolean).Should().BeTrue(); } - [Test] - public async Task IsSctype_NPTypeCode_Invalid() + [TestMethod] + public void IsSctype_NPTypeCode_Invalid() { - await Assert.That(np.issctype(NPTypeCode.Empty)).IsFalse(); - await Assert.That(np.issctype(NPTypeCode.String)).IsFalse(); + np.issctype(NPTypeCode.Empty).Should().BeFalse(); + np.issctype(NPTypeCode.String).Should().BeFalse(); } - [Test] - public async Task IsSctype_Type_Valid() + [TestMethod] + public void IsSctype_Type_Valid() { - await Assert.That(np.issctype(typeof(int))).IsTrue(); - await Assert.That(np.issctype(typeof(double))).IsTrue(); + np.issctype(typeof(int)).Should().BeTrue(); + np.issctype(typeof(double)).Should().BeTrue(); } - [Test] - public async Task IsSctype_Type_Invalid() + [TestMethod] + public void IsSctype_Type_Invalid() { - await Assert.That(np.issctype(typeof(NDArray))).IsFalse(); - await Assert.That(np.issctype(typeof(string))).IsFalse(); + np.issctype(typeof(NDArray)).Should().BeFalse(); + np.issctype(typeof(string)).Should().BeFalse(); } - [Test] - public async Task IsSctype_Null_ReturnsFalse() + [TestMethod] + public void IsSctype_Null_ReturnsFalse() { - await Assert.That(np.issctype(null)).IsFalse(); + np.issctype(null).Should().BeFalse(); } #endregion #region isdtype Tests - NPTypeCode - [Test] - public async Task IsDtype_Bool() + [TestMethod] + public void IsDtype_Bool() { - await Assert.That(np.isdtype(NPTypeCode.Boolean, "bool")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Int32, "bool")).IsFalse(); + np.isdtype(NPTypeCode.Boolean, "bool").Should().BeTrue(); + np.isdtype(NPTypeCode.Int32, "bool").Should().BeFalse(); } - [Test] - public async Task IsDtype_Integral() + [TestMethod] + public void IsDtype_Integral() { - await Assert.That(np.isdtype(NPTypeCode.Int32, "integral")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Byte, "integral")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Double, "integral")).IsFalse(); + np.isdtype(NPTypeCode.Int32, "integral").Should().BeTrue(); + np.isdtype(NPTypeCode.Byte, "integral").Should().BeTrue(); + np.isdtype(NPTypeCode.Double, "integral").Should().BeFalse(); } - [Test] - public async Task IsDtype_RealFloating() + [TestMethod] + public void IsDtype_RealFloating() { - await Assert.That(np.isdtype(NPTypeCode.Double, "real floating")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Int32, "real floating")).IsFalse(); + np.isdtype(NPTypeCode.Double, "real floating").Should().BeTrue(); + np.isdtype(NPTypeCode.Int32, "real floating").Should().BeFalse(); } - [Test] - public async Task IsDtype_Numeric() + [TestMethod] + public void IsDtype_Numeric() { - await Assert.That(np.isdtype(NPTypeCode.Int32, "numeric")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Double, "numeric")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Boolean, "numeric")).IsFalse(); + np.isdtype(NPTypeCode.Int32, "numeric").Should().BeTrue(); + np.isdtype(NPTypeCode.Double, "numeric").Should().BeTrue(); + np.isdtype(NPTypeCode.Boolean, "numeric").Should().BeFalse(); } - [Test] - public async Task IsDtype_MultipleKinds() + [TestMethod] + public void IsDtype_MultipleKinds() { - await Assert.That(np.isdtype(NPTypeCode.Int32, new[] { "integral", "real floating" })).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Double, new[] { "integral", "real floating" })).IsTrue(); + np.isdtype(NPTypeCode.Int32, new[] { "integral", "real floating" }).Should().BeTrue(); + np.isdtype(NPTypeCode.Double, new[] { "integral", "real floating" }).Should().BeTrue(); } #endregion #region isdtype Tests - Type Overload - [Test] - public async Task IsDtype_Type_Integral() + [TestMethod] + public void IsDtype_Type_Integral() { - await Assert.That(np.isdtype(typeof(int), "integral")).IsTrue(); - await Assert.That(np.isdtype(typeof(double), "integral")).IsFalse(); + np.isdtype(typeof(int), "integral").Should().BeTrue(); + np.isdtype(typeof(double), "integral").Should().BeFalse(); } #endregion #region isdtype Tests - NDArray Overload - [Test] - public async Task IsDtype_NDArray_Integral() + [TestMethod] + public void IsDtype_NDArray_Integral() { var arr = np.array(new int[] { 1, 2, 3 }); - await Assert.That(np.isdtype(arr, "integral")).IsTrue(); - await Assert.That(np.isdtype(arr, "floating")).IsFalse(); + np.isdtype(arr, "integral").Should().BeTrue(); + np.isdtype(arr, "floating").Should().BeFalse(); } - [Test] - public async Task IsDtype_NDArray_Null_Throws() + [TestMethod] + public void IsDtype_NDArray_Null_Throws() { - await Assert.That(() => np.isdtype((NDArray)null!, "integral")).ThrowsException(); + new Action(() => np.isdtype((NDArray)null!, "integral")).Should().Throw(); } #endregion #region sctype2char Tests - [Test] - public async Task Sctype2Char_Boolean() + [TestMethod] + public void Sctype2Char_Boolean() { - await Assert.That(np.sctype2char(NPTypeCode.Boolean)).IsEqualTo('b'); + np.sctype2char(NPTypeCode.Boolean).Should().Be('b'); } - [Test] - public async Task Sctype2Char_Byte() + [TestMethod] + public void Sctype2Char_Byte() { - await Assert.That(np.sctype2char(NPTypeCode.Byte)).IsEqualTo('B'); + np.sctype2char(NPTypeCode.Byte).Should().Be('B'); } - [Test] - public async Task Sctype2Char_Int32() + [TestMethod] + public void Sctype2Char_Int32() { - await Assert.That(np.sctype2char(NPTypeCode.Int32)).IsEqualTo('i'); + np.sctype2char(NPTypeCode.Int32).Should().Be('i'); } - [Test] - public async Task Sctype2Char_Int64() + [TestMethod] + public void Sctype2Char_Int64() { - await Assert.That(np.sctype2char(NPTypeCode.Int64)).IsEqualTo('q'); + np.sctype2char(NPTypeCode.Int64).Should().Be('q'); } - [Test] - public async Task Sctype2Char_Single() + [TestMethod] + public void Sctype2Char_Single() { - await Assert.That(np.sctype2char(NPTypeCode.Single)).IsEqualTo('f'); + np.sctype2char(NPTypeCode.Single).Should().Be('f'); } - [Test] - public async Task Sctype2Char_Double() + [TestMethod] + public void Sctype2Char_Double() { - await Assert.That(np.sctype2char(NPTypeCode.Double)).IsEqualTo('d'); + np.sctype2char(NPTypeCode.Double).Should().Be('d'); } - [Test] - public async Task Sctype2Char_Unknown() + [TestMethod] + public void Sctype2Char_Unknown() { - await Assert.That(np.sctype2char(NPTypeCode.Empty)).IsEqualTo('?'); + np.sctype2char(NPTypeCode.Empty).Should().Be('?'); } #endregion #region maximum_sctype Tests - [Test] - public async Task MaximumSctype_Boolean_StaysBoolean() + [TestMethod] + public void MaximumSctype_Boolean_StaysBoolean() { - await Assert.That(np.maximum_sctype(NPTypeCode.Boolean)).IsEqualTo(NPTypeCode.Boolean); + np.maximum_sctype(NPTypeCode.Boolean).Should().Be(NPTypeCode.Boolean); } - [Test] - public async Task MaximumSctype_SignedIntegers_ToInt64() + [TestMethod] + public void MaximumSctype_SignedIntegers_ToInt64() { - await Assert.That(np.maximum_sctype(NPTypeCode.Int16)).IsEqualTo(NPTypeCode.Int64); - await Assert.That(np.maximum_sctype(NPTypeCode.Int32)).IsEqualTo(NPTypeCode.Int64); - await Assert.That(np.maximum_sctype(NPTypeCode.Int64)).IsEqualTo(NPTypeCode.Int64); + np.maximum_sctype(NPTypeCode.Int16).Should().Be(NPTypeCode.Int64); + np.maximum_sctype(NPTypeCode.Int32).Should().Be(NPTypeCode.Int64); + np.maximum_sctype(NPTypeCode.Int64).Should().Be(NPTypeCode.Int64); } - [Test] - public async Task MaximumSctype_UnsignedIntegers_ToUInt64() + [TestMethod] + public void MaximumSctype_UnsignedIntegers_ToUInt64() { - await Assert.That(np.maximum_sctype(NPTypeCode.Byte)).IsEqualTo(NPTypeCode.UInt64); - await Assert.That(np.maximum_sctype(NPTypeCode.UInt32)).IsEqualTo(NPTypeCode.UInt64); + np.maximum_sctype(NPTypeCode.Byte).Should().Be(NPTypeCode.UInt64); + np.maximum_sctype(NPTypeCode.UInt32).Should().Be(NPTypeCode.UInt64); } - [Test] - public async Task MaximumSctype_Floats_ToDouble() + [TestMethod] + public void MaximumSctype_Floats_ToDouble() { - await Assert.That(np.maximum_sctype(NPTypeCode.Single)).IsEqualTo(NPTypeCode.Double); - await Assert.That(np.maximum_sctype(NPTypeCode.Double)).IsEqualTo(NPTypeCode.Double); + np.maximum_sctype(NPTypeCode.Single).Should().Be(NPTypeCode.Double); + np.maximum_sctype(NPTypeCode.Double).Should().Be(NPTypeCode.Double); } - [Test] - public async Task MaximumSctype_Decimal_StaysDecimal() + [TestMethod] + public void MaximumSctype_Decimal_StaysDecimal() { - await Assert.That(np.maximum_sctype(NPTypeCode.Decimal)).IsEqualTo(NPTypeCode.Decimal); + np.maximum_sctype(NPTypeCode.Decimal).Should().Be(NPTypeCode.Decimal); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np.typing.Test.cs b/test/NumSharp.UnitTest/APIs/np.typing.Test.cs index 411e74842..da0f68dcc 100644 --- a/test/NumSharp.UnitTest/APIs/np.typing.Test.cs +++ b/test/NumSharp.UnitTest/APIs/np.typing.Test.cs @@ -1,562 +1,559 @@ using System; -using System.Threading.Tasks; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; /// /// Tests for NumPy type introspection and promotion functions. /// +[TestClass] public class NpTypingTests { #region iinfo tests - [Test] - public async Task IInfo_Int32_Bits() + [TestMethod] + public void IInfo_Int32_Bits() { var info = np.iinfo(NPTypeCode.Int32); - await Assert.That(info.bits).IsEqualTo(32); + info.bits.Should().Be(32); } - [Test] - public async Task IInfo_Int32_Min() + [TestMethod] + public void IInfo_Int32_Min() { var info = np.iinfo(NPTypeCode.Int32); - await Assert.That(info.min).IsEqualTo(int.MinValue); + info.min.Should().Be(int.MinValue); } - [Test] - public async Task IInfo_Int32_Max() + [TestMethod] + public void IInfo_Int32_Max() { var info = np.iinfo(NPTypeCode.Int32); - await Assert.That(info.max).IsEqualTo(int.MaxValue); + info.max.Should().Be(int.MaxValue); } - [Test] - public async Task IInfo_Int32_Kind() + [TestMethod] + public void IInfo_Int32_Kind() { var info = np.iinfo(NPTypeCode.Int32); - await Assert.That(info.kind).IsEqualTo('i'); + info.kind.Should().Be('i'); } - [Test] - public async Task IInfo_UInt8_Min() + [TestMethod] + public void IInfo_UInt8_Min() { var info = np.iinfo(NPTypeCode.Byte); - await Assert.That(info.min).IsEqualTo(0); + info.min.Should().Be(0); } - [Test] - public async Task IInfo_UInt8_Max() + [TestMethod] + public void IInfo_UInt8_Max() { var info = np.iinfo(NPTypeCode.Byte); - await Assert.That(info.max).IsEqualTo(255); + info.max.Should().Be(255); } - [Test] - public async Task IInfo_UInt8_Kind() + [TestMethod] + public void IInfo_UInt8_Kind() { var info = np.iinfo(NPTypeCode.Byte); - await Assert.That(info.kind).IsEqualTo('u'); + info.kind.Should().Be('u'); } - [Test] - public async Task IInfo_Bool_Bits() + [TestMethod] + public void IInfo_Bool_Bits() { var info = np.iinfo(NPTypeCode.Boolean); - await Assert.That(info.bits).IsEqualTo(8); + info.bits.Should().Be(8); } - [Test] - public async Task IInfo_Bool_MinMax() + [TestMethod] + public void IInfo_Bool_MinMax() { var info = np.iinfo(NPTypeCode.Boolean); - await Assert.That(info.min).IsEqualTo(0); - await Assert.That(info.max).IsEqualTo(1); + info.min.Should().Be(0); + info.max.Should().Be(1); } - [Test] - public async Task IInfo_Float_Throws() + [TestMethod] + public void IInfo_Float_Throws() { - await Assert.That(() => np.iinfo(NPTypeCode.Double)).ThrowsException(); + Assert.Throws(() => np.iinfo(NPTypeCode.Double)); } - [Test] - public async Task IInfo_Int64_Values() + [TestMethod] + public void IInfo_Int64_Values() { var info = np.iinfo(NPTypeCode.Int64); - await Assert.That(info.bits).IsEqualTo(64); - await Assert.That(info.min).IsEqualTo(long.MinValue); - await Assert.That(info.max).IsEqualTo(long.MaxValue); + info.bits.Should().Be(64); + info.min.Should().Be(long.MinValue); + info.max.Should().Be(long.MaxValue); } - [Test] - public async Task IInfo_UInt64_MaxUnsigned() + [TestMethod] + public void IInfo_UInt64_MaxUnsigned() { var info = np.iinfo(NPTypeCode.UInt64); - await Assert.That(info.maxUnsigned).IsEqualTo(ulong.MaxValue); + info.maxUnsigned.Should().Be(ulong.MaxValue); } #endregion #region finfo tests - [Test] - public async Task FInfo_Float64_Bits() + [TestMethod] + public void FInfo_Float64_Bits() { var info = np.finfo(NPTypeCode.Double); - await Assert.That(info.bits).IsEqualTo(64); + info.bits.Should().Be(64); } - [Test] - public async Task FInfo_Float64_Precision() + [TestMethod] + public void FInfo_Float64_Precision() { var info = np.finfo(NPTypeCode.Double); - await Assert.That(info.precision).IsEqualTo(15); + info.precision.Should().Be(15); } - [Test] - public async Task FInfo_Float64_Eps() + [TestMethod] + public void FInfo_Float64_Eps() { var info = np.finfo(NPTypeCode.Double); // eps should be approximately 2.22e-16 - await Assert.That(info.eps).IsGreaterThan(2e-16); - await Assert.That(info.eps).IsLessThan(3e-16); + info.eps.Should().BeGreaterThan(2e-16); + info.eps.Should().BeLessThan(3e-16); } - [Test] - public async Task FInfo_Float32_Bits() + [TestMethod] + public void FInfo_Float32_Bits() { var info = np.finfo(NPTypeCode.Single); - await Assert.That(info.bits).IsEqualTo(32); + info.bits.Should().Be(32); } - [Test] - public async Task FInfo_Float32_Precision() + [TestMethod] + public void FInfo_Float32_Precision() { var info = np.finfo(NPTypeCode.Single); - await Assert.That(info.precision).IsEqualTo(6); + info.precision.Should().Be(6); } - [Test] - public async Task FInfo_Int_Throws() + [TestMethod] + public void FInfo_Int_Throws() { - await Assert.That(() => np.finfo(NPTypeCode.Int32)).ThrowsException(); + Assert.Throws(() => np.finfo(NPTypeCode.Int32)); } - [Test] - public async Task FInfo_Decimal() + [TestMethod] + public void FInfo_Decimal() { var info = np.finfo(NPTypeCode.Decimal); - await Assert.That(info.bits).IsEqualTo(128); - await Assert.That(info.precision).IsEqualTo(28); + info.bits.Should().Be(128); + info.precision.Should().Be(28); } #endregion #region can_cast tests - [Test] - public async Task CanCast_Int32ToInt64_Safe() + [TestMethod] + public void CanCast_Int32ToInt64_Safe() { - await Assert.That(np.can_cast(NPTypeCode.Int32, NPTypeCode.Int64)).IsTrue(); + np.can_cast(NPTypeCode.Int32, NPTypeCode.Int64).Should().BeTrue(); } - [Test] - public async Task CanCast_Int64ToInt32_Safe() + [TestMethod] + public void CanCast_Int64ToInt32_Safe() { - await Assert.That(np.can_cast(NPTypeCode.Int64, NPTypeCode.Int32)).IsFalse(); + np.can_cast(NPTypeCode.Int64, NPTypeCode.Int32).Should().BeFalse(); } - [Test] - public async Task CanCast_Int32ToFloat64_Safe() + [TestMethod] + public void CanCast_Int32ToFloat64_Safe() { - await Assert.That(np.can_cast(NPTypeCode.Int32, NPTypeCode.Double)).IsTrue(); + np.can_cast(NPTypeCode.Int32, NPTypeCode.Double).Should().BeTrue(); } - [Test] - public async Task CanCast_Float32ToFloat64_Safe() + [TestMethod] + public void CanCast_Float32ToFloat64_Safe() { - await Assert.That(np.can_cast(NPTypeCode.Single, NPTypeCode.Double)).IsTrue(); + np.can_cast(NPTypeCode.Single, NPTypeCode.Double).Should().BeTrue(); } - [Test] - public async Task CanCast_Float64ToInt32_Safe() + [TestMethod] + public void CanCast_Float64ToInt32_Safe() { - await Assert.That(np.can_cast(NPTypeCode.Double, NPTypeCode.Int32)).IsFalse(); + np.can_cast(NPTypeCode.Double, NPTypeCode.Int32).Should().BeFalse(); } - [Test] - public async Task CanCast_Int32ToInt16_SameKind() + [TestMethod] + public void CanCast_Int32ToInt16_SameKind() { - await Assert.That(np.can_cast(NPTypeCode.Int32, NPTypeCode.Int16, "same_kind")).IsTrue(); + np.can_cast(NPTypeCode.Int32, NPTypeCode.Int16, "same_kind").Should().BeTrue(); } - [Test] - public async Task CanCast_Int32ToFloat32_SameKind() + [TestMethod] + public void CanCast_Int32ToFloat32_SameKind() { // Int to float is NOT same_kind - different type kinds - await Assert.That(np.can_cast(NPTypeCode.Int32, NPTypeCode.Single, "same_kind")).IsFalse(); + np.can_cast(NPTypeCode.Int32, NPTypeCode.Single, "same_kind").Should().BeFalse(); } - [Test] - public async Task CanCast_Int32ToInt16_Unsafe() + [TestMethod] + public void CanCast_Int32ToInt16_Unsafe() { - await Assert.That(np.can_cast(NPTypeCode.Int32, NPTypeCode.Int16, "unsafe")).IsTrue(); + np.can_cast(NPTypeCode.Int32, NPTypeCode.Int16, "unsafe").Should().BeTrue(); } - [Test] - public async Task CanCast_ScalarFits() + [TestMethod] + public void CanCast_ScalarFits() { - await Assert.That(np.can_cast(100, NPTypeCode.Byte)).IsTrue(); + np.can_cast(100, NPTypeCode.Byte).Should().BeTrue(); } - [Test] - public async Task CanCast_ScalarOverflow() + [TestMethod] + public void CanCast_ScalarOverflow() { - await Assert.That(np.can_cast(1000, NPTypeCode.Byte)).IsFalse(); + np.can_cast(1000, NPTypeCode.Byte).Should().BeFalse(); } - [Test] - public async Task CanCast_BoolToInt() + [TestMethod] + public void CanCast_BoolToInt() { - await Assert.That(np.can_cast(NPTypeCode.Boolean, NPTypeCode.Int32)).IsTrue(); + np.can_cast(NPTypeCode.Boolean, NPTypeCode.Int32).Should().BeTrue(); } #endregion #region result_type tests - [Test] - public async Task ResultType_Int32Int64() + [TestMethod] + public void ResultType_Int32Int64() { - await Assert.That(np.result_type(NPTypeCode.Int32, NPTypeCode.Int64)).IsEqualTo(NPTypeCode.Int64); + np.result_type(NPTypeCode.Int32, NPTypeCode.Int64).Should().Be(NPTypeCode.Int64); } - [Test] - public async Task ResultType_Int32Float32() + [TestMethod] + public void ResultType_Int32Float32() { // Mixed int/float promotes to higher precision var result = np.result_type(NPTypeCode.Int32, NPTypeCode.Single); // Result should be single or double - we accept either - await Assert.That(result == NPTypeCode.Single || result == NPTypeCode.Double).IsTrue(); + (result == NPTypeCode.Single || result == NPTypeCode.Double).Should().BeTrue(); } - [Test] - public async Task ResultType_Float32Float64() + [TestMethod] + public void ResultType_Float32Float64() { - await Assert.That(np.result_type(NPTypeCode.Single, NPTypeCode.Double)).IsEqualTo(NPTypeCode.Double); + np.result_type(NPTypeCode.Single, NPTypeCode.Double).Should().Be(NPTypeCode.Double); } - [Test] - public async Task ResultType_Arrays() + [TestMethod] + public void ResultType_Arrays() { var a = np.array(new int[] { 1, 2 }); var b = np.array(new float[] { 1.0f, 2.0f }); var result = np.result_type(a, b); // Result should be single or double - we accept either - await Assert.That(result == NPTypeCode.Single || result == NPTypeCode.Double).IsTrue(); + (result == NPTypeCode.Single || result == NPTypeCode.Double).Should().BeTrue(); } #endregion #region promote_types tests - [Test] - public async Task PromoteTypes_SameType() + [TestMethod] + public void PromoteTypes_SameType() { - await Assert.That(np.promote_types(NPTypeCode.Int32, NPTypeCode.Int32)).IsEqualTo(NPTypeCode.Int32); + np.promote_types(NPTypeCode.Int32, NPTypeCode.Int32).Should().Be(NPTypeCode.Int32); } - [Test] - public async Task PromoteTypes_Int16Int32() + [TestMethod] + public void PromoteTypes_Int16Int32() { - await Assert.That(np.promote_types(NPTypeCode.Int16, NPTypeCode.Int32)).IsEqualTo(NPTypeCode.Int32); + np.promote_types(NPTypeCode.Int16, NPTypeCode.Int32).Should().Be(NPTypeCode.Int32); } - [Test] - public async Task PromoteTypes_Float32Float64() + [TestMethod] + public void PromoteTypes_Float32Float64() { - await Assert.That(np.promote_types(NPTypeCode.Single, NPTypeCode.Double)).IsEqualTo(NPTypeCode.Double); + np.promote_types(NPTypeCode.Single, NPTypeCode.Double).Should().Be(NPTypeCode.Double); } #endregion #region min_scalar_type tests - [Test] - public async Task MinScalarType_SmallPositive() + [TestMethod] + public void MinScalarType_SmallPositive() { - await Assert.That(np.min_scalar_type(10)).IsEqualTo(NPTypeCode.Byte); + np.min_scalar_type(10).Should().Be(NPTypeCode.Byte); } - [Test] - public async Task MinScalarType_SmallNegative() + [TestMethod] + public void MinScalarType_SmallNegative() { // No Int8 in NumSharp, so smallest signed is Int16 - await Assert.That(np.min_scalar_type(-10)).IsEqualTo(NPTypeCode.Int16); + np.min_scalar_type(-10).Should().Be(NPTypeCode.Int16); } - [Test] - public async Task MinScalarType_Large() + [TestMethod] + public void MinScalarType_Large() { - await Assert.That(np.min_scalar_type(100000)).IsEqualTo(NPTypeCode.UInt32); + np.min_scalar_type(100000).Should().Be(NPTypeCode.UInt32); } - [Test] - public async Task MinScalarType_Bool() + [TestMethod] + public void MinScalarType_Bool() { - await Assert.That(np.min_scalar_type(true)).IsEqualTo(NPTypeCode.Boolean); + np.min_scalar_type(true).Should().Be(NPTypeCode.Boolean); } - [Test] - public async Task MinScalarType_ByteRange() + [TestMethod] + public void MinScalarType_ByteRange() { - await Assert.That(np.min_scalar_type(255)).IsEqualTo(NPTypeCode.Byte); - await Assert.That(np.min_scalar_type(256)).IsEqualTo(NPTypeCode.UInt16); + np.min_scalar_type(255).Should().Be(NPTypeCode.Byte); + np.min_scalar_type(256).Should().Be(NPTypeCode.UInt16); } #endregion #region issubdtype tests - [Test] - public async Task IsSubdtype_Int32Integer() + [TestMethod] + public void IsSubdtype_Int32Integer() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, "integer")).IsTrue(); + np.issubdtype(NPTypeCode.Int32, "integer").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_Int32SignedInteger() + [TestMethod] + public void IsSubdtype_Int32SignedInteger() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, "signedinteger")).IsTrue(); + np.issubdtype(NPTypeCode.Int32, "signedinteger").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_UInt32UnsignedInteger() + [TestMethod] + public void IsSubdtype_UInt32UnsignedInteger() { - await Assert.That(np.issubdtype(NPTypeCode.UInt32, "unsignedinteger")).IsTrue(); + np.issubdtype(NPTypeCode.UInt32, "unsignedinteger").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_Int32Floating() + [TestMethod] + public void IsSubdtype_Int32Floating() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, "floating")).IsFalse(); + np.issubdtype(NPTypeCode.Int32, "floating").Should().BeFalse(); } - [Test] - public async Task IsSubdtype_Float64Number() + [TestMethod] + public void IsSubdtype_Float64Number() { - await Assert.That(np.issubdtype(NPTypeCode.Double, "number")).IsTrue(); + np.issubdtype(NPTypeCode.Double, "number").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_Float64Floating() + [TestMethod] + public void IsSubdtype_Float64Floating() { - await Assert.That(np.issubdtype(NPTypeCode.Double, "floating")).IsTrue(); + np.issubdtype(NPTypeCode.Double, "floating").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_Float64Inexact() + [TestMethod] + public void IsSubdtype_Float64Inexact() { - await Assert.That(np.issubdtype(NPTypeCode.Double, "inexact")).IsTrue(); + np.issubdtype(NPTypeCode.Double, "inexact").Should().BeTrue(); } - [Test] - public async Task IsSubdtype_BoolInteger_NumPy2x() + [TestMethod] + public void IsSubdtype_BoolInteger_NumPy2x() { // In NumPy 2.x, bool is NOT a subtype of integer - await Assert.That(np.issubdtype(NPTypeCode.Boolean, "integer")).IsFalse(); + np.issubdtype(NPTypeCode.Boolean, "integer").Should().BeFalse(); } - [Test] - public async Task IsSubdtype_BoolGeneric() + [TestMethod] + public void IsSubdtype_BoolGeneric() { - await Assert.That(np.issubdtype(NPTypeCode.Boolean, "generic")).IsTrue(); + np.issubdtype(NPTypeCode.Boolean, "generic").Should().BeTrue(); } #endregion #region common_type tests - [Test] - public async Task CommonType_Int32ReturnsDouble() + [TestMethod] + public void CommonType_Int32ReturnsDouble() { var a = np.array(new int[] { 1, 2 }); - await Assert.That(np.common_type_code(a)).IsEqualTo(NPTypeCode.Double); + np.common_type_code(a).Should().Be(NPTypeCode.Double); } - [Test] - public async Task CommonType_Float32Float64() + [TestMethod] + public void CommonType_Float32Float64() { var a = np.array(new float[] { 1.0f }); var b = np.array(new double[] { 1.0 }); - await Assert.That(np.common_type_code(a, b)).IsEqualTo(NPTypeCode.Double); + np.common_type_code(a, b).Should().Be(NPTypeCode.Double); } - [Test] - public async Task CommonType_Float32Only() + [TestMethod] + public void CommonType_Float32Only() { var a = np.array(new float[] { 1.0f }); - await Assert.That(np.common_type_code(a)).IsEqualTo(NPTypeCode.Single); + np.common_type_code(a).Should().Be(NPTypeCode.Single); } #endregion #region Type checking functions tests - [Test] - public async Task IsSctype_Int32() + [TestMethod] + public void IsSctype_Int32() { - await Assert.That(np.issctype(typeof(int))).IsTrue(); + np.issctype(typeof(int)).Should().BeTrue(); } - [Test] - public async Task IsSctype_NPTypeCode() + [TestMethod] + public void IsSctype_NPTypeCode() { - await Assert.That(np.issctype(NPTypeCode.Int32)).IsTrue(); + np.issctype(NPTypeCode.Int32).Should().BeTrue(); } - [Test] - public async Task IsDtype_Int32Integral() + [TestMethod] + public void IsDtype_Int32Integral() { - await Assert.That(np.isdtype(NPTypeCode.Int32, "integral")).IsTrue(); + np.isdtype(NPTypeCode.Int32, "integral").Should().BeTrue(); } - [Test] - public async Task IsDtype_Float64RealFloating() + [TestMethod] + public void IsDtype_Float64RealFloating() { - await Assert.That(np.isdtype(NPTypeCode.Double, "real floating")).IsTrue(); + np.isdtype(NPTypeCode.Double, "real floating").Should().BeTrue(); } - [Test] - public async Task IsDtype_Int32Numeric() + [TestMethod] + public void IsDtype_Int32Numeric() { - await Assert.That(np.isdtype(NPTypeCode.Int32, "numeric")).IsTrue(); + np.isdtype(NPTypeCode.Int32, "numeric").Should().BeTrue(); } - [Test] - public async Task Sctype2Char_Int32() + [TestMethod] + public void Sctype2Char_Int32() { - await Assert.That(np.sctype2char(NPTypeCode.Int32)).IsEqualTo('i'); + np.sctype2char(NPTypeCode.Int32).Should().Be('i'); } - [Test] - public async Task Sctype2Char_Double() + [TestMethod] + public void Sctype2Char_Double() { - await Assert.That(np.sctype2char(NPTypeCode.Double)).IsEqualTo('d'); + np.sctype2char(NPTypeCode.Double).Should().Be('d'); } - [Test] - public async Task Sctype2Char_UInt8() + [TestMethod] + public void Sctype2Char_UInt8() { - await Assert.That(np.sctype2char(NPTypeCode.Byte)).IsEqualTo('B'); + np.sctype2char(NPTypeCode.Byte).Should().Be('B'); } - [Test] - public async Task MaximumSctype_Int32() + [TestMethod] + public void MaximumSctype_Int32() { - await Assert.That(np.maximum_sctype(NPTypeCode.Int32)).IsEqualTo(NPTypeCode.Int64); + np.maximum_sctype(NPTypeCode.Int32).Should().Be(NPTypeCode.Int64); } - [Test] - public async Task MaximumSctype_UInt16() + [TestMethod] + public void MaximumSctype_UInt16() { - await Assert.That(np.maximum_sctype(NPTypeCode.UInt16)).IsEqualTo(NPTypeCode.UInt64); + np.maximum_sctype(NPTypeCode.UInt16).Should().Be(NPTypeCode.UInt64); } - [Test] - public async Task MaximumSctype_Float32() + [TestMethod] + public void MaximumSctype_Float32() { - await Assert.That(np.maximum_sctype(NPTypeCode.Single)).IsEqualTo(NPTypeCode.Double); + np.maximum_sctype(NPTypeCode.Single).Should().Be(NPTypeCode.Double); } #endregion #region isreal/iscomplex tests - [Test] - public async Task IsReal_IntArray() + [TestMethod] + public void IsReal_IntArray() { var a = np.array(new int[] { 1, 2, 3 }); var result = np.isreal(a); // All elements should be real for non-complex arrays - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] - public async Task IsComplex_IntArray() + [TestMethod] + public void IsComplex_IntArray() { var a = np.array(new int[] { 1, 2, 3 }); var result = np.iscomplex(a); // No elements should be complex for non-complex arrays - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeFalse(); } - [Test] - public async Task IsRealObj_IntArray() + [TestMethod] + public void IsRealObj_IntArray() { var a = np.array(new int[] { 1, 2 }); - await Assert.That(np.isrealobj(a)).IsTrue(); + np.isrealobj(a).Should().BeTrue(); } - [Test] - public async Task IsComplexObj_IntArray() + [TestMethod] + public void IsComplexObj_IntArray() { var a = np.array(new int[] { 1, 2 }); - await Assert.That(np.iscomplexobj(a)).IsFalse(); + np.iscomplexobj(a).Should().BeFalse(); } - [Test] - public async Task IsRealObj_FloatArray() + [TestMethod] + public void IsRealObj_FloatArray() { var a = np.array(new double[] { 1.0, 2.0 }); - await Assert.That(np.isrealobj(a)).IsTrue(); + np.isrealobj(a).Should().BeTrue(); } #endregion #region NPTypeCode extension tests - [Test] - public async Task NPTypeCode_IsFloatingPoint() + [TestMethod] + public void NPTypeCode_IsFloatingPoint() { - await Assert.That(NPTypeCode.Double.IsFloatingPoint()).IsTrue(); - await Assert.That(NPTypeCode.Single.IsFloatingPoint()).IsTrue(); - await Assert.That(NPTypeCode.Decimal.IsFloatingPoint()).IsTrue(); - await Assert.That(NPTypeCode.Int32.IsFloatingPoint()).IsFalse(); + NPTypeCode.Double.IsFloatingPoint().Should().BeTrue(); + NPTypeCode.Single.IsFloatingPoint().Should().BeTrue(); + NPTypeCode.Decimal.IsFloatingPoint().Should().BeTrue(); + NPTypeCode.Int32.IsFloatingPoint().Should().BeFalse(); } - [Test] - public async Task NPTypeCode_IsInteger() + [TestMethod] + public void NPTypeCode_IsInteger() { - await Assert.That(NPTypeCode.Int32.IsInteger()).IsTrue(); - await Assert.That(NPTypeCode.UInt64.IsInteger()).IsTrue(); - await Assert.That(NPTypeCode.Double.IsInteger()).IsFalse(); - await Assert.That(NPTypeCode.Boolean.IsInteger()).IsFalse(); + NPTypeCode.Int32.IsInteger().Should().BeTrue(); + NPTypeCode.UInt64.IsInteger().Should().BeTrue(); + NPTypeCode.Double.IsInteger().Should().BeFalse(); + NPTypeCode.Boolean.IsInteger().Should().BeFalse(); } - [Test] - public async Task NPTypeCode_IsSimdCapable() + [TestMethod] + public void NPTypeCode_IsSimdCapable() { - await Assert.That(NPTypeCode.Int32.IsSimdCapable()).IsTrue(); - await Assert.That(NPTypeCode.Double.IsSimdCapable()).IsTrue(); - await Assert.That(NPTypeCode.Decimal.IsSimdCapable()).IsFalse(); - await Assert.That(NPTypeCode.Boolean.IsSimdCapable()).IsFalse(); + NPTypeCode.Int32.IsSimdCapable().Should().BeTrue(); + NPTypeCode.Double.IsSimdCapable().Should().BeTrue(); + NPTypeCode.Decimal.IsSimdCapable().Should().BeFalse(); + NPTypeCode.Boolean.IsSimdCapable().Should().BeFalse(); } - [Test] - public async Task NPTypeCode_GetOneValue() + [TestMethod] + public void NPTypeCode_GetOneValue() { - await Assert.That((int)NPTypeCode.Int32.GetOneValue()).IsEqualTo(1); - await Assert.That((double)NPTypeCode.Double.GetOneValue()).IsEqualTo(1.0); - await Assert.That((bool)NPTypeCode.Boolean.GetOneValue()).IsTrue(); + ((int)NPTypeCode.Int32.GetOneValue()).Should().Be(1); + ((double)NPTypeCode.Double.GetOneValue()).Should().Be(1.0); + ((bool)NPTypeCode.Boolean.GetOneValue()).Should().BeTrue(); } #endregion diff --git a/test/NumSharp.UnitTest/APIs/np_searchsorted_edge_cases.cs b/test/NumSharp.UnitTest/APIs/np_searchsorted_edge_cases.cs index 7cd338558..9f465b04f 100644 --- a/test/NumSharp.UnitTest/APIs/np_searchsorted_edge_cases.cs +++ b/test/NumSharp.UnitTest/APIs/np_searchsorted_edge_cases.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.APIs; @@ -10,11 +9,12 @@ namespace NumSharp.UnitTest.APIs; /// Edge case tests for np.searchsorted to verify fix from commit 40a5c831. /// Tests validated against NumPy 2.4.2. /// +[TestClass] public class NpSearchsortedEdgeCaseTests { #region Scalar Input Tests (Main Fix) - [Test] + [TestMethod] public void ScalarInt_ExactMatch() { // NumPy 2.4.2: np.searchsorted([1, 2, 3, 4, 5], 3) = 2 @@ -23,7 +23,7 @@ public void ScalarInt_ExactMatch() Assert.AreEqual(2, result); } - [Test] + [TestMethod] public void ScalarInt_NotInArray() { // NumPy 2.4.2: np.searchsorted([1, 3, 5], 4) = 2 @@ -32,7 +32,7 @@ public void ScalarInt_NotInArray() Assert.AreEqual(2, result); } - [Test] + [TestMethod] public void ScalarDouble_ExactMatch() { // NumPy 2.4.2: np.searchsorted([1.0, 2.0, 3.0], 2.0) = 1 @@ -41,7 +41,7 @@ public void ScalarDouble_ExactMatch() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void ScalarDouble_Between() { // NumPy 2.4.2: np.searchsorted([1.0, 2.0, 3.0], 2.5) = 2 @@ -54,7 +54,7 @@ public void ScalarDouble_Between() #region Value Not In Array Tests - [Test] + [TestMethod] public void Value_BeforeAllElements() { // NumPy 2.4.2: np.searchsorted([10, 20, 30], 5) = 0 @@ -63,7 +63,7 @@ public void Value_BeforeAllElements() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void Value_AfterAllElements() { // NumPy 2.4.2: np.searchsorted([10, 20, 30], 100) = 3 @@ -72,7 +72,7 @@ public void Value_AfterAllElements() Assert.AreEqual(3, result); } - [Test] + [TestMethod] public void Value_InMiddleGap() { // NumPy 2.4.2: np.searchsorted([1, 5, 10, 50], 7) = 2 @@ -85,7 +85,7 @@ public void Value_InMiddleGap() #region Empty Array Edge Cases - [Test] + [TestMethod] public void EmptySearchArray_ReturnZero() { // NumPy 2.4.2: np.searchsorted([], 5) = 0 @@ -94,7 +94,7 @@ public void EmptySearchArray_ReturnZero() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void EmptySearchArray_ReturnZeroForDouble() { // NumPy 2.4.2: np.searchsorted([], 5.0) = 0 @@ -103,7 +103,7 @@ public void EmptySearchArray_ReturnZeroForDouble() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void EmptyValuesArray_ReturnEmptyArray() { // NumPy 2.4.2: np.searchsorted([1, 2, 3], []) returns array([], dtype=int64) @@ -117,7 +117,7 @@ public void EmptyValuesArray_ReturnEmptyArray() #region Duplicate Values Tests - [Test] + [TestMethod] public void DuplicateValues_ReturnsLeftmostIndex() { // NumPy 2.4.2 (side='left' default): np.searchsorted([1, 2, 2, 2, 3], 2) = 1 @@ -126,7 +126,7 @@ public void DuplicateValues_ReturnsLeftmostIndex() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void AllDuplicates_ReturnsZero() { // NumPy 2.4.2: np.searchsorted([5, 5, 5, 5], 5) = 0 @@ -135,7 +135,7 @@ public void AllDuplicates_ReturnsZero() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void AllDuplicates_ValueGreater() { // NumPy 2.4.2: np.searchsorted([5, 5, 5, 5], 10) = 4 @@ -144,7 +144,7 @@ public void AllDuplicates_ValueGreater() Assert.AreEqual(4, result); } - [Test] + [TestMethod] public void AllDuplicates_ValueLess() { // NumPy 2.4.2: np.searchsorted([5, 5, 5, 5], 1) = 0 @@ -157,7 +157,7 @@ public void AllDuplicates_ValueLess() #region Different dtypes Tests - [Test] + [TestMethod] public void Int32Array_IntSearch() { var arr = np.array(new long[] { 1, 2, 3, 4, 5 }); @@ -165,7 +165,7 @@ public void Int32Array_IntSearch() Assert.AreEqual(2, result); } - [Test] + [TestMethod] public void Int64Array_IntSearch() { var arr = np.array(new long[] { 1L, 2L, 3L, 4L, 5L }); @@ -173,7 +173,7 @@ public void Int64Array_IntSearch() Assert.AreEqual(2, result); } - [Test] + [TestMethod] public void FloatArray_DoubleSearch() { var arr = np.array(new float[] { 1.0f, 2.0f, 3.0f }); @@ -181,7 +181,7 @@ public void FloatArray_DoubleSearch() Assert.AreEqual(2, result); } - [Test] + [TestMethod] public void DoubleArray_IntSearch() { // Cross-type search: int value in double array @@ -190,7 +190,7 @@ public void DoubleArray_IntSearch() Assert.AreEqual(2, result); } - [Test] + [TestMethod] public void ByteArray_Search() { var arr = np.array(new byte[] { 10, 20, 30, 40 }); @@ -202,7 +202,7 @@ public void ByteArray_Search() #region NDArray Input Tests - [Test] + [TestMethod] public void NDArrayInput_SingleElement() { // NumPy 2.4.2: np.searchsorted([1, 2, 3], [2]) = array([1]) @@ -213,7 +213,7 @@ public void NDArrayInput_SingleElement() Assert.AreEqual(1L, result.GetInt64(0)); } - [Test] + [TestMethod] public void NDArrayInput_MultipleElements() { // NumPy 2.4.2: np.searchsorted([1, 2, 3, 4, 5], [2, 4]) = array([1, 3]) @@ -225,7 +225,7 @@ public void NDArrayInput_MultipleElements() Assert.AreEqual(3L, result.GetInt64(1)); } - [Test] + [TestMethod] public void NDArrayInput_AllOutOfRange() { // NumPy 2.4.2: np.searchsorted([10, 20, 30], [-5, 100]) = array([0, 3]) @@ -237,7 +237,7 @@ public void NDArrayInput_AllOutOfRange() Assert.AreEqual(3L, result.GetInt64(1)); } - [Test] + [TestMethod] public void NDArrayInput_MixedInAndOut() { // NumPy 2.4.2: np.searchsorted([11, 12, 13, 14, 15], [-10, 20, 12, 13]) = array([0, 5, 1, 2]) @@ -251,7 +251,7 @@ public void NDArrayInput_MixedInAndOut() Assert.AreEqual(2L, result.GetInt64(3)); } - [Test] + [TestMethod] public void NDArrayInput_DoubleValues() { // NumPy 2.4.2: np.searchsorted([1.0, 2.0, 3.0], [1.5, 2.5]) = array([1, 2]) @@ -267,7 +267,7 @@ public void NDArrayInput_DoubleValues() #region Scalar NDArray Tests (Key Fix Area) - [Test] + [TestMethod] public void ScalarNDArray_ReturnsScalar() { // NumPy 2.4.2: np.searchsorted([1, 2, 3], np.array(2)) returns scalar 1 @@ -280,7 +280,7 @@ public void ScalarNDArray_ReturnsScalar() Assert.AreEqual(1L, result.GetInt64()); } - [Test] + [TestMethod] public void ScalarNDArray_Double_ReturnsScalar() { // np.searchsorted([1.0, 2.0, 3.0], np.array(2.5)) returns scalar 2 @@ -296,7 +296,7 @@ public void ScalarNDArray_Double_ReturnsScalar() #region Single Element Array Tests - [Test] + [TestMethod] public void SingleElementArray_ValueLess() { // NumPy 2.4.2: np.searchsorted([5], 1) = 0 @@ -305,7 +305,7 @@ public void SingleElementArray_ValueLess() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void SingleElementArray_ValueEqual() { // NumPy 2.4.2: np.searchsorted([5], 5) = 0 @@ -314,7 +314,7 @@ public void SingleElementArray_ValueEqual() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void SingleElementArray_ValueGreater() { // NumPy 2.4.2: np.searchsorted([5], 10) = 1 @@ -327,7 +327,7 @@ public void SingleElementArray_ValueGreater() #region Boundary Value Tests - [Test] + [TestMethod] public void FirstElement_Match() { // NumPy 2.4.2: np.searchsorted([1, 2, 3], 1) = 0 @@ -336,7 +336,7 @@ public void FirstElement_Match() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void LastElement_Match() { // NumPy 2.4.2: np.searchsorted([1, 2, 3], 3) = 2 @@ -345,7 +345,7 @@ public void LastElement_Match() Assert.AreEqual(2, result); } - [Test] + [TestMethod] public void JustBeforeFirst() { // NumPy 2.4.2: np.searchsorted([10, 20, 30], 9) = 0 @@ -354,7 +354,7 @@ public void JustBeforeFirst() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void JustAfterLast() { // NumPy 2.4.2: np.searchsorted([10, 20, 30], 31) = 3 @@ -367,7 +367,7 @@ public void JustAfterLast() #region Large Array Tests - [Test] + [TestMethod] public void LargeArray_FindMiddle() { // Create array 0..999 @@ -376,7 +376,7 @@ public void LargeArray_FindMiddle() Assert.AreEqual(500, result); } - [Test] + [TestMethod] public void LargeArray_FindNearEnd() { // Create array 0..999 @@ -385,7 +385,7 @@ public void LargeArray_FindNearEnd() Assert.AreEqual(999, result); } - [Test] + [TestMethod] public void LargeArray_FindBetweenElements() { // Create array [0, 10, 20, ..., 990] @@ -398,7 +398,7 @@ public void LargeArray_FindBetweenElements() #region Negative Value Tests - [Test] + [TestMethod] public void NegativeValues_InArray() { // NumPy 2.4.2: np.searchsorted([-3, -1, 0, 2, 5], -2) = 1 @@ -407,7 +407,7 @@ public void NegativeValues_InArray() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void NegativeValues_SearchNegative() { // NumPy 2.4.2: np.searchsorted([-10, -5, 0, 5, 10], -7) = 1 @@ -416,7 +416,7 @@ public void NegativeValues_SearchNegative() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void NegativeValues_SearchZero() { // NumPy 2.4.2: np.searchsorted([-10, -5, 0, 5, 10], 0) = 2 @@ -429,7 +429,7 @@ public void NegativeValues_SearchZero() #region Floating Point Precision Tests - [Test] + [TestMethod] public void FloatPrecision_VeryClose() { // Test with very close floating point values @@ -438,7 +438,7 @@ public void FloatPrecision_VeryClose() Assert.AreEqual(2, result); } - [Test] + [TestMethod] public void FloatPrecision_SmallValues() { // Test with small values diff --git a/test/NumSharp.UnitTest/Backends/ContainerProtocolBattleTests.cs b/test/NumSharp.UnitTest/Backends/ContainerProtocolBattleTests.cs index 5d4739e3f..42a09d0ab 100644 --- a/test/NumSharp.UnitTest/Backends/ContainerProtocolBattleTests.cs +++ b/test/NumSharp.UnitTest/Backends/ContainerProtocolBattleTests.cs @@ -2,11 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using NumSharp; -using TUnit.Core; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; namespace NumSharp.UnitTest.Backends; @@ -14,212 +10,213 @@ namespace NumSharp.UnitTest.Backends; /// Comprehensive battle tests for container protocol implementation. /// Tests all edge cases, dtypes, and memory layouts. /// +[TestClass] public class ContainerProtocolBattleTests { #region __len__ Battle Tests - [Test] - public async Task Len_AllDtypes_1DArray() + [TestMethod] + public void Len_AllDtypes_1DArray() { // Test __len__ works for all 12 dtypes - await Assert.That(np.array(new bool[] { true, false, true }).__len__()).IsEqualTo(3); - await Assert.That(np.array(new byte[] { 1, 2, 3, 4 }).__len__()).IsEqualTo(4); - await Assert.That(np.array(new short[] { 1, 2 }).__len__()).IsEqualTo(2); - await Assert.That(np.array(new ushort[] { 1, 2, 3 }).__len__()).IsEqualTo(3); - await Assert.That(np.array(new int[] { 1, 2, 3, 4, 5 }).__len__()).IsEqualTo(5); - await Assert.That(np.array(new uint[] { 1 }).__len__()).IsEqualTo(1); - await Assert.That(np.array(new long[] { 1, 2, 3, 4, 5, 6 }).__len__()).IsEqualTo(6); - await Assert.That(np.array(new ulong[] { 1, 2 }).__len__()).IsEqualTo(2); - await Assert.That(np.array(new char[] { 'a', 'b', 'c' }).__len__()).IsEqualTo(3); - await Assert.That(np.array(new float[] { 1f, 2f }).__len__()).IsEqualTo(2); - await Assert.That(np.array(new double[] { 1.0, 2.0, 3.0, 4.0 }).__len__()).IsEqualTo(4); - await Assert.That(np.array(new decimal[] { 1m, 2m, 3m }).__len__()).IsEqualTo(3); - } - - [Test] - public async Task Len_3DArray_ReturnsFirstDimension() + np.array(new bool[] { true, false, true }).__len__().Should().Be(3); + np.array(new byte[] { 1, 2, 3, 4 }).__len__().Should().Be(4); + np.array(new short[] { 1, 2 }).__len__().Should().Be(2); + np.array(new ushort[] { 1, 2, 3 }).__len__().Should().Be(3); + np.array(new int[] { 1, 2, 3, 4, 5 }).__len__().Should().Be(5); + np.array(new uint[] { 1 }).__len__().Should().Be(1); + np.array(new long[] { 1, 2, 3, 4, 5, 6 }).__len__().Should().Be(6); + np.array(new ulong[] { 1, 2 }).__len__().Should().Be(2); + np.array(new char[] { 'a', 'b', 'c' }).__len__().Should().Be(3); + np.array(new float[] { 1f, 2f }).__len__().Should().Be(2); + np.array(new double[] { 1.0, 2.0, 3.0, 4.0 }).__len__().Should().Be(4); + np.array(new decimal[] { 1m, 2m, 3m }).__len__().Should().Be(3); + } + + [TestMethod] + public void Len_3DArray_ReturnsFirstDimension() { // NumPy: len(np.zeros((2, 3, 4))) = 2 var arr = np.zeros(new[] { 2, 3, 4 }); - await Assert.That(arr.__len__()).IsEqualTo(2); + arr.__len__().Should().Be(2); } - [Test] - public async Task Len_4DArray_ReturnsFirstDimension() + [TestMethod] + public void Len_4DArray_ReturnsFirstDimension() { var arr = np.zeros(new[] { 5, 4, 3, 2 }); - await Assert.That(arr.__len__()).IsEqualTo(5); + arr.__len__().Should().Be(5); } - [Test] - public async Task Len_EmptyArray_ReturnsZero() + [TestMethod] + public void Len_EmptyArray_ReturnsZero() { // NumPy: len(np.array([])) = 0 var arr = np.array(Array.Empty()); - await Assert.That(arr.__len__()).IsEqualTo(0); + arr.__len__().Should().Be(0); } - [Test] - public async Task Len_EmptyArray_2D_ReturnsZero() + [TestMethod] + public void Len_EmptyArray_2D_ReturnsZero() { // NumPy: len(np.zeros((0, 5))) = 0 var arr = np.zeros(new[] { 0, 5 }); - await Assert.That(arr.__len__()).IsEqualTo(0); + arr.__len__().Should().Be(0); } - [Test] - public async Task Len_SlicedArray_ReturnsCorrectLength() + [TestMethod] + public void Len_SlicedArray_ReturnsCorrectLength() { var arr = np.arange(10); var sliced = arr["2:7"]; // [2, 3, 4, 5, 6] - await Assert.That(sliced.__len__()).IsEqualTo(5); + sliced.__len__().Should().Be(5); } - [Test] - public async Task Len_SlicedArray_Strided_ReturnsCorrectLength() + [TestMethod] + public void Len_SlicedArray_Strided_ReturnsCorrectLength() { var arr = np.arange(10); var sliced = arr["::2"]; // [0, 2, 4, 6, 8] - await Assert.That(sliced.__len__()).IsEqualTo(5); + sliced.__len__().Should().Be(5); } - [Test] - public async Task Len_SlicedArray_Reversed_ReturnsCorrectLength() + [TestMethod] + public void Len_SlicedArray_Reversed_ReturnsCorrectLength() { var arr = np.arange(10); var sliced = arr["::-1"]; // [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] - await Assert.That(sliced.__len__()).IsEqualTo(10); + sliced.__len__().Should().Be(10); } - [Test] - public async Task Len_TransposedArray_ReturnsFirstDimension() + [TestMethod] + public void Len_TransposedArray_ReturnsFirstDimension() { // NumPy: len(np.zeros((3, 5)).T) = 5 var arr = np.zeros(new[] { 3, 5 }); var transposed = arr.T; - await Assert.That(transposed.__len__()).IsEqualTo(5); + transposed.__len__().Should().Be(5); } - [Test] - public async Task Len_ReshapedArray_ReturnsFirstDimension() + [TestMethod] + public void Len_ReshapedArray_ReturnsFirstDimension() { var arr = np.arange(12).reshape(3, 4); - await Assert.That(arr.__len__()).IsEqualTo(3); + arr.__len__().Should().Be(3); } - [Test] - public async Task Len_BroadcastArray_ReturnsFirstDimension() + [TestMethod] + public void Len_BroadcastArray_ReturnsFirstDimension() { var arr = np.array(new[] { 1, 2, 3 }); var broadcast = np.broadcast_to(arr, new Shape(4, 3)); - await Assert.That(broadcast.__len__()).IsEqualTo(4); + broadcast.__len__().Should().Be(4); } - [Test] - public async Task Len_SingleElementArray_ReturnsOne() + [TestMethod] + public void Len_SingleElementArray_ReturnsOne() { var arr = np.array(new[] { 42 }); - await Assert.That(arr.__len__()).IsEqualTo(1); + arr.__len__().Should().Be(1); } - [Test] - public async Task Len_ScalarAllDtypes_ThrowsTypeError() + [TestMethod] + public void Len_ScalarAllDtypes_ThrowsTypeError() { // All scalar types should throw TypeError - await Assert.That(() => NDArray.Scalar(true).__len__()).Throws(); - await Assert.That(() => NDArray.Scalar((byte)1).__len__()).Throws(); - await Assert.That(() => NDArray.Scalar((short)1).__len__()).Throws(); - await Assert.That(() => NDArray.Scalar((ushort)1).__len__()).Throws(); - await Assert.That(() => NDArray.Scalar(1).__len__()).Throws(); - await Assert.That(() => NDArray.Scalar(1u).__len__()).Throws(); - await Assert.That(() => NDArray.Scalar(1L).__len__()).Throws(); - await Assert.That(() => NDArray.Scalar(1ul).__len__()).Throws(); - await Assert.That(() => NDArray.Scalar('a').__len__()).Throws(); - await Assert.That(() => NDArray.Scalar(1f).__len__()).Throws(); - await Assert.That(() => NDArray.Scalar(1.0).__len__()).Throws(); - await Assert.That(() => NDArray.Scalar(1m).__len__()).Throws(); + Assert.Throws(() => NDArray.Scalar(true).__len__()); + Assert.Throws(() => NDArray.Scalar((byte)1).__len__()); + Assert.Throws(() => NDArray.Scalar((short)1).__len__()); + Assert.Throws(() => NDArray.Scalar((ushort)1).__len__()); + Assert.Throws(() => NDArray.Scalar(1).__len__()); + Assert.Throws(() => NDArray.Scalar(1u).__len__()); + Assert.Throws(() => NDArray.Scalar(1L).__len__()); + Assert.Throws(() => NDArray.Scalar(1ul).__len__()); + Assert.Throws(() => NDArray.Scalar('a').__len__()); + Assert.Throws(() => NDArray.Scalar(1f).__len__()); + Assert.Throws(() => NDArray.Scalar(1.0).__len__()); + Assert.Throws(() => NDArray.Scalar(1m).__len__()); } #endregion #region __getitem__ Battle Tests - [Test] - public async Task GetItem_AllDtypes_IntIndex() + [TestMethod] + public void GetItem_AllDtypes_IntIndex() { - await Assert.That((bool)np.array(new[] { true, false }).__getitem__(0)).IsTrue(); - await Assert.That((int)(byte)np.array(new byte[] { 1, 2 }).__getitem__(1)).IsEqualTo(2); - await Assert.That((int)(short)np.array(new short[] { 10, 20 }).__getitem__(0)).IsEqualTo(10); - await Assert.That((int)(ushort)np.array(new ushort[] { 100, 200 }).__getitem__(1)).IsEqualTo(200); - await Assert.That((int)np.array(new[] { 1, 2, 3 }).__getitem__(2)).IsEqualTo(3); - await Assert.That((long)(uint)np.array(new uint[] { 1, 2 }).__getitem__(0)).IsEqualTo(1L); - await Assert.That((long)np.array(new long[] { 100L, 200L }).__getitem__(1)).IsEqualTo(200L); - await Assert.That((long)(ulong)np.array(new ulong[] { 1, 2 }).__getitem__(0)).IsEqualTo(1L); - await Assert.That((char)np.array(new[] { 'x', 'y' }).__getitem__(1)).IsEqualTo('y'); - await Assert.That((float)np.array(new[] { 1.5f, 2.5f }).__getitem__(0)).IsEqualTo(1.5f); - await Assert.That((double)np.array(new[] { 1.5, 2.5 }).__getitem__(1)).IsEqualTo(2.5); - await Assert.That((decimal)np.array(new[] { 1.5m, 2.5m }).__getitem__(0)).IsEqualTo(1.5m); + ((bool)np.array(new[] { true, false }).__getitem__(0)).Should().BeTrue(); + ((int)(byte)np.array(new byte[] { 1, 2 }).__getitem__(1)).Should().Be(2); + ((int)(short)np.array(new short[] { 10, 20 }).__getitem__(0)).Should().Be(10); + ((int)(ushort)np.array(new ushort[] { 100, 200 }).__getitem__(1)).Should().Be(200); + ((int)np.array(new[] { 1, 2, 3 }).__getitem__(2)).Should().Be(3); + ((long)(uint)np.array(new uint[] { 1, 2 }).__getitem__(0)).Should().Be(1L); + ((long)np.array(new long[] { 100L, 200L }).__getitem__(1)).Should().Be(200L); + ((long)(ulong)np.array(new ulong[] { 1, 2 }).__getitem__(0)).Should().Be(1L); + ((char)np.array(new[] { 'x', 'y' }).__getitem__(1)).Should().Be('y'); + ((float)np.array(new[] { 1.5f, 2.5f }).__getitem__(0)).Should().Be(1.5f); + ((double)np.array(new[] { 1.5, 2.5 }).__getitem__(1)).Should().Be(2.5); + ((decimal)np.array(new[] { 1.5m, 2.5m }).__getitem__(0)).Should().Be(1.5m); } - [Test] - public async Task GetItem_NegativeIndex_AllPositions() + [TestMethod] + public void GetItem_NegativeIndex_AllPositions() { var arr = np.array(new[] { 10, 20, 30, 40, 50 }); - await Assert.That((int)arr.__getitem__(-1)).IsEqualTo(50); - await Assert.That((int)arr.__getitem__(-2)).IsEqualTo(40); - await Assert.That((int)arr.__getitem__(-3)).IsEqualTo(30); - await Assert.That((int)arr.__getitem__(-4)).IsEqualTo(20); - await Assert.That((int)arr.__getitem__(-5)).IsEqualTo(10); + ((int)arr.__getitem__(-1)).Should().Be(50); + ((int)arr.__getitem__(-2)).Should().Be(40); + ((int)arr.__getitem__(-3)).Should().Be(30); + ((int)arr.__getitem__(-4)).Should().Be(20); + ((int)arr.__getitem__(-5)).Should().Be(10); } - [Test] - public async Task GetItem_SliceStrings_Various() + [TestMethod] + public void GetItem_SliceStrings_Various() { var arr = np.array(new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); // Start:Stop - await Assert.That(arr.__getitem__("2:5").size).IsEqualTo(3); - await Assert.That((int)arr.__getitem__("2:5")[0]).IsEqualTo(2); + arr.__getitem__("2:5").size.Should().Be(3); + ((int)arr.__getitem__("2:5")[0]).Should().Be(2); // :Stop - await Assert.That(arr.__getitem__(":3").size).IsEqualTo(3); - await Assert.That((int)arr.__getitem__(":3")[0]).IsEqualTo(0); + arr.__getitem__(":3").size.Should().Be(3); + ((int)arr.__getitem__(":3")[0]).Should().Be(0); // Start: - await Assert.That(arr.__getitem__("7:").size).IsEqualTo(3); - await Assert.That((int)arr.__getitem__("7:")[0]).IsEqualTo(7); + arr.__getitem__("7:").size.Should().Be(3); + ((int)arr.__getitem__("7:")[0]).Should().Be(7); // ::Step - await Assert.That(arr.__getitem__("::2").size).IsEqualTo(5); - await Assert.That((int)arr.__getitem__("::2")[1]).IsEqualTo(2); + arr.__getitem__("::2").size.Should().Be(5); + ((int)arr.__getitem__("::2")[1]).Should().Be(2); // ::-1 (reverse) - await Assert.That(arr.__getitem__("::-1").size).IsEqualTo(10); - await Assert.That((int)arr.__getitem__("::-1")[0]).IsEqualTo(9); + arr.__getitem__("::-1").size.Should().Be(10); + ((int)arr.__getitem__("::-1")[0]).Should().Be(9); // Negative indices - await Assert.That(arr.__getitem__("-3:").size).IsEqualTo(3); - await Assert.That((int)arr.__getitem__("-3:")[0]).IsEqualTo(7); + arr.__getitem__("-3:").size.Should().Be(3); + ((int)arr.__getitem__("-3:")[0]).Should().Be(7); } - [Test] - public async Task GetItem_2DArray_RowAccess() + [TestMethod] + public void GetItem_2DArray_RowAccess() { var arr = np.array(new[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }); var row0 = arr.__getitem__(0); - await Assert.That(row0.ndim).IsEqualTo(1); - await Assert.That(row0.size).IsEqualTo(3); - await Assert.That((int)row0[0]).IsEqualTo(1); - await Assert.That((int)row0[2]).IsEqualTo(3); + row0.ndim.Should().Be(1); + row0.size.Should().Be(3); + (((int)row0[0])).Should().Be(1); + (((int)row0[2])).Should().Be(3); var row2 = arr.__getitem__(-1); - await Assert.That((int)row2[0]).IsEqualTo(7); + (((int)row2[0])).Should().Be(7); } - [Test] - public async Task GetItem_SliceReturnsView_NotCopy() + [TestMethod] + public void GetItem_SliceReturnsView_NotCopy() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); var slice = arr.__getitem__("1:4"); @@ -228,144 +225,144 @@ public async Task GetItem_SliceReturnsView_NotCopy() arr[2] = 99; // View should reflect change - await Assert.That((int)slice[1]).IsEqualTo(99); + (((int)slice[1])).Should().Be(99); } - [Test] - public async Task GetItem_OutOfBounds_Throws() + [TestMethod] + public void GetItem_OutOfBounds_Throws() { var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(() => arr.__getitem__(10)).Throws(); - await Assert.That(() => arr.__getitem__(-10)).Throws(); + Assert.Throws(() => arr.__getitem__(10)); + Assert.Throws(() => arr.__getitem__(-10)); } - [Test] - public async Task GetItem_EmptySlice_ReturnsEmptyArray() + [TestMethod] + public void GetItem_EmptySlice_ReturnsEmptyArray() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); var empty = arr.__getitem__("2:2"); // Empty slice - await Assert.That(empty.size).IsEqualTo(0); + empty.size.Should().Be(0); } - [Test] - public async Task GetItem_SlicedSourceArray() + [TestMethod] + public void GetItem_SlicedSourceArray() { var arr = np.arange(20); var sliced = arr["5:15"]; // [5, 6, 7, 8, 9, 10, 11, 12, 13, 14] var subslice = sliced.__getitem__("2:5"); - await Assert.That((int)subslice[0]).IsEqualTo(7); - await Assert.That(subslice.size).IsEqualTo(3); + (((int)subslice[0])).Should().Be(7); + subslice.size.Should().Be(3); } #endregion #region __setitem__ Battle Tests - [Test] - public async Task SetItem_AllDtypes_ScalarAssignment() + [TestMethod] + public void SetItem_AllDtypes_ScalarAssignment() { var boolArr = np.array(new[] { true, false }); boolArr.__setitem__(0, false); - await Assert.That((bool)boolArr[0]).IsFalse(); + (((bool)boolArr[0])).Should().BeFalse(); var intArr = np.array(new[] { 1, 2, 3 }); intArr.__setitem__(1, 99); - await Assert.That((int)intArr[1]).IsEqualTo(99); + (((int)intArr[1])).Should().Be(99); var doubleArr = np.array(new[] { 1.0, 2.0, 3.0 }); doubleArr.__setitem__(2, 99.5); - await Assert.That((double)doubleArr[2]).IsEqualTo(99.5); + (((double)doubleArr[2])).Should().Be(99.5); } - [Test] - public async Task SetItem_NegativeIndex() + [TestMethod] + public void SetItem_NegativeIndex() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); arr.__setitem__(-1, 99); - await Assert.That((int)arr[4]).IsEqualTo(99); + (((int)arr[4])).Should().Be(99); arr.__setitem__(-3, 88); - await Assert.That((int)arr[2]).IsEqualTo(88); + (((int)arr[2])).Should().Be(88); } - [Test] - public async Task SetItem_SliceString_ScalarBroadcast() + [TestMethod] + public void SetItem_SliceString_ScalarBroadcast() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); arr.__setitem__("1:4", 0); - await Assert.That((int)arr[0]).IsEqualTo(1); // Unchanged - await Assert.That((int)arr[1]).IsEqualTo(0); - await Assert.That((int)arr[2]).IsEqualTo(0); - await Assert.That((int)arr[3]).IsEqualTo(0); - await Assert.That((int)arr[4]).IsEqualTo(5); // Unchanged + (((int)arr[0])).Should().Be(1); // Unchanged + (((int)arr[1])).Should().Be(0); + (((int)arr[2])).Should().Be(0); + (((int)arr[3])).Should().Be(0); + (((int)arr[4])).Should().Be(5); // Unchanged } - [Test] - public async Task SetItem_SliceString_ArrayAssignment() + [TestMethod] + public void SetItem_SliceString_ArrayAssignment() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); arr.__setitem__("1:4", np.array(new[] { 10, 20, 30 })); - await Assert.That((int)arr[0]).IsEqualTo(1); - await Assert.That((int)arr[1]).IsEqualTo(10); - await Assert.That((int)arr[2]).IsEqualTo(20); - await Assert.That((int)arr[3]).IsEqualTo(30); - await Assert.That((int)arr[4]).IsEqualTo(5); + (((int)arr[0])).Should().Be(1); + (((int)arr[1])).Should().Be(10); + (((int)arr[2])).Should().Be(20); + (((int)arr[3])).Should().Be(30); + (((int)arr[4])).Should().Be(5); } - [Test] - public async Task SetItem_ViewAffectsOriginal() + [TestMethod] + public void SetItem_ViewAffectsOriginal() { var original = np.array(new[] { 1, 2, 3, 4, 5 }); var view = original["1:4"]; view.__setitem__(0, 99); - await Assert.That((int)original[1]).IsEqualTo(99); + (((int)original[1])).Should().Be(99); } - [Test] - public async Task SetItem_2DArray_RowAssignment() + [TestMethod] + public void SetItem_2DArray_RowAssignment() { var arr = np.array(new[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }); arr.__setitem__(1, np.array(new[] { 10, 20, 30 })); - await Assert.That((int)arr[1, 0]).IsEqualTo(10); - await Assert.That((int)arr[1, 1]).IsEqualTo(20); - await Assert.That((int)arr[1, 2]).IsEqualTo(30); + (((int)arr[1, 0])).Should().Be(10); + (((int)arr[1, 1])).Should().Be(20); + (((int)arr[1, 2])).Should().Be(30); } - [Test] - public async Task SetItem_TypePromotion() + [TestMethod] + public void SetItem_TypePromotion() { var arr = np.array(new[] { 1.0, 2.0, 3.0 }); // Set with int, should promote to double arr.__setitem__(1, 99); - await Assert.That((double)arr[1]).IsEqualTo(99.0); + (((double)arr[1])).Should().Be(99.0); } - [Test] - public async Task SetItem_AllElements_WithColon() + [TestMethod] + public void SetItem_AllElements_WithColon() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); arr.__setitem__(":", 0); - await Assert.That(np.all(arr == 0)).IsTrue(); + np.all(arr == 0).Should().BeTrue(); } - [Test] - public async Task SetItem_ReversedSlice() + [TestMethod] + public void SetItem_ReversedSlice() { // NumPy: arr[::-1] = [10, 20, 30, 40, 50] assigns in reverse order // arr[4]=10, arr[3]=20, arr[2]=30, arr[1]=40, arr[0]=50 @@ -374,70 +371,70 @@ public async Task SetItem_ReversedSlice() arr.__setitem__("::-1", np.array(new[] { 10, 20, 30, 40, 50 })); - await Assert.That((int)arr[0]).IsEqualTo(50); // Last of source - await Assert.That((int)arr[4]).IsEqualTo(10); // First of source + (((int)arr[0])).Should().Be(50); // Last of source + (((int)arr[4])).Should().Be(10); // First of source } #endregion #region __hash__ Battle Tests - [Test] - public async Task Hash_AllDtypes_Throw() + [TestMethod] + public void Hash_AllDtypes_Throw() { - await Assert.That(() => np.array(new[] { true, false }).GetHashCode()).Throws(); - await Assert.That(() => np.array(new byte[] { 1, 2 }).GetHashCode()).Throws(); - await Assert.That(() => np.array(new short[] { 1, 2 }).GetHashCode()).Throws(); - await Assert.That(() => np.array(new ushort[] { 1, 2 }).GetHashCode()).Throws(); - await Assert.That(() => np.array(new[] { 1, 2 }).GetHashCode()).Throws(); - await Assert.That(() => np.array(new uint[] { 1, 2 }).GetHashCode()).Throws(); - await Assert.That(() => np.array(new long[] { 1, 2 }).GetHashCode()).Throws(); - await Assert.That(() => np.array(new ulong[] { 1, 2 }).GetHashCode()).Throws(); - await Assert.That(() => np.array(new[] { 'a', 'b' }).GetHashCode()).Throws(); - await Assert.That(() => np.array(new[] { 1f, 2f }).GetHashCode()).Throws(); - await Assert.That(() => np.array(new[] { 1.0, 2.0 }).GetHashCode()).Throws(); - await Assert.That(() => np.array(new[] { 1m, 2m }).GetHashCode()).Throws(); + Assert.Throws(() => np.array(new[] { true, false }).GetHashCode()); + Assert.Throws(() => np.array(new byte[] { 1, 2 }).GetHashCode()); + Assert.Throws(() => np.array(new short[] { 1, 2 }).GetHashCode()); + Assert.Throws(() => np.array(new ushort[] { 1, 2 }).GetHashCode()); + Assert.Throws(() => np.array(new[] { 1, 2 }).GetHashCode()); + Assert.Throws(() => np.array(new uint[] { 1, 2 }).GetHashCode()); + Assert.Throws(() => np.array(new long[] { 1, 2 }).GetHashCode()); + Assert.Throws(() => np.array(new ulong[] { 1, 2 }).GetHashCode()); + Assert.Throws(() => np.array(new[] { 'a', 'b' }).GetHashCode()); + Assert.Throws(() => np.array(new[] { 1f, 2f }).GetHashCode()); + Assert.Throws(() => np.array(new[] { 1.0, 2.0 }).GetHashCode()); + Assert.Throws(() => np.array(new[] { 1m, 2m }).GetHashCode()); } - [Test] - public async Task Hash_EmptyArray_Throws() + [TestMethod] + public void Hash_EmptyArray_Throws() { - await Assert.That(() => np.array(Array.Empty()).GetHashCode()).Throws(); + Assert.Throws(() => np.array(Array.Empty()).GetHashCode()); } - [Test] - public async Task Hash_ScalarArray_Throws() + [TestMethod] + public void Hash_ScalarArray_Throws() { - await Assert.That(() => NDArray.Scalar(5).GetHashCode()).Throws(); + Assert.Throws(() => NDArray.Scalar(5).GetHashCode()); } - [Test] - public async Task Hash_SlicedArray_Throws() + [TestMethod] + public void Hash_SlicedArray_Throws() { var arr = np.arange(10); var sliced = arr["2:8"]; - await Assert.That(() => sliced.GetHashCode()).Throws(); + Assert.Throws(() => sliced.GetHashCode()); } - [Test] - public async Task Hash_BroadcastArray_Throws() + [TestMethod] + public void Hash_BroadcastArray_Throws() { var arr = np.array(new[] { 1, 2, 3 }); var broadcast = np.broadcast_to(arr, new Shape(4, 3)); - await Assert.That(() => broadcast.GetHashCode()).Throws(); + Assert.Throws(() => broadcast.GetHashCode()); } - [Test] - public async Task Hash_HashSetUsage_Fails() + [TestMethod] + public void Hash_HashSetUsage_Fails() { var arr = np.array(new[] { 1, 2, 3 }); var set = new HashSet(); - await Assert.That(() => set.Add(arr)).Throws(); + Assert.Throws(() => set.Add(arr)); } - [Test] - public async Task Hash_ErrorMessage_IsDescriptive() + [TestMethod] + public void Hash_ErrorMessage_IsDescriptive() { var arr = np.array(new[] { 1, 2, 3 }); @@ -448,8 +445,8 @@ public async Task Hash_ErrorMessage_IsDescriptive() } catch (NotSupportedException ex) { - await Assert.That(ex.Message).Contains("unhashable"); - await Assert.That(ex.Message).Contains("mutable"); + ex.Message.Should().Contain("unhashable"); + ex.Message.Should().Contain("mutable"); } } @@ -457,110 +454,110 @@ public async Task Hash_ErrorMessage_IsDescriptive() #region __contains__ Battle Tests - [Test] - public async Task Contains_AllDtypes() + [TestMethod] + public void Contains_AllDtypes() { - await Assert.That(np.array(new[] { true, false }).Contains(true)).IsTrue(); - await Assert.That(np.array(new byte[] { 1, 2, 3 }).Contains((byte)2)).IsTrue(); - await Assert.That(np.array(new short[] { 1, 2, 3 }).Contains((short)2)).IsTrue(); - await Assert.That(np.array(new ushort[] { 1, 2, 3 }).Contains((ushort)2)).IsTrue(); - await Assert.That(np.array(new[] { 1, 2, 3 }).Contains(2)).IsTrue(); - await Assert.That(np.array(new uint[] { 1, 2, 3 }).Contains(2u)).IsTrue(); - await Assert.That(np.array(new long[] { 1, 2, 3 }).Contains(2L)).IsTrue(); - await Assert.That(np.array(new ulong[] { 1, 2, 3 }).Contains(2ul)).IsTrue(); - await Assert.That(np.array(new[] { 'a', 'b', 'c' }).Contains('b')).IsTrue(); - await Assert.That(np.array(new[] { 1f, 2f, 3f }).Contains(2f)).IsTrue(); - await Assert.That(np.array(new[] { 1.0, 2.0, 3.0 }).Contains(2.0)).IsTrue(); - await Assert.That(np.array(new[] { 1m, 2m, 3m }).Contains(2m)).IsTrue(); + np.array(new[] { true, false }).Contains(true).Should().BeTrue(); + np.array(new byte[] { 1, 2, 3 }).Contains(((byte)2)).Should().BeTrue(); + np.array(new short[] { 1, 2, 3 }).Contains(((short)2)).Should().BeTrue(); + np.array(new ushort[] { 1, 2, 3 }).Contains(((ushort)2)).Should().BeTrue(); + np.array(new[] { 1, 2, 3 }).Contains(2).Should().BeTrue(); + np.array(new uint[] { 1, 2, 3 }).Contains(2u).Should().BeTrue(); + np.array(new long[] { 1, 2, 3 }).Contains(2L).Should().BeTrue(); + np.array(new ulong[] { 1, 2, 3 }).Contains(2ul).Should().BeTrue(); + np.array(new[] { 'a', 'b', 'c' }).Contains('b').Should().BeTrue(); + np.array(new[] { 1f, 2f, 3f }).Contains(2f).Should().BeTrue(); + np.array(new[] { 1.0, 2.0, 3.0 }).Contains(2.0).Should().BeTrue(); + np.array(new[] { 1m, 2m, 3m }).Contains(2m).Should().BeTrue(); } - [Test] - public async Task Contains_LargeArray() + [TestMethod] + public void Contains_LargeArray() { var arr = np.arange(10000); - await Assert.That(arr.Contains(0)).IsTrue(); - await Assert.That(arr.Contains(5000)).IsTrue(); - await Assert.That(arr.Contains(9999)).IsTrue(); - await Assert.That(arr.Contains(10000)).IsFalse(); + arr.Contains(0).Should().BeTrue(); + arr.Contains(5000).Should().BeTrue(); + arr.Contains(9999).Should().BeTrue(); + arr.Contains(10000).Should().BeFalse(); } - [Test] - public async Task Contains_Infinity() + [TestMethod] + public void Contains_Infinity() { var arr = np.array(new[] { double.NegativeInfinity, 0.0, double.PositiveInfinity }); - await Assert.That(arr.Contains(double.PositiveInfinity)).IsTrue(); - await Assert.That(arr.Contains(double.NegativeInfinity)).IsTrue(); - await Assert.That(arr.Contains(0.0)).IsTrue(); + arr.Contains(double.PositiveInfinity).Should().BeTrue(); + arr.Contains(double.NegativeInfinity).Should().BeTrue(); + arr.Contains(0.0).Should().BeTrue(); } - [Test] - public async Task Contains_NegativeValues() + [TestMethod] + public void Contains_NegativeValues() { var arr = np.array(new[] { -5, -3, -1, 0, 1, 3, 5 }); - await Assert.That(arr.Contains(-3)).IsTrue(); - await Assert.That(arr.Contains(-10)).IsFalse(); + arr.Contains(-3).Should().BeTrue(); + arr.Contains(-10).Should().BeFalse(); } - [Test] - public async Task Contains_3DArray() + [TestMethod] + public void Contains_3DArray() { var arr = np.arange(24).reshape(2, 3, 4); - await Assert.That(arr.Contains(0)).IsTrue(); - await Assert.That(arr.Contains(23)).IsTrue(); - await Assert.That(arr.Contains(12)).IsTrue(); - await Assert.That(arr.Contains(100)).IsFalse(); + arr.Contains(0).Should().BeTrue(); + arr.Contains(23).Should().BeTrue(); + arr.Contains(12).Should().BeTrue(); + arr.Contains(100).Should().BeFalse(); } - [Test] - public async Task Contains_SlicedArray() + [TestMethod] + public void Contains_SlicedArray() { var arr = np.arange(10); var sliced = arr["3:7"]; // [3, 4, 5, 6] - await Assert.That(sliced.Contains(5)).IsTrue(); - await Assert.That(sliced.Contains(2)).IsFalse(); // Not in slice - await Assert.That(sliced.Contains(8)).IsFalse(); // Not in slice + sliced.Contains(5).Should().BeTrue(); + sliced.Contains(2).Should().BeFalse(); // Not in slice + sliced.Contains(8).Should().BeFalse(); // Not in slice } - [Test] - public async Task Contains_StridedArray() + [TestMethod] + public void Contains_StridedArray() { var arr = np.arange(10); var strided = arr["::2"]; // [0, 2, 4, 6, 8] - await Assert.That(strided.Contains(4)).IsTrue(); - await Assert.That(strided.Contains(3)).IsFalse(); // Odd numbers not included + strided.Contains(4).Should().BeTrue(); + strided.Contains(3).Should().BeFalse(); // Odd numbers not included } - [Test] - public async Task Contains_BroadcastArray() + [TestMethod] + public void Contains_BroadcastArray() { var arr = np.array(new[] { 1, 2, 3 }); var broadcast = np.broadcast_to(arr, new Shape(4, 3)); - await Assert.That(broadcast.Contains(2)).IsTrue(); - await Assert.That(broadcast.Contains(5)).IsFalse(); + broadcast.Contains(2).Should().BeTrue(); + broadcast.Contains(5).Should().BeFalse(); } - [Test] - public async Task Contains_ScalarArray() + [TestMethod] + public void Contains_ScalarArray() { var scalar = NDArray.Scalar(42); - await Assert.That(scalar.Contains(42)).IsTrue(); - await Assert.That(scalar.Contains(0)).IsFalse(); + scalar.Contains(42).Should().BeTrue(); + scalar.Contains(0).Should().BeFalse(); } #endregion #region __iter__ Battle Tests - [Test] - public async Task Iter_AllDtypes_Enumerate() + [TestMethod] + public void Iter_AllDtypes_Enumerate() { // Just verify iteration doesn't crash for all types foreach (var _ in np.array(new[] { true, false })) { } @@ -576,11 +573,11 @@ public async Task Iter_AllDtypes_Enumerate() foreach (var _ in np.array(new[] { 1.0, 2.0 })) { } foreach (var _ in np.array(new[] { 1m, 2m })) { } - await Assert.That(true).IsTrue(); // Passed if no exception + true.Should().BeTrue(); // Passed if no exception } - [Test] - public async Task Iter_1DArray_ElementsMatch() + [TestMethod] + public void Iter_1DArray_ElementsMatch() { var arr = np.array(new[] { 10, 20, 30 }); var collected = new List(); @@ -591,11 +588,11 @@ public async Task Iter_1DArray_ElementsMatch() collected.Add(Convert.ToInt32(item)); } - await Assert.That(collected).IsEquivalentTo(new[] { 10, 20, 30 }); + collected.Should().BeEquivalentTo(new[] { 10, 20, 30 }); } - [Test] - public async Task Iter_2DArray_IteratesRows() + [TestMethod] + public void Iter_2DArray_IteratesRows() { var arr = np.array(new[,] { { 1, 2 }, { 3, 4 }, { 5, 6 } }); var rowCount = 0; @@ -605,17 +602,17 @@ public async Task Iter_2DArray_IteratesRows() { if (item is NDArray row) { - await Assert.That(row.ndim).IsEqualTo(1); - await Assert.That(row.size).IsEqualTo(2); + row.ndim.Should().Be(1); + row.size.Should().Be(2); } rowCount++; } - await Assert.That(rowCount).IsEqualTo(3); + rowCount.Should().Be(3); } - [Test] - public async Task Iter_3DArray_Iterates2DSlices() + [TestMethod] + public void Iter_3DArray_Iterates2DSlices() { var arr = np.zeros(new[] { 2, 3, 4 }); var sliceCount = 0; @@ -625,17 +622,17 @@ public async Task Iter_3DArray_Iterates2DSlices() { if (item is NDArray slice) { - await Assert.That(slice.ndim).IsEqualTo(2); - await Assert.That(slice.shape).IsEquivalentTo(new long[] { 3, 4 }); + slice.ndim.Should().Be(2); + slice.shape.Should().BeEquivalentTo(new long[] { 3, 4 }); } sliceCount++; } - await Assert.That(sliceCount).IsEqualTo(2); + sliceCount.Should().Be(2); } - [Test] - public async Task Iter_EmptyArray_NoIterations() + [TestMethod] + public void Iter_EmptyArray_NoIterations() { var arr = np.array(Array.Empty()); var count = 0; @@ -645,11 +642,11 @@ public async Task Iter_EmptyArray_NoIterations() count++; } - await Assert.That(count).IsEqualTo(0); + count.Should().Be(0); } - [Test] - public async Task Iter_SingleElement_OneIteration() + [TestMethod] + public void Iter_SingleElement_OneIteration() { var arr = np.array(new[] { 42 }); var count = 0; @@ -662,12 +659,12 @@ public async Task Iter_SingleElement_OneIteration() count++; } - await Assert.That(count).IsEqualTo(1); - await Assert.That(value).IsEqualTo(42); + count.Should().Be(1); + value.Should().Be(42); } - [Test] - public async Task Iter_MultipleEnumeration() + [TestMethod] + public void Iter_MultipleEnumeration() { var arr = np.array(new[] { 1, 2, 3 }); @@ -681,31 +678,31 @@ public async Task Iter_MultipleEnumeration() foreach (var item in arr) second.Add(Convert.ToInt32(item)); - await Assert.That(first).IsEquivalentTo(second); + first.Should().BeEquivalentTo(second); } - [Test] - public async Task Iter_LINQ_ToList() + [TestMethod] + public void Iter_LINQ_ToList() { var arr = np.array(new[] { 1, 2, 3 }); var list = arr.Cast().ToList(); - await Assert.That(list.Count).IsEqualTo(3); + list.Count.Should().Be(3); } - [Test] - public async Task Iter_LINQ_Count() + [TestMethod] + public void Iter_LINQ_Count() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); var count = arr.Cast().Count(); - await Assert.That(count).IsEqualTo(5); + count.Should().Be(5); } - [Test] - public async Task Iter_SlicedArray() + [TestMethod] + public void Iter_SlicedArray() { var arr = np.arange(10); var sliced = arr["2:7"]; @@ -714,11 +711,11 @@ public async Task Iter_SlicedArray() foreach (var _ in sliced) count++; - await Assert.That(count).IsEqualTo(5); + count.Should().Be(5); } - [Test] - public async Task Iter_BreakEarly() + [TestMethod] + public void Iter_BreakEarly() { var arr = np.arange(100); var count = 0; @@ -730,22 +727,22 @@ public async Task Iter_BreakEarly() break; } - await Assert.That(count).IsEqualTo(5); + count.Should().Be(5); } - [Test] - public async Task Iter_ScalarArray_ThrowsTypeError() + [TestMethod] + public void Iter_ScalarArray_ThrowsTypeError() { // NumPy: iteration over a 0-d array throws TypeError var scalar = NDArray.Scalar(42); - await Assert.That(() => + Assert.Throws(() => { foreach (var _ in scalar) { // Should not reach here } - }).Throws(); + }); } #endregion diff --git a/test/NumSharp.UnitTest/Backends/ContainerProtocolBattleTests2.cs b/test/NumSharp.UnitTest/Backends/ContainerProtocolBattleTests2.cs index a8e819c3d..2a5f26a4d 100644 --- a/test/NumSharp.UnitTest/Backends/ContainerProtocolBattleTests2.cs +++ b/test/NumSharp.UnitTest/Backends/ContainerProtocolBattleTests2.cs @@ -2,11 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using NumSharp; -using TUnit.Core; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; namespace NumSharp.UnitTest.Backends; @@ -14,130 +10,131 @@ namespace NumSharp.UnitTest.Backends; /// Second round of battle tests for container protocol. /// Focuses on edge cases, long indexing, and complex scenarios. /// +[TestClass] public class ContainerProtocolBattleTests2 { #region __len__ Round 2 - [Test] - public async Task Len_LargeArray_ReturnsCorrectLength() + [TestMethod] + public void Len_LargeArray_ReturnsCorrectLength() { // Test with large first dimension var arr = np.zeros(new long[] { 10000, 10 }); - await Assert.That(arr.__len__()).IsEqualTo(10000); + arr.__len__().Should().Be(10000); } - [Test] - public async Task Len_FirstDimensionOne_ReturnsOne() + [TestMethod] + public void Len_FirstDimensionOne_ReturnsOne() { var arr = np.zeros(new long[] { 1, 100, 100 }); - await Assert.That(arr.__len__()).IsEqualTo(1); + arr.__len__().Should().Be(1); } - [Test] - public async Task Len_HighDimensional_5D() + [TestMethod] + public void Len_HighDimensional_5D() { var arr = np.zeros(new long[] { 2, 3, 4, 5, 6 }); - await Assert.That(arr.__len__()).IsEqualTo(2); + arr.__len__().Should().Be(2); } - [Test] - public async Task Len_AfterTranspose_ChangesFirstDimension() + [TestMethod] + public void Len_AfterTranspose_ChangesFirstDimension() { var arr = np.arange(24).reshape(2, 3, 4); - await Assert.That(arr.__len__()).IsEqualTo(2); + arr.__len__().Should().Be(2); // After transpose, dimensions are reversed var transposed = arr.T; - await Assert.That(transposed.__len__()).IsEqualTo(4); + transposed.__len__().Should().Be(4); } - [Test] - public async Task Len_NegativeStridedSlice() + [TestMethod] + public void Len_NegativeStridedSlice() { var arr = np.arange(10); var reversed = arr["::-2"]; // [9, 7, 5, 3, 1] - await Assert.That(reversed.__len__()).IsEqualTo(5); + reversed.__len__().Should().Be(5); } - [Test] - public async Task Len_SliceOfSlice() + [TestMethod] + public void Len_SliceOfSlice() { var arr = np.arange(100); var slice1 = arr["10:90"]; var slice2 = slice1["20:60"]; - await Assert.That(slice2.__len__()).IsEqualTo(40); + slice2.__len__().Should().Be(40); } #endregion #region __getitem__ Round 2 - Long Indexing - [Test] - public async Task GetItem_LongIndex_PositiveWorks() + [TestMethod] + public void GetItem_LongIndex_PositiveWorks() { var arr = np.arange(10); var result = arr.__getitem__(5L); - await Assert.That((int)result).IsEqualTo(5); + ((int)result).Should().Be(5); } - [Test] - public async Task GetItem_LongIndex_NegativeWorks() + [TestMethod] + public void GetItem_LongIndex_NegativeWorks() { var arr = np.arange(10); var result = arr.__getitem__(-1L); - await Assert.That((int)result).IsEqualTo(9); + ((int)result).Should().Be(9); } - [Test] - public async Task GetItem_LongIndex_2DArray() + [TestMethod] + public void GetItem_LongIndex_2DArray() { var arr = np.arange(12).reshape(3, 4); var row = arr.__getitem__(2L); - await Assert.That(row.size).IsEqualTo(4); - await Assert.That((int)row[0]).IsEqualTo(8); + row.size.Should().Be(4); + ((int)row[0]).Should().Be(8); } - [Test] - public async Task GetItem_Ellipsis_Basic() + [TestMethod] + public void GetItem_Ellipsis_Basic() { var arr = np.arange(24).reshape(2, 3, 4); // "..., 0" = all dimensions except last, then index 0 on last var result = arr["..., 0"]; - await Assert.That(result.shape).IsEquivalentTo(new long[] { 2, 3 }); + result.shape.Should().BeEquivalentTo(new long[] { 2, 3 }); } - [Test] - public async Task GetItem_ComplexSlice_StartStopStep() + [TestMethod] + public void GetItem_ComplexSlice_StartStopStep() { var arr = np.arange(20); var result = arr["2:18:3"]; // [2, 5, 8, 11, 14, 17] - await Assert.That(result.size).IsEqualTo(6); - await Assert.That((int)result[0]).IsEqualTo(2); - await Assert.That((int)result[5]).IsEqualTo(17); + result.size.Should().Be(6); + ((int)result[0]).Should().Be(2); + ((int)result[5]).Should().Be(17); } - [Test] - public async Task GetItem_2D_ColumnSlice() + [TestMethod] + public void GetItem_2D_ColumnSlice() { var arr = np.arange(12).reshape(3, 4); var column = arr[":, 1"]; // All rows, column 1 - await Assert.That(column.size).IsEqualTo(3); - await Assert.That((int)column[0]).IsEqualTo(1); - await Assert.That((int)column[1]).IsEqualTo(5); - await Assert.That((int)column[2]).IsEqualTo(9); + column.size.Should().Be(3); + ((int)column[0]).Should().Be(1); + ((int)column[1]).Should().Be(5); + ((int)column[2]).Should().Be(9); } - [Test] - public async Task GetItem_2D_SubMatrix() + [TestMethod] + public void GetItem_2D_SubMatrix() { var arr = np.arange(20).reshape(4, 5); var submat = arr["1:3, 2:5"]; - await Assert.That(submat.shape).IsEquivalentTo(new long[] { 2, 3 }); - await Assert.That((int)submat[0, 0]).IsEqualTo(7); + submat.shape.Should().BeEquivalentTo(new long[] { 2, 3 }); + ((int)submat[0, 0]).Should().Be(7); } - [Test] - public async Task GetItem_ViewChaining_PreservesData() + [TestMethod] + public void GetItem_ViewChaining_PreservesData() { var original = np.arange(100).reshape(10, 10); var view1 = original["2:8, :"]; @@ -148,42 +145,42 @@ public async Task GetItem_ViewChaining_PreservesData() original[3, 5] = 999; // Check all views see the change - await Assert.That((int)view1[1, 5]).IsEqualTo(999); - await Assert.That((int)view2[1, 2]).IsEqualTo(999); - await Assert.That((int)view3[0, 2]).IsEqualTo(999); + ((int)view1[1, 5]).Should().Be(999); + ((int)view2[1, 2]).Should().Be(999); + ((int)view3[0, 2]).Should().Be(999); } #endregion #region __setitem__ Round 2 - [Test] - public async Task SetItem_LongIndex_Works() + [TestMethod] + public void SetItem_LongIndex_Works() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); arr.__setitem__(3L, 99); - await Assert.That((int)arr[3]).IsEqualTo(99); + ((int)arr[3]).Should().Be(99); } - [Test] - public async Task SetItem_NegativeLongIndex_Works() + [TestMethod] + public void SetItem_NegativeLongIndex_Works() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); arr.__setitem__(-2L, 88); - await Assert.That((int)arr[3]).IsEqualTo(88); + ((int)arr[3]).Should().Be(88); } - [Test] - public async Task SetItem_BroadcastScalarTo2D() + [TestMethod] + public void SetItem_BroadcastScalarTo2D() { var arr = np.zeros(new long[] { 3, 4 }, np.int32); arr.__setitem__(":", 5); - await Assert.That(np.all(arr == 5)).IsTrue(); + np.all(arr == 5).Should().BeTrue(); } - [Test] + [TestMethod] [OpenBugs] // BUG: NumPy broadcasts row to all rows, NumSharp doesn't - public async Task SetItem_BroadcastRowTo2D() + public void SetItem_BroadcastRowTo2D() { // NumPy: arr[:] = row broadcasts row to all rows // NumSharp: doesn't support this broadcast pattern yet @@ -194,127 +191,127 @@ public async Task SetItem_BroadcastRowTo2D() // When fixed, all rows should be [1, 2, 3, 4] for (int i = 0; i < 3; i++) { - await Assert.That((int)arr[i, 0]).IsEqualTo(1); - await Assert.That((int)arr[i, 3]).IsEqualTo(4); + ((int)arr[i, 0]).Should().Be(1); + ((int)arr[i, 3]).Should().Be(4); } } - [Test] - public async Task SetItem_SliceToSlice() + [TestMethod] + public void SetItem_SliceToSlice() { var arr = np.zeros(new long[] { 10 }, np.int32); var source = np.arange(3) + 1; // [1, 2, 3] arr.__setitem__("2:5", source); - await Assert.That((int)arr[0]).IsEqualTo(0); - await Assert.That((int)arr[1]).IsEqualTo(0); - await Assert.That((int)arr[2]).IsEqualTo(1); - await Assert.That((int)arr[3]).IsEqualTo(2); - await Assert.That((int)arr[4]).IsEqualTo(3); - await Assert.That((int)arr[5]).IsEqualTo(0); + ((int)arr[0]).Should().Be(0); + ((int)arr[1]).Should().Be(0); + ((int)arr[2]).Should().Be(1); + ((int)arr[3]).Should().Be(2); + ((int)arr[4]).Should().Be(3); + ((int)arr[5]).Should().Be(0); } - [Test] - public async Task SetItem_StridedSlice() + [TestMethod] + public void SetItem_StridedSlice() { var arr = np.zeros(new long[] { 10 }, np.int32); arr.__setitem__("::2", 1); // Set every other element - await Assert.That((int)arr[0]).IsEqualTo(1); - await Assert.That((int)arr[1]).IsEqualTo(0); - await Assert.That((int)arr[2]).IsEqualTo(1); - await Assert.That((int)arr[3]).IsEqualTo(0); + ((int)arr[0]).Should().Be(1); + ((int)arr[1]).Should().Be(0); + ((int)arr[2]).Should().Be(1); + ((int)arr[3]).Should().Be(0); } - [Test] - public async Task SetItem_TypePromotion_IntToDouble() + [TestMethod] + public void SetItem_TypePromotion_IntToDouble() { var arr = np.array(new[] { 1.5, 2.5, 3.5 }); arr.__setitem__(1, 10); // int assigned to double array - await Assert.That((double)arr[1]).IsEqualTo(10.0); + ((double)arr[1]).Should().Be(10.0); } - [Test] + [TestMethod] [Misaligned] // NumPy truncates (2.9 -> 2), NumSharp rounds (2.9 -> 3) - public async Task SetItem_TypePromotion_DoubleToInt_Rounds() + public void SetItem_TypePromotion_DoubleToInt_Rounds() { // NumPy truncates: arr[1] = 2.9 becomes 2 // NumSharp rounds: arr[1] = 2.9 becomes 3 var arr = np.array(new[] { 1, 2, 3 }); arr.__setitem__(1, 2.9); - await Assert.That((int)arr[1]).IsEqualTo(3); // NumSharp rounds + ((int)arr[1]).Should().Be(3); // NumSharp rounds } - [Test] - public async Task SetItem_ViewModifiesOriginal() + [TestMethod] + public void SetItem_ViewModifiesOriginal() { var original = np.arange(10); var view = original["3:7"]; view.__setitem__(1, 999); - await Assert.That((int)original[4]).IsEqualTo(999); + ((int)original[4]).Should().Be(999); } #endregion #region __contains__ Round 2 - [Test] - public async Task Contains_NaN_InFloatArray_ReturnsFalse() + [TestMethod] + public void Contains_NaN_InFloatArray_ReturnsFalse() { // NaN != NaN in IEEE 754 var arr = np.array(new[] { 1.0f, float.NaN, 3.0f }); - await Assert.That(arr.Contains(float.NaN)).IsFalse(); + arr.Contains(float.NaN).Should().BeFalse(); } - [Test] - public async Task Contains_NaN_DoubleArray_ReturnsFalse() + [TestMethod] + public void Contains_NaN_DoubleArray_ReturnsFalse() { var arr = np.array(new[] { 1.0, double.NaN, 3.0 }); - await Assert.That(arr.Contains(double.NaN)).IsFalse(); + arr.Contains(double.NaN).Should().BeFalse(); } - [Test] - public async Task Contains_MaxValue_Int32() + [TestMethod] + public void Contains_MaxValue_Int32() { var arr = np.array(new[] { int.MinValue, 0, int.MaxValue }); - await Assert.That(arr.Contains(int.MaxValue)).IsTrue(); - await Assert.That(arr.Contains(int.MinValue)).IsTrue(); + arr.Contains(int.MaxValue).Should().BeTrue(); + arr.Contains(int.MinValue).Should().BeTrue(); } - [Test] - public async Task Contains_MaxValue_Int64() + [TestMethod] + public void Contains_MaxValue_Int64() { var arr = np.array(new[] { long.MinValue, 0L, long.MaxValue }); - await Assert.That(arr.Contains(long.MaxValue)).IsTrue(); - await Assert.That(arr.Contains(long.MinValue)).IsTrue(); + arr.Contains(long.MaxValue).Should().BeTrue(); + arr.Contains(long.MinValue).Should().BeTrue(); } - [Test] - public async Task Contains_TypePromotion_ByteInInt32Array() + [TestMethod] + public void Contains_TypePromotion_ByteInInt32Array() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); - await Assert.That(arr.Contains((byte)3)).IsTrue(); + arr.Contains(((byte)3)).Should().BeTrue(); } - [Test] - public async Task Contains_TypePromotion_Int32InInt64Array() + [TestMethod] + public void Contains_TypePromotion_Int32InInt64Array() { var arr = np.array(new long[] { 1, 2, 3, 4, 5 }); - await Assert.That(arr.Contains(3)).IsTrue(); + arr.Contains(3).Should().BeTrue(); } - [Test] - public async Task Contains_ZeroInMixedSignArray() + [TestMethod] + public void Contains_ZeroInMixedSignArray() { var arr = np.array(new[] { -5, -3, 0, 3, 5 }); - await Assert.That(arr.Contains(0)).IsTrue(); + arr.Contains(0).Should().BeTrue(); } - [Test] - public async Task Contains_SpecialFloats() + [TestMethod] + public void Contains_SpecialFloats() { var arr = np.array(new[] { double.NegativeInfinity, @@ -324,34 +321,34 @@ public async Task Contains_SpecialFloats() double.PositiveInfinity }); - await Assert.That(arr.Contains(double.NegativeInfinity)).IsTrue(); - await Assert.That(arr.Contains(double.PositiveInfinity)).IsTrue(); - await Assert.That(arr.Contains(double.MinValue)).IsTrue(); - await Assert.That(arr.Contains(double.MaxValue)).IsTrue(); + arr.Contains(double.NegativeInfinity).Should().BeTrue(); + arr.Contains(double.PositiveInfinity).Should().BeTrue(); + arr.Contains(double.MinValue).Should().BeTrue(); + arr.Contains(double.MaxValue).Should().BeTrue(); } - [Test] - public async Task Contains_TransposedArray() + [TestMethod] + public void Contains_TransposedArray() { var arr = np.arange(12).reshape(3, 4).T; - await Assert.That(arr.Contains(5)).IsTrue(); - await Assert.That(arr.Contains(100)).IsFalse(); + arr.Contains(5).Should().BeTrue(); + arr.Contains(100).Should().BeFalse(); } - [Test] - public async Task Contains_ReversedArray() + [TestMethod] + public void Contains_ReversedArray() { var arr = np.arange(10)["::-1"]; - await Assert.That(arr.Contains(5)).IsTrue(); - await Assert.That(arr.Contains(100)).IsFalse(); + arr.Contains(5).Should().BeTrue(); + arr.Contains(100).Should().BeFalse(); } #endregion #region __iter__ Round 2 - [Test] - public async Task Iter_ViewIteration_CorrectValues() + [TestMethod] + public void Iter_ViewIteration_CorrectValues() { var arr = np.arange(20).reshape(4, 5); var view = arr["1:3, :"]; @@ -362,13 +359,13 @@ public async Task Iter_ViewIteration_CorrectValues() rows.Add((NDArray)item); } - await Assert.That(rows.Count).IsEqualTo(2); - await Assert.That((int)rows[0][0]).IsEqualTo(5); - await Assert.That((int)rows[1][0]).IsEqualTo(10); + rows.Count.Should().Be(2); + ((int)rows[0][0]).Should().Be(5); + ((int)rows[1][0]).Should().Be(10); } - [Test] - public async Task Iter_NestedIteration_3DArray() + [TestMethod] + public void Iter_NestedIteration_3DArray() { var arr = np.arange(24).reshape(2, 3, 4); @@ -384,13 +381,13 @@ public async Task Iter_NestedIteration_3DArray() } } - await Assert.That(allValues.Count).IsEqualTo(24); - await Assert.That(allValues[0]).IsEqualTo(0); - await Assert.That(allValues[23]).IsEqualTo(23); + allValues.Count.Should().Be(24); + allValues[0].Should().Be(0); + allValues[23].Should().Be(23); } - [Test] - public async Task Iter_MultipleEnumerators_Independent() + [TestMethod] + public void Iter_MultipleEnumerators_Independent() { var arr = np.array(new[] { 1, 2, 3 }); @@ -401,12 +398,12 @@ public async Task Iter_MultipleEnumerators_Independent() enum1.MoveNext(); enum2.MoveNext(); - await Assert.That(Convert.ToInt32(enum1.Current)).IsEqualTo(2); - await Assert.That(Convert.ToInt32(enum2.Current)).IsEqualTo(1); + Convert.ToInt32(enum1.Current).Should().Be(2); + Convert.ToInt32(enum2.Current).Should().Be(1); } - [Test] - public async Task Iter_ResetEnumerator_ThrowsNotSupported() + [TestMethod] + public void Iter_ResetEnumerator_ThrowsNotSupported() { // NDIterator does not support Reset - document this behavior var arr = np.array(new[] { 1, 2, 3 }); @@ -414,14 +411,14 @@ public async Task Iter_ResetEnumerator_ThrowsNotSupported() enumerator.MoveNext(); enumerator.MoveNext(); - await Assert.That(Convert.ToInt32(enumerator.Current)).IsEqualTo(2); + Convert.ToInt32(enumerator.Current).Should().Be(2); // Reset throws NotSupportedException - await Assert.That(() => enumerator.Reset()).Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => enumerator.Reset()); } - [Test] - public async Task Iter_TransposedArray_CorrectOrder() + [TestMethod] + public void Iter_TransposedArray_CorrectOrder() { var arr = np.arange(6).reshape(2, 3).T; // Shape (3, 2) @@ -431,14 +428,14 @@ public async Task Iter_TransposedArray_CorrectOrder() rows.Add((NDArray)item); } - await Assert.That(rows.Count).IsEqualTo(3); + rows.Count.Should().Be(3); // First row of transposed is [0, 3] - await Assert.That((int)rows[0][0]).IsEqualTo(0); - await Assert.That((int)rows[0][1]).IsEqualTo(3); + ((int)rows[0][0]).Should().Be(0); + ((int)rows[0][1]).Should().Be(3); } - [Test] - public async Task Iter_SlicedArray_CorrectElements() + [TestMethod] + public void Iter_SlicedArray_CorrectElements() { var arr = np.arange(20); var sliced = arr["5:10"]; // [5, 6, 7, 8, 9] @@ -449,11 +446,11 @@ public async Task Iter_SlicedArray_CorrectElements() values.Add(Convert.ToInt32(item)); } - await Assert.That(values).IsEquivalentTo(new[] { 5, 6, 7, 8, 9 }); + values.Should().BeEquivalentTo(new[] { 5, 6, 7, 8, 9 }); } - [Test] - public async Task Iter_StridedArray_CorrectElements() + [TestMethod] + public void Iter_StridedArray_CorrectElements() { var arr = np.arange(10); var strided = arr["1::2"]; // [1, 3, 5, 7, 9] @@ -464,11 +461,11 @@ public async Task Iter_StridedArray_CorrectElements() values.Add(Convert.ToInt32(item)); } - await Assert.That(values).IsEquivalentTo(new[] { 1, 3, 5, 7, 9 }); + values.Should().BeEquivalentTo(new[] { 1, 3, 5, 7, 9 }); } - [Test] - public async Task Iter_ReversedArray_CorrectOrder() + [TestMethod] + public void Iter_ReversedArray_CorrectOrder() { var arr = np.arange(5)["::-1"]; // [4, 3, 2, 1, 0] @@ -478,11 +475,11 @@ public async Task Iter_ReversedArray_CorrectOrder() values.Add(Convert.ToInt32(item)); } - await Assert.That(values).IsEquivalentTo(new[] { 4, 3, 2, 1, 0 }); + values.Should().BeEquivalentTo(new[] { 4, 3, 2, 1, 0 }); } - [Test] - public async Task Iter_BroadcastArray_IteratesOverBroadcastDimension() + [TestMethod] + public void Iter_BroadcastArray_IteratesOverBroadcastDimension() { var arr = np.array(new[] { 1, 2, 3 }); var broadcast = np.broadcast_to(arr, new Shape(4, 3)); @@ -493,12 +490,12 @@ public async Task Iter_BroadcastArray_IteratesOverBroadcastDimension() rows.Add((NDArray)item); } - await Assert.That(rows.Count).IsEqualTo(4); + rows.Count.Should().Be(4); // All rows should be [1, 2, 3] foreach (var row in rows) { - await Assert.That((int)row[0]).IsEqualTo(1); - await Assert.That((int)row[2]).IsEqualTo(3); + ((int)row[0]).Should().Be(1); + ((int)row[2]).Should().Be(3); } } @@ -506,47 +503,47 @@ public async Task Iter_BroadcastArray_IteratesOverBroadcastDimension() #region Edge Cases and Error Conditions - [Test] - public async Task GetItem_EmptySlice_ReturnsEmpty() + [TestMethod] + public void GetItem_EmptySlice_ReturnsEmpty() { var arr = np.arange(10); var empty = arr["5:5"]; // Empty slice - await Assert.That(empty.size).IsEqualTo(0); + empty.size.Should().Be(0); } - [Test] - public async Task GetItem_OutOfBoundsStart_ClampsToZero() + [TestMethod] + public void GetItem_OutOfBoundsStart_ClampsToZero() { var arr = np.arange(5); var result = arr["-100:3"]; // Should be equivalent to [:3] - await Assert.That(result.size).IsEqualTo(3); + result.size.Should().Be(3); } - [Test] - public async Task GetItem_OutOfBoundsStop_ClampsToEnd() + [TestMethod] + public void GetItem_OutOfBoundsStop_ClampsToEnd() { var arr = np.arange(5); var result = arr["2:100"]; // Should be equivalent to [2:] - await Assert.That(result.size).IsEqualTo(3); + result.size.Should().Be(3); } - [Test] - public async Task Len_EmptyHighDimensional() + [TestMethod] + public void Len_EmptyHighDimensional() { var arr = np.zeros(new long[] { 0, 5, 10 }); - await Assert.That(arr.__len__()).IsEqualTo(0); + arr.__len__().Should().Be(0); } - [Test] - public async Task Contains_WrongType_ReturnsFalse() + [TestMethod] + public void Contains_WrongType_ReturnsFalse() { var arr = np.array(new[] { 1, 2, 3 }); // String can't be in int array - await Assert.That(arr.Contains("hello")).IsFalse(); + arr.Contains("hello").Should().BeFalse(); } - [Test] - public async Task Iter_EmptyDimension_NoIterations() + [TestMethod] + public void Iter_EmptyDimension_NoIterations() { var arr = np.zeros(new long[] { 0, 5 }); var count = 0; @@ -554,11 +551,11 @@ public async Task Iter_EmptyDimension_NoIterations() { count++; } - await Assert.That(count).IsEqualTo(0); + count.Should().Be(0); } - [Test] - public async Task Hash_DifferentArrays_AllThrow() + [TestMethod] + public void Hash_DifferentArrays_AllThrow() { var arrays = new[] { @@ -570,7 +567,7 @@ public async Task Hash_DifferentArrays_AllThrow() foreach (var arr in arrays) { - await Assert.That(() => arr.GetHashCode()).Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.GetHashCode()); } } @@ -578,8 +575,8 @@ public async Task Hash_DifferentArrays_AllThrow() #region Python API Naming - [Test] - public async Task PythonAPI_AllMethodsAccessible() + [TestMethod] + public void PythonAPI_AllMethodsAccessible() { var arr = np.arange(12).reshape(3, 4); @@ -589,28 +586,28 @@ public async Task PythonAPI_AllMethodsAccessible() var item = arr.__getitem__(1); var iter = arr.__iter__(); - await Assert.That(len).IsEqualTo(3); - await Assert.That(contains).IsTrue(); - await Assert.That(item.size).IsEqualTo(4); - await Assert.That(iter).IsNotNull(); + len.Should().Be(3); + contains.Should().BeTrue(); + item.size.Should().Be(4); + iter.Should().NotBeNull(); } - [Test] - public async Task PythonAPI_SetItem_Works() + [TestMethod] + public void PythonAPI_SetItem_Works() { var arr = np.zeros(new long[] { 3, 3 }, np.int32); arr.__setitem__(1, 5); - await Assert.That((int)arr[1, 0]).IsEqualTo(5); - await Assert.That((int)arr[1, 1]).IsEqualTo(5); - await Assert.That((int)arr[1, 2]).IsEqualTo(5); + ((int)arr[1, 0]).Should().Be(5); + ((int)arr[1, 1]).Should().Be(5); + ((int)arr[1, 2]).Should().Be(5); } - [Test] - public async Task PythonAPI_Hash_Throws() + [TestMethod] + public void PythonAPI_Hash_Throws() { var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(() => arr.__hash__()).Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.__hash__()); } #endregion diff --git a/test/NumSharp.UnitTest/Backends/ContainerProtocolTests.cs b/test/NumSharp.UnitTest/Backends/ContainerProtocolTests.cs index a6ccf8f33..7b3ceb91f 100644 --- a/test/NumSharp.UnitTest/Backends/ContainerProtocolTests.cs +++ b/test/NumSharp.UnitTest/Backends/ContainerProtocolTests.cs @@ -1,10 +1,6 @@ using System; using System.Collections.Generic; -using System.Threading.Tasks; using NumSharp; -using TUnit.Core; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; namespace NumSharp.UnitTest.Backends; @@ -12,147 +8,148 @@ namespace NumSharp.UnitTest.Backends; /// Tests for container protocol implementation (__contains__, __hash__). /// Verifies NumPy-compatible behavior for Contains and GetHashCode. /// +[TestClass] public class ContainerProtocolTests { #region Contains Tests - [Test] - public async Task Contains_Int32_ValueExists_ReturnsTrue() + [TestMethod] + public void Contains_Int32_ValueExists_ReturnsTrue() { // NumPy: 3 in np.array([1, 2, 3, 4, 5]) = True var arr = np.array(new[] { 1, 2, 3, 4, 5 }); - await Assert.That(arr.Contains(3)).IsTrue(); - await Assert.That(arr.__contains__(3)).IsTrue(); + arr.Contains(3).Should().BeTrue(); + arr.__contains__(3).Should().BeTrue(); } - [Test] - public async Task Contains_Int32_ValueNotExists_ReturnsFalse() + [TestMethod] + public void Contains_Int32_ValueNotExists_ReturnsFalse() { // NumPy: 10 in np.array([1, 2, 3, 4, 5]) = False var arr = np.array(new[] { 1, 2, 3, 4, 5 }); - await Assert.That(arr.Contains(10)).IsFalse(); - await Assert.That(arr.__contains__(10)).IsFalse(); + arr.Contains(10).Should().BeFalse(); + arr.__contains__(10).Should().BeFalse(); } - [Test] - public async Task Contains_Double_ValueExists_ReturnsTrue() + [TestMethod] + public void Contains_Double_ValueExists_ReturnsTrue() { // NumPy: 2.5 in np.array([1.0, 2.5, 3.0]) = True var arr = np.array(new[] { 1.0, 2.5, 3.0 }); - await Assert.That(arr.Contains(2.5)).IsTrue(); + arr.Contains(2.5).Should().BeTrue(); } - [Test] - public async Task Contains_Double_NaN_ReturnsFalse() + [TestMethod] + public void Contains_Double_NaN_ReturnsFalse() { // NumPy: np.nan in np.array([1.0, np.nan, 3.0]) = False // NaN != NaN in IEEE 754, so Contains returns False var arr = np.array(new[] { 1.0, double.NaN, 3.0 }); - await Assert.That(arr.Contains(double.NaN)).IsFalse(); + arr.Contains(double.NaN).Should().BeFalse(); } - [Test] - public async Task Contains_EmptyArray_ReturnsFalse() + [TestMethod] + public void Contains_EmptyArray_ReturnsFalse() { // NumPy: 1 in np.array([]) = False var arr = np.array(Array.Empty()); - await Assert.That(arr.Contains(1)).IsFalse(); + arr.Contains(1).Should().BeFalse(); } - [Test] - public async Task Contains_2DArray_SearchesAllElements() + [TestMethod] + public void Contains_2DArray_SearchesAllElements() { // NumPy: 5 in np.array([[1, 2], [3, 4], [5, 6]]) = True var arr = np.array(new[,] { { 1, 2 }, { 3, 4 }, { 5, 6 } }); - await Assert.That(arr.Contains(5)).IsTrue(); - await Assert.That(arr.Contains(10)).IsFalse(); + arr.Contains(5).Should().BeTrue(); + arr.Contains(10).Should().BeFalse(); } - [Test] - public async Task Contains_Boolean_True() + [TestMethod] + public void Contains_Boolean_True() { // NumPy: True in np.array([False, True, False]) = True var arr = np.array(new[] { false, true, false }); - await Assert.That(arr.Contains(true)).IsTrue(); - await Assert.That(arr.Contains(false)).IsTrue(); + arr.Contains(true).Should().BeTrue(); + arr.Contains(false).Should().BeTrue(); } - [Test] - public async Task Contains_TypePromotion_IntInFloatArray() + [TestMethod] + public void Contains_TypePromotion_IntInFloatArray() { // NumPy: 2 in np.array([1.0, 2.0, 3.0]) = True // Type promotion: int 2 is compared with float 2.0 var arr = np.array(new[] { 1.0, 2.0, 3.0 }); - await Assert.That(arr.Contains(2)).IsTrue(); + arr.Contains(2).Should().BeTrue(); } - [Test] - public async Task Contains_Null_ReturnsFalse() + [TestMethod] + public void Contains_Null_ReturnsFalse() { var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(arr.Contains(null)).IsFalse(); + arr.Contains(null).Should().BeFalse(); } - [Test] - public async Task Contains_FirstElement() + [TestMethod] + public void Contains_FirstElement() { var arr = np.array(new[] { 42, 1, 2, 3 }); - await Assert.That(arr.Contains(42)).IsTrue(); + arr.Contains(42).Should().BeTrue(); } - [Test] - public async Task Contains_LastElement() + [TestMethod] + public void Contains_LastElement() { var arr = np.array(new[] { 1, 2, 3, 42 }); - await Assert.That(arr.Contains(42)).IsTrue(); + arr.Contains(42).Should().BeTrue(); } #endregion #region Hash Tests - [Test] - public async Task GetHashCode_ThrowsNotSupportedException() + [TestMethod] + public void GetHashCode_ThrowsNotSupportedException() { // NumPy: hash(np.array([1, 2, 3])) -> TypeError: unhashable type: 'numpy.ndarray' var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(() => arr.GetHashCode()).Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.GetHashCode()); } - [Test] - public async Task __hash___ThrowsNotSupportedException() + [TestMethod] + public void __hash___ThrowsNotSupportedException() { // NumPy: hash(np.array([1, 2, 3])) -> TypeError: unhashable type: 'numpy.ndarray' var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(() => arr.__hash__()).Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.__hash__()); } - [Test] - public async Task Dictionary_WithNDArrayKey_ThrowsOnAccess() + [TestMethod] + public void Dictionary_WithNDArrayKey_ThrowsOnAccess() { // Attempting to use NDArray as dictionary key should fail var arr = np.array(new[] { 1, 2, 3 }); var dict = new Dictionary(); // Adding to dictionary calls GetHashCode, which throws - await Assert.That(() => dict.Add(arr, "value")).Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => dict.Add(arr, "value")); } - [Test] - public async Task Dictionary_WithReferenceEqualityComparer_Works() + [TestMethod] + public void Dictionary_WithReferenceEqualityComparer_Works() { // Workaround: use ReferenceEqualityComparer var arr1 = np.array(new[] { 1, 2, 3 }); @@ -162,123 +159,123 @@ public async Task Dictionary_WithReferenceEqualityComparer_Works() dict[arr1] = "first"; dict[arr2] = "second"; - await Assert.That(dict[arr1]).IsEqualTo("first"); - await Assert.That(dict[arr2]).IsEqualTo("second"); - await Assert.That(dict.Count).IsEqualTo(2); // Two distinct references + dict[arr1].Should().Be("first"); + dict[arr2].Should().Be("second"); + dict.Count.Should().Be(2); // Two distinct references } #endregion #region Python Naming Convention Tests - [Test] - public async Task __contains___IsSameAsContains() + [TestMethod] + public void __contains___IsSameAsContains() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); // Both methods should return the same result - await Assert.That(arr.__contains__(3)).IsEqualTo(arr.Contains(3)); - await Assert.That(arr.__contains__(10)).IsEqualTo(arr.Contains(10)); + arr.__contains__(3).Should().Be(arr.Contains(3)); + arr.__contains__(10).Should().Be(arr.Contains(10)); } #endregion #region Length Tests (__len__) - [Test] - public async Task __len___1DArray_ReturnsLength() + [TestMethod] + public void __len___1DArray_ReturnsLength() { // NumPy: len(np.array([1, 2, 3])) = 3 var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(arr.__len__()).IsEqualTo(3); + arr.__len__().Should().Be(3); } - [Test] - public async Task __len___2DArray_ReturnsFirstDimension() + [TestMethod] + public void __len___2DArray_ReturnsFirstDimension() { // NumPy: len(np.array([[1, 2], [3, 4], [5, 6]])) = 3 var arr = np.array(new[,] { { 1, 2 }, { 3, 4 }, { 5, 6 } }); - await Assert.That(arr.__len__()).IsEqualTo(3); + arr.__len__().Should().Be(3); } - [Test] - public async Task __len___ScalarArray_ThrowsTypeError() + [TestMethod] + public void __len___ScalarArray_ThrowsTypeError() { // NumPy: len(np.array(5)) -> TypeError: len() of unsized object // Note: NDArray.Scalar creates a true 0-d array, while np.array(5) creates 1-d var scalar = NDArray.Scalar(5); - await Assert.That(scalar.ndim).IsEqualTo(0); // Verify it's a true scalar - await Assert.That(() => scalar.__len__()).Throws(); + scalar.ndim.Should().Be(0); // Verify it's a true scalar + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => scalar.__len__()); } #endregion #region Iteration Tests (__iter__) - [Test] - public async Task __iter___ReturnsEnumerator() + [TestMethod] + public void __iter___ReturnsEnumerator() { var arr = np.array(new[] { 1, 2, 3 }); var iter = arr.__iter__(); - await Assert.That(iter).IsNotNull(); - await Assert.That(iter.MoveNext()).IsTrue(); + iter.Should().NotBeNull(); + iter.MoveNext().Should().BeTrue(); } #endregion #region Indexing Tests (__getitem__, __setitem__) - [Test] - public async Task __getitem___IntIndex_ReturnsElement() + [TestMethod] + public void __getitem___IntIndex_ReturnsElement() { var arr = np.array(new[] { 10, 20, 30 }); var result = arr.__getitem__(1); - await Assert.That((int)result).IsEqualTo(20); + ((int)result).Should().Be(20); } - [Test] - public async Task __getitem___NegativeIndex_ReturnsFromEnd() + [TestMethod] + public void __getitem___NegativeIndex_ReturnsFromEnd() { var arr = np.array(new[] { 10, 20, 30 }); var result = arr.__getitem__(-1); - await Assert.That((int)result).IsEqualTo(30); + ((int)result).Should().Be(30); } - [Test] - public async Task __getitem___SliceString_ReturnsSlice() + [TestMethod] + public void __getitem___SliceString_ReturnsSlice() { var arr = np.array(new[] { 10, 20, 30, 40, 50 }); var result = arr.__getitem__("1:4"); - await Assert.That(result.size).IsEqualTo(3); - await Assert.That((int)result[0]).IsEqualTo(20); + result.size.Should().Be(3); + ((int)result[0]).Should().Be(20); } - [Test] - public async Task __setitem___IntIndex_SetsElement() + [TestMethod] + public void __setitem___IntIndex_SetsElement() { var arr = np.array(new[] { 10, 20, 30 }); arr.__setitem__(1, 99); - await Assert.That((int)arr[1]).IsEqualTo(99); + ((int)arr[1]).Should().Be(99); } - [Test] - public async Task __setitem___SliceString_SetsSlice() + [TestMethod] + public void __setitem___SliceString_SetsSlice() { var arr = np.array(new[] { 10, 20, 30, 40, 50 }); arr.__setitem__(":3", 0); - await Assert.That((int)arr[0]).IsEqualTo(0); - await Assert.That((int)arr[1]).IsEqualTo(0); - await Assert.That((int)arr[2]).IsEqualTo(0); - await Assert.That((int)arr[3]).IsEqualTo(40); // Unchanged + ((int)arr[0]).Should().Be(0); + ((int)arr[1]).Should().Be(0); + ((int)arr[2]).Should().Be(0); + ((int)arr[3]).Should().Be(40); // Unchanged } #endregion diff --git a/test/NumSharp.UnitTest/Backends/ContainsNumPyAlignmentTests.cs b/test/NumSharp.UnitTest/Backends/ContainsNumPyAlignmentTests.cs index 16d74336c..a171e3ffe 100644 --- a/test/NumSharp.UnitTest/Backends/ContainsNumPyAlignmentTests.cs +++ b/test/NumSharp.UnitTest/Backends/ContainsNumPyAlignmentTests.cs @@ -1,9 +1,5 @@ using System; -using System.Threading.Tasks; using NumSharp; -using TUnit.Core; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; namespace NumSharp.UnitTest.Backends; @@ -16,497 +12,477 @@ namespace NumSharp.UnitTest.Backends; /// - Type mismatch (string in int array) returns False /// - Broadcastable shapes work correctly /// +[TestClass] public class ContainsNumPyAlignmentTests { #region Gap #1: Broadcasting Errors Should Propagate - [Test] - public async Task Contains_1DArrayIn1D_ShapeMismatch_Throws() + [TestMethod] + public void Contains_1DArrayIn1D_ShapeMismatch_Throws() { // NumPy: [1,2] in np.array([1,2,3]) throws ValueError var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(() => arr.Contains(new[] { 1, 2 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new[] { 1, 2 })); } - [Test] - public async Task Contains_NDArrayIn1D_ShapeMismatch_Throws() + [TestMethod] + public void Contains_NDArrayIn1D_ShapeMismatch_Throws() { // NumPy: np.array([1,2]) in np.array([1,2,3]) throws ValueError var arr = np.array(new[] { 1, 2, 3 }); var search = np.array(new[] { 1, 2 }); - await Assert.That(() => arr.Contains(search)) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(search)); } - [Test] - public async Task Contains_LargerArrayIn1D_ShapeMismatch_Throws() + [TestMethod] + public void Contains_LargerArrayIn1D_ShapeMismatch_Throws() { // NumPy: [1,2,3,4,5] in np.array([1,2,3]) throws ValueError var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(() => arr.Contains(new[] { 1, 2, 3, 4, 5 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new[] { 1, 2, 3, 4, 5 })); } - [Test] - public async Task Contains_2DArrayIn1D_ShapeMismatch_Throws() + [TestMethod] + public void Contains_2DArrayIn1D_ShapeMismatch_Throws() { // NumPy: [[1,2],[3,4]] in np.array([1,2,3]) throws ValueError var arr = np.array(new[] { 1, 2, 3 }); var search = np.array(new[,] { { 1, 2 }, { 3, 4 } }); - await Assert.That(() => arr.Contains(search)) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(search)); } - [Test] - public async Task Contains_EmptyArrayIn1D_ShapeMismatch_Throws() + [TestMethod] + public void Contains_EmptyArrayIn1D_ShapeMismatch_Throws() { // Empty array has shape (0,) which can't broadcast with (3,) var arr = np.array(new[] { 1, 2, 3 }); var empty = np.array(new int[0]); - await Assert.That(() => arr.Contains(empty)) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(empty)); } #endregion #region Broadcastable Cases Should Work - [Test] - public async Task Contains_ScalarIn1D_Works() + [TestMethod] + public void Contains_ScalarIn1D_Works() { var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(arr.Contains(2)).IsTrue(); - await Assert.That(arr.Contains(10)).IsFalse(); + arr.Contains(2).Should().BeTrue(); + arr.Contains(10).Should().BeFalse(); } - [Test] - public async Task Contains_ScalarIn2D_SearchesAll() + [TestMethod] + public void Contains_ScalarIn2D_SearchesAll() { // NumPy: 3 in np.array([[1,2],[3,4]]) returns True var arr = np.array(new[,] { { 1, 2 }, { 3, 4 } }); - await Assert.That(arr.Contains(3)).IsTrue(); - await Assert.That(arr.Contains(10)).IsFalse(); + arr.Contains(3).Should().BeTrue(); + arr.Contains(10).Should().BeFalse(); } - [Test] - public async Task Contains_RowIn2D_Broadcasts() + [TestMethod] + public void Contains_RowIn2D_Broadcasts() { // NumPy: [1,2] in np.array([[1,2],[3,4]]) returns True // Broadcasting: [1,2] compares element-wise, then any() checks if ANY match var arr = np.array(new[,] { { 1, 2 }, { 3, 4 } }); - await Assert.That(arr.Contains(new[] { 1, 2 })).IsTrue(); // All match first row - await Assert.That(arr.Contains(new[] { 3, 4 })).IsTrue(); // All match second row - await Assert.That(arr.Contains(new[] { 1, 3 })).IsTrue(); // 1 matches [0,0], so any()=True - await Assert.That(arr.Contains(new[] { 5, 6 })).IsFalse(); // No element matches + arr.Contains(new[] { 1, 2 }).Should().BeTrue(); // All match first row + arr.Contains(new[] { 3, 4 }).Should().BeTrue(); // All match second row + arr.Contains(new[] { 1, 3 }).Should().BeTrue(); // 1 matches [0,0], so any()=True + arr.Contains(new[] { 5, 6 }).Should().BeFalse(); // No element matches } - [Test] - public async Task Contains_NDArrayRowIn2D_Broadcasts() + [TestMethod] + public void Contains_NDArrayRowIn2D_Broadcasts() { var arr = np.array(new[,] { { 1, 2 }, { 3, 4 } }); var row = np.array(new[] { 1, 2 }); - await Assert.That(arr.Contains(row)).IsTrue(); + arr.Contains(row).Should().BeTrue(); } - [Test] - public async Task Contains_ColumnIn2D_Broadcasts() + [TestMethod] + public void Contains_ColumnIn2D_Broadcasts() { // [[1],[3]] broadcasts against [[1,2],[3,4]] -> checks column-wise var arr = np.array(new[,] { { 1, 2 }, { 3, 4 } }); var col = np.array(new[,] { { 1 }, { 3 } }); - await Assert.That(arr.Contains(col)).IsTrue(); + arr.Contains(col).Should().BeTrue(); } - [Test] - public async Task Contains_ScalarIn3D_SearchesAll() + [TestMethod] + public void Contains_ScalarIn3D_SearchesAll() { var arr = np.arange(24).reshape(2, 3, 4); - await Assert.That(arr.Contains(0)).IsTrue(); - await Assert.That(arr.Contains(23)).IsTrue(); - await Assert.That(arr.Contains(100)).IsFalse(); + arr.Contains(0).Should().BeTrue(); + arr.Contains(23).Should().BeTrue(); + arr.Contains(100).Should().BeFalse(); } - [Test] - public async Task Contains_0DScalar_Works() + [TestMethod] + public void Contains_0DScalar_Works() { var scalar = NDArray.Scalar(42); - await Assert.That(scalar.Contains(42)).IsTrue(); - await Assert.That(scalar.Contains(0)).IsFalse(); + scalar.Contains(42).Should().BeTrue(); + scalar.Contains(0).Should().BeFalse(); } #endregion #region Type Mismatch Returns False (Not Exception) - [Test] - public async Task Contains_StringInIntArray_ReturnsFalse() + [TestMethod] + public void Contains_StringInIntArray_ReturnsFalse() { // NumPy: "hello" in np.array([1,2,3]) returns False var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(arr.Contains("hello")).IsFalse(); + arr.Contains("hello").Should().BeFalse(); } - [Test] - public async Task Contains_StringInFloatArray_ReturnsFalse() + [TestMethod] + public void Contains_StringInFloatArray_ReturnsFalse() { var arr = np.array(new[] { 1.0, 2.0, 3.0 }); - await Assert.That(arr.Contains("test")).IsFalse(); + arr.Contains("test").Should().BeFalse(); } - [Test] - public async Task Contains_StringInBoolArray_ReturnsFalse() + [TestMethod] + public void Contains_StringInBoolArray_ReturnsFalse() { var arr = np.array(new[] { true, false }); - await Assert.That(arr.Contains("true")).IsFalse(); + arr.Contains("true").Should().BeFalse(); } - [Test] - public async Task Contains_NullInAnyArray_ReturnsFalse() + [TestMethod] + public void Contains_NullInAnyArray_ReturnsFalse() { // NumPy: None in np.array([1,2,3]) returns False var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(arr.Contains(null)).IsFalse(); + arr.Contains(null).Should().BeFalse(); } #endregion #region Char Array Special Cases - [Test] - public async Task Contains_CharInCharArray_Works() + [TestMethod] + public void Contains_CharInCharArray_Works() { var arr = np.array(new[] { 'a', 'b', 'c' }); - await Assert.That(arr.Contains('a')).IsTrue(); - await Assert.That(arr.Contains('d')).IsFalse(); + arr.Contains('a').Should().BeTrue(); + arr.Contains('d').Should().BeFalse(); } - [Test] - public async Task Contains_MatchingStringInCharArray_Broadcasts() + [TestMethod] + public void Contains_MatchingStringInCharArray_Broadcasts() { // "abc" creates char[3], broadcasts element-wise with char[3] var arr = np.array(new[] { 'a', 'b', 'c' }); - await Assert.That(arr.Contains("abc")).IsTrue(); + arr.Contains("abc").Should().BeTrue(); } - [Test] - public async Task Contains_MismatchedStringInCharArray_Throws() + [TestMethod] + public void Contains_MismatchedStringInCharArray_Throws() { // "hello" creates char[5], can't broadcast with char[3] var arr = np.array(new[] { 'a', 'b', 'c' }); - await Assert.That(() => arr.Contains("hello")) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains("hello")); } - [Test] - public async Task Contains_SingleCharStringInCharArray_Broadcasts() + [TestMethod] + public void Contains_SingleCharStringInCharArray_Broadcasts() { // "a" creates char[1], broadcasts against char[3] var arr = np.array(new[] { 'a', 'b', 'c' }); // This broadcasts [a] against [a,b,c] -> [True, False, False].any() = True - await Assert.That(arr.Contains("a")).IsTrue(); + arr.Contains("a").Should().BeTrue(); } #endregion #region All 12 Dtypes - Shape Mismatch Throws - [Test] - public async Task Contains_ShapeMismatch_Boolean_Throws() + [TestMethod] + public void Contains_ShapeMismatch_Boolean_Throws() { var arr = np.array(new[] { true, false, true }); - await Assert.That(() => arr.Contains(new[] { true, false })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new[] { true, false })); } - [Test] - public async Task Contains_ShapeMismatch_Byte_Throws() + [TestMethod] + public void Contains_ShapeMismatch_Byte_Throws() { var arr = np.array(new byte[] { 1, 2, 3 }); - await Assert.That(() => arr.Contains(new byte[] { 1, 2 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new byte[] { 1, 2 })); } - [Test] - public async Task Contains_ShapeMismatch_Int16_Throws() + [TestMethod] + public void Contains_ShapeMismatch_Int16_Throws() { var arr = np.array(new short[] { 1, 2, 3 }); - await Assert.That(() => arr.Contains(new short[] { 1, 2 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new short[] { 1, 2 })); } - [Test] - public async Task Contains_ShapeMismatch_UInt16_Throws() + [TestMethod] + public void Contains_ShapeMismatch_UInt16_Throws() { var arr = np.array(new ushort[] { 1, 2, 3 }); - await Assert.That(() => arr.Contains(new ushort[] { 1, 2 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new ushort[] { 1, 2 })); } - [Test] - public async Task Contains_ShapeMismatch_Int32_Throws() + [TestMethod] + public void Contains_ShapeMismatch_Int32_Throws() { var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(() => arr.Contains(new[] { 1, 2 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new[] { 1, 2 })); } - [Test] - public async Task Contains_ShapeMismatch_UInt32_Throws() + [TestMethod] + public void Contains_ShapeMismatch_UInt32_Throws() { var arr = np.array(new uint[] { 1, 2, 3 }); - await Assert.That(() => arr.Contains(new uint[] { 1, 2 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new uint[] { 1, 2 })); } - [Test] - public async Task Contains_ShapeMismatch_Int64_Throws() + [TestMethod] + public void Contains_ShapeMismatch_Int64_Throws() { var arr = np.array(new long[] { 1, 2, 3 }); - await Assert.That(() => arr.Contains(new long[] { 1, 2 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new long[] { 1, 2 })); } - [Test] - public async Task Contains_ShapeMismatch_UInt64_Throws() + [TestMethod] + public void Contains_ShapeMismatch_UInt64_Throws() { var arr = np.array(new ulong[] { 1, 2, 3 }); - await Assert.That(() => arr.Contains(new ulong[] { 1, 2 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new ulong[] { 1, 2 })); } - [Test] - public async Task Contains_ShapeMismatch_Single_Throws() + [TestMethod] + public void Contains_ShapeMismatch_Single_Throws() { var arr = np.array(new[] { 1f, 2f, 3f }); - await Assert.That(() => arr.Contains(new[] { 1f, 2f })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new[] { 1f, 2f })); } - [Test] - public async Task Contains_ShapeMismatch_Double_Throws() + [TestMethod] + public void Contains_ShapeMismatch_Double_Throws() { var arr = np.array(new[] { 1.0, 2.0, 3.0 }); - await Assert.That(() => arr.Contains(new[] { 1.0, 2.0 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new[] { 1.0, 2.0 })); } - [Test] - public async Task Contains_ShapeMismatch_Decimal_Throws() + [TestMethod] + public void Contains_ShapeMismatch_Decimal_Throws() { var arr = np.array(new[] { 1m, 2m, 3m }); - await Assert.That(() => arr.Contains(new[] { 1m, 2m })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new[] { 1m, 2m })); } - [Test] - public async Task Contains_ShapeMismatch_Char_Throws() + [TestMethod] + public void Contains_ShapeMismatch_Char_Throws() { var arr = np.array(new[] { 'a', 'b', 'c' }); - await Assert.That(() => arr.Contains(new[] { 'a', 'b' })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(new[] { 'a', 'b' })); } #endregion #region Edge Cases - [Test] - public async Task Contains_EmptyArray_ReturnsFalse() + [TestMethod] + public void Contains_EmptyArray_ReturnsFalse() { var empty = np.array(new int[0]); - await Assert.That(empty.Contains(1)).IsFalse(); + empty.Contains(1).Should().BeFalse(); } - [Test] - public async Task Contains_NaN_InFloatArray_ReturnsFalse() + [TestMethod] + public void Contains_NaN_InFloatArray_ReturnsFalse() { // NaN == NaN is false in IEEE 754 var arr = np.array(new[] { 1.0, double.NaN, 3.0 }); - await Assert.That(arr.Contains(double.NaN)).IsFalse(); + arr.Contains(double.NaN).Should().BeFalse(); } - [Test] - public async Task Contains_Infinity_Works() + [TestMethod] + public void Contains_Infinity_Works() { var arr = np.array(new[] { 1.0, double.PositiveInfinity, 3.0 }); - await Assert.That(arr.Contains(double.PositiveInfinity)).IsTrue(); - await Assert.That(arr.Contains(double.NegativeInfinity)).IsFalse(); + arr.Contains(double.PositiveInfinity).Should().BeTrue(); + arr.Contains(double.NegativeInfinity).Should().BeFalse(); } - [Test] - public async Task Contains_TypePromotion_IntInFloat_Works() + [TestMethod] + public void Contains_TypePromotion_IntInFloat_Works() { // 2 (int) should match 2.0 (double) after promotion var arr = np.array(new[] { 1.0, 2.0, 3.0 }); - await Assert.That(arr.Contains(2)).IsTrue(); + arr.Contains(2).Should().BeTrue(); } - [Test] - public async Task Contains_TypePromotion_FloatInInt_Works() + [TestMethod] + public void Contains_TypePromotion_FloatInInt_Works() { // 2.0 should match 2 (int) after promotion var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(arr.Contains(2.0)).IsTrue(); + arr.Contains(2.0).Should().BeTrue(); } - [Test] - public async Task Contains_BoolIntInterop_Works() + [TestMethod] + public void Contains_BoolIntInterop_Works() { // NumPy: 1 in np.array([True, False]) returns True (1 == True) var arr = np.array(new[] { true, false }); - await Assert.That(arr.Contains(1)).IsTrue(); - await Assert.That(arr.Contains(0)).IsTrue(); - await Assert.That(arr.Contains(2)).IsFalse(); + arr.Contains(1).Should().BeTrue(); + arr.Contains(0).Should().BeTrue(); + arr.Contains(2).Should().BeFalse(); } - [Test] - public async Task Contains_SlicedArray_Works() + [TestMethod] + public void Contains_SlicedArray_Works() { var arr = np.arange(10); var sliced = arr["2:8:2"]; // [2, 4, 6] - await Assert.That(sliced.Contains(4)).IsTrue(); - await Assert.That(sliced.Contains(3)).IsFalse(); + sliced.Contains(4).Should().BeTrue(); + sliced.Contains(3).Should().BeFalse(); } - [Test] - public async Task Contains_SlicedArray_ShapeMismatch_Throws() + [TestMethod] + public void Contains_SlicedArray_ShapeMismatch_Throws() { var arr = np.arange(10); var sliced = arr["2:5"]; // [2, 3, 4] - shape (3,) - await Assert.That(() => sliced.Contains(new[] { 1, 2 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => sliced.Contains(new[] { 1, 2 })); } - [Test] - public async Task Contains_TransposedArray_Works() + [TestMethod] + public void Contains_TransposedArray_Works() { var arr = np.array(new[,] { { 1, 2 }, { 3, 4 } }); var transposed = arr.T; - await Assert.That(transposed.Contains(3)).IsTrue(); + transposed.Contains(3).Should().BeTrue(); } - [Test] - public async Task Contains_BroadcastView_Works() + [TestMethod] + public void Contains_BroadcastView_Works() { var arr = np.array(new[] { 1, 2, 3 }); var broadcast = np.broadcast_to(arr, new Shape(4, 3)); - await Assert.That(broadcast.Contains(2)).IsTrue(); - await Assert.That(broadcast.Contains(10)).IsFalse(); + broadcast.Contains(2).Should().BeTrue(); + broadcast.Contains(10).Should().BeFalse(); } - [Test] - public async Task Contains_ReversedArray_Works() + [TestMethod] + public void Contains_ReversedArray_Works() { var arr = np.arange(5)["::-1"]; // [4, 3, 2, 1, 0] - await Assert.That(arr.Contains(3)).IsTrue(); - await Assert.That(arr.Contains(10)).IsFalse(); + arr.Contains(3).Should().BeTrue(); + arr.Contains(10).Should().BeFalse(); } - [Test] - public async Task Contains_LargeArray_Works() + [TestMethod] + public void Contains_LargeArray_Works() { var arr = np.arange(1_000_000); - await Assert.That(arr.Contains(500_000)).IsTrue(); - await Assert.That(arr.Contains(2_000_000)).IsFalse(); + arr.Contains(500_000).Should().BeTrue(); + arr.Contains(2_000_000).Should().BeFalse(); } #endregion #region N-Dimensional Broadcasting - [Test] - public async Task Contains_3D_ScalarSearch_Works() + [TestMethod] + public void Contains_3D_ScalarSearch_Works() { var arr = np.arange(24).reshape(2, 3, 4); - await Assert.That(arr.Contains(15)).IsTrue(); - await Assert.That(arr.Contains(100)).IsFalse(); + arr.Contains(15).Should().BeTrue(); + arr.Contains(100).Should().BeFalse(); } - [Test] - public async Task Contains_3D_1DSearch_Broadcasts() + [TestMethod] + public void Contains_3D_1DSearch_Broadcasts() { // Search for [0,1,2,3] in (2,3,4) array // Should broadcast and find matches in first row of each 2D slice var arr = np.arange(24).reshape(2, 3, 4); var search = np.array(new[] { 0, 1, 2, 3 }); - await Assert.That(arr.Contains(search)).IsTrue(); + arr.Contains(search).Should().BeTrue(); } - [Test] - public async Task Contains_3D_2DSearch_Broadcasts() + [TestMethod] + public void Contains_3D_2DSearch_Broadcasts() { // Search for 2D slice in 3D array var arr = np.arange(24).reshape(2, 3, 4); var search = np.arange(12).reshape(3, 4); // First 2D slice - await Assert.That(arr.Contains(search)).IsTrue(); + arr.Contains(search).Should().BeTrue(); } - [Test] - public async Task Contains_3D_IncompatibleShape_Throws() + [TestMethod] + public void Contains_3D_IncompatibleShape_Throws() { var arr = np.arange(24).reshape(2, 3, 4); var search = np.array(new[] { 1, 2 }); // Can't broadcast (2,) with (2,3,4) - await Assert.That(() => arr.Contains(search)) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.Contains(search)); } #endregion #region __contains__ Method Alias - [Test] - public async Task DunderContains_SameAsContains() + [TestMethod] + public void DunderContains_SameAsContains() { var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(arr.__contains__(2)).IsTrue(); - await Assert.That(arr.__contains__(10)).IsFalse(); + arr.__contains__(2).Should().BeTrue(); + arr.__contains__(10).Should().BeFalse(); } - [Test] - public async Task DunderContains_ShapeMismatch_Throws() + [TestMethod] + public void DunderContains_ShapeMismatch_Throws() { var arr = np.array(new[] { 1, 2, 3 }); - await Assert.That(() => arr.__contains__(new[] { 1, 2 })) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => arr.__contains__(new[] { 1, 2 })); } #endregion diff --git a/test/NumSharp.UnitTest/Backends/Kernels/ArgMaxArgMinComprehensiveTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/ArgMaxArgMinComprehensiveTests.cs index 59a969ac7..6b9c4e1e0 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/ArgMaxArgMinComprehensiveTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/ArgMaxArgMinComprehensiveTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -17,11 +16,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// - Edge cases (single element, identical values, NaN handling) /// - Shape variations (square, rectangular, higher dimensional) /// +[TestClass] public class ArgMaxArgMinComprehensiveTests { #region ArgMax 1D Tests - [Test] + [TestMethod] public void ArgMax_1D_Int32() { // NumPy: np.argmax(np.array([1, 3, 2, 5, 4])) = 3 @@ -30,7 +30,7 @@ public void ArgMax_1D_Int32() Assert.AreEqual(3L, (long)result); } - [Test] + [TestMethod] public void ArgMax_1D_Int64() { // NumPy: np.argmax(np.array([1, 3, 2, 5, 4], dtype=np.int64)) = 3 @@ -39,7 +39,7 @@ public void ArgMax_1D_Int64() Assert.AreEqual(3L, (long)result); } - [Test] + [TestMethod] public void ArgMax_1D_Float32() { // NumPy: np.argmax(np.array([1.1, 3.3, 2.2, 5.5, 4.4], dtype=np.float32)) = 3 @@ -48,7 +48,7 @@ public void ArgMax_1D_Float32() Assert.AreEqual(3L, (long)result); } - [Test] + [TestMethod] public void ArgMax_1D_Float64() { // NumPy: np.argmax(np.array([1.1, 3.3, 2.2, 5.5, 4.4], dtype=np.float64)) = 3 @@ -61,7 +61,7 @@ public void ArgMax_1D_Float64() #region ArgMax 2D Tests - [Test] + [TestMethod] public void ArgMax_2D_NoAxis() { // NumPy: np.argmax([[1, 5, 3], [7, 2, 8], [4, 6, 0]]) = 5 @@ -71,7 +71,7 @@ public void ArgMax_2D_NoAxis() Assert.AreEqual(5L, (long)result); } - [Test] + [TestMethod] public void ArgMax_2D_Axis0() { // NumPy: np.argmax([[1, 5, 3], [7, 2, 8], [4, 6, 0]], axis=0) = [1, 2, 1] @@ -81,7 +81,7 @@ public void ArgMax_2D_Axis0() result.Should().BeOfValues(1L, 2L, 1L); } - [Test] + [TestMethod] public void ArgMax_2D_Axis1() { // NumPy: np.argmax([[1, 5, 3], [7, 2, 8], [4, 6, 0]], axis=1) = [1, 2, 1] @@ -91,7 +91,7 @@ public void ArgMax_2D_Axis1() result.Should().BeOfValues(1L, 2L, 1L); } - [Test] + [TestMethod] public void ArgMax_2D_AxisNeg1() { // NumPy: np.argmax([[1, 5, 3], [7, 2, 8], [4, 6, 0]], axis=-1) = [1, 2, 1] @@ -106,7 +106,7 @@ public void ArgMax_2D_AxisNeg1() #region ArgMax 3D Tests - [Test] + [TestMethod] public void ArgMax_3D_NoAxis() { // NumPy: np.argmax([[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]]) = 11 @@ -115,7 +115,7 @@ public void ArgMax_3D_NoAxis() Assert.AreEqual(11L, (long)result); } - [Test] + [TestMethod] public void ArgMax_3D_Axis0() { // NumPy: np.argmax([[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]], axis=0) = [[2, 2], [2, 2]] @@ -125,7 +125,7 @@ public void ArgMax_3D_Axis0() result.Should().BeOfValues(2L, 2L, 2L, 2L); } - [Test] + [TestMethod] public void ArgMax_3D_Axis1() { // NumPy: np.argmax([[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]], axis=1) = [[1, 1], [1, 1], [1, 1]] @@ -135,7 +135,7 @@ public void ArgMax_3D_Axis1() result.Should().BeOfValues(1L, 1L, 1L, 1L, 1L, 1L); } - [Test] + [TestMethod] public void ArgMax_3D_Axis2() { // NumPy: np.argmax([[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]], axis=2) = [[1, 1], [1, 1], [1, 1]] @@ -149,7 +149,7 @@ public void ArgMax_3D_Axis2() #region ArgMax Edge Cases - [Test] + [TestMethod] public void ArgMax_SingleElement() { // NumPy: np.argmax([42]) = 0 @@ -158,7 +158,7 @@ public void ArgMax_SingleElement() Assert.AreEqual(0L, (long)result); } - [Test] + [TestMethod] public void ArgMax_IdenticalValues() { // NumPy: np.argmax([5, 5, 5, 5]) = 0 (returns first occurrence) @@ -167,7 +167,7 @@ public void ArgMax_IdenticalValues() Assert.AreEqual(0L, (long)result); } - [Test] + [TestMethod] public void ArgMax_WithNaN() { // NumPy: np.argmax([1.0, nan, 3.0, 2.0]) = 1 (NaN returns its index) @@ -180,7 +180,7 @@ public void ArgMax_WithNaN() #region ArgMax Rectangular Arrays - [Test] + [TestMethod] public void ArgMax_Rectangular_2x5_Axis0() { // NumPy: np.argmax([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]], axis=0) = [1, 1, 1, 1, 1] @@ -190,7 +190,7 @@ public void ArgMax_Rectangular_2x5_Axis0() result.Should().BeOfValues(1L, 1L, 1L, 1L, 1L); } - [Test] + [TestMethod] public void ArgMax_Rectangular_2x5_Axis1() { // NumPy: np.argmax([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]], axis=1) = [4, 4] @@ -204,7 +204,7 @@ public void ArgMax_Rectangular_2x5_Axis1() #region ArgMax Square Arrays - [Test] + [TestMethod] public void ArgMax_Square_4x4_Axis0() { // NumPy: np.argmax([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], axis=0) = [3, 3, 3, 3] @@ -214,7 +214,7 @@ public void ArgMax_Square_4x4_Axis0() result.Should().BeOfValues(3L, 3L, 3L, 3L); } - [Test] + [TestMethod] public void ArgMax_Square_4x4_Axis1() { // NumPy: np.argmax([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], axis=1) = [3, 3, 3, 3] @@ -228,7 +228,7 @@ public void ArgMax_Square_4x4_Axis1() #region ArgMax Higher Dimensional - [Test] + [TestMethod] public void ArgMax_3D_2x3x4_AxisNeg1() { // NumPy: np.argmax(np.arange(24).reshape(2, 3, 4), axis=-1) = [[3, 3, 3], [3, 3, 3]] @@ -238,7 +238,7 @@ public void ArgMax_3D_2x3x4_AxisNeg1() result.Should().BeOfValues(3L, 3L, 3L, 3L, 3L, 3L); } - [Test] + [TestMethod] public void ArgMax_3D_2x3x4_AxisNeg2() { // NumPy: np.argmax(np.arange(24).reshape(2, 3, 4), axis=-2) = [[2, 2, 2, 2], [2, 2, 2, 2]] @@ -248,7 +248,7 @@ public void ArgMax_3D_2x3x4_AxisNeg2() result.Should().BeOfValues(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L); } - [Test] + [TestMethod] public void ArgMax_3D_2x3x4_AxisNeg3() { // NumPy: np.argmax(np.arange(24).reshape(2, 3, 4), axis=-3) = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]] @@ -262,7 +262,7 @@ public void ArgMax_3D_2x3x4_AxisNeg3() #region ArgMin 1D Tests - [Test] + [TestMethod] public void ArgMin_1D_Int32() { // NumPy: np.argmin(np.array([1, 3, 2, 5, 4])) = 0 @@ -271,7 +271,7 @@ public void ArgMin_1D_Int32() Assert.AreEqual(0L, (long)result); } - [Test] + [TestMethod] public void ArgMin_1D_Int64() { // NumPy: np.argmin(np.array([1, 3, 2, 5, 4], dtype=np.int64)) = 0 @@ -280,7 +280,7 @@ public void ArgMin_1D_Int64() Assert.AreEqual(0L, (long)result); } - [Test] + [TestMethod] public void ArgMin_1D_Float32() { // NumPy: np.argmin(np.array([1.1, 3.3, 2.2, 5.5, 4.4], dtype=np.float32)) = 0 @@ -289,7 +289,7 @@ public void ArgMin_1D_Float32() Assert.AreEqual(0L, (long)result); } - [Test] + [TestMethod] public void ArgMin_1D_Float64() { // NumPy: np.argmin(np.array([1.1, 3.3, 2.2, 5.5, 4.4], dtype=np.float64)) = 0 @@ -302,7 +302,7 @@ public void ArgMin_1D_Float64() #region ArgMin 2D Tests - [Test] + [TestMethod] public void ArgMin_2D_NoAxis() { // NumPy: np.argmin([[1, 5, 3], [7, 2, 8], [4, 6, 0]]) = 8 @@ -312,7 +312,7 @@ public void ArgMin_2D_NoAxis() Assert.AreEqual(8L, (long)result); } - [Test] + [TestMethod] public void ArgMin_2D_Axis0() { // NumPy: np.argmin([[1, 5, 3], [7, 2, 8], [4, 6, 0]], axis=0) = [0, 1, 2] @@ -322,7 +322,7 @@ public void ArgMin_2D_Axis0() result.Should().BeOfValues(0L, 1L, 2L); } - [Test] + [TestMethod] public void ArgMin_2D_Axis1() { // NumPy: np.argmin([[1, 5, 3], [7, 2, 8], [4, 6, 0]], axis=1) = [0, 1, 2] @@ -332,7 +332,7 @@ public void ArgMin_2D_Axis1() result.Should().BeOfValues(0L, 1L, 2L); } - [Test] + [TestMethod] public void ArgMin_2D_AxisNeg1() { // NumPy: np.argmin([[1, 5, 3], [7, 2, 8], [4, 6, 0]], axis=-1) = [0, 1, 2] @@ -346,7 +346,7 @@ public void ArgMin_2D_AxisNeg1() #region ArgMin 3D Tests - [Test] + [TestMethod] public void ArgMin_3D_NoAxis() { // NumPy: np.argmin([[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]]) = 0 @@ -355,7 +355,7 @@ public void ArgMin_3D_NoAxis() Assert.AreEqual(0L, (long)result); } - [Test] + [TestMethod] public void ArgMin_3D_Axis0() { // NumPy: np.argmin([[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]], axis=0) = [[0, 0], [0, 0]] @@ -365,7 +365,7 @@ public void ArgMin_3D_Axis0() result.Should().BeOfValues(0L, 0L, 0L, 0L); } - [Test] + [TestMethod] public void ArgMin_3D_Axis1() { // NumPy: np.argmin([[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]], axis=1) = [[0, 0], [0, 0], [0, 0]] @@ -375,7 +375,7 @@ public void ArgMin_3D_Axis1() result.Should().BeOfValues(0L, 0L, 0L, 0L, 0L, 0L); } - [Test] + [TestMethod] public void ArgMin_3D_Axis2() { // NumPy: np.argmin([[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]], axis=2) = [[0, 0], [0, 0], [0, 0]] @@ -389,7 +389,7 @@ public void ArgMin_3D_Axis2() #region ArgMin Edge Cases - [Test] + [TestMethod] public void ArgMin_SingleElement() { // NumPy: np.argmin([42]) = 0 @@ -398,7 +398,7 @@ public void ArgMin_SingleElement() Assert.AreEqual(0L, (long)result); } - [Test] + [TestMethod] public void ArgMin_IdenticalValues() { // NumPy: np.argmin([5, 5, 5, 5]) = 0 (returns first occurrence) @@ -407,7 +407,7 @@ public void ArgMin_IdenticalValues() Assert.AreEqual(0L, (long)result); } - [Test] + [TestMethod] public void ArgMin_WithNaN() { // NumPy: np.argmin([1.0, nan, 3.0, 2.0]) = 1 (NaN returns its index) @@ -420,7 +420,7 @@ public void ArgMin_WithNaN() #region ArgMin Rectangular Arrays - [Test] + [TestMethod] public void ArgMin_Rectangular_2x5_Axis0() { // NumPy: np.argmin([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]], axis=0) = [0, 0, 0, 0, 0] @@ -430,7 +430,7 @@ public void ArgMin_Rectangular_2x5_Axis0() result.Should().BeOfValues(0L, 0L, 0L, 0L, 0L); } - [Test] + [TestMethod] public void ArgMin_Rectangular_2x5_Axis1() { // NumPy: np.argmin([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]], axis=1) = [0, 0] @@ -444,7 +444,7 @@ public void ArgMin_Rectangular_2x5_Axis1() #region ArgMin Higher Dimensional - [Test] + [TestMethod] public void ArgMin_3D_2x3x4_AxisNeg1() { // NumPy: np.argmin(np.arange(24).reshape(2, 3, 4), axis=-1) = [[0, 0, 0], [0, 0, 0]] @@ -458,7 +458,7 @@ public void ArgMin_3D_2x3x4_AxisNeg1() #region keepdims Tests - [Test] + [TestMethod] public void ArgMax_2D_Axis0_Keepdims() { // NumPy: np.argmax([[1, 2, 3], [4, 5, 6]], axis=0, keepdims=True).shape = (1, 3) @@ -467,7 +467,7 @@ public void ArgMax_2D_Axis0_Keepdims() result.Should().BeShaped(1, 3); } - [Test] + [TestMethod] public void ArgMax_2D_Axis1_Keepdims() { // NumPy: np.argmax([[1, 2, 3], [4, 5, 6]], axis=1, keepdims=True).shape = (2, 1) diff --git a/test/NumSharp.UnitTest/Backends/Kernels/ArgMaxNaNTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/ArgMaxNaNTests.cs index 2712bba67..b1a66a7ed 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/ArgMaxNaNTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/ArgMaxNaNTests.cs @@ -2,18 +2,18 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels { /// /// Comprehensive tests for ArgMax/ArgMin based on NumPy 2.4.2 behavior. /// + [TestClass] public class ArgMaxMinTests { #region NaN Handling - [Test] + [TestMethod] public void ArgMax_NaN_InMiddle_ReturnsNaNIndex() { // NumPy: argmax([1.0, nan, 3.0]) = 1 (NaN wins) @@ -23,7 +23,7 @@ public void ArgMax_NaN_InMiddle_ReturnsNaNIndex() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void ArgMax_NaN_AtStart_ReturnsNaNIndex() { // NumPy: argmax([nan, 1.0, 3.0]) = 0 (first NaN wins) @@ -33,7 +33,7 @@ public void ArgMax_NaN_AtStart_ReturnsNaNIndex() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void ArgMax_NaN_AtEnd_ReturnsNaNIndex() { // NumPy: argmax([1.0, 3.0, nan]) = 2 (NaN wins) @@ -43,7 +43,7 @@ public void ArgMax_NaN_AtEnd_ReturnsNaNIndex() Assert.AreEqual(2, result); } - [Test] + [TestMethod] public void ArgMax_MultipleNaN_ReturnsFirstNaNIndex() { // NumPy: argmax([nan, nan, 1.0]) = 0 (first NaN wins) @@ -53,7 +53,7 @@ public void ArgMax_MultipleNaN_ReturnsFirstNaNIndex() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void ArgMin_NaN_InMiddle_ReturnsNaNIndex() { // NumPy: argmin([1.0, nan, 3.0]) = 1 (NaN wins - same as argmax!) @@ -63,7 +63,7 @@ public void ArgMin_NaN_InMiddle_ReturnsNaNIndex() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void ArgMin_NaN_AtStart_ReturnsNaNIndex() { // NumPy: argmin([nan, 1.0, 3.0]) = 0 @@ -73,7 +73,7 @@ public void ArgMin_NaN_AtStart_ReturnsNaNIndex() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void ArgMax_Inf_Vs_NaN() { // NumPy: argmax([inf, nan, 2.0]) = 1 (NaN wins over Inf) @@ -83,7 +83,7 @@ public void ArgMax_Inf_Vs_NaN() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void ArgMin_NegInf_Vs_NaN() { // NumPy: argmin([-inf, nan, 2.0]) = 1 (NaN wins over -Inf) @@ -93,7 +93,7 @@ public void ArgMin_NegInf_Vs_NaN() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void ArgMax_Float32_NaN() { // NumPy: argmax(float32 with nan) = 1 @@ -107,7 +107,7 @@ public void ArgMax_Float32_NaN() #region Empty Array - [Test] + [TestMethod] public void ArgMax_EmptyArray_ThrowsArgumentException() { // NumPy: argmax([]) raises ValueError @@ -116,7 +116,7 @@ public void ArgMax_EmptyArray_ThrowsArgumentException() Assert.ThrowsException(() => np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_EmptyArray_ThrowsArgumentException() { // NumPy: argmin([]) raises ValueError @@ -129,7 +129,7 @@ public void ArgMin_EmptyArray_ThrowsArgumentException() #region Boolean Support - [Test] + [TestMethod] public void ArgMax_Boolean_ReturnsFirstTrueIndex() { // NumPy: argmax([False, True, False, True]) = 1 (first True) @@ -139,7 +139,7 @@ public void ArgMax_Boolean_ReturnsFirstTrueIndex() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void ArgMin_Boolean_ReturnsFirstFalseIndex() { // NumPy: argmin([False, True, False, True]) = 0 (first False) @@ -149,7 +149,7 @@ public void ArgMin_Boolean_ReturnsFirstFalseIndex() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void ArgMax_Boolean_AllFalse_ReturnsZero() { // NumPy: argmax([False, False, False]) = 0 (first occurrence) @@ -159,7 +159,7 @@ public void ArgMax_Boolean_AllFalse_ReturnsZero() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void ArgMin_Boolean_AllTrue_ReturnsZero() { // NumPy: argmin([True, True, True]) = 0 (first occurrence) @@ -173,7 +173,7 @@ public void ArgMin_Boolean_AllTrue_ReturnsZero() #region Scalar and Single Element - [Test] + [TestMethod] public void ArgMax_SingleElement_ReturnsZero() { // NumPy: argmax([42]) = 0 @@ -183,7 +183,7 @@ public void ArgMax_SingleElement_ReturnsZero() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void ArgMax_Scalar_ReturnsZero() { // NumPy: argmax(scalar) = 0 @@ -197,7 +197,7 @@ public void ArgMax_Scalar_ReturnsZero() #region Ties (First Occurrence) - [Test] + [TestMethod] public void ArgMax_Ties_ReturnsFirstOccurrence() { // NumPy: argmax([5, 1, 5, 3, 5]) = 0 (first max) @@ -207,7 +207,7 @@ public void ArgMax_Ties_ReturnsFirstOccurrence() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void ArgMin_Ties_ReturnsFirstOccurrence() { // NumPy: argmin([5, 1, 5, 1, 5]) = 1 (first min) @@ -221,7 +221,7 @@ public void ArgMin_Ties_ReturnsFirstOccurrence() #region Inf Handling - [Test] + [TestMethod] public void ArgMax_PositiveInf() { // NumPy: argmax([1, inf, 3]) = 1 @@ -231,7 +231,7 @@ public void ArgMax_PositiveInf() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void ArgMin_NegativeInf() { // NumPy: argmin([1, -inf, 3]) = 1 @@ -245,7 +245,7 @@ public void ArgMin_NegativeInf() #region 2D With Axis - [Test] + [TestMethod] public void ArgMax_2D_Axis0() { // NumPy: argmax([[1, 5, 3], [4, 2, 6]], axis=0) = [1, 0, 1] @@ -255,7 +255,7 @@ public void ArgMax_2D_Axis0() CollectionAssert.AreEqual(new long[] { 1, 0, 1 }, result.ToArray()); } - [Test] + [TestMethod] public void ArgMax_2D_Axis1() { // NumPy: argmax([[1, 5, 3], [4, 2, 6]], axis=1) = [1, 2] @@ -265,7 +265,7 @@ public void ArgMax_2D_Axis1() CollectionAssert.AreEqual(new long[] { 1, 2 }, result.ToArray()); } - [Test] + [TestMethod] public void ArgMax_2D_AxisNegative() { // NumPy: argmax([[1, 5, 3], [4, 2, 6]], axis=-1) = [1, 2] (same as axis=1) @@ -275,7 +275,7 @@ public void ArgMax_2D_AxisNegative() CollectionAssert.AreEqual(new long[] { 1, 2 }, result.ToArray()); } - [Test] + [TestMethod] public void ArgMin_2D_Axis0() { // NumPy: argmin([[1, 5, 3], [4, 2, 6]], axis=0) = [0, 1, 0] @@ -285,7 +285,7 @@ public void ArgMin_2D_Axis0() CollectionAssert.AreEqual(new long[] { 0, 1, 0 }, result.ToArray()); } - [Test] + [TestMethod] public void ArgMin_2D_Axis1() { // NumPy: argmin([[1, 5, 3], [4, 2, 6]], axis=1) = [0, 1] @@ -299,7 +299,7 @@ public void ArgMin_2D_Axis1() #region NDArray Instance Methods - [Test] + [TestMethod] public void NDArray_ArgMax_Instance() { var a = np.array(new[] { 1, 5, 3 }); @@ -308,7 +308,7 @@ public void NDArray_ArgMax_Instance() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void NDArray_ArgMin_Instance() { // NumPy: argmin([1, 5, 3]) = 0 (index of minimum value 1) @@ -318,7 +318,7 @@ public void NDArray_ArgMin_Instance() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void NDArray_ArgMax_WithAxis_ReturnsNDArray() { var a = np.array(new[,] { { 1, 5, 3 }, { 4, 2, 6 } }); @@ -327,7 +327,7 @@ public void NDArray_ArgMax_WithAxis_ReturnsNDArray() CollectionAssert.AreEqual(new long[] { 1, 2 }, result.ToArray()); } - [Test] + [TestMethod] public void NDArray_ArgMin_WithAxis_ReturnsNDArray() { var a = np.array(new[,] { { 1, 5, 3 }, { 4, 2, 6 } }); diff --git a/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionBenchmarkTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionBenchmarkTests.cs index 3f8d599d8..8f0ddab2f 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionBenchmarkTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionBenchmarkTests.cs @@ -3,7 +3,6 @@ using System.Runtime.Intrinsics.X86; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -12,11 +11,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Tests correctness of strided SIMD (AVX2 gather) and parallel outer loop. /// Issue #576: Complete SIMD axis reductions /// +[TestClass] public class AxisReductionBenchmarkTests { #region Correctness Tests - Strided Access with SIMD Gather - [Test] + [TestMethod] public void Sum_Axis0_LargeStrided_CorrectResults() { // Sum along axis 0 requires strided access (rows are not contiguous) @@ -41,7 +41,7 @@ public void Sum_Axis0_LargeStrided_CorrectResults() } } - [Test] + [TestMethod] public void Sum_Axis0_LargeStrided_Double_CorrectResults() { // Test AVX2 gather for double @@ -64,7 +64,7 @@ public void Sum_Axis0_LargeStrided_Double_CorrectResults() } } - [Test] + [TestMethod] public void Max_Axis0_LargeStrided_CorrectResults() { // Test strided Max with AVX2 gather @@ -88,7 +88,7 @@ public void Max_Axis0_LargeStrided_CorrectResults() } } - [Test] + [TestMethod] public void Min_Axis0_LargeStrided_CorrectResults() { // Test strided Min with AVX2 gather @@ -112,7 +112,7 @@ public void Min_Axis0_LargeStrided_CorrectResults() } } - [Test] + [TestMethod] public void Prod_Axis0_SmallStrided_CorrectResults() { // Test strided Prod (small to avoid overflow) @@ -139,7 +139,7 @@ public void Prod_Axis0_SmallStrided_CorrectResults() #region Correctness Tests - Parallel Outer Loop - [Test] + [TestMethod] public void Sum_Axis1_LargeOutput_ParallelPath() { // Large number of output elements triggers parallel outer loop @@ -164,7 +164,7 @@ public void Sum_Axis1_LargeOutput_ParallelPath() } } - [Test] + [TestMethod] public void Mean_Axis0_LargeOutput_ParallelPath() { // Test Mean with parallel outer loop @@ -188,7 +188,7 @@ public void Mean_Axis0_LargeOutput_ParallelPath() } } - [Test] + [TestMethod] public void Max_Axis1_LargeOutput_ParallelPath() { // Test Max with parallel outer loop @@ -215,7 +215,7 @@ public void Max_Axis1_LargeOutput_ParallelPath() #region Correctness Tests - Integer Types (non-gather path) - [Test] + [TestMethod] public void Sum_Axis0_LargeStrided_Int32_CorrectResults() { // Int32 uses scalar strided path (no gather) @@ -238,7 +238,7 @@ public void Sum_Axis0_LargeStrided_Int32_CorrectResults() } } - [Test] + [TestMethod] public void Sum_Axis0_LargeStrided_Int64_CorrectResults() { // Int64 uses scalar strided path (no gather) @@ -265,7 +265,7 @@ public void Sum_Axis0_LargeStrided_Int64_CorrectResults() #region Edge Cases - [Test] + [TestMethod] public void Sum_Axis0_SmallOutput_SequentialPath() { // Small output (< 1000) should use sequential path @@ -287,7 +287,7 @@ public void Sum_Axis0_SmallOutput_SequentialPath() } } - [Test] + [TestMethod] public void Sum_Axis0_SmallAxisSize_CorrectResults() { // Very small axis size (< 8, below gather vector count) @@ -310,7 +310,7 @@ public void Sum_Axis0_SmallAxisSize_CorrectResults() } } - [Test] + [TestMethod] public void Sum_3D_MiddleAxis_Strided() { // 3D array, reduce along middle axis @@ -332,7 +332,7 @@ public void Sum_3D_MiddleAxis_Strided() Assert.AreEqual((double)d1, result.GetDouble(i, k), 1e-10); } - [Test] + [TestMethod] public void Sum_WithNaN_StridedPath() { // NaN propagation in strided path @@ -363,7 +363,7 @@ public void Sum_WithNaN_StridedPath() #region Performance Verification (not timing, just that it runs) - [Test] + [TestMethod] public void Sum_VeryLarge_Axis0_CompletesWithoutError() { // Very large array to stress test parallel + gather paths @@ -377,7 +377,7 @@ public void Sum_VeryLarge_Axis0_CompletesWithoutError() Assert.AreEqual((double)rows, result.GetDouble(0), 1e-10); } - [Test] + [TestMethod] public void Sum_VeryLarge_Axis1_CompletesWithoutError() { // Very large output to stress test parallel path @@ -395,7 +395,7 @@ public void Sum_VeryLarge_Axis1_CompletesWithoutError() #region AVX2 Feature Detection - [Test] + [TestMethod] public void Avx2IsSupported_ReportStatus() { // Informational test to report AVX2 status diff --git a/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionEdgeCaseTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionEdgeCaseTests.cs index 9cdf97cfa..419ec5668 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionEdgeCaseTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionEdgeCaseTests.cs @@ -1,6 +1,5 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -8,11 +7,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Edge case tests for axis reduction operations. /// Covers scenarios from Task #118: Battle-test axis reduction SIMD kernels. /// +[TestClass] public class AxisReductionEdgeCaseTests { #region Basic axis parameter tests - [Test] + [TestMethod] public void Sum_Axis0_2D_MatchesNumPy() { // NumPy: np.sum([[1,2,3],[4,5,6]], axis=0) = [5, 7, 9] @@ -25,7 +25,7 @@ public void Sum_Axis0_2D_MatchesNumPy() Assert.AreEqual(9L, result.GetInt64(2)); } - [Test] + [TestMethod] public void Sum_Axis1_2D_MatchesNumPy() { // NumPy: np.sum([[1,2,3],[4,5,6]], axis=1) = [6, 15] @@ -37,7 +37,7 @@ public void Sum_Axis1_2D_MatchesNumPy() Assert.AreEqual(15L, result.GetInt64(1)); } - [Test] + [TestMethod] public void Sum_AxisNeg1_2D_MatchesNumPy() { // NumPy: np.sum([[1,2,3],[4,5,6]], axis=-1) = [6, 15] @@ -53,7 +53,7 @@ public void Sum_AxisNeg1_2D_MatchesNumPy() #region keepdims=True tests - [Test] + [TestMethod] public void Sum_Axis0_Keepdims_2D() { // NumPy: np.sum([[1,2,3],[4,5,6]], axis=0, keepdims=True) = [[5, 7, 9]] @@ -66,7 +66,7 @@ public void Sum_Axis0_Keepdims_2D() Assert.AreEqual(9L, result.GetInt64(0, 2)); } - [Test] + [TestMethod] public void Sum_Axis1_Keepdims_2D() { // NumPy: np.sum([[1,2,3],[4,5,6]], axis=1, keepdims=True) = [[6], [15]] @@ -78,7 +78,7 @@ public void Sum_Axis1_Keepdims_2D() Assert.AreEqual(15L, result.GetInt64(1, 0)); } - [Test] + [TestMethod] public void Max_Axis0_Keepdims_3D() { // NumPy: np.max(np.arange(24).reshape(2,3,4), axis=0, keepdims=True).shape = (1, 3, 4) @@ -88,7 +88,7 @@ public void Max_Axis0_Keepdims_3D() result.Should().BeShaped(1, 3, 4); } - [Test] + [TestMethod] public void Min_Axis1_Keepdims_3D() { // NumPy: np.min(np.arange(24).reshape(2,3,4), axis=1, keepdims=True).shape = (2, 1, 4) @@ -98,7 +98,7 @@ public void Min_Axis1_Keepdims_3D() result.Should().BeShaped(2, 1, 4); } - [Test] + [TestMethod] public void Prod_Axis2_Keepdims_3D() { // NumPy: np.prod(np.arange(1,25).reshape(2,3,4), axis=2, keepdims=True).shape = (2, 3, 1) @@ -112,7 +112,7 @@ public void Prod_Axis2_Keepdims_3D() #region Negative axis tests - [Test] + [TestMethod] public void Sum_AxisNeg2_3D() { // NumPy: np.sum(np.arange(24).reshape(2,3,4), axis=-2).shape = (2, 4) @@ -122,7 +122,7 @@ public void Sum_AxisNeg2_3D() result.Should().BeShaped(2, 4); } - [Test] + [TestMethod] public void Max_AxisNeg1_3D() { // NumPy: np.max(np.arange(24).reshape(2,3,4), axis=-1).shape = (2, 3) @@ -132,7 +132,7 @@ public void Max_AxisNeg1_3D() result.Should().BeShaped(2, 3); } - [Test] + [TestMethod] public void Min_AxisNeg3_3D() { // NumPy: np.min(np.arange(24).reshape(2,3,4), axis=-3).shape = (3, 4) @@ -147,7 +147,7 @@ public void Min_AxisNeg3_3D() #region Empty array along axis tests - [Test] + [TestMethod] public void Sum_EmptyAlongAxis0() { // NumPy: np.sum(np.zeros((0, 3)), axis=0) = [0., 0., 0.] @@ -161,7 +161,7 @@ public void Sum_EmptyAlongAxis0() Assert.AreEqual(0.0, result.GetDouble(2)); } - [Test] + [TestMethod] public void Sum_EmptyAlongAxis1() { // NumPy: np.sum(np.zeros((2, 0)), axis=1) = [0., 0.] @@ -174,7 +174,7 @@ public void Sum_EmptyAlongAxis1() Assert.AreEqual(0.0, result.GetDouble(1)); } - [Test] + [TestMethod] public void Prod_EmptyAlongAxis() { // NumPy: np.prod(np.ones((0, 3)), axis=0) = [1., 1., 1.] @@ -192,7 +192,7 @@ public void Prod_EmptyAlongAxis() #region NaN handling in reductions - [Test] + [TestMethod] public void Sum_WithNaN_Axis0_PropagatesNaN() { // NumPy: np.sum([[1., np.nan], [3., 4.]], axis=0) = [4., nan] @@ -204,7 +204,7 @@ public void Sum_WithNaN_Axis0_PropagatesNaN() Assert.IsTrue(double.IsNaN(result.GetDouble(1))); } - [Test] + [TestMethod] public void Sum_WithNaN_Axis1_PropagatesNaN() { // NumPy: np.sum([[1., 2.], [np.nan, 4.]], axis=1) = [3., nan] @@ -216,7 +216,7 @@ public void Sum_WithNaN_Axis1_PropagatesNaN() Assert.IsTrue(double.IsNaN(result.GetDouble(1))); } - [Test] + [TestMethod] public void Max_WithNaN_PropagatesNaN() { // NumPy: np.max([[1., np.nan], [3., 4.]], axis=0) = [3., nan] @@ -228,7 +228,7 @@ public void Max_WithNaN_PropagatesNaN() Assert.IsTrue(double.IsNaN(result.GetDouble(1))); } - [Test] + [TestMethod] public void Min_WithNaN_PropagatesNaN() { // NumPy: np.min([[1., 2.], [np.nan, 4.]], axis=1) = [1., nan] @@ -244,7 +244,7 @@ public void Min_WithNaN_PropagatesNaN() #region Broadcast array with axis reduction - [Test] + [TestMethod] public void Sum_BroadcastArray_Axis0() { // Create a broadcast array and reduce along axis @@ -260,7 +260,7 @@ public void Sum_BroadcastArray_Axis0() Assert.AreEqual(12L, result.GetInt64(2)); // 3+3+3+3 = 12 } - [Test] + [TestMethod] public void Sum_BroadcastArray_Axis1() { // Create a broadcast array and reduce along axis @@ -279,7 +279,7 @@ public void Sum_BroadcastArray_Axis1() #region prod with axis parameter - [Test] + [TestMethod] public void Prod_Axis0_2D() { // NumPy: np.prod([[1,2,3],[4,5,6]], axis=0) = [4, 10, 18] @@ -292,7 +292,7 @@ public void Prod_Axis0_2D() Assert.AreEqual(18L, result.GetInt64(2)); } - [Test] + [TestMethod] public void Prod_Axis1_2D() { // NumPy: np.prod([[1,2,3],[4,5,6]], axis=1) = [6, 120] @@ -308,7 +308,7 @@ public void Prod_Axis1_2D() #region min/max with axis parameter - [Test] + [TestMethod] public void Max_Axis0_2D() { // NumPy: np.max([[1,5,3],[4,2,6]], axis=0) = [4, 5, 6] @@ -321,7 +321,7 @@ public void Max_Axis0_2D() Assert.AreEqual(6, result.GetInt32(2)); } - [Test] + [TestMethod] public void Max_Axis1_2D() { // NumPy: np.max([[1,5,3],[4,2,6]], axis=1) = [5, 6] @@ -333,7 +333,7 @@ public void Max_Axis1_2D() Assert.AreEqual(6, result.GetInt32(1)); } - [Test] + [TestMethod] public void Min_Axis0_2D() { // NumPy: np.min([[1,5,3],[4,2,6]], axis=0) = [1, 2, 3] @@ -346,7 +346,7 @@ public void Min_Axis0_2D() Assert.AreEqual(3, result.GetInt32(2)); } - [Test] + [TestMethod] public void Min_Axis1_2D() { // NumPy: np.min([[1,5,3],[4,2,6]], axis=1) = [1, 2] @@ -362,7 +362,7 @@ public void Min_Axis1_2D() #region mean with axis parameter - [Test] + [TestMethod] public void Mean_Axis0_2D() { // NumPy: np.mean([[1,2,3],[4,5,6]], axis=0) = [2.5, 3.5, 4.5] @@ -375,7 +375,7 @@ public void Mean_Axis0_2D() Assert.AreEqual(4.5, result.GetDouble(2), 1e-10); } - [Test] + [TestMethod] public void Mean_Axis1_2D() { // NumPy: np.mean([[1,2,3],[4,5,6]], axis=1) = [2., 5.] @@ -387,7 +387,7 @@ public void Mean_Axis1_2D() Assert.AreEqual(5.0, result.GetDouble(1), 1e-10); } - [Test] + [TestMethod] public void Mean_Axis0_Keepdims() { // NumPy: np.mean([[1,2,3],[4,5,6]], axis=0, keepdims=True) = [[2.5, 3.5, 4.5]] @@ -404,7 +404,7 @@ public void Mean_Axis0_Keepdims() #region argmax/argmin with axis parameter - [Test] + [TestMethod] public void Argmax_Axis0_2D() { // NumPy: np.argmax([[1,5,3],[4,2,6]], axis=0) = [1, 0, 1] @@ -417,7 +417,7 @@ public void Argmax_Axis0_2D() Assert.AreEqual(1L, result.GetInt64(2)); } - [Test] + [TestMethod] public void Argmax_Axis1_2D() { // NumPy: np.argmax([[1,5,3],[4,2,6]], axis=1) = [1, 2] @@ -429,7 +429,7 @@ public void Argmax_Axis1_2D() Assert.AreEqual(2L, result.GetInt64(1)); } - [Test] + [TestMethod] public void Argmin_Axis0_2D() { // NumPy: np.argmin([[1,5,3],[4,2,6]], axis=0) = [0, 1, 0] @@ -442,7 +442,7 @@ public void Argmin_Axis0_2D() Assert.AreEqual(0L, result.GetInt64(2)); } - [Test] + [TestMethod] public void Argmin_Axis1_2D() { // NumPy: np.argmin([[1,5,3],[4,2,6]], axis=1) = [0, 1] @@ -454,7 +454,7 @@ public void Argmin_Axis1_2D() Assert.AreEqual(1L, result.GetInt64(1)); } - [Test] + [TestMethod] public void Argmax_Axis0_Keepdims() { // NumPy: np.argmax([[1,5,3],[4,2,6]], axis=0, keepdims=True) = [[1, 0, 1]] @@ -467,7 +467,7 @@ public void Argmax_Axis0_Keepdims() Assert.AreEqual(1L, result.GetInt64(0, 2)); } - [Test] + [TestMethod] public void Argmax_WithNaN_Axis0() { // NumPy: np.argmax([[1., np.nan], [3., 4.]], axis=0) = [1, 0] @@ -484,7 +484,7 @@ public void Argmax_WithNaN_Axis0() #region Single element axis tests - [Test] + [TestMethod] public void Sum_SingleRowMatrix_Axis0() { // NumPy: np.sum([[1, 2, 3]], axis=0) = [1, 2, 3] @@ -499,7 +499,7 @@ public void Sum_SingleRowMatrix_Axis0() Assert.AreEqual(3L, result.GetInt64(2)); } - [Test] + [TestMethod] public void Sum_SingleColumnMatrix_Axis1() { // NumPy: np.sum([[1], [2], [3]], axis=1) = [1, 2, 3] @@ -517,7 +517,7 @@ public void Sum_SingleColumnMatrix_Axis1() #region Large array tests (ensure SIMD path is used) - [Test] + [TestMethod] public void Sum_LargeArray_Axis0_CorrectResults() { // Create a large 2D array to trigger SIMD path @@ -538,7 +538,7 @@ public void Sum_LargeArray_Axis0_CorrectResults() } } - [Test] + [TestMethod] public void Sum_LargeArray_Axis1_CorrectResults() { // Create a large 2D array to trigger SIMD path @@ -559,7 +559,7 @@ public void Sum_LargeArray_Axis1_CorrectResults() } } - [Test] + [TestMethod] public void Max_LargeArray_Axis0() { int rows = 256; @@ -579,7 +579,7 @@ public void Max_LargeArray_Axis0() } } - [Test] + [TestMethod] public void Min_LargeArray_Axis1() { int rows = 64; @@ -603,7 +603,7 @@ public void Min_LargeArray_Axis1() #region Sliced array tests - [Test] + [TestMethod] public void Sum_SlicedArray_Axis0() { // Create array and slice it, then reduce @@ -622,7 +622,7 @@ public void Sum_SlicedArray_Axis0() Assert.AreEqual(26L, result.GetInt64(3)); } - [Test] + [TestMethod] public void Sum_SlicedArray_Axis1() { var arr = np.arange(24).reshape(4, 6); diff --git a/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionMemoryTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionMemoryTests.cs index ee9f660e3..e59f811c7 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionMemoryTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionMemoryTests.cs @@ -1,8 +1,5 @@ using System.Threading.Tasks; using NumSharp; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -11,11 +8,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// not views that share memory with the original array (matching NumPy behavior). /// Bug: Single-element axis reduction was returning views causing corruption when modified. /// +[TestClass] public class AxisReductionMemoryTests { // ===== Sum ===== - [Test] + [TestMethod] public async Task Sum_AxisWithSize1_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -27,10 +25,10 @@ public async Task Sum_AxisWithSize1_ReturnsIndependentCopy() result[0] = 999.0; // Original should be unchanged - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Sum_AxisWithSize1_Keepdims_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -42,12 +40,12 @@ public async Task Sum_AxisWithSize1_Keepdims_ReturnsIndependentCopy() result[0, 0] = 999.0; // Original should be unchanged - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } // ===== Prod ===== - [Test] + [TestMethod] public async Task Prod_AxisWithSize1_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -57,10 +55,10 @@ public async Task Prod_AxisWithSize1_ReturnsIndependentCopy() result[0] = 999.0; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Prod_AxisWithSize1_Keepdims_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -70,12 +68,12 @@ public async Task Prod_AxisWithSize1_Keepdims_ReturnsIndependentCopy() result[0, 0] = 999.0; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } // ===== Max ===== - [Test] + [TestMethod] public async Task Max_AxisWithSize1_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -85,10 +83,10 @@ public async Task Max_AxisWithSize1_ReturnsIndependentCopy() result[0] = 999.0; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Max_AxisWithSize1_Keepdims_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -98,12 +96,12 @@ public async Task Max_AxisWithSize1_Keepdims_ReturnsIndependentCopy() result[0, 0] = 999.0; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } // ===== Min ===== - [Test] + [TestMethod] public async Task Min_AxisWithSize1_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -113,10 +111,10 @@ public async Task Min_AxisWithSize1_ReturnsIndependentCopy() result[0] = 999.0; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Min_AxisWithSize1_Keepdims_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -126,12 +124,12 @@ public async Task Min_AxisWithSize1_Keepdims_ReturnsIndependentCopy() result[0, 0] = 999.0; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } // ===== Mean ===== - [Test] + [TestMethod] public async Task Mean_AxisWithSize1_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -141,10 +139,10 @@ public async Task Mean_AxisWithSize1_ReturnsIndependentCopy() result[0] = 999.0; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Mean_AxisWithSize1_Keepdims_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -154,12 +152,12 @@ public async Task Mean_AxisWithSize1_Keepdims_ReturnsIndependentCopy() result[0, 0] = 999.0; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } // ===== Cumsum (axis with size 1) ===== - [Test] + [TestMethod] public async Task Cumsum_AxisWithSize1_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -169,12 +167,12 @@ public async Task Cumsum_AxisWithSize1_ReturnsIndependentCopy() result[0, 0] = 999.0; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } // ===== Var (returns zeros for single element) ===== - [Test] + [TestMethod] public async Task Var_AxisWithSize1_ReturnsZeros() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -182,50 +180,50 @@ public async Task Var_AxisWithSize1_ReturnsZeros() var result = np.var(original, axis: 0); // Variance of a single element is 0 - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That((double)result[0]).IsEqualTo(0.0); - await Assert.That((double)result[1]).IsEqualTo(0.0); - await Assert.That((double)result[2]).IsEqualTo(0.0); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + ((double)result[0]).Should().Be(0.0); + ((double)result[1]).Should().Be(0.0); + ((double)result[2]).Should().Be(0.0); } - [Test] + [TestMethod] public async Task Var_AxisWithSize1_Keepdims_ReturnsZeros() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) var result = np.var(original, axis: 0, keepdims: true); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 1, 3 }); - await Assert.That((double)result[0, 0]).IsEqualTo(0.0); + result.shape.Should().BeEquivalentTo(new long[] { 1, 3 }); + ((double)result[0, 0]).Should().Be(0.0); } // ===== Std (returns zeros for single element) ===== - [Test] + [TestMethod] public async Task Std_AxisWithSize1_ReturnsZeros() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) var result = np.std(original, axis: 0); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That((double)result[0]).IsEqualTo(0.0); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + ((double)result[0]).Should().Be(0.0); } - [Test] + [TestMethod] public async Task Std_AxisWithSize1_Keepdims_ReturnsZeros() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) var result = np.std(original, axis: 0, keepdims: true); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 1, 3 }); - await Assert.That((double)result[0, 0]).IsEqualTo(0.0); + result.shape.Should().BeEquivalentTo(new long[] { 1, 3 }); + ((double)result[0, 0]).Should().Be(0.0); } // ===== ArgMax/ArgMin (already fixed, but verify they work) ===== - [Test] + [TestMethod] public async Task ArgMax_AxisWithSize1_ReturnsZeros() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) @@ -233,26 +231,26 @@ public async Task ArgMax_AxisWithSize1_ReturnsZeros() var result = np.argmax(original, axis: 0); // ArgMax on axis with size 1 always returns 0 - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That((long)result[0]).IsEqualTo(0L); - await Assert.That((long)result[1]).IsEqualTo(0L); - await Assert.That((long)result[2]).IsEqualTo(0L); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + ((long)result[0]).Should().Be(0L); + ((long)result[1]).Should().Be(0L); + ((long)result[2]).Should().Be(0L); } - [Test] + [TestMethod] public async Task ArgMin_AxisWithSize1_ReturnsZeros() { var original = np.array(new[,] { { 1.0, 2.0, 3.0 } }); // shape (1, 3) var result = np.argmin(original, axis: 0); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That((long)result[0]).IsEqualTo(0L); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + ((long)result[0]).Should().Be(0L); } // ===== 3D array tests (more complex shapes) ===== - [Test] + [TestMethod] public async Task Sum_3D_MiddleAxisWithSize1_ReturnsIndependentCopy() { var original = np.arange(6).reshape(2, 1, 3); // shape (2, 1, 3) @@ -262,10 +260,10 @@ public async Task Sum_3D_MiddleAxisWithSize1_ReturnsIndependentCopy() result[0, 0] = 999; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Max_3D_LastAxisWithSize1_ReturnsIndependentCopy() { var original = np.arange(6).reshape(2, 3, 1); // shape (2, 3, 1) @@ -275,12 +273,12 @@ public async Task Max_3D_LastAxisWithSize1_ReturnsIndependentCopy() result[0, 0] = 999; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } // ===== Integer dtype tests ===== - [Test] + [TestMethod] public async Task Sum_IntArray_AxisWithSize1_ReturnsIndependentCopy() { var original = np.array(new[,] { { 1, 2, 3 } }); // int32, shape (1, 3) @@ -290,6 +288,6 @@ public async Task Sum_IntArray_AxisWithSize1_ReturnsIndependentCopy() result[0] = 999; - await Assert.That(np.array_equal(original, originalCopy)).IsTrue(); + np.array_equal(original, originalCopy).Should().BeTrue(); } } diff --git a/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionSimdTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionSimdTests.cs index 21d7cc680..bda081f57 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionSimdTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/AxisReductionSimdTests.cs @@ -1,16 +1,16 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.Backends.Kernels; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; /// /// Tests for SIMD-optimized axis reduction kernels. /// +[TestClass] public class AxisReductionSimdTests { - [Test] + [TestMethod] public void Sum_Axis0_2D_Contiguous() { // Create array [[1, 2, 3], [4, 5, 6]] @@ -25,7 +25,7 @@ public void Sum_Axis0_2D_Contiguous() Assert.AreEqual(9, (int)result[2]); } - [Test] + [TestMethod] public void Sum_Axis1_2D_Contiguous() { // Create array [[1, 2, 3], [4, 5, 6]] @@ -39,7 +39,7 @@ public void Sum_Axis1_2D_Contiguous() Assert.AreEqual(15, (int)result[1]); } - [Test] + [TestMethod] public void Sum_Axis1_LargeArray_UsesSimd() { // Create a large 2D array to ensure SIMD path is used @@ -67,7 +67,7 @@ public void Sum_Axis1_LargeArray_UsesSimd() } } - [Test] + [TestMethod] public void Sum_Axis0_LargeArray_UsesSimd() { // Create a large 2D array to ensure SIMD path is used @@ -95,7 +95,7 @@ public void Sum_Axis0_LargeArray_UsesSimd() } } - [Test] + [TestMethod] public void Max_Axis1_2D() { var arr = np.array(new int[,] { { 3, 1, 4 }, { 1, 5, 9 } }); @@ -107,7 +107,7 @@ public void Max_Axis1_2D() Assert.AreEqual(9, (int)result[1]); } - [Test] + [TestMethod] public void Min_Axis0_2D() { var arr = np.array(new double[,] { { 3.0, 1.0, 4.0 }, { 1.0, 5.0, 9.0 } }); @@ -120,7 +120,7 @@ public void Min_Axis0_2D() Assert.AreEqual(4.0, (double)result[2], 1e-10); } - [Test] + [TestMethod] public void Prod_Axis1_2D() { var arr = np.array(new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }); @@ -132,7 +132,7 @@ public void Prod_Axis1_2D() Assert.AreEqual(120L, (long)result[1]); } - [Test] + [TestMethod] public void Sum_Axis2_3D_ContiguousInnerAxis() { // 2x3x4 array @@ -160,7 +160,7 @@ public void Sum_Axis2_3D_ContiguousInnerAxis() Assert.AreEqual(58L, (long)result[1, 0]); } - [Test] + [TestMethod] public void Sum_NegativeAxis() { var arr = np.array(new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }); @@ -173,7 +173,7 @@ public void Sum_NegativeAxis() Assert.AreEqual(15L, (long)result[1]); } - [Test] + [TestMethod] public void Sum_Keepdims() { var arr = np.array(new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }); @@ -185,7 +185,7 @@ public void Sum_Keepdims() Assert.AreEqual(15L, (long)result[1, 0]); } - [Test] + [TestMethod] public void AxisReductionKernel_IsAvailable() { // Test that the kernel is available for supported types @@ -206,7 +206,7 @@ public void AxisReductionKernel_IsAvailable() } } - [Test] + [TestMethod] public void Sum_AllDtypes_Axis1() { // Test that axis reduction works for various dtypes diff --git a/test/NumSharp.UnitTest/Backends/Kernels/BattleProofTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/BattleProofTests.cs index 984eff72d..26e5602c5 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/BattleProofTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/BattleProofTests.cs @@ -10,11 +10,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Battle-proof tests verifying IL kernel fixes against NumPy behavior. /// Each test documents the NumPy output and verifies NumSharp matches. /// +[TestClass] public class BattleProofTests : TestClass { #region Fix 1: Sliced Array × Scalar (ClassifyPath contiguity check) - [Test] + [TestMethod] public void SlicedColumn_MultiplyByScalar_MatchesNumPy() { // NumPy: x = np.arange(4).reshape(2,2); y = x[:,1]; z = y * 2 @@ -30,7 +31,7 @@ public void SlicedColumn_MultiplyByScalar_MatchesNumPy() Assert.AreEqual(6L, z.GetInt64(1), "y[1]*2 = 3*2 = 6"); } - [Test] + [TestMethod] public void StepSlice_MultiplyByScalar_MatchesNumPy() { // NumPy: np.arange(10)[::2] * 3 = [0, 6, 12, 18, 24] @@ -44,7 +45,7 @@ public void StepSlice_MultiplyByScalar_MatchesNumPy() result.Should().BeOfValues(0, 6, 12, 18, 24); } - [Test] + [TestMethod] public void ReverseSlice_MultiplyByScalar_MatchesNumPy() { // NumPy: np.arange(10)[::-1] * 2 = [18, 16, 14, 12, 10, 8, 6, 4, 2, 0] @@ -56,7 +57,7 @@ public void ReverseSlice_MultiplyByScalar_MatchesNumPy() result.Should().BeOfValues(18, 16, 14, 12, 10, 8, 6, 4, 2, 0); } - [Test] + [TestMethod] public void SlicedRow_MultiplyByScalar_MatchesNumPy() { // NumPy: np.arange(12).reshape(3,4)[1,:] * 3 = [12, 15, 18, 21] @@ -71,7 +72,7 @@ public void SlicedRow_MultiplyByScalar_MatchesNumPy() result.Should().BeOfValues(12, 15, 18, 21); } - [Test] + [TestMethod] public void ScalarMultiplySlice_BothDirections_MatchesNumPy() { // NumPy: 2 * x[:,1] and x[:,1] * 2 should give same result @@ -89,7 +90,7 @@ public void ScalarMultiplySlice_BothDirections_MatchesNumPy() #region Fix 2: Division Type Promotion (True Division → float64) - [Test] + [TestMethod] public void IntDivInt_ReturnsFloat64_MatchesNumPy() { // NumPy: np.array([1,2,3,4], dtype=int32) / np.array([2,2,2,2], dtype=int32) @@ -103,7 +104,7 @@ public void IntDivInt_ReturnsFloat64_MatchesNumPy() result.Should().BeOfValues(0.5, 1.0, 1.5, 2.0); } - [Test] + [TestMethod] public void UInt8DivScalar_ReturnsFloat64_MatchesNumPy() { // NumPy: np.array([10, 20, 30], dtype=uint8) / 5 @@ -116,7 +117,7 @@ public void UInt8DivScalar_ReturnsFloat64_MatchesNumPy() result.Should().BeOfValues(2.0, 4.0, 6.0); } - [Test] + [TestMethod] public void IntDivInt_FractionalResult_MatchesNumPy() { // NumPy: 3 / 2 = 1.5 (not 1 like integer division) @@ -129,7 +130,7 @@ public void IntDivInt_FractionalResult_MatchesNumPy() Assert.AreEqual(1.5, result.GetDouble(0), 0.001, "3/2 should be 1.5, not 1"); } - [Test] + [TestMethod] public void Float32DivFloat32_StaysFloat32_MatchesNumPy() { // NumPy: float32 / float32 = float32 (not promoted to float64) @@ -141,7 +142,7 @@ public void Float32DivFloat32_StaysFloat32_MatchesNumPy() Assert.AreEqual(typeof(float), result.dtype, "float32/float32 should stay float32"); } - [Test] + [TestMethod] public void Float64DivFloat64_StaysFloat64_MatchesNumPy() { // NumPy: float64 / float64 = float64 @@ -157,7 +158,7 @@ public void Float64DivFloat64_StaysFloat64_MatchesNumPy() #region Fix 3: Sign(NaN) Returns NaN (not exception) - [Test] + [TestMethod] public void SignNaN_ReturnsNaN_MatchesNumPy() { // NumPy: np.sign(np.nan) = nan @@ -169,7 +170,7 @@ public void SignNaN_ReturnsNaN_MatchesNumPy() Assert.IsTrue(double.IsNaN(result.GetDouble(0)), "sign(NaN) should return NaN, not throw"); } - [Test] + [TestMethod] public void SignFloat32NaN_ReturnsNaN_MatchesNumPy() { // NumPy: np.sign(np.float32('nan')) = nan @@ -180,7 +181,7 @@ public void SignFloat32NaN_ReturnsNaN_MatchesNumPy() Assert.IsTrue(float.IsNaN(result.GetSingle(0)), "sign(float32 NaN) should return NaN"); } - [Test] + [TestMethod] public void SignInfinity_ReturnsOne_MatchesNumPy() { // NumPy: np.sign([inf, -inf]) = [1, -1] @@ -192,7 +193,7 @@ public void SignInfinity_ReturnsOne_MatchesNumPy() Assert.AreEqual(-1.0, result.GetDouble(1), "sign(-inf) = -1"); } - [Test] + [TestMethod] public void SignMixedWithNaN_MatchesNumPy() { // NumPy: np.sign([nan, 1, -1, 0, nan]) = [nan, 1, -1, 0, nan] @@ -207,7 +208,7 @@ public void SignMixedWithNaN_MatchesNumPy() Assert.IsTrue(double.IsNaN(result.GetDouble(4)), "[4] NaN -> NaN"); } - [Test] + [TestMethod] public void SignBasicValues_MatchesNumPy() { // NumPy: np.sign([1, -1, 0, 5, -5]) = [1, -1, 0, 1, -1] diff --git a/test/NumSharp.UnitTest/Backends/Kernels/BinaryOpTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/BinaryOpTests.cs index 5f8822740..dcbc93f66 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/BinaryOpTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/BinaryOpTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -10,11 +9,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Comprehensive tests for binary operations (Add, Subtract, Multiply, Divide, Mod). /// All expected values are verified against NumPy 2.x output. /// +[TestClass] public class BinaryOpTests { #region Same-Type Add Tests - [Test] + [TestMethod] public void Add_Bool_SameType() { // NumPy: np.add([True, False, True, False], [True, True, False, False]) = [True, True, True, False] @@ -28,7 +28,7 @@ public void Add_Bool_SameType() Assert.IsFalse(result.GetBoolean(3)); } - [Test] + [TestMethod] public void Add_Byte_SameType() { // NumPy: [1, 2, 3, 4] + [2, 2, 2, 2] = [3, 4, 5, 6] @@ -39,7 +39,7 @@ public void Add_Byte_SameType() result.Should().BeOfValues(3, 4, 5, 6).And.BeOfType(NPTypeCode.Byte); } - [Test] + [TestMethod] public void Add_Int16_SameType() { var a = np.array(new short[] { 1, 2, 3, 4 }); @@ -49,7 +49,7 @@ public void Add_Int16_SameType() result.Should().BeOfValues(3, 4, 5, 6).And.BeOfType(NPTypeCode.Int16); } - [Test] + [TestMethod] public void Add_UInt16_SameType() { var a = np.array(new ushort[] { 1, 2, 3, 4 }); @@ -59,7 +59,7 @@ public void Add_UInt16_SameType() result.Should().BeOfValues(3, 4, 5, 6).And.BeOfType(NPTypeCode.UInt16); } - [Test] + [TestMethod] public void Add_Int32_SameType() { var a = np.array(new[] { 1, 2, 3, 4 }); @@ -69,7 +69,7 @@ public void Add_Int32_SameType() result.Should().BeOfValues(3, 4, 5, 6).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Add_UInt32_SameType() { var a = np.array(new uint[] { 1, 2, 3, 4 }); @@ -79,7 +79,7 @@ public void Add_UInt32_SameType() result.Should().BeOfValues(3, 4, 5, 6).And.BeOfType(NPTypeCode.UInt32); } - [Test] + [TestMethod] public void Add_Int64_SameType() { var a = np.array(new long[] { 1, 2, 3, 4 }); @@ -89,7 +89,7 @@ public void Add_Int64_SameType() result.Should().BeOfValues(3L, 4L, 5L, 6L).And.BeOfType(NPTypeCode.Int64); } - [Test] + [TestMethod] public void Add_UInt64_SameType() { var a = np.array(new ulong[] { 1, 2, 3, 4 }); @@ -99,7 +99,7 @@ public void Add_UInt64_SameType() result.Should().BeOfValues(3UL, 4UL, 5UL, 6UL).And.BeOfType(NPTypeCode.UInt64); } - [Test] + [TestMethod] public void Add_Float32_SameType() { var a = np.array(new float[] { 1f, 2f, 3f, 4f }); @@ -109,7 +109,7 @@ public void Add_Float32_SameType() result.Should().BeOfValues(3f, 4f, 5f, 6f).And.BeOfType(NPTypeCode.Single); } - [Test] + [TestMethod] public void Add_Float64_SameType() { var a = np.array(new double[] { 1.0, 2.0, 3.0, 4.0 }); @@ -123,7 +123,7 @@ public void Add_Float64_SameType() #region Same-Type Subtract Tests - [Test] + [TestMethod] public void Subtract_Int32_SameType() { // NumPy: [1, 2, 3, 4] - [2, 2, 2, 2] = [-1, 0, 1, 2] @@ -134,7 +134,7 @@ public void Subtract_Int32_SameType() result.Should().BeOfValues(-1, 0, 1, 2).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Subtract_Byte_Underflow() { // NumPy: uint8 [1, 2, 3, 4] - [2, 2, 2, 2] = [255, 0, 1, 2] (wraps) @@ -145,7 +145,7 @@ public void Subtract_Byte_Underflow() result.Should().BeOfValues(255, 0, 1, 2).And.BeOfType(NPTypeCode.Byte); } - [Test] + [TestMethod] public void Subtract_UInt16_Underflow() { // NumPy: uint16 [1, 2, 3, 4] - [2, 2, 2, 2] = [65535, 0, 1, 2] @@ -156,7 +156,7 @@ public void Subtract_UInt16_Underflow() result.Should().BeOfValues(65535, 0, 1, 2).And.BeOfType(NPTypeCode.UInt16); } - [Test] + [TestMethod] public void Subtract_UInt32_Underflow() { // NumPy: uint32 [1, 2, 3, 4] - [2, 2, 2, 2] = [4294967295, 0, 1, 2] @@ -167,7 +167,7 @@ public void Subtract_UInt32_Underflow() result.Should().BeOfValues(4294967295u, 0u, 1u, 2u).And.BeOfType(NPTypeCode.UInt32); } - [Test] + [TestMethod] public void Subtract_Float64_SameType() { var a = np.array(new double[] { 1.0, 2.0, 3.0, 4.0 }); @@ -181,7 +181,7 @@ public void Subtract_Float64_SameType() #region Same-Type Multiply Tests - [Test] + [TestMethod] public void Multiply_Bool_SameType() { // NumPy: True * True = True, True * False = False (logical AND behavior) @@ -195,7 +195,7 @@ public void Multiply_Bool_SameType() Assert.IsFalse(result.GetBoolean(3)); } - [Test] + [TestMethod] public void Multiply_Int32_SameType() { var a = np.array(new[] { 1, 2, 3, 4 }); @@ -205,7 +205,7 @@ public void Multiply_Int32_SameType() result.Should().BeOfValues(2, 4, 6, 8).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Multiply_Float64_SameType() { var a = np.array(new double[] { 1.0, 2.0, 3.0, 4.0 }); @@ -219,7 +219,7 @@ public void Multiply_Float64_SameType() #region Same-Type Divide Tests - [Test] + [TestMethod] public void Divide_Float32_SameType() { var a = np.array(new float[] { 1f, 2f, 3f, 4f }); @@ -229,7 +229,7 @@ public void Divide_Float32_SameType() result.Should().BeOfValues(0.5f, 1.0f, 1.5f, 2.0f).And.BeOfType(NPTypeCode.Single); } - [Test] + [TestMethod] public void Divide_Float64_SameType() { var a = np.array(new double[] { 1.0, 2.0, 3.0, 4.0 }); @@ -239,7 +239,7 @@ public void Divide_Float64_SameType() result.Should().BeOfValues(0.5, 1.0, 1.5, 2.0).And.BeOfType(NPTypeCode.Double); } - [Test] + [TestMethod] public void Divide_Int32_ReturnsDouble() { // NumPy: int32 / int32 returns float64 @@ -254,7 +254,7 @@ public void Divide_Int32_ReturnsDouble() #region Same-Type Mod Tests - [Test] + [TestMethod] public void Mod_Int32_SameType() { // NumPy: [1, 2, 3, 4] % [2, 3, 2, 3] = [1, 2, 1, 1] @@ -265,7 +265,7 @@ public void Mod_Int32_SameType() result.Should().BeOfValues(1, 2, 1, 1).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Mod_Float64_SameType() { var a = np.array(new double[] { 1.0, 2.0, 3.0, 4.0 }); @@ -279,7 +279,7 @@ public void Mod_Float64_SameType() #region Scalar Broadcasting Tests - [Test] + [TestMethod] public void Add_ArrayPlusScalar_Int32() { // NumPy: [1, 2, 3, 4] + 2 = [3, 4, 5, 6] @@ -289,7 +289,7 @@ public void Add_ArrayPlusScalar_Int32() result.Should().BeOfValues(3, 4, 5, 6).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Add_ScalarPlusArray_Int32() { // NumPy: 2 + [1, 2, 3, 4] = [3, 4, 5, 6] @@ -299,7 +299,7 @@ public void Add_ScalarPlusArray_Int32() result.Should().BeOfValues(3, 4, 5, 6).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Subtract_ArrayMinusScalar_Int32() { // NumPy: [1, 2, 3, 4] - 2 = [-1, 0, 1, 2] @@ -309,7 +309,7 @@ public void Subtract_ArrayMinusScalar_Int32() result.Should().BeOfValues(-1, 0, 1, 2).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Subtract_ScalarMinusArray_Int32() { // NumPy: 2 - [1, 2, 3, 4] = [1, 0, -1, -2] @@ -319,7 +319,7 @@ public void Subtract_ScalarMinusArray_Int32() result.Should().BeOfValues(1, 0, -1, -2).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Multiply_ArrayTimesScalar_Float64() { var a = np.array(new double[] { 1.0, 2.0, 3.0, 4.0 }); @@ -328,7 +328,7 @@ public void Multiply_ArrayTimesScalar_Float64() result.Should().BeOfValues(2.0, 4.0, 6.0, 8.0).And.BeOfType(NPTypeCode.Double); } - [Test] + [TestMethod] public void Divide_ArrayDividedByScalar_Float64() { var a = np.array(new double[] { 1.0, 2.0, 3.0, 4.0 }); @@ -337,7 +337,7 @@ public void Divide_ArrayDividedByScalar_Float64() result.Should().BeOfValues(0.5, 1.0, 1.5, 2.0).And.BeOfType(NPTypeCode.Double); } - [Test] + [TestMethod] public void Divide_ScalarDividedByArray_Float64() { // NumPy: 2 / [1, 2, 3, 4] = [2.0, 1.0, 0.666..., 0.5] @@ -350,7 +350,7 @@ public void Divide_ScalarDividedByArray_Float64() Assert.AreEqual(0.5, result.GetDouble(3)); } - [Test] + [TestMethod] public void Mod_ArrayModScalar_Int32() { // NumPy: [1, 2, 3, 4] % 2 = [1, 0, 1, 0] @@ -360,7 +360,7 @@ public void Mod_ArrayModScalar_Int32() result.Should().BeOfValues(1, 0, 1, 0).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Mod_ScalarModArray_Int32() { // NumPy: 2 % [1, 2, 3, 4] = [0, 0, 2, 2] @@ -374,7 +374,7 @@ public void Mod_ScalarModArray_Int32() #region Broadcasting Shape Tests - [Test] + [TestMethod] public void Add_2D_Plus_1D_Broadcasting() { // NumPy: (3,4) + (4,) = [[2,4,6,8],[6,8,10,12],[10,12,14,16]] @@ -386,7 +386,7 @@ public void Add_2D_Plus_1D_Broadcasting() result.Should().BeOfValues(2, 4, 6, 8, 6, 8, 10, 12, 10, 12, 14, 16); } - [Test] + [TestMethod] public void Add_Column_Plus_Row_Broadcasting() { // NumPy: (3,1) + (1,4) = [[2,3,4,5],[3,4,5,6],[4,5,6,7]] @@ -398,7 +398,7 @@ public void Add_Column_Plus_Row_Broadcasting() result.Should().BeOfValues(2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7); } - [Test] + [TestMethod] public void Add_2D_Plus_1D_Float64() { // NumPy: [[1,2],[3,4]] + [10,20] = [[11,22],[13,24]] @@ -414,7 +414,7 @@ public void Add_2D_Plus_1D_Float64() #region Edge Cases - Division by Zero - [Test] + [TestMethod] public void Divide_Float64_DivisionByZero() { // NumPy: [1.0, -1.0, 0.0] / [0.0, 0.0, 0.0] = [inf, -inf, nan] @@ -431,7 +431,7 @@ public void Divide_Float64_DivisionByZero() #region Edge Cases - Infinity Arithmetic - [Test] + [TestMethod] public void Add_InfinityArithmetic() { // NumPy: [inf, -inf, inf, 1.0] + [1.0, 1.0, inf, inf] = [inf, -inf, inf, inf] @@ -445,7 +445,7 @@ public void Add_InfinityArithmetic() Assert.IsTrue(double.IsPositiveInfinity(result.GetDouble(3))); } - [Test] + [TestMethod] public void Subtract_InfMinusInf_IsNaN() { // NumPy: inf - inf = nan @@ -456,7 +456,7 @@ public void Subtract_InfMinusInf_IsNaN() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Multiply_InfTimesZero_IsNaN() { // NumPy: inf * 0 = nan @@ -471,7 +471,7 @@ public void Multiply_InfTimesZero_IsNaN() #region Edge Cases - NaN Propagation - [Test] + [TestMethod] public void Add_NaNPropagation() { // NumPy: [1.0, nan, 3.0] + [2.0, 2.0, nan] = [3.0, nan, nan] @@ -484,7 +484,7 @@ public void Add_NaNPropagation() Assert.IsTrue(double.IsNaN(result.GetDouble(2))); } - [Test] + [TestMethod] public void Multiply_NaNPropagation() { var a = np.array(new double[] { 1.0, double.NaN, 3.0 }); @@ -500,7 +500,7 @@ public void Multiply_NaNPropagation() #region Edge Cases - 0D Scalars - [Test] + [TestMethod] public void Add_0DScalars() { // NumPy: np.array(5) + np.array(3) = 8, shape=() @@ -516,7 +516,7 @@ public void Add_0DScalars() #region Edge Cases - Empty Arrays - [Test] + [TestMethod] public void Add_EmptyArrays() { // NumPy: [] + [] = [], shape=(0,) @@ -532,7 +532,7 @@ public void Add_EmptyArrays() #region Type Promotion Tests - [Test] + [TestMethod] public void Add_Int32_Float64_Promotion() { // NumPy: int32 + float64 → float64: [1, 2, 3] + [0.5, 0.5, 0.5] = [1.5, 2.5, 3.5] @@ -543,7 +543,7 @@ public void Add_Int32_Float64_Promotion() result.Should().BeOfValues(1.5, 2.5, 3.5).And.BeOfType(NPTypeCode.Double); } - [Test] + [TestMethod] public void Add_Int32_Int64_Promotion() { // NumPy: int32 + int64 → int64 @@ -554,7 +554,7 @@ public void Add_Int32_Int64_Promotion() result.Should().BeOfValues(2L, 4L, 6L).And.BeOfType(NPTypeCode.Int64); } - [Test] + [TestMethod] public void Add_Byte_Int32_Promotion() { // NumPy: uint8 + int32 → int32 @@ -565,7 +565,7 @@ public void Add_Byte_Int32_Promotion() result.Should().BeOfValues(2, 4, 6).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Add_Bool_Int32_Promotion() { // NumPy: bool + int32 → int32: [True, False, True] + [1, 2, 3] = [2, 2, 4] @@ -580,7 +580,7 @@ public void Add_Bool_Int32_Promotion() #region Overflow Behavior Tests - [Test] + [TestMethod] public void Add_Byte_Overflow() { // NumPy: uint8 255 + 1 = 0 (wraps) @@ -591,7 +591,7 @@ public void Add_Byte_Overflow() result.Should().BeOfValues(0).And.BeOfType(NPTypeCode.Byte); } - [Test] + [TestMethod] public void Add_Int32_Overflow() { // NumPy: int32 2147483647 + 1 = -2147483648 (wraps) @@ -606,7 +606,7 @@ public void Add_Int32_Overflow() #region ATan2 Tests (Bug Fix Verification) - [Test] + [TestMethod] public void ATan2_Float64() { // NumPy: np.arctan2([1, 1, -1, -1], [1, -1, 1, -1]) = [π/4, 3π/4, -π/4, -3π/4] @@ -620,7 +620,7 @@ public void ATan2_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(3) - (-3 * Math.PI / 4)) < 1e-10); } - [Test] + [TestMethod] public void ATan2_Float32() { // NumPy: np.arctan2([1, 0, -1], [0, 1, 0]) = [π/2, 0, -π/2] @@ -633,7 +633,7 @@ public void ATan2_Float32() Assert.IsTrue(Math.Abs(result.GetSingle(2) - (float)(-Math.PI / 2)) < 1e-6f); } - [Test] + [TestMethod] public void ATan2_Int32() { // NumPy: np.arctan2([1000, 0, -1000], [0, 1000, 0]) returns float64 @@ -649,7 +649,7 @@ public void ATan2_Int32() Assert.IsTrue(Math.Abs(result.GetDouble(2) + Math.PI / 2) < 1e-10); // atan2(-1000, 0) = -π/2 } - [Test] + [TestMethod] public void ATan2_Int64() { // NumPy: np.arctan2(int64, int64) returns float64 @@ -665,7 +665,7 @@ public void ATan2_Int64() Assert.IsTrue(Math.Abs(result.GetDouble(2) + Math.PI / 2) < 1e-10); // atan2(-1M, 0) = -π/2 } - [Test] + [TestMethod] public void ATan2_SpecialValues() { // NumPy: arctan2(0, 0) = 0, arctan2(inf, 1) = π/2, arctan2(1, inf) = 0 @@ -679,7 +679,7 @@ public void ATan2_SpecialValues() Assert.IsTrue(double.IsNaN(result.GetDouble(3))); } - [Test] + [TestMethod] public void ATan2_SlicedArray() { // Test with sliced (non-contiguous) input: arr[::2] @@ -703,7 +703,7 @@ public void ATan2_SlicedArray() Assert.IsTrue(Math.Abs(result.GetDouble(2) - (-Math.PI / 4)) < 1e-10); } - [Test] + [TestMethod] public void ATan2_BroadcastScalar() { // Test broadcasting: arctan2(array, scalar) @@ -719,7 +719,7 @@ public void ATan2_BroadcastScalar() Assert.IsTrue(Math.Abs(result.GetDouble(2) - (-Math.PI / 4)) < 1e-10); } - [Test] + [TestMethod] public void ATan2_Broadcast2D() { // Test 2D broadcasting: arctan2(column, row) diff --git a/test/NumSharp.UnitTest/Backends/Kernels/BitwiseOpTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/BitwiseOpTests.cs index 89287b964..f927d5d14 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/BitwiseOpTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/BitwiseOpTests.cs @@ -3,7 +3,6 @@ using NumSharp; using NumSharp.Generic; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -11,11 +10,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Comprehensive tests for bitwise operations (And, Or, Xor). /// All expected values are verified against NumPy 2.x output. /// +[TestClass] public class BitwiseOpTests { #region Boolean AND Tests - [Test] + [TestMethod] public void BitwiseAnd_Bool_TruthTable() { // NumPy: [True, True, False, False] & [True, False, True, False] @@ -30,7 +30,7 @@ public void BitwiseAnd_Bool_TruthTable() Assert.IsFalse(result.GetBoolean(3)); } - [Test] + [TestMethod] public void BitwiseAnd_Bool_WithScalar_True() { var a = np.array(new[] { true, true, false, false }); @@ -42,7 +42,7 @@ public void BitwiseAnd_Bool_WithScalar_True() Assert.IsFalse(result.GetBoolean(3)); } - [Test] + [TestMethod] public void BitwiseAnd_Bool_WithScalar_False() { var a = np.array(new[] { true, true, false, false }); @@ -58,7 +58,7 @@ public void BitwiseAnd_Bool_WithScalar_False() #region Boolean OR Tests - [Test] + [TestMethod] public void BitwiseOr_Bool_TruthTable() { // NumPy: [True, True, False, False] | [True, False, True, False] @@ -73,7 +73,7 @@ public void BitwiseOr_Bool_TruthTable() Assert.IsFalse(result.GetBoolean(3)); } - [Test] + [TestMethod] public void BitwiseOr_Bool_WithScalar_True() { var a = np.array(new[] { true, true, false, false }); @@ -85,7 +85,7 @@ public void BitwiseOr_Bool_WithScalar_True() Assert.IsTrue(result.GetBoolean(3)); } - [Test] + [TestMethod] public void BitwiseOr_Bool_WithScalar_False() { var a = np.array(new[] { true, true, false, false }); @@ -101,7 +101,7 @@ public void BitwiseOr_Bool_WithScalar_False() #region Boolean XOR Tests - [Test] + [TestMethod] public void BitwiseXor_Bool_TruthTable() { // NumPy: [True, True, False, False] ^ [True, False, True, False] @@ -121,7 +121,7 @@ public void BitwiseXor_Bool_TruthTable() #region Boolean NOT Tests - [Test] + [TestMethod] public void BitwiseNot_Bool() { // NumPy: ~[True, True, False, False] = [False, False, True, True] @@ -138,7 +138,7 @@ public void BitwiseNot_Bool() #region Integer Bitwise AND Tests - [Test] + [TestMethod] public void BitwiseAnd_Byte() { // NumPy: [0b11110000, 0b10101010, 0b00001111] & [0b11001100, 0b01010101, 0b11110000] @@ -150,7 +150,7 @@ public void BitwiseAnd_Byte() result.Should().BeOfValues(192, 0, 0).And.BeOfType(NPTypeCode.Byte); } - [Test] + [TestMethod] public void BitwiseAnd_Int32() { var a = np.array(new[] { 0b11110000, 0b10101010, 0b00001111 }); @@ -160,7 +160,7 @@ public void BitwiseAnd_Int32() result.Should().BeOfValues(192, 0, 0).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void BitwiseAnd_Int64() { var a = np.array(new long[] { 0b11110000, 0b10101010, 0b00001111 }); @@ -174,7 +174,7 @@ public void BitwiseAnd_Int64() #region Integer Bitwise OR Tests - [Test] + [TestMethod] public void BitwiseOr_Byte() { // NumPy: [0b11110000, 0b10101010, 0b00001111] | [0b11001100, 0b01010101, 0b11110000] @@ -186,7 +186,7 @@ public void BitwiseOr_Byte() result.Should().BeOfValues(252, 255, 255).And.BeOfType(NPTypeCode.Byte); } - [Test] + [TestMethod] public void BitwiseOr_Int32() { var a = np.array(new[] { 0b11110000, 0b10101010, 0b00001111 }); @@ -200,7 +200,7 @@ public void BitwiseOr_Int32() #region Integer Bitwise XOR Tests - [Test] + [TestMethod] public void BitwiseXor_Byte() { // NumPy: [0b11110000, 0b10101010, 0b00001111] ^ [0b11001100, 0b01010101, 0b11110000] @@ -212,7 +212,7 @@ public void BitwiseXor_Byte() result.Should().BeOfValues(60, 255, 255).And.BeOfType(NPTypeCode.Byte); } - [Test] + [TestMethod] public void BitwiseXor_Int32() { NDArray a = np.array(new[] { 0b11110000, 0b10101010, 0b00001111 }).MakeGeneric(); @@ -226,7 +226,7 @@ public void BitwiseXor_Int32() #region Broadcasting Tests - [Test] + [TestMethod] public void BitwiseAnd_2D_With_1D_Broadcasting() { // NumPy: [[True, False], [True, False]] & [True, False] @@ -242,7 +242,7 @@ public void BitwiseAnd_2D_With_1D_Broadcasting() Assert.IsFalse((bool)result[1, 1]); } - [Test] + [TestMethod] public void BitwiseOr_2D_With_1D_Broadcasting() { var a = np.array(new[,] { { true, false }, { false, false } }); @@ -256,7 +256,7 @@ public void BitwiseOr_2D_With_1D_Broadcasting() Assert.IsTrue((bool)result[1, 1]); } - [Test] + [TestMethod] public void BitwiseAnd_Int32_Scalar_Broadcasting() { // Array AND with scalar @@ -270,7 +270,7 @@ public void BitwiseAnd_Int32_Scalar_Broadcasting() #region Boolean Mask Scenario Tests - [Test] + [TestMethod] public void BitwiseAnd_BooleanMasks() { // Common pattern: combining comparison results @@ -287,7 +287,7 @@ public void BitwiseAnd_BooleanMasks() Assert.IsFalse(combined.GetBoolean(4)); } - [Test] + [TestMethod] public void BitwiseOr_BooleanMasks() { // data > 2 OR data < 5 = all True in this case @@ -307,7 +307,7 @@ public void BitwiseOr_BooleanMasks() #region Typed NDArray Tests - [Test] + [TestMethod] public void BitwiseOr_TypedBoolArray() { // This tests the NDArray | NDArray operator @@ -321,7 +321,7 @@ public void BitwiseOr_TypedBoolArray() Assert.IsFalse(result.GetBoolean(3)); } - [Test] + [TestMethod] public void BitwiseAnd_TypedBoolArray() { var a = np.array(new[] { true, false, true, false }).MakeGeneric(); @@ -334,7 +334,7 @@ public void BitwiseAnd_TypedBoolArray() Assert.IsFalse(result.GetBoolean(3)); } - [Test] + [TestMethod] public void BitwiseXor_TypedBoolArray() { var a = np.array(new[] { true, false, true, false }).MakeGeneric(); @@ -351,7 +351,7 @@ public void BitwiseXor_TypedBoolArray() #region Sliced Array Tests - [Test] + [TestMethod] public void BitwiseAnd_SlicedArrays() { var a = np.array(new[] { true, false, true, false, true, false }); @@ -372,7 +372,7 @@ public void BitwiseAnd_SlicedArrays() #region Empty Array Tests - [Test] + [TestMethod] public void BitwiseAnd_EmptyArrays() { var a = np.array(Array.Empty()); diff --git a/test/NumSharp.UnitTest/Backends/Kernels/ComparisonOpTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/ComparisonOpTests.cs index 9138a6e04..61d9397c6 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/ComparisonOpTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/ComparisonOpTests.cs @@ -2,9 +2,6 @@ using System.Threading.Tasks; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; namespace NumSharp.UnitTest.Backends.Kernels; @@ -12,11 +9,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Comprehensive tests for comparison operations (==, !=, <, >, <=, >=). /// All expected values are verified against NumPy 2.x output. /// +[TestClass] public class ComparisonOpTests { #region Basic Equality Tests (Test 1) - [Test] + [TestMethod] public async Task Equal_Int32_SameType() { // NumPy: np.array([1, 2, 3, 4, 5]) == np.array([1, 3, 3, 5, 5]) = [True, False, True, False, True] @@ -24,14 +22,14 @@ public async Task Equal_Int32_SameType() var b = np.array(new[] { 1, 3, 3, 5, 5 }); var result = a == b; - await Assert.That(result.GetBoolean(0)).IsTrue(); // 1 == 1 - await Assert.That(result.GetBoolean(1)).IsFalse(); // 2 != 3 - await Assert.That(result.GetBoolean(2)).IsTrue(); // 3 == 3 - await Assert.That(result.GetBoolean(3)).IsFalse(); // 4 != 5 - await Assert.That(result.GetBoolean(4)).IsTrue(); // 5 == 5 + result.GetBoolean(0).Should().BeTrue(); // 1 == 1 + result.GetBoolean(1).Should().BeFalse(); // 2 != 3 + result.GetBoolean(2).Should().BeTrue(); // 3 == 3 + result.GetBoolean(3).Should().BeFalse(); // 4 != 5 + result.GetBoolean(4).Should().BeTrue(); // 5 == 5 } - [Test] + [TestMethod] public async Task NotEqual_Int32_SameType() { // NumPy: np.array([1, 2, 3, 4, 5]) != np.array([1, 3, 3, 5, 5]) = [False, True, False, True, False] @@ -39,14 +37,14 @@ public async Task NotEqual_Int32_SameType() var b = np.array(new[] { 1, 3, 3, 5, 5 }); var result = a != b; - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsFalse(); - await Assert.That(result.GetBoolean(3)).IsTrue(); - await Assert.That(result.GetBoolean(4)).IsFalse(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeFalse(); + result.GetBoolean(3).Should().BeTrue(); + result.GetBoolean(4).Should().BeFalse(); } - [Test] + [TestMethod] public async Task Less_Int32_SameType() { // NumPy: np.array([1, 2, 3, 4, 5]) < np.array([1, 3, 3, 5, 5]) = [False, True, False, True, False] @@ -54,14 +52,14 @@ public async Task Less_Int32_SameType() var b = np.array(new[] { 1, 3, 3, 5, 5 }); var result = a < b; - await Assert.That(result.GetBoolean(0)).IsFalse(); // 1 < 1 = False - await Assert.That(result.GetBoolean(1)).IsTrue(); // 2 < 3 = True - await Assert.That(result.GetBoolean(2)).IsFalse(); // 3 < 3 = False - await Assert.That(result.GetBoolean(3)).IsTrue(); // 4 < 5 = True - await Assert.That(result.GetBoolean(4)).IsFalse(); // 5 < 5 = False + result.GetBoolean(0).Should().BeFalse(); // 1 < 1 = False + result.GetBoolean(1).Should().BeTrue(); // 2 < 3 = True + result.GetBoolean(2).Should().BeFalse(); // 3 < 3 = False + result.GetBoolean(3).Should().BeTrue(); // 4 < 5 = True + result.GetBoolean(4).Should().BeFalse(); // 5 < 5 = False } - [Test] + [TestMethod] public async Task Greater_Int32_SameType() { // NumPy: np.array([1, 2, 3, 4, 5]) > np.array([1, 3, 3, 5, 5]) = [False, False, False, False, False] @@ -69,14 +67,14 @@ public async Task Greater_Int32_SameType() var b = np.array(new[] { 1, 3, 3, 5, 5 }); var result = a > b; - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsFalse(); - await Assert.That(result.GetBoolean(3)).IsFalse(); - await Assert.That(result.GetBoolean(4)).IsFalse(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeFalse(); + result.GetBoolean(3).Should().BeFalse(); + result.GetBoolean(4).Should().BeFalse(); } - [Test] + [TestMethod] public async Task LessEqual_Int32_SameType() { // NumPy: np.array([1, 2, 3, 4, 5]) <= np.array([1, 3, 3, 5, 5]) = [True, True, True, True, True] @@ -84,14 +82,14 @@ public async Task LessEqual_Int32_SameType() var b = np.array(new[] { 1, 3, 3, 5, 5 }); var result = a <= b; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsTrue(); - await Assert.That(result.GetBoolean(3)).IsTrue(); - await Assert.That(result.GetBoolean(4)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeTrue(); + result.GetBoolean(3).Should().BeTrue(); + result.GetBoolean(4).Should().BeTrue(); } - [Test] + [TestMethod] public async Task GreaterEqual_Int32_SameType() { // NumPy: np.array([1, 2, 3, 4, 5]) >= np.array([1, 3, 3, 5, 5]) = [True, False, True, False, True] @@ -99,18 +97,18 @@ public async Task GreaterEqual_Int32_SameType() var b = np.array(new[] { 1, 3, 3, 5, 5 }); var result = a >= b; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); - await Assert.That(result.GetBoolean(3)).IsFalse(); - await Assert.That(result.GetBoolean(4)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); + result.GetBoolean(3).Should().BeFalse(); + result.GetBoolean(4).Should().BeTrue(); } #endregion #region Mixed Types Tests (Test 2) - [Test] + [TestMethod] public async Task Equal_MixedTypes_Int32_Float64() { // NumPy: np.array([1, 2, 3, 4], dtype=int32) == np.array([1.5, 2.0, 2.5, 4.0], dtype=float64) = [False, True, False, True] @@ -118,13 +116,13 @@ public async Task Equal_MixedTypes_Int32_Float64() var y = np.array(new[] { 1.5, 2.0, 2.5, 4.0 }); var result = x == y; - await Assert.That(result.GetBoolean(0)).IsFalse(); // 1 != 1.5 - await Assert.That(result.GetBoolean(1)).IsTrue(); // 2 == 2.0 - await Assert.That(result.GetBoolean(2)).IsFalse(); // 3 != 2.5 - await Assert.That(result.GetBoolean(3)).IsTrue(); // 4 == 4.0 + result.GetBoolean(0).Should().BeFalse(); // 1 != 1.5 + result.GetBoolean(1).Should().BeTrue(); // 2 == 2.0 + result.GetBoolean(2).Should().BeFalse(); // 3 != 2.5 + result.GetBoolean(3).Should().BeTrue(); // 4 == 4.0 } - [Test] + [TestMethod] public async Task Less_MixedTypes_Int32_Float64() { // NumPy: np.array([1, 2, 3, 4], dtype=int32) < np.array([1.5, 2.0, 2.5, 4.0], dtype=float64) = [True, False, False, False] @@ -132,13 +130,13 @@ public async Task Less_MixedTypes_Int32_Float64() var y = np.array(new[] { 1.5, 2.0, 2.5, 4.0 }); var result = x < y; - await Assert.That(result.GetBoolean(0)).IsTrue(); // 1 < 1.5 - await Assert.That(result.GetBoolean(1)).IsFalse(); // 2 >= 2.0 - await Assert.That(result.GetBoolean(2)).IsFalse(); // 3 >= 2.5 - await Assert.That(result.GetBoolean(3)).IsFalse(); // 4 >= 4.0 + result.GetBoolean(0).Should().BeTrue(); // 1 < 1.5 + result.GetBoolean(1).Should().BeFalse(); // 2 >= 2.0 + result.GetBoolean(2).Should().BeFalse(); // 3 >= 2.5 + result.GetBoolean(3).Should().BeFalse(); // 4 >= 4.0 } - [Test] + [TestMethod] public async Task GreaterEqual_MixedTypes_Int32_Float64() { // NumPy: np.array([1, 2, 3, 4], dtype=int32) >= np.array([1.5, 2.0, 2.5, 4.0], dtype=float64) = [False, True, True, True] @@ -146,17 +144,17 @@ public async Task GreaterEqual_MixedTypes_Int32_Float64() var y = np.array(new[] { 1.5, 2.0, 2.5, 4.0 }); var result = x >= y; - await Assert.That(result.GetBoolean(0)).IsFalse(); // 1 < 1.5 - await Assert.That(result.GetBoolean(1)).IsTrue(); // 2 >= 2.0 - await Assert.That(result.GetBoolean(2)).IsTrue(); // 3 >= 2.5 - await Assert.That(result.GetBoolean(3)).IsTrue(); // 4 >= 4.0 + result.GetBoolean(0).Should().BeFalse(); // 1 < 1.5 + result.GetBoolean(1).Should().BeTrue(); // 2 >= 2.0 + result.GetBoolean(2).Should().BeTrue(); // 3 >= 2.5 + result.GetBoolean(3).Should().BeTrue(); // 4 >= 4.0 } #endregion #region Broadcasting Tests (Test 3) - [Test] + [TestMethod] public async Task Greater_Broadcasting_2D_vs_1D() { // NumPy: arr2d = [[1, 2, 3], [4, 5, 6]], arr1d = [2, 3, 4] @@ -166,17 +164,17 @@ public async Task Greater_Broadcasting_2D_vs_1D() var result = arr2d > arr1d; // Row 0: [1>2, 2>3, 3>4] = [False, False, False] - await Assert.That(result.GetBoolean(0, 0)).IsFalse(); - await Assert.That(result.GetBoolean(0, 1)).IsFalse(); - await Assert.That(result.GetBoolean(0, 2)).IsFalse(); + result.GetBoolean(0, 0).Should().BeFalse(); + result.GetBoolean(0, 1).Should().BeFalse(); + result.GetBoolean(0, 2).Should().BeFalse(); // Row 1: [4>2, 5>3, 6>4] = [True, True, True] - await Assert.That(result.GetBoolean(1, 0)).IsTrue(); - await Assert.That(result.GetBoolean(1, 1)).IsTrue(); - await Assert.That(result.GetBoolean(1, 2)).IsTrue(); + result.GetBoolean(1, 0).Should().BeTrue(); + result.GetBoolean(1, 1).Should().BeTrue(); + result.GetBoolean(1, 2).Should().BeTrue(); } - [Test] + [TestMethod] public async Task LessEqual_Broadcasting_2D_vs_1D() { // NumPy: arr2d <= arr1d = [[True, True, True], [False, False, False]] @@ -185,67 +183,67 @@ public async Task LessEqual_Broadcasting_2D_vs_1D() var result = arr2d <= arr1d; // Row 0: [1<=2, 2<=3, 3<=4] = [True, True, True] - await Assert.That(result.GetBoolean(0, 0)).IsTrue(); - await Assert.That(result.GetBoolean(0, 1)).IsTrue(); - await Assert.That(result.GetBoolean(0, 2)).IsTrue(); + result.GetBoolean(0, 0).Should().BeTrue(); + result.GetBoolean(0, 1).Should().BeTrue(); + result.GetBoolean(0, 2).Should().BeTrue(); // Row 1: [4<=2, 5<=3, 6<=4] = [False, False, False] - await Assert.That(result.GetBoolean(1, 0)).IsFalse(); - await Assert.That(result.GetBoolean(1, 1)).IsFalse(); - await Assert.That(result.GetBoolean(1, 2)).IsFalse(); + result.GetBoolean(1, 0).Should().BeFalse(); + result.GetBoolean(1, 1).Should().BeFalse(); + result.GetBoolean(1, 2).Should().BeFalse(); } #endregion #region Scalar Comparison Tests (Test 4) - [Test] + [TestMethod] public async Task Greater_ScalarRight() { // NumPy: arr > 3 = [False, False, False, True, True] var arr = np.array(new[] { 1.0, 2.0, 3.0, 4.0, 5.0 }); var result = arr > 3; - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsFalse(); - await Assert.That(result.GetBoolean(3)).IsTrue(); - await Assert.That(result.GetBoolean(4)).IsTrue(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeFalse(); + result.GetBoolean(3).Should().BeTrue(); + result.GetBoolean(4).Should().BeTrue(); } - [Test] + [TestMethod] public async Task LessEqual_ScalarRight() { // NumPy: arr <= 2.5 = [True, True, False, False, False] var arr = np.array(new[] { 1.0, 2.0, 3.0, 4.0, 5.0 }); var result = arr <= 2.5; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsFalse(); - await Assert.That(result.GetBoolean(3)).IsFalse(); - await Assert.That(result.GetBoolean(4)).IsFalse(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeFalse(); + result.GetBoolean(3).Should().BeFalse(); + result.GetBoolean(4).Should().BeFalse(); } - [Test] + [TestMethod] public async Task Equal_ScalarRight() { // NumPy: arr == 3.0 = [False, False, True, False, False] var arr = np.array(new[] { 1.0, 2.0, 3.0, 4.0, 5.0 }); var result = arr == 3.0; - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); - await Assert.That(result.GetBoolean(3)).IsFalse(); - await Assert.That(result.GetBoolean(4)).IsFalse(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); + result.GetBoolean(3).Should().BeFalse(); + result.GetBoolean(4).Should().BeFalse(); } #endregion #region Boolean Comparison Tests (Test 5) - [Test] + [TestMethod] public async Task Equal_Boolean() { // NumPy: [True, True, False, False] == [True, False, True, False] = [True, False, False, True] @@ -253,13 +251,13 @@ public async Task Equal_Boolean() var b = np.array(new[] { true, false, true, false }); var result = a == b; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsFalse(); - await Assert.That(result.GetBoolean(3)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeFalse(); + result.GetBoolean(3).Should().BeTrue(); } - [Test] + [TestMethod] public async Task NotEqual_Boolean() { // NumPy: [True, True, False, False] != [True, False, True, False] = [False, True, True, False] @@ -267,13 +265,13 @@ public async Task NotEqual_Boolean() var b = np.array(new[] { true, false, true, false }); var result = a != b; - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsTrue(); - await Assert.That(result.GetBoolean(3)).IsFalse(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeTrue(); + result.GetBoolean(3).Should().BeFalse(); } - [Test] + [TestMethod] public async Task Less_Boolean() { // NumPy: [True, True, False, False] < [True, False, True, False] = [False, False, True, False] @@ -282,13 +280,13 @@ public async Task Less_Boolean() var b = np.array(new[] { true, false, true, false }); var result = a < b; - await Assert.That(result.GetBoolean(0)).IsFalse(); // True < True = False - await Assert.That(result.GetBoolean(1)).IsFalse(); // True < False = False - await Assert.That(result.GetBoolean(2)).IsTrue(); // False < True = True - await Assert.That(result.GetBoolean(3)).IsFalse(); // False < False = False + result.GetBoolean(0).Should().BeFalse(); // True < True = False + result.GetBoolean(1).Should().BeFalse(); // True < False = False + result.GetBoolean(2).Should().BeTrue(); // False < True = True + result.GetBoolean(3).Should().BeFalse(); // False < False = False } - [Test] + [TestMethod] public async Task Greater_Boolean() { // NumPy: [True, True, False, False] > [True, False, True, False] = [False, True, False, False] @@ -296,17 +294,17 @@ public async Task Greater_Boolean() var b = np.array(new[] { true, false, true, false }); var result = a > b; - await Assert.That(result.GetBoolean(0)).IsFalse(); // True > True = False - await Assert.That(result.GetBoolean(1)).IsTrue(); // True > False = True - await Assert.That(result.GetBoolean(2)).IsFalse(); // False > True = False - await Assert.That(result.GetBoolean(3)).IsFalse(); // False > False = False + result.GetBoolean(0).Should().BeFalse(); // True > True = False + result.GetBoolean(1).Should().BeTrue(); // True > False = True + result.GetBoolean(2).Should().BeFalse(); // False > True = False + result.GetBoolean(3).Should().BeFalse(); // False > False = False } #endregion #region Byte Comparison Tests (Test 6) - [Test] + [TestMethod] public async Task Equal_Byte() { // NumPy: np.array([0, 128, 255], dtype=uint8) == np.array([1, 128, 254], dtype=uint8) = [False, True, False] @@ -314,12 +312,12 @@ public async Task Equal_Byte() var b = np.array(new byte[] { 1, 128, 254 }); var result = a == b; - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeFalse(); } - [Test] + [TestMethod] public async Task Less_Byte() { // NumPy: np.array([0, 128, 255], dtype=uint8) < np.array([1, 128, 254], dtype=uint8) = [True, False, False] @@ -327,16 +325,16 @@ public async Task Less_Byte() var b = np.array(new byte[] { 1, 128, 254 }); var result = a < b; - await Assert.That(result.GetBoolean(0)).IsTrue(); // 0 < 1 - await Assert.That(result.GetBoolean(1)).IsFalse(); // 128 >= 128 - await Assert.That(result.GetBoolean(2)).IsFalse(); // 255 > 254 + result.GetBoolean(0).Should().BeTrue(); // 0 < 1 + result.GetBoolean(1).Should().BeFalse(); // 128 >= 128 + result.GetBoolean(2).Should().BeFalse(); // 255 > 254 } #endregion #region Scalar vs Scalar Tests (Test 7) - [Test] + [TestMethod] public async Task Equal_ScalarVsScalar() { // NumPy: np.array(3) == np.array(5) = False (shape: ()) @@ -344,11 +342,11 @@ public async Task Equal_ScalarVsScalar() var s2 = NDArray.Scalar(5); var result = s1 == s2; - await Assert.That(result.Shape.IsScalar).IsTrue(); - await Assert.That(result.GetBoolean()).IsFalse(); + result.Shape.IsScalar.Should().BeTrue(); + result.GetBoolean().Should().BeFalse(); } - [Test] + [TestMethod] public async Task Less_ScalarVsScalar() { // NumPy: np.array(3) < np.array(5) = True @@ -356,11 +354,11 @@ public async Task Less_ScalarVsScalar() var s2 = NDArray.Scalar(5); var result = s1 < s2; - await Assert.That(result.Shape.IsScalar).IsTrue(); - await Assert.That(result.GetBoolean()).IsTrue(); + result.Shape.IsScalar.Should().BeTrue(); + result.GetBoolean().Should().BeTrue(); } - [Test] + [TestMethod] public async Task GreaterEqual_ScalarVsScalar() { // NumPy: np.array(3) >= np.array(5) = False @@ -368,15 +366,15 @@ public async Task GreaterEqual_ScalarVsScalar() var s2 = NDArray.Scalar(5); var result = s1 >= s2; - await Assert.That(result.Shape.IsScalar).IsTrue(); - await Assert.That(result.GetBoolean()).IsFalse(); + result.Shape.IsScalar.Should().BeTrue(); + result.GetBoolean().Should().BeFalse(); } #endregion #region Float Edge Cases Tests (Test 8) - [Test] + [TestMethod] public async Task Equal_FloatWithNaN() { // NumPy: [1.0, nan, inf, -inf, 0.0] == [1.0, nan, inf, -inf, 0.0] = [True, False, True, True, True] @@ -384,125 +382,125 @@ public async Task Equal_FloatWithNaN() var floats = np.array(new[] { 1.0, double.NaN, double.PositiveInfinity, double.NegativeInfinity, 0.0 }); var result = floats == floats; - await Assert.That(result.GetBoolean(0)).IsTrue(); // 1.0 == 1.0 - await Assert.That(result.GetBoolean(1)).IsFalse(); // NaN != NaN (IEEE 754) - await Assert.That(result.GetBoolean(2)).IsTrue(); // Inf == Inf - await Assert.That(result.GetBoolean(3)).IsTrue(); // -Inf == -Inf - await Assert.That(result.GetBoolean(4)).IsTrue(); // 0.0 == 0.0 + result.GetBoolean(0).Should().BeTrue(); // 1.0 == 1.0 + result.GetBoolean(1).Should().BeFalse(); // NaN != NaN (IEEE 754) + result.GetBoolean(2).Should().BeTrue(); // Inf == Inf + result.GetBoolean(3).Should().BeTrue(); // -Inf == -Inf + result.GetBoolean(4).Should().BeTrue(); // 0.0 == 0.0 } - [Test] + [TestMethod] public async Task Less_FloatWithInfinity() { // NumPy: [1.0, nan, inf, -inf, 0.0] < 1.0 = [False, False, False, True, True] var floats = np.array(new[] { 1.0, double.NaN, double.PositiveInfinity, double.NegativeInfinity, 0.0 }); var result = floats < 1.0; - await Assert.That(result.GetBoolean(0)).IsFalse(); // 1.0 < 1.0 = False - await Assert.That(result.GetBoolean(1)).IsFalse(); // NaN < anything = False - await Assert.That(result.GetBoolean(2)).IsFalse(); // Inf < 1.0 = False - await Assert.That(result.GetBoolean(3)).IsTrue(); // -Inf < 1.0 = True - await Assert.That(result.GetBoolean(4)).IsTrue(); // 0.0 < 1.0 = True + result.GetBoolean(0).Should().BeFalse(); // 1.0 < 1.0 = False + result.GetBoolean(1).Should().BeFalse(); // NaN < anything = False + result.GetBoolean(2).Should().BeFalse(); // Inf < 1.0 = False + result.GetBoolean(3).Should().BeTrue(); // -Inf < 1.0 = True + result.GetBoolean(4).Should().BeTrue(); // 0.0 < 1.0 = True } #endregion #region All dtypes tests - [Test] + [TestMethod] public async Task Equal_Int16() { var a = np.array(new short[] { 1, 2, 3 }); var b = np.array(new short[] { 1, 3, 3 }); var result = a == b; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Equal_UInt16() { var a = np.array(new ushort[] { 1, 2, 3 }); var b = np.array(new ushort[] { 1, 3, 3 }); var result = a == b; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Equal_UInt32() { var a = np.array(new uint[] { 1, 2, 3 }); var b = np.array(new uint[] { 1, 3, 3 }); var result = a == b; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Equal_Int64() { var a = np.array(new long[] { 1, 2, 3 }); var b = np.array(new long[] { 1, 3, 3 }); var result = a == b; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Equal_UInt64() { var a = np.array(new ulong[] { 1, 2, 3 }); var b = np.array(new ulong[] { 1, 3, 3 }); var result = a == b; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Equal_Single() { var a = np.array(new float[] { 1.0f, 2.0f, 3.0f }); var b = np.array(new float[] { 1.0f, 3.0f, 3.0f }); var result = a == b; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Equal_Decimal() { var a = np.array(new decimal[] { 1.0m, 2.0m, 3.0m }); var b = np.array(new decimal[] { 1.0m, 3.0m, 3.0m }); var result = a == b; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Equal_Char() { var a = np.array(new char[] { 'a', 'b', 'c' }); var b = np.array(new char[] { 'a', 'x', 'c' }); var result = a == b; - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } #endregion diff --git a/test/NumSharp.UnitTest/Backends/Kernels/CumSumComprehensiveTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/CumSumComprehensiveTests.cs index 7e1ae10d4..4e315be20 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/CumSumComprehensiveTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/CumSumComprehensiveTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -18,11 +17,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// - Shape variations (square, rectangular, higher dimensional) /// - Type promotion (int32 -> int64) /// +[TestClass] public class CumSumComprehensiveTests { #region CumSum 1D Tests - [Test] + [TestMethod] public void CumSum_1D_Int32() { // NumPy: np.cumsum([1, 2, 3, 4, 5]) = [1, 3, 6, 10, 15] @@ -33,7 +33,7 @@ public void CumSum_1D_Int32() result.Should().BeOfValues(1L, 3L, 6L, 10L, 15L); } - [Test] + [TestMethod] public void CumSum_1D_Int64() { // NumPy: np.cumsum([1, 2, 3, 4, 5], dtype=int64) = [1, 3, 6, 10, 15] @@ -43,7 +43,7 @@ public void CumSum_1D_Int64() result.Should().BeOfValues(1L, 3L, 6L, 10L, 15L); } - [Test] + [TestMethod] public void CumSum_1D_Float32() { // NumPy: np.cumsum([1.0, 2.0, 3.0, 4.0, 5.0], dtype=float32) = [1.0, 3.0, 6.0, 10.0, 15.0] @@ -53,7 +53,7 @@ public void CumSum_1D_Float32() result.Should().BeOfValues(1.0f, 3.0f, 6.0f, 10.0f, 15.0f); } - [Test] + [TestMethod] public void CumSum_1D_Float64() { // NumPy: np.cumsum([1.0, 2.0, 3.0, 4.0, 5.0]) = [1.0, 3.0, 6.0, 10.0, 15.0] @@ -67,7 +67,7 @@ public void CumSum_1D_Float64() #region CumSum 2D Tests - No Axis (Flatten) - [Test] + [TestMethod] public void CumSum_2D_NoAxis() { // NumPy: np.cumsum([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) = [1, 3, 6, 10, 15, 21, 28, 36, 45] @@ -82,7 +82,7 @@ public void CumSum_2D_NoAxis() #region CumSum 2D Tests - With Axis - [Test] + [TestMethod] public void CumSum_2D_Axis0() { // NumPy: np.cumsum([[1, 2, 3], [4, 5, 6], [7, 8, 9]], axis=0) = [[1, 2, 3], [5, 7, 9], [12, 15, 18]] @@ -92,7 +92,7 @@ public void CumSum_2D_Axis0() result.Should().BeOfValues(1L, 2L, 3L, 5L, 7L, 9L, 12L, 15L, 18L); } - [Test] + [TestMethod] public void CumSum_2D_Axis1() { // NumPy: np.cumsum([[1, 2, 3], [4, 5, 6], [7, 8, 9]], axis=1) = [[1, 3, 6], [4, 9, 15], [7, 15, 24]] @@ -102,7 +102,7 @@ public void CumSum_2D_Axis1() result.Should().BeOfValues(1L, 3L, 6L, 4L, 9L, 15L, 7L, 15L, 24L); } - [Test] + [TestMethod] public void CumSum_2D_AxisNeg1() { // NumPy: np.cumsum([[1, 2, 3], [4, 5, 6], [7, 8, 9]], axis=-1) = [[1, 3, 6], [4, 9, 15], [7, 15, 24]] @@ -117,7 +117,7 @@ public void CumSum_2D_AxisNeg1() #region CumSum 3D Tests - [Test] + [TestMethod] public void CumSum_3D_NoAxis() { // NumPy: np.cumsum([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) = [1, 3, 6, 10, 15, 21, 28, 36] @@ -127,7 +127,7 @@ public void CumSum_3D_NoAxis() result.Should().BeOfValues(1L, 3L, 6L, 10L, 15L, 21L, 28L, 36L); } - [Test] + [TestMethod] public void CumSum_3D_Axis0() { // NumPy: np.cumsum([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], axis=0) = [[[1, 2], [3, 4]], [[6, 8], [10, 12]]] @@ -137,7 +137,7 @@ public void CumSum_3D_Axis0() result.Should().BeOfValues(1L, 2L, 3L, 4L, 6L, 8L, 10L, 12L); } - [Test] + [TestMethod] public void CumSum_3D_Axis1() { // NumPy: np.cumsum([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], axis=1) = [[[1, 2], [4, 6]], [[5, 6], [12, 14]]] @@ -147,7 +147,7 @@ public void CumSum_3D_Axis1() result.Should().BeOfValues(1L, 2L, 4L, 6L, 5L, 6L, 12L, 14L); } - [Test] + [TestMethod] public void CumSum_3D_Axis2() { // NumPy: np.cumsum([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], axis=2) = [[[1, 3], [3, 7]], [[5, 11], [7, 15]]] @@ -161,7 +161,7 @@ public void CumSum_3D_Axis2() #region CumSum Edge Cases - [Test] + [TestMethod] public void CumSum_SingleElement() { // NumPy: np.cumsum([42]) = [42] @@ -171,7 +171,7 @@ public void CumSum_SingleElement() result.Should().BeOfValues(42L); } - [Test] + [TestMethod] public void CumSum_EmptyArray() { // NumPy: np.cumsum([]) = [] @@ -184,7 +184,7 @@ public void CumSum_EmptyArray() #region CumSum Rectangular Arrays - [Test] + [TestMethod] public void CumSum_Rectangular_2x5_Axis0() { // NumPy: np.cumsum([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]], axis=0) = [[1, 2, 3, 4, 5], [7, 9, 11, 13, 15]] @@ -194,7 +194,7 @@ public void CumSum_Rectangular_2x5_Axis0() result.Should().BeOfValues(1L, 2L, 3L, 4L, 5L, 7L, 9L, 11L, 13L, 15L); } - [Test] + [TestMethod] public void CumSum_Rectangular_2x5_Axis1() { // NumPy: np.cumsum([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]], axis=1) = [[1, 3, 6, 10, 15], [6, 13, 21, 30, 40]] @@ -208,7 +208,7 @@ public void CumSum_Rectangular_2x5_Axis1() #region CumSum Square Arrays - [Test] + [TestMethod] public void CumSum_Square_4x4_Axis0() { // NumPy: np.cumsum([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], axis=0) @@ -219,7 +219,7 @@ public void CumSum_Square_4x4_Axis0() result.Should().BeOfValues(1L, 2L, 3L, 4L, 6L, 8L, 10L, 12L, 15L, 18L, 21L, 24L, 28L, 32L, 36L, 40L); } - [Test] + [TestMethod] public void CumSum_Square_4x4_Axis1() { // NumPy: np.cumsum([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], axis=1) @@ -234,7 +234,7 @@ public void CumSum_Square_4x4_Axis1() #region CumSum Higher Dimensional (2x3x4) - [Test] + [TestMethod] public void CumSum_HigherDim_2x3x4_NoAxis() { // NumPy: np.cumsum(np.arange(24).reshape(2, 3, 4)) @@ -248,7 +248,7 @@ public void CumSum_HigherDim_2x3x4_NoAxis() ); } - [Test] + [TestMethod] public void CumSum_HigherDim_2x3x4_Axis0_Shape() { // NumPy: np.cumsum(np.arange(24).reshape(2, 3, 4), axis=0).shape = (2, 3, 4) @@ -257,7 +257,7 @@ public void CumSum_HigherDim_2x3x4_Axis0_Shape() result.Should().BeShaped(2, 3, 4); } - [Test] + [TestMethod] public void CumSum_HigherDim_2x3x4_Axis1_Shape() { // NumPy: np.cumsum(np.arange(24).reshape(2, 3, 4), axis=1).shape = (2, 3, 4) @@ -266,7 +266,7 @@ public void CumSum_HigherDim_2x3x4_Axis1_Shape() result.Should().BeShaped(2, 3, 4); } - [Test] + [TestMethod] public void CumSum_HigherDim_2x3x4_Axis2_Shape() { // NumPy: np.cumsum(np.arange(24).reshape(2, 3, 4), axis=2).shape = (2, 3, 4) @@ -279,7 +279,7 @@ public void CumSum_HigherDim_2x3x4_Axis2_Shape() #region CumSum Type Promotion - [Test] + [TestMethod] public void CumSum_Int32_ReturnsInt64() { // NumPy 2.x (NEP50): cumsum of int32 returns int64 @@ -288,7 +288,7 @@ public void CumSum_Int32_ReturnsInt64() Assert.AreEqual(NPTypeCode.Int64, result.typecode); } - [Test] + [TestMethod] public void CumSum_Int64_ReturnsInt64() { // NumPy: cumsum of int64 returns int64 @@ -297,7 +297,7 @@ public void CumSum_Int64_ReturnsInt64() Assert.AreEqual(NPTypeCode.Int64, result.typecode); } - [Test] + [TestMethod] public void CumSum_Float32_ReturnsFloat32() { // NumPy: cumsum of float32 returns float32 @@ -306,7 +306,7 @@ public void CumSum_Float32_ReturnsFloat32() Assert.AreEqual(NPTypeCode.Single, result.typecode); } - [Test] + [TestMethod] public void CumSum_Float64_ReturnsFloat64() { // NumPy: cumsum of float64 returns float64 @@ -319,7 +319,7 @@ public void CumSum_Float64_ReturnsFloat64() #region CumSum Float Values - [Test] + [TestMethod] public void CumSum_Float64_2D_NoAxis() { // NumPy: np.cumsum([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]) = [1.0, 3.0, 6.0, 10.0, 15.0, 21.0] @@ -329,7 +329,7 @@ public void CumSum_Float64_2D_NoAxis() result.Should().BeOfValues(1.0, 3.0, 6.0, 10.0, 15.0, 21.0); } - [Test] + [TestMethod] public void CumSum_Float64_2D_Axis0() { // NumPy: np.cumsum([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], axis=0) = [[1.0, 2.0, 3.0], [5.0, 7.0, 9.0]] @@ -339,7 +339,7 @@ public void CumSum_Float64_2D_Axis0() result.Should().BeOfValues(1.0, 2.0, 3.0, 5.0, 7.0, 9.0); } - [Test] + [TestMethod] public void CumSum_Float64_2D_Axis1() { // NumPy: np.cumsum([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], axis=1) = [[1.0, 3.0, 6.0], [4.0, 9.0, 15.0]] @@ -353,7 +353,7 @@ public void CumSum_Float64_2D_Axis1() #region CumSum Negative Axis - [Test] + [TestMethod] public void CumSum_3D_AxisNegative1() { // NumPy: np.cumsum([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], axis=-1) @@ -365,7 +365,7 @@ public void CumSum_3D_AxisNegative1() result.Should().BeOfValues(1L, 3L, 3L, 7L, 5L, 11L, 7L, 15L); } - [Test] + [TestMethod] public void CumSum_3D_AxisNegative2() { // NumPy: np.cumsum([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], axis=-2) diff --git a/test/NumSharp.UnitTest/Backends/Kernels/DtypeCoverageTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/DtypeCoverageTests.cs index 36d87d087..bc6a70290 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/DtypeCoverageTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/DtypeCoverageTests.cs @@ -19,6 +19,7 @@ namespace NumSharp.UnitTest.Backends.Kernels /// /// Known limitations documented inline. /// + [TestClass] public class DtypeCoverageTests { #region Dtype Lists @@ -78,10 +79,10 @@ public class DtypeCoverageTests #region Unary Operations - [Test] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Sqrt_FloatDtypes(NPTypeCode dtype) { // sqrt is meaningful for float types @@ -100,14 +101,14 @@ public void Sqrt_FloatDtypes(NPTypeCode dtype) Assert.IsTrue(v2 >= 2.9 && v2 <= 3.1, $"sqrt(9) should be 3, got {v2}"); } - [Test] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] + [TestMethod] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] public void Sqrt_IntegerDtypes(NPTypeCode dtype) { // sqrt on integers works (result is float64) @@ -119,17 +120,17 @@ public void Sqrt_IntegerDtypes(NPTypeCode dtype) Assert.AreEqual(NPTypeCode.Double, result.typecode); } - [Test] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Abs_NumericDtypes(NPTypeCode dtype) { // abs works for all numeric types @@ -142,13 +143,13 @@ public void Abs_NumericDtypes(NPTypeCode dtype) Assert.IsTrue(value >= 0, $"abs result should be non-negative, got {value}"); } - [Test] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Negate_SignedDtypes(NPTypeCode dtype) { // negate works for signed types @@ -165,19 +166,19 @@ public void Negate_SignedDtypes(NPTypeCode dtype) #region Binary Operations - [Test] - [Arguments(NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Char)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Char)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Add_AllDtypes(NPTypeCode dtype) { // Addition works for all 12 dtypes @@ -207,19 +208,19 @@ public void Add_AllDtypes(NPTypeCode dtype) } } - [Test] - [Arguments(NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Char)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Char)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Multiply_AllDtypes(NPTypeCode dtype) { // Multiplication works for all 12 dtypes @@ -248,11 +249,11 @@ public void Multiply_AllDtypes(NPTypeCode dtype) } } - [Test] - [Arguments(NPTypeCode.Int32, NPTypeCode.Double)] - [Arguments(NPTypeCode.Int64, NPTypeCode.Single)] - [Arguments(NPTypeCode.Byte, NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt16, NPTypeCode.Int64)] + [TestMethod] + [DataRow(NPTypeCode.Int32, NPTypeCode.Double)] + [DataRow(NPTypeCode.Int64, NPTypeCode.Single)] + [DataRow(NPTypeCode.Byte, NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt16, NPTypeCode.Int64)] public void Add_MixedDtypes(NPTypeCode dtype1, NPTypeCode dtype2) { // Mixed type addition with type promotion @@ -268,19 +269,19 @@ public void Add_MixedDtypes(NPTypeCode dtype1, NPTypeCode dtype2) #region Reduction Operations - [Test] - [Arguments(NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Char)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Char)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Sum_AllDtypes(NPTypeCode dtype) { // Sum works for all 12 dtypes @@ -302,18 +303,18 @@ public void Sum_AllDtypes(NPTypeCode dtype) Assert.IsTrue(value >= 5.9 && value <= 6.1, $"Sum should be 6, got {value}"); } - [Test] + [TestMethod] // Note: Boolean and Char are excluded - np.amax doesn't support them - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Max_AllDtypes(NPTypeCode dtype) { // Max works for numeric dtypes (excluding Boolean and Char) @@ -329,18 +330,18 @@ public void Max_AllDtypes(NPTypeCode dtype) Assert.IsTrue(value >= 2.9 && value <= 3.1, $"Max should be 3, got {value}"); } - [Test] + [TestMethod] // Note: Boolean and Char are excluded - np.amin doesn't support them - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Min_AllDtypes(NPTypeCode dtype) { // Min works for numeric dtypes (excluding Boolean and Char) @@ -358,17 +359,17 @@ public void Min_AllDtypes(NPTypeCode dtype) Assert.IsTrue(value >= 0.9 && value <= 1.1, $"Min should be 1, got {value}"); } - [Test] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Mean_NumericDtypes(NPTypeCode dtype) { // Mean works for numeric dtypes @@ -387,19 +388,19 @@ public void Mean_NumericDtypes(NPTypeCode dtype) #region Comparison Operations - [Test] - [Arguments(NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Char)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Char)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Equal_AllDtypes(NPTypeCode dtype) { // Equality comparison works for all 12 dtypes @@ -414,18 +415,18 @@ public void Equal_AllDtypes(NPTypeCode dtype) Assert.IsTrue(result.GetBoolean(2)); // 3 == 3 } - [Test] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Char)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Char)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Less_NumericDtypes(NPTypeCode dtype) { // Less-than comparison for numeric dtypes @@ -440,18 +441,18 @@ public void Less_NumericDtypes(NPTypeCode dtype) Assert.IsFalse(result.GetBoolean(2)); // 3 < 2 is false } - [Test] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Char)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Char)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Greater_NumericDtypes(NPTypeCode dtype) { // Greater-than comparison for numeric dtypes @@ -470,19 +471,19 @@ public void Greater_NumericDtypes(NPTypeCode dtype) #region Edge Cases - [Test] - [Arguments(NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Char)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Char)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void EmptyArray_AllDtypes(NPTypeCode dtype) { // Empty arrays should be handled for all dtypes @@ -490,19 +491,19 @@ public void EmptyArray_AllDtypes(NPTypeCode dtype) Assert.AreEqual(0, arr.size); } - [Test] - [Arguments(NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Char)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Char)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void ScalarArray_AllDtypes(NPTypeCode dtype) { // Scalar arrays should work for all dtypes @@ -510,19 +511,19 @@ public void ScalarArray_AllDtypes(NPTypeCode dtype) Assert.IsTrue(arr.Shape.IsScalar || arr.size == 1); } - [Test] - [Arguments(NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Char)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Char)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Reshape_AllDtypes(NPTypeCode dtype) { // Reshape should work for all dtypes @@ -533,19 +534,19 @@ public void Reshape_AllDtypes(NPTypeCode dtype) Assert.AreEqual(6L, reshaped.size); } - [Test] - [Arguments(NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Char)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Char)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Slice_AllDtypes(NPTypeCode dtype) { // Slicing should work for all dtypes @@ -555,19 +556,19 @@ public void Slice_AllDtypes(NPTypeCode dtype) Assert.AreEqual(3, sliced.size); } - [Test] - [Arguments(NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Char)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Decimal)] + [TestMethod] + [DataRow(NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Char)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Decimal)] public void Copy_AllDtypes(NPTypeCode dtype) { // Copy should work for all dtypes diff --git a/test/NumSharp.UnitTest/Backends/Kernels/DtypePromotionTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/DtypePromotionTests.cs index 38b390ebe..2994f783a 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/DtypePromotionTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/DtypePromotionTests.cs @@ -2,9 +2,6 @@ using System.Threading.Tasks; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -20,140 +17,141 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// - min/max preserve input dtype /// - var/std always return float64 /// +[TestClass] public class DtypePromotionTests { #region Sum Dtype Promotion - [Test] + [TestMethod] public async Task Sum_Int32_ReturnsInt64() { // NumPy: np.sum(np.array([1, 2, 3], dtype=np.int32)).dtype == int64 var a = np.array(new int[] { 1, 2, 3 }); var result = np.sum(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); - await Assert.That(result.GetInt64(0)).IsEqualTo(6L); + result.typecode.Should().Be(NPTypeCode.Int64); + result.GetInt64(0).Should().Be(6L); } - [Test] + [TestMethod] public async Task Sum_UInt32_ReturnsUInt64() { // NumPy: np.sum(np.array([1, 2, 3], dtype=np.uint32)).dtype == uint64 var a = np.array(new uint[] { 1, 2, 3 }); var result = np.sum(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.UInt64); - await Assert.That(result.GetUInt64(0)).IsEqualTo(6UL); + result.typecode.Should().Be(NPTypeCode.UInt64); + result.GetUInt64(0).Should().Be(6UL); } - [Test] + [TestMethod] public async Task Sum_Int16_ReturnsInt64() { // NumPy: np.sum(np.array([1, 2, 3], dtype=np.int16)).dtype == int64 var a = np.array(new short[] { 1, 2, 3 }); var result = np.sum(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); - await Assert.That(result.GetInt64(0)).IsEqualTo(6L); + result.typecode.Should().Be(NPTypeCode.Int64); + result.GetInt64(0).Should().Be(6L); } - [Test] + [TestMethod] public async Task Sum_UInt16_ReturnsUInt64() { // NumPy: np.sum(np.array([1, 2, 3], dtype=np.uint16)).dtype == uint64 var a = np.array(new ushort[] { 1, 2, 3 }); var result = np.sum(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.UInt64); - await Assert.That(result.GetUInt64(0)).IsEqualTo(6UL); + result.typecode.Should().Be(NPTypeCode.UInt64); + result.GetUInt64(0).Should().Be(6UL); } - [Test] + [TestMethod] public async Task Sum_Byte_ReturnsUInt64() { // NumPy: np.sum(np.array([1, 2, 3], dtype=np.uint8)).dtype == uint64 var a = np.array(new byte[] { 1, 2, 3 }); var result = np.sum(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.UInt64); - await Assert.That(result.GetUInt64(0)).IsEqualTo(6UL); + result.typecode.Should().Be(NPTypeCode.UInt64); + result.GetUInt64(0).Should().Be(6UL); } - [Test] + [TestMethod] public async Task Sum_Float32_ReturnsFloat32() { // NumPy 2.x (NEP50): np.sum(np.array([1.0, 2.0, 3.0], dtype=np.float32)).dtype == float32 var a = np.array(new float[] { 1.0f, 2.0f, 3.0f }); var result = np.sum(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Single); - await Assert.That(result.GetSingle(0)).IsEqualTo(6.0f); + result.typecode.Should().Be(NPTypeCode.Single); + result.GetSingle(0).Should().Be(6.0f); } - [Test] + [TestMethod] public async Task Sum_Float64_ReturnsFloat64() { // NumPy: np.sum(np.array([1.0, 2.0, 3.0], dtype=np.float64)).dtype == float64 var a = np.array(new double[] { 1.0, 2.0, 3.0 }); var result = np.sum(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Double); - await Assert.That(result.GetDouble(0)).IsEqualTo(6.0); + result.typecode.Should().Be(NPTypeCode.Double); + result.GetDouble(0).Should().Be(6.0); } - [Test] + [TestMethod] public async Task Sum_Int64_ReturnsInt64() { // NumPy: np.sum(np.array([1, 2, 3], dtype=np.int64)).dtype == int64 var a = np.array(new long[] { 1, 2, 3 }); var result = np.sum(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); - await Assert.That(result.GetInt64(0)).IsEqualTo(6L); + result.typecode.Should().Be(NPTypeCode.Int64); + result.GetInt64(0).Should().Be(6L); } #endregion #region Prod Dtype Promotion - [Test] + [TestMethod] public async Task Prod_Int32_ReturnsInt64() { // NumPy: np.prod(np.array([1, 2, 3], dtype=np.int32)).dtype == int64 var a = np.array(new int[] { 1, 2, 3 }); var result = np.prod(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); - await Assert.That(result.GetInt64(0)).IsEqualTo(6L); + result.typecode.Should().Be(NPTypeCode.Int64); + result.GetInt64(0).Should().Be(6L); } - [Test] + [TestMethod] public async Task Prod_Float32_ReturnsFloat32() { // NumPy 2.x (NEP50): np.prod(np.array([1.0, 2.0, 3.0], dtype=np.float32)).dtype == float32 var a = np.array(new float[] { 1.0f, 2.0f, 3.0f }); var result = np.prod(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Single); - await Assert.That(result.GetSingle(0)).IsEqualTo(6.0f); + result.typecode.Should().Be(NPTypeCode.Single); + result.GetSingle(0).Should().Be(6.0f); } #endregion #region Mean Dtype Promotion - [Test] + [TestMethod] public async Task Mean_Int32_ReturnsFloat64() { // NumPy: np.mean(np.array([1, 2, 3], dtype=np.int32)).dtype == float64 var a = np.array(new int[] { 1, 2, 3 }); var result = np.mean(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Double); - await Assert.That(result.GetDouble(0)).IsEqualTo(2.0); + result.typecode.Should().Be(NPTypeCode.Double); + result.GetDouble(0).Should().Be(2.0); } - [Test] + [TestMethod] public async Task Mean_Float32_ReturnsFloat64() { // NumSharp: np.mean(float32_array) returns float64 by default @@ -161,94 +159,94 @@ public async Task Mean_Float32_ReturnsFloat64() var a = np.array(new float[] { 1.0f, 2.0f, 3.0f }); var result = np.mean(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Double); - await Assert.That(result.GetDouble(0)).IsEqualTo(2.0); + result.typecode.Should().Be(NPTypeCode.Double); + result.GetDouble(0).Should().Be(2.0); } - [Test] + [TestMethod] public async Task Mean_Float64_ReturnsFloat64() { // NumPy: np.mean(np.array([1.0, 2.0, 3.0], dtype=np.float64)).dtype == float64 var a = np.array(new double[] { 1.0, 2.0, 3.0 }); var result = np.mean(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Double); - await Assert.That(result.GetDouble(0)).IsEqualTo(2.0); + result.typecode.Should().Be(NPTypeCode.Double); + result.GetDouble(0).Should().Be(2.0); } #endregion #region Min/Max Dtype Promotion (Preserve Input) - [Test] + [TestMethod] public async Task Min_Int32_ReturnsInt32() { // NumPy: np.min(np.array([1, 2, 3], dtype=np.int32)).dtype == int32 var a = np.array(new int[] { 1, 2, 3 }); var result = np.amin(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int32); - await Assert.That(result.GetInt32(0)).IsEqualTo(1); + result.typecode.Should().Be(NPTypeCode.Int32); + result.GetInt32(0).Should().Be(1); } - [Test] + [TestMethod] public async Task Max_Int32_ReturnsInt32() { // NumPy: np.max(np.array([1, 2, 3], dtype=np.int32)).dtype == int32 var a = np.array(new int[] { 1, 2, 3 }); var result = np.amax(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int32); - await Assert.That(result.GetInt32(0)).IsEqualTo(3); + result.typecode.Should().Be(NPTypeCode.Int32); + result.GetInt32(0).Should().Be(3); } - [Test] + [TestMethod] public async Task Min_Float32_ReturnsFloat32() { // NumPy: np.min(np.array([1.0, 2.0, 3.0], dtype=np.float32)).dtype == float32 var a = np.array(new float[] { 1.0f, 2.0f, 3.0f }); var result = np.amin(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Single); - await Assert.That(result.GetSingle(0)).IsEqualTo(1.0f); + result.typecode.Should().Be(NPTypeCode.Single); + result.GetSingle(0).Should().Be(1.0f); } - [Test] + [TestMethod] public async Task Max_Float64_ReturnsFloat64() { // NumPy: np.max(np.array([1.0, 2.0, 3.0], dtype=np.float64)).dtype == float64 var a = np.array(new double[] { 1.0, 2.0, 3.0 }); var result = np.amax(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Double); - await Assert.That(result.GetDouble(0)).IsEqualTo(3.0); + result.typecode.Should().Be(NPTypeCode.Double); + result.GetDouble(0).Should().Be(3.0); } #endregion #region Var/Std Dtype Promotion - [Test] + [TestMethod] public async Task Var_Int32_ReturnsFloat64() { // NumPy: np.var(np.array([1, 2, 3], dtype=np.int32)).dtype == float64 var a = np.array(new int[] { 1, 2, 3 }); var result = np.var(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Double); + result.typecode.Should().Be(NPTypeCode.Double); } - [Test] + [TestMethod] public async Task Std_Int32_ReturnsFloat64() { // NumPy: np.std(np.array([1, 2, 3], dtype=np.int32)).dtype == float64 var a = np.array(new int[] { 1, 2, 3 }); var result = np.std(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Double); + result.typecode.Should().Be(NPTypeCode.Double); } - [Test] + [TestMethod] [OpenBugs] // NumPy 2.x returns float64 for var(float32), NumSharp returns float32 public async Task Var_Float32_NumPyReturnsFloat64() { @@ -259,10 +257,10 @@ public async Task Var_Float32_NumPyReturnsFloat64() var result = np.var(a); // This test documents NumPy expected behavior (fails currently) - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Double); + result.typecode.Should().Be(NPTypeCode.Double); } - [Test] + [TestMethod] public async Task Var_Float32_ReturnsFloat32() { // NumSharp's current behavior - preserves float32 via GetComputingType() @@ -270,54 +268,54 @@ public async Task Var_Float32_ReturnsFloat32() var a = np.array(new float[] { 1.0f, 2.0f, 3.0f }); var result = np.var(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Single); + result.typecode.Should().Be(NPTypeCode.Single); } #endregion #region Axis Reduction Dtype Promotion - [Test] + [TestMethod] public async Task Sum_Int32_Axis_ReturnsInt64() { // NumPy: np.sum(np.array([[1, 2], [3, 4]], dtype=np.int32), axis=0).dtype == int64 var a = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); var result = np.sum(a, axis: 0); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.typecode.Should().Be(NPTypeCode.Int64); result.Should().BeOfValues(4L, 6L); } - [Test] + [TestMethod] public async Task Sum_Float32_Axis_ReturnsFloat32() { // NumPy 2.x (NEP50): np.sum(np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32), axis=0).dtype == float32 var a = np.array(new float[,] { { 1.0f, 2.0f }, { 3.0f, 4.0f } }); var result = np.sum(a, axis: 0); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Single); + result.typecode.Should().Be(NPTypeCode.Single); result.Should().BeOfValues(4.0f, 6.0f); } - [Test] + [TestMethod] public async Task Min_Int32_Axis_ReturnsInt32() { // NumPy: np.min(np.array([[1, 2], [3, 4]], dtype=np.int32), axis=0).dtype == int32 var a = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); var result = np.amin(a, axis: 0); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int32); + result.typecode.Should().Be(NPTypeCode.Int32); result.Should().BeOfValues(1, 2); } - [Test] + [TestMethod] public async Task Mean_Int32_Axis_ReturnsFloat64() { // NumPy: np.mean(np.array([[1, 2], [3, 4]], dtype=np.int32), axis=0).dtype == float64 var a = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); var result = np.mean(a, axis: 0); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Double); + result.typecode.Should().Be(NPTypeCode.Double); result.Should().BeOfValues(2.0, 3.0); } @@ -325,25 +323,25 @@ public async Task Mean_Int32_Axis_ReturnsFloat64() #region CumSum Dtype Promotion - [Test] + [TestMethod] public async Task CumSum_Int32_ReturnsInt64() { // NumPy: np.cumsum(np.array([1, 2, 3], dtype=np.int32)).dtype == int64 var a = np.array(new int[] { 1, 2, 3 }); var result = np.cumsum(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.typecode.Should().Be(NPTypeCode.Int64); result.Should().BeOfValues(1L, 3L, 6L); } - [Test] + [TestMethod] public async Task CumSum_Float32_ReturnsFloat32() { // NumPy 2.x (NEP50): np.cumsum(np.array([1.0, 2.0, 3.0], dtype=np.float32)).dtype == float32 var a = np.array(new float[] { 1.0f, 2.0f, 3.0f }); var result = np.cumsum(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Single); + result.typecode.Should().Be(NPTypeCode.Single); result.Should().BeOfValues(1.0f, 3.0f, 6.0f); } diff --git a/test/NumSharp.UnitTest/Backends/Kernels/EdgeCaseTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/EdgeCaseTests.cs index 40b9be927..c596a54bd 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/EdgeCaseTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/EdgeCaseTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -10,11 +9,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Edge case tests discovered through NumPy battle testing. /// All expected values are verified against NumPy 2.x output. /// +[TestClass] public class EdgeCaseTests { #region Modulo Edge Cases - Python vs C Semantics - [Test] + [TestMethod] public void Mod_NegativeDividend_PythonSemantics() { // NumPy: -7 % 3 = 2 (Python semantics: result has same sign as divisor) @@ -27,7 +27,7 @@ public void Mod_NegativeDividend_PythonSemantics() Assert.AreEqual(2, result.GetInt32(0), "NumPy uses Python modulo semantics"); } - [Test] + [TestMethod] public void Mod_NegativeDivisor_PythonSemantics() { // NumPy: 7 % -3 = -2 (Python semantics) @@ -40,7 +40,7 @@ public void Mod_NegativeDivisor_PythonSemantics() Assert.AreEqual(-2, result.GetInt32(0), "NumPy uses Python modulo semantics"); } - [Test] + [TestMethod] public void Mod_BothNegative() { // NumPy: -7 % -3 = -1 (both semantics agree here) @@ -52,7 +52,7 @@ public void Mod_BothNegative() Assert.AreEqual(-1, result.GetInt32(0)); } - [Test] + [TestMethod] public void Mod_Float_ByZero() { // NumPy: 5.0 % 0.0 = NaN @@ -68,7 +68,7 @@ public void Mod_Float_ByZero() #region Absolute Value Edge Cases - [Test] + [TestMethod] [OpenBugs] // Int8 abs overflow is a known edge case public void Abs_Int8_MinValue_Overflow() { @@ -82,7 +82,7 @@ public void Abs_Int8_MinValue_Overflow() Assert.AreEqual(-128, (sbyte)result.GetByte(0), "abs(MIN_VALUE) overflows to MIN_VALUE"); } - [Test] + [TestMethod] public void Abs_NegativeZero() { // NumPy: np.abs(-0.0) = 0.0 (positive zero) @@ -94,7 +94,7 @@ public void Abs_NegativeZero() // Note: Checking if it's positive zero vs negative zero is tricky } - [Test] + [TestMethod] public void Abs_NegativeInfinity() { // NumPy: np.abs(-inf) = inf @@ -105,7 +105,7 @@ public void Abs_NegativeInfinity() Assert.IsTrue(double.IsPositiveInfinity(result.GetDouble(0))); } - [Test] + [TestMethod] public void Abs_NaN() { // NumPy: np.abs(nan) = nan @@ -120,7 +120,7 @@ public void Abs_NaN() #region Sign Edge Cases - [Test] + [TestMethod] public void Sign_NaN_ReturnsNaN() { // NumPy: np.sign(nan) = nan @@ -132,7 +132,7 @@ public void Sign_NaN_ReturnsNaN() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Sign_Infinity() { // NumPy: np.sign(inf) = 1.0, np.sign(-inf) = -1.0 @@ -144,7 +144,7 @@ public void Sign_Infinity() Assert.AreEqual(-1.0, result.GetDouble(1)); } - [Test] + [TestMethod] public void Sign_Zero() { // NumPy: np.sign(0) = 0, np.sign(-0.0) = 0.0 @@ -156,7 +156,7 @@ public void Sign_Zero() Assert.AreEqual(0.0, result.GetDouble(1)); } - [Test] + [TestMethod] public void Sign_PreservesIntegerType() { // NumPy: np.sign(int16) returns int16 @@ -178,7 +178,7 @@ public void Sign_PreservesIntegerType() #region Negative Edge Cases - [Test] + [TestMethod] [OpenBugs] // NumSharp throws NotSupportedException for unsigned types public void Negative_UInt8_Wraps() { @@ -194,7 +194,7 @@ public void Negative_UInt8_Wraps() Assert.AreEqual(0, result.GetByte(2)); } - [Test] + [TestMethod] public void Negative_NegativeZero() { // NumPy: np.negative(-0.0) = 0.0 (becomes positive zero) @@ -205,7 +205,7 @@ public void Negative_NegativeZero() Assert.AreEqual(0.0, result.GetDouble(0)); } - [Test] + [TestMethod] public void Negative_Infinity() { // NumPy: np.negative(inf) = -inf @@ -216,7 +216,7 @@ public void Negative_Infinity() Assert.IsTrue(double.IsNegativeInfinity(result.GetDouble(0))); } - [Test] + [TestMethod] public void Negative_NaN() { // NumPy: np.negative(nan) = nan @@ -231,7 +231,7 @@ public void Negative_NaN() #region Integer Overflow Edge Cases - [Test] + [TestMethod] [OpenBugs] // sbyte array operations may not work correctly public void Add_Int8_Overflow_Wraps() { @@ -244,7 +244,7 @@ public void Add_Int8_Overflow_Wraps() Assert.AreEqual(-128, (sbyte)result.GetByte(0)); } - [Test] + [TestMethod] [OpenBugs] // sbyte array operations may not work correctly public void Subtract_Int8_Underflow_Wraps() { @@ -257,7 +257,7 @@ public void Subtract_Int8_Underflow_Wraps() Assert.AreEqual(127, (sbyte)result.GetByte(0)); } - [Test] + [TestMethod] public void Add_UInt8_Overflow_Wraps() { // NumPy: np.uint8(255) + np.uint8(1) = 0 @@ -269,7 +269,7 @@ public void Add_UInt8_Overflow_Wraps() Assert.AreEqual(0, result.GetByte(0)); } - [Test] + [TestMethod] public void Subtract_UInt8_Underflow_Wraps() { // NumPy: np.uint8(0) - np.uint8(1) = 255 @@ -281,7 +281,7 @@ public void Subtract_UInt8_Underflow_Wraps() Assert.AreEqual(255, result.GetByte(0)); } - [Test] + [TestMethod] [OpenBugs] // sbyte array operations may not work correctly public void Multiply_Int8_Overflow_Wraps() { @@ -298,7 +298,7 @@ public void Multiply_Int8_Overflow_Wraps() #region Division Edge Cases - [Test] + [TestMethod] public void Divide_Float_ByPositiveZero() { // NumPy: 1.0 / 0.0 = inf @@ -310,7 +310,7 @@ public void Divide_Float_ByPositiveZero() Assert.IsTrue(double.IsPositiveInfinity(result.GetDouble(0))); } - [Test] + [TestMethod] public void Divide_Float_ByNegativeZero() { // NumPy: 1.0 / -0.0 = -inf @@ -322,7 +322,7 @@ public void Divide_Float_ByNegativeZero() Assert.IsTrue(double.IsNegativeInfinity(result.GetDouble(0))); } - [Test] + [TestMethod] public void Divide_ZeroByZero() { // NumPy: 0.0 / 0.0 = nan @@ -334,7 +334,7 @@ public void Divide_ZeroByZero() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Divide_InfinityByInfinity() { // NumPy: inf / inf = nan @@ -346,7 +346,7 @@ public void Divide_InfinityByInfinity() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Divide_ZeroByInfinity() { // NumPy: 0.0 / inf = 0.0 @@ -362,7 +362,7 @@ public void Divide_ZeroByInfinity() #region Infinity Arithmetic Edge Cases - [Test] + [TestMethod] public void Subtract_InfinityFromInfinity() { // NumPy: inf - inf = nan @@ -374,7 +374,7 @@ public void Subtract_InfinityFromInfinity() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Multiply_InfinityByZero() { // NumPy: inf * 0 = nan @@ -386,7 +386,7 @@ public void Multiply_InfinityByZero() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Add_InfinityPlusOne() { // NumPy: inf + 1 = inf @@ -398,7 +398,7 @@ public void Add_InfinityPlusOne() Assert.IsTrue(double.IsPositiveInfinity(result.GetDouble(0))); } - [Test] + [TestMethod] public void Add_NegativeInfinityPlusInfinity() { // NumPy: -inf + inf = nan @@ -414,7 +414,7 @@ public void Add_NegativeInfinityPlusInfinity() #region Trig Function Edge Cases - [Test] + [TestMethod] public void Sin_Infinity() { // NumPy: np.sin(inf) = nan @@ -425,7 +425,7 @@ public void Sin_Infinity() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Cos_Infinity() { // NumPy: np.cos(inf) = nan @@ -436,7 +436,7 @@ public void Cos_Infinity() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void ArcSin_OutOfRange() { // NumPy: np.arcsin(2) = nan @@ -447,7 +447,7 @@ public void ArcSin_OutOfRange() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void ArcTan_Infinity() { // NumPy: np.arctan(inf) = pi/2 @@ -463,7 +463,7 @@ public void ArcTan_Infinity() #region Log/Exp Edge Cases - [Test] + [TestMethod] public void Log_Zero() { // NumPy: np.log(0) = -inf @@ -474,7 +474,7 @@ public void Log_Zero() Assert.IsTrue(double.IsNegativeInfinity(result.GetDouble(0))); } - [Test] + [TestMethod] public void Log_Negative() { // NumPy: np.log(-1) = nan @@ -485,7 +485,7 @@ public void Log_Negative() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Log1p_MinusOne() { // NumPy: np.log1p(-1) = -inf @@ -496,7 +496,7 @@ public void Log1p_MinusOne() Assert.IsTrue(double.IsNegativeInfinity(result.GetDouble(0))); } - [Test] + [TestMethod] public void Log1p_LessThanMinusOne() { // NumPy: np.log1p(-2) = nan @@ -507,7 +507,7 @@ public void Log1p_LessThanMinusOne() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Exp_NegativeInfinity() { // NumPy: np.exp(-inf) = 0 @@ -518,7 +518,7 @@ public void Exp_NegativeInfinity() Assert.AreEqual(0.0, result.GetDouble(0)); } - [Test] + [TestMethod] public void Expm1_NegativeInfinity() { // NumPy: np.expm1(-inf) = -1 @@ -529,7 +529,7 @@ public void Expm1_NegativeInfinity() Assert.AreEqual(-1.0, result.GetDouble(0)); } - [Test] + [TestMethod] public void Exp2_NegativeInfinity() { // NumPy: np.exp2(-inf) = 0 @@ -544,7 +544,7 @@ public void Exp2_NegativeInfinity() #region Sqrt Edge Cases - [Test] + [TestMethod] public void Sqrt_Negative() { // NumPy: np.sqrt(-1) = nan @@ -555,7 +555,7 @@ public void Sqrt_Negative() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Sqrt_NegativeInfinity() { // NumPy: np.sqrt(-inf) = nan @@ -566,7 +566,7 @@ public void Sqrt_NegativeInfinity() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Sqrt_PositiveInfinity() { // NumPy: np.sqrt(inf) = inf @@ -581,7 +581,7 @@ public void Sqrt_PositiveInfinity() #region Hyperbolic Edge Cases - [Test] + [TestMethod] public void Tanh_Infinity() { // NumPy: np.tanh(inf) = 1.0, np.tanh(-inf) = -1.0 @@ -593,7 +593,7 @@ public void Tanh_Infinity() Assert.AreEqual(-1.0, result.GetDouble(1)); } - [Test] + [TestMethod] public void Tanh_LargeValue() { // NumPy: np.tanh(1000) = 1.0 (saturates to 1) @@ -604,7 +604,7 @@ public void Tanh_LargeValue() Assert.AreEqual(1.0, result.GetDouble(0)); } - [Test] + [TestMethod] public void Sinh_Infinity() { // NumPy: np.sinh(inf) = inf, np.sinh(-inf) = -inf @@ -616,7 +616,7 @@ public void Sinh_Infinity() Assert.IsTrue(double.IsNegativeInfinity(result.GetDouble(1))); } - [Test] + [TestMethod] public void Cosh_Infinity() { // NumPy: np.cosh(inf) = inf (both +inf and -inf give +inf) @@ -632,7 +632,8 @@ public void Cosh_Infinity() #region Rounding Edge Cases (Banker's Rounding) - [Test] + [TestMethod] + [OpenBugs] // Vector512 SIMD: "Could not find Round for Vector512" on AVX-512 capable runners public void Round_HalfToEven_BankersRounding() { // NumPy uses banker's rounding: round half to even @@ -648,7 +649,8 @@ public void Round_HalfToEven_BankersRounding() Assert.AreEqual(4.0, result.GetDouble(4)); // Half rounds to even (4) } - [Test] + [TestMethod] + [OpenBugs] // Vector512 SIMD: "Could not find Round for Vector512" on AVX-512 capable runners public void Round_NegativeHalf() { // NumPy: np.round(-0.5) = -0.0, np.round(-1.5) = -2.0 @@ -661,7 +663,7 @@ public void Round_NegativeHalf() Assert.AreEqual(-2.0, result.GetDouble(2)); // Half rounds to even (-2) } - [Test] + [TestMethod] public void Floor_Infinity() { // NumPy: np.floor(inf) = inf, np.floor(-inf) = -inf @@ -673,7 +675,7 @@ public void Floor_Infinity() Assert.IsTrue(double.IsNegativeInfinity(result.GetDouble(1))); } - [Test] + [TestMethod] public void Floor_NaN() { // NumPy: np.floor(nan) = nan @@ -684,7 +686,7 @@ public void Floor_NaN() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Ceil_NegativeHalf() { // NumPy: np.ceil(-0.5) = -0.0 @@ -699,7 +701,7 @@ public void Ceil_NegativeHalf() #region Empty Array Edge Cases - [Test] + [TestMethod] public void Sum_EmptyArray() { // NumPy: np.sum([]) = 0.0 @@ -710,7 +712,7 @@ public void Sum_EmptyArray() Assert.AreEqual(0.0, result.GetDouble(0)); } - [Test] + [TestMethod] public void Prod_EmptyArray() { // NumPy: np.prod([]) = 1.0 @@ -721,7 +723,7 @@ public void Prod_EmptyArray() Assert.AreEqual(1.0, result.GetDouble(0)); } - [Test] + [TestMethod] public void Mean_EmptyArray() { // NumPy: np.mean([]) = nan @@ -732,7 +734,7 @@ public void Mean_EmptyArray() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Cumsum_EmptyArray() { // NumPy: np.cumsum([]) = [] (empty array) @@ -744,7 +746,7 @@ public void Cumsum_EmptyArray() Assert.AreEqual(1, result.ndim); } - [Test] + [TestMethod] public void Dot_EmptyArrays() { // NumPy: np.dot([], []) = 0.0 @@ -760,7 +762,7 @@ public void Dot_EmptyArrays() #region Type Promotion Edge Cases - [Test] + [TestMethod] public void Add_Bool_ActsAsLogicalOr() { // NumPy: True + True = True (bool + bool stays bool, acts as OR) @@ -773,7 +775,7 @@ public void Add_Bool_ActsAsLogicalOr() Assert.IsTrue(result.GetBoolean(0)); } - [Test] + [TestMethod] public void Add_Bool_False() { // NumPy: False + False = False @@ -786,7 +788,7 @@ public void Add_Bool_False() Assert.IsFalse(result.GetBoolean(0)); } - [Test] + [TestMethod] public void Multiply_Bool_ActsAsLogicalAnd() { // NumPy: True * False = False (bool * bool stays bool, acts as AND) @@ -799,7 +801,7 @@ public void Multiply_Bool_ActsAsLogicalAnd() Assert.IsFalse(result.GetBoolean(0)); } - [Test] + [TestMethod] public void Multiply_Bool_WithInt() { // NumPy: True * 5 = 5 (promotes to int64) @@ -811,7 +813,7 @@ public void Multiply_Bool_WithInt() Assert.AreEqual(5, result.GetInt32(0)); } - [Test] + [TestMethod] public void Add_UInt64_Int64_PromotesToFloat64() { // NumPy: uint64 + int64 = float64 (can't safely fit in either) @@ -828,7 +830,7 @@ public void Add_UInt64_Int64_PromotesToFloat64() #region NaN Comparison Edge Cases - [Test] + [TestMethod] public void Equal_NaN_NaN_IsFalse() { // NumPy: nan == nan -> False (IEEE 754) @@ -840,7 +842,7 @@ public void Equal_NaN_NaN_IsFalse() Assert.IsFalse(result.GetBoolean(0)); } - [Test] + [TestMethod] public void NotEqual_NaN_NaN_IsTrue() { // NumPy: nan != nan -> True (IEEE 754) @@ -852,7 +854,7 @@ public void NotEqual_NaN_NaN_IsTrue() Assert.IsTrue(result.GetBoolean(0)); } - [Test] + [TestMethod] public void LessThan_NaN_IsFalse() { // NumPy: nan < anything -> False @@ -864,7 +866,7 @@ public void LessThan_NaN_IsFalse() Assert.IsFalse(result.GetBoolean(0)); } - [Test] + [TestMethod] public void GreaterThan_NaN_IsFalse() { // NumPy: nan > anything -> False @@ -880,7 +882,7 @@ public void GreaterThan_NaN_IsFalse() #region Infinity Comparison Edge Cases - [Test] + [TestMethod] public void Equal_Infinity_Infinity_IsTrue() { // NumPy: inf == inf -> True @@ -892,7 +894,7 @@ public void Equal_Infinity_Infinity_IsTrue() Assert.IsTrue(result.GetBoolean(0)); } - [Test] + [TestMethod] public void GreaterThan_Infinity_Infinity_IsFalse() { // NumPy: inf > inf -> False @@ -904,7 +906,7 @@ public void GreaterThan_Infinity_Infinity_IsFalse() Assert.IsFalse(result.GetBoolean(0)); } - [Test] + [TestMethod] public void GreaterThanOrEqual_Infinity_Infinity_IsTrue() { // NumPy: inf >= inf -> True diff --git a/test/NumSharp.UnitTest/Backends/Kernels/EmptyArrayReductionTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/EmptyArrayReductionTests.cs index ccc261598..0a42a9ed5 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/EmptyArrayReductionTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/EmptyArrayReductionTests.cs @@ -1,7 +1,6 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -10,6 +9,7 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// NumPy raises ValueError for max/min of empty arrays (no identity element). /// NumPy returns identity values for sum/prod (0 and 1 respectively). /// +[TestClass] public class EmptyArrayReductionTests { #region Max/Min Should Throw @@ -18,7 +18,7 @@ public class EmptyArrayReductionTests /// NumPy: np.max(np.array([])) raises ValueError /// "zero-size array to reduction operation maximum which has no identity" /// - [Test] + [TestMethod] public void Max_EmptyArray_ThrowsArgumentException() { var empty = np.array(new double[0]); @@ -30,7 +30,7 @@ public void Max_EmptyArray_ThrowsArgumentException() /// NumPy: np.min(np.array([])) raises ValueError /// "zero-size array to reduction operation minimum which has no identity" /// - [Test] + [TestMethod] public void Min_EmptyArray_ThrowsArgumentException() { var empty = np.array(new double[0]); @@ -41,7 +41,7 @@ public void Min_EmptyArray_ThrowsArgumentException() /// /// NumPy: np.amax(np.array([])) raises ValueError /// - [Test] + [TestMethod] public void AMax_EmptyArray_ThrowsArgumentException() { var empty = np.array(new double[0]); @@ -52,7 +52,7 @@ public void AMax_EmptyArray_ThrowsArgumentException() /// /// NumPy: np.amin(np.array([])) raises ValueError /// - [Test] + [TestMethod] public void AMin_EmptyArray_ThrowsArgumentException() { var empty = np.array(new double[0]); @@ -63,7 +63,7 @@ public void AMin_EmptyArray_ThrowsArgumentException() /// /// Verify error message matches NumPy's format. /// - [Test] + [TestMethod] public void Max_EmptyArray_ErrorMessageMatchesNumPy() { var empty = np.array(new double[0]); @@ -78,7 +78,7 @@ public void Max_EmptyArray_ErrorMessageMatchesNumPy() /// /// Verify error message matches NumPy's format. /// - [Test] + [TestMethod] public void Min_EmptyArray_ErrorMessageMatchesNumPy() { var empty = np.array(new double[0]); @@ -97,7 +97,7 @@ public void Min_EmptyArray_ErrorMessageMatchesNumPy() /// /// NumPy: np.sum(np.array([])) returns 0.0 (identity element for addition) /// - [Test] + [TestMethod] public void Sum_EmptyArray_ReturnsZero() { var empty = np.array(new double[0]); @@ -110,7 +110,7 @@ public void Sum_EmptyArray_ReturnsZero() /// /// NumPy: np.prod(np.array([])) returns 1.0 (identity element for multiplication) /// - [Test] + [TestMethod] public void Prod_EmptyArray_ReturnsOne() { var empty = np.array(new double[0]); @@ -127,7 +127,7 @@ public void Prod_EmptyArray_ReturnsOne() /// /// Verify non-empty arrays still work correctly for max. /// - [Test] + [TestMethod] public void Max_NonEmptyArray_ReturnsMax() { var arr = np.array(new double[] { 1.0, 5.0, 3.0 }); @@ -140,7 +140,7 @@ public void Max_NonEmptyArray_ReturnsMax() /// /// Verify non-empty arrays still work correctly for min. /// - [Test] + [TestMethod] public void Min_NonEmptyArray_ReturnsMin() { var arr = np.array(new double[] { 1.0, 5.0, 3.0 }); @@ -153,7 +153,7 @@ public void Min_NonEmptyArray_ReturnsMin() /// /// Single element array should work for max. /// - [Test] + [TestMethod] public void Max_SingleElementArray_ReturnsElement() { var arr = np.array(new double[] { 42.0 }); @@ -166,7 +166,7 @@ public void Max_SingleElementArray_ReturnsElement() /// /// Single element array should work for min. /// - [Test] + [TestMethod] public void Min_SingleElementArray_ReturnsElement() { var arr = np.array(new double[] { 42.0 }); @@ -183,7 +183,7 @@ public void Min_SingleElementArray_ReturnsElement() /// /// Empty int32 array should throw for max. /// - [Test] + [TestMethod] public void Max_EmptyInt32Array_ThrowsArgumentException() { var empty = np.array(new int[0]); @@ -194,7 +194,7 @@ public void Max_EmptyInt32Array_ThrowsArgumentException() /// /// Empty float32 array should throw for max. /// - [Test] + [TestMethod] public void Max_EmptyFloat32Array_ThrowsArgumentException() { var empty = np.array(new float[0]); diff --git a/test/NumSharp.UnitTest/Backends/Kernels/EmptyAxisReductionTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/EmptyAxisReductionTests.cs index 877885177..197edde3f 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/EmptyAxisReductionTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/EmptyAxisReductionTests.cs @@ -1,9 +1,6 @@ using System; using System.Threading.Tasks; using NumSharp; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels { @@ -11,277 +8,274 @@ namespace NumSharp.UnitTest.Backends.Kernels /// Tests for empty array axis reduction behavior. /// NumPy: np.sum(np.zeros((0,3)), axis=0) returns array([0., 0., 0.]) with shape (3,) /// + [TestClass] public class EmptyAxisReductionTests { #region Sum Tests - [Test] + [TestMethod] public async Task Sum_EmptyAxis0_ReturnsZerosWithReducedShape() { // NumPy: np.sum(np.zeros((0, 3)), axis=0) returns array([0., 0., 0.]) with shape (3,) var arr = np.zeros(new Shape(0, 3)); var result = np.sum(arr, axis: 0); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That(result.GetDouble(0)).IsEqualTo(0.0); - await Assert.That(result.GetDouble(1)).IsEqualTo(0.0); - await Assert.That(result.GetDouble(2)).IsEqualTo(0.0); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + result.GetDouble(0).Should().Be(0.0); + result.GetDouble(1).Should().Be(0.0); + result.GetDouble(2).Should().Be(0.0); } - [Test] + [TestMethod] public async Task Sum_EmptyAxis1_ReturnsEmptyArray() { // NumPy: np.sum(np.zeros((0, 3)), axis=1) returns array([]) with shape (0,) var arr = np.zeros(new Shape(0, 3)); var result = np.sum(arr, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 0 }); - await Assert.That(result.size).IsEqualTo(0); + result.shape.Should().BeEquivalentTo(new long[] { 0 }); + result.size.Should().Be(0); } - [Test] + [TestMethod] public async Task Sum_EmptyAxis0_Keepdims_ReturnsCorrectShape() { // NumPy: np.sum(np.zeros((0, 3)), axis=0, keepdims=True) returns shape (1, 3) var arr = np.zeros(new Shape(0, 3)); var result = np.sum(arr, axis: 0, keepdims: true); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 1, 3 }); + result.shape.Should().BeEquivalentTo(new long[] { 1, 3 }); } - [Test] + [TestMethod] public async Task Sum_EmptyAxis1_Keepdims_ReturnsCorrectShape() { // NumPy: np.sum(np.zeros((0, 3)), axis=1, keepdims=True) returns shape (0, 1) var arr = np.zeros(new Shape(0, 3)); var result = np.sum(arr, axis: 1, keepdims: true); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 0, 1 }); + result.shape.Should().BeEquivalentTo(new long[] { 0, 1 }); } - [Test] + [TestMethod] public async Task Sum_Empty3D_ReturnsCorrectShapes() { // NumPy: np.sum(np.zeros((2, 0, 4)), axis=1) returns shape (2, 4) var arr = np.zeros(new Shape(2, 0, 4)); var result = np.sum(arr, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 2, 4 }); - await Assert.That(result.size).IsEqualTo(8); + result.shape.Should().BeEquivalentTo(new long[] { 2, 4 }); + result.size.Should().Be(8); } #endregion #region Prod Tests - [Test] + [TestMethod] public async Task Prod_EmptyAxis0_ReturnsOnesWithReducedShape() { // NumPy: np.prod(np.zeros((0, 3)), axis=0) returns array([1., 1., 1.]) with shape (3,) var arr = np.zeros(new Shape(0, 3)); var result = np.prod(arr, axis: 0); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That(result.GetDouble(0)).IsEqualTo(1.0); - await Assert.That(result.GetDouble(1)).IsEqualTo(1.0); - await Assert.That(result.GetDouble(2)).IsEqualTo(1.0); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + result.GetDouble(0).Should().Be(1.0); + result.GetDouble(1).Should().Be(1.0); + result.GetDouble(2).Should().Be(1.0); } - [Test] + [TestMethod] public async Task Prod_EmptyAxis1_ReturnsEmptyArray() { // NumPy: np.prod(np.zeros((0, 3)), axis=1) returns array([]) with shape (0,) var arr = np.zeros(new Shape(0, 3)); var result = np.prod(arr, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 0 }); - await Assert.That(result.size).IsEqualTo(0); + result.shape.Should().BeEquivalentTo(new long[] { 0 }); + result.size.Should().Be(0); } #endregion #region Min/Max Tests - [Test] + [TestMethod] public async Task Min_EmptyAxis0_ThrowsArgumentException() { // NumPy: np.min(np.zeros((0, 3)), axis=0) raises ValueError var arr = np.zeros(new Shape(0, 3)); - await Assert.That(() => np.amin(arr, axis: 0)) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => np.amin(arr, axis: 0)); } - [Test] + [TestMethod] public async Task Min_EmptyAxis1_ReturnsEmptyArray() { // NumPy: np.min(np.zeros((0, 3)), axis=1) returns array([]) with shape (0,) var arr = np.zeros(new Shape(0, 3)); var result = np.amin(arr, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 0 }); - await Assert.That(result.size).IsEqualTo(0); + result.shape.Should().BeEquivalentTo(new long[] { 0 }); + result.size.Should().Be(0); } - [Test] + [TestMethod] public async Task Max_EmptyAxis0_ThrowsArgumentException() { // NumPy: np.max(np.zeros((0, 3)), axis=0) raises ValueError var arr = np.zeros(new Shape(0, 3)); - await Assert.That(() => np.amax(arr, axis: 0)) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => np.amax(arr, axis: 0)); } - [Test] + [TestMethod] public async Task Max_EmptyAxis1_ReturnsEmptyArray() { // NumPy: np.max(np.zeros((0, 3)), axis=1) returns array([]) with shape (0,) var arr = np.zeros(new Shape(0, 3)); var result = np.amax(arr, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 0 }); - await Assert.That(result.size).IsEqualTo(0); + result.shape.Should().BeEquivalentTo(new long[] { 0 }); + result.size.Should().Be(0); } #endregion #region ArgMax/ArgMin Tests - [Test] + [TestMethod] public async Task ArgMax_EmptyAxis0_ThrowsArgumentException() { // NumPy: np.argmax(np.zeros((0, 3)), axis=0) raises ValueError var arr = np.zeros(new Shape(0, 3)); - await Assert.That(() => np.argmax(arr, axis: 0)) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => np.argmax(arr, axis: 0)); } - [Test] + [TestMethod] public async Task ArgMax_EmptyAxis1_ReturnsEmptyArray() { // NumPy: np.argmax(np.zeros((0, 3)), axis=1) returns array([], dtype=int64) with shape (0,) var arr = np.zeros(new Shape(0, 3)); var result = np.argmax(arr, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 0 }); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.shape.Should().BeEquivalentTo(new long[] { 0 }); + result.size.Should().Be(0); + result.typecode.Should().Be(NPTypeCode.Int64); } - [Test] + [TestMethod] public async Task ArgMin_EmptyAxis0_ThrowsArgumentException() { // NumPy: np.argmin(np.zeros((0, 3)), axis=0) raises ValueError var arr = np.zeros(new Shape(0, 3)); - await Assert.That(() => np.argmin(arr, axis: 0)) - .Throws(); + Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowsException(() => np.argmin(arr, axis: 0)); } - [Test] + [TestMethod] public async Task ArgMin_EmptyAxis1_ReturnsEmptyArray() { // NumPy: np.argmin(np.zeros((0, 3)), axis=1) returns array([], dtype=int64) with shape (0,) var arr = np.zeros(new Shape(0, 3)); var result = np.argmin(arr, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 0 }); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.shape.Should().BeEquivalentTo(new long[] { 0 }); + result.size.Should().Be(0); + result.typecode.Should().Be(NPTypeCode.Int64); } #endregion #region Mean/Std/Var Tests - [Test] + [TestMethod] public async Task Mean_EmptyAxis0_ReturnsNaNArray() { // NumPy: np.mean(np.zeros((0, 3)), axis=0) returns array([nan, nan, nan]) var arr = np.zeros(new Shape(0, 3)); var result = np.mean(arr, axis: 0); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That(double.IsNaN(result.GetDouble(0))).IsTrue(); - await Assert.That(double.IsNaN(result.GetDouble(1))).IsTrue(); - await Assert.That(double.IsNaN(result.GetDouble(2))).IsTrue(); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + double.IsNaN(result.GetDouble(0)).Should().BeTrue(); + double.IsNaN(result.GetDouble(1)).Should().BeTrue(); + double.IsNaN(result.GetDouble(2)).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Mean_EmptyAxis1_ReturnsEmptyArray() { // NumPy: np.mean(np.zeros((0, 3)), axis=1) returns array([]) with shape (0,) var arr = np.zeros(new Shape(0, 3)); var result = np.mean(arr, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 0 }); - await Assert.That(result.size).IsEqualTo(0); + result.shape.Should().BeEquivalentTo(new long[] { 0 }); + result.size.Should().Be(0); } - [Test] + [TestMethod] public async Task Std_EmptyAxis0_ReturnsNaNArray() { // NumPy: np.std(np.zeros((0, 3)), axis=0) returns array([nan, nan, nan]) var arr = np.zeros(new Shape(0, 3)); var result = np.std(arr, axis: 0); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That(double.IsNaN(result.GetDouble(0))).IsTrue(); - await Assert.That(double.IsNaN(result.GetDouble(1))).IsTrue(); - await Assert.That(double.IsNaN(result.GetDouble(2))).IsTrue(); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + double.IsNaN(result.GetDouble(0)).Should().BeTrue(); + double.IsNaN(result.GetDouble(1)).Should().BeTrue(); + double.IsNaN(result.GetDouble(2)).Should().BeTrue(); } - [Test] + [TestMethod] public async Task Var_EmptyAxis0_ReturnsNaNArray() { // NumPy: np.var(np.zeros((0, 3)), axis=0) returns array([nan, nan, nan]) var arr = np.zeros(new Shape(0, 3)); var result = np.var(arr, axis: 0); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That(double.IsNaN(result.GetDouble(0))).IsTrue(); - await Assert.That(double.IsNaN(result.GetDouble(1))).IsTrue(); - await Assert.That(double.IsNaN(result.GetDouble(2))).IsTrue(); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + double.IsNaN(result.GetDouble(0)).Should().BeTrue(); + double.IsNaN(result.GetDouble(1)).Should().BeTrue(); + double.IsNaN(result.GetDouble(2)).Should().BeTrue(); } #endregion #region Edge Cases - [Test] + [TestMethod] public async Task Sum_Reversed_EmptyAxis() { // NumPy: np.sum(np.zeros((3, 0)), axis=1) returns array([0., 0., 0.]) with shape (3,) var arr = np.zeros(new Shape(3, 0)); var result = np.sum(arr, axis: 1); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That(result.GetDouble(0)).IsEqualTo(0.0); - await Assert.That(result.GetDouble(1)).IsEqualTo(0.0); - await Assert.That(result.GetDouble(2)).IsEqualTo(0.0); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + result.GetDouble(0).Should().Be(0.0); + result.GetDouble(1).Should().Be(0.0); + result.GetDouble(2).Should().Be(0.0); } - [Test] + [TestMethod] public async Task Sum_NoAxis_EmptyArray_ReturnsScalar() { // NumPy: np.sum(np.zeros((0,))) returns 0.0 var arr = np.zeros(new Shape(0)); var result = np.sum(arr); - await Assert.That(result.shape).IsEquivalentTo(Array.Empty()); - await Assert.That((double)result).IsEqualTo(0.0); + result.shape.Should().BeEquivalentTo(Array.Empty()); + ((double)result).Should().Be(0.0); } - [Test] + [TestMethod] public async Task Prod_NoAxis_EmptyArray_ReturnsOne() { // NumPy: np.prod(np.zeros((0,))) returns 1.0 var arr = np.zeros(new Shape(0)); var result = np.prod(arr); - await Assert.That((double)result).IsEqualTo(1.0); + ((double)result).Should().Be(1.0); } #endregion diff --git a/test/NumSharp.UnitTest/Backends/Kernels/ILKernelGenerator.LargeArray.BattleTest.cs b/test/NumSharp.UnitTest/Backends/Kernels/ILKernelGenerator.LargeArray.BattleTest.cs index ee45cd8d2..164ef14ee 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/ILKernelGenerator.LargeArray.BattleTest.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/ILKernelGenerator.LargeArray.BattleTest.cs @@ -3,9 +3,6 @@ using System.Threading.Tasks; using NumSharp; using NumSharp.UnitTest; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -29,7 +26,7 @@ public class ILKernelGenerator_LargeArray_BattleTest #region Binary Operations - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Binary_Add_LargeByteArray() { // Two 1.4B byte arrays = 2.8GB total @@ -39,19 +36,19 @@ public async Task Binary_Add_LargeByteArray() var result = a + b; // Verify first, middle, and last elements - await Assert.That((byte)result[0]).IsEqualTo((byte)2); - await Assert.That((byte)result[DualArraySize / 2]).IsEqualTo((byte)2); - await Assert.That((byte)result[DualArraySize - 1]).IsEqualTo((byte)2); + ((byte)result[0]).Should().Be((byte)2); + ((byte)result[DualArraySize / 2]).Should().Be((byte)2); + ((byte)result[DualArraySize - 1]).Should().Be((byte)2); // Verify element beyond int.MaxValue long beyondIntMax = (long)int.MaxValue + 1000; if (beyondIntMax < DualArraySize) { - await Assert.That((byte)result[beyondIntMax]).IsEqualTo((byte)2); + ((byte)result[beyondIntMax]).Should().Be((byte)2); } } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Binary_Subtract_LargeByteArray() { var a = np.full(new Shape(DualArraySize), (byte)10, NPTypeCode.Byte); @@ -59,17 +56,17 @@ public async Task Binary_Subtract_LargeByteArray() var result = a - b; - await Assert.That((byte)result[0]).IsEqualTo((byte)9); - await Assert.That((byte)result[DualArraySize - 1]).IsEqualTo((byte)9); + ((byte)result[0]).Should().Be((byte)9); + ((byte)result[DualArraySize - 1]).Should().Be((byte)9); long beyondIntMax = (long)int.MaxValue + 1000; if (beyondIntMax < DualArraySize) { - await Assert.That((byte)result[beyondIntMax]).IsEqualTo((byte)9); + ((byte)result[beyondIntMax]).Should().Be((byte)9); } } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Binary_Multiply_LargeByteArray() { var a = np.full(new Shape(DualArraySize), (byte)2, NPTypeCode.Byte); @@ -77,15 +74,15 @@ public async Task Binary_Multiply_LargeByteArray() var result = a * b; - await Assert.That((byte)result[0]).IsEqualTo((byte)6); - await Assert.That((byte)result[DualArraySize - 1]).IsEqualTo((byte)6); + ((byte)result[0]).Should().Be((byte)6); + ((byte)result[DualArraySize - 1]).Should().Be((byte)6); } #endregion #region Unary Operations - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Unary_Negate_LargeInt16Array() { // Int16: 1.4B elements = 2.8GB @@ -93,32 +90,32 @@ public async Task Unary_Negate_LargeInt16Array() var result = -a; - await Assert.That((short)result[0]).IsEqualTo((short)-1); - await Assert.That((short)result[DualArraySize - 1]).IsEqualTo((short)-1); + ((short)result[0]).Should().Be((short)-1); + ((short)result[DualArraySize - 1]).Should().Be((short)-1); long beyondIntMax = (long)int.MaxValue + 1000; if (beyondIntMax < DualArraySize) { - await Assert.That((short)result[beyondIntMax]).IsEqualTo((short)-1); + ((short)result[beyondIntMax]).Should().Be((short)-1); } } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Unary_Abs_LargeInt16Array() { var a = np.full(new Shape(DualArraySize), (short)-5, NPTypeCode.Int16); var result = np.abs(a); - await Assert.That((short)result[0]).IsEqualTo((short)5); - await Assert.That((short)result[DualArraySize - 1]).IsEqualTo((short)5); + ((short)result[0]).Should().Be((short)5); + ((short)result[DualArraySize - 1]).Should().Be((short)5); } #endregion #region Reduction Operations - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Reduction_Sum_LargeByteArray() { // All ones - sum should equal size @@ -127,10 +124,10 @@ public async Task Reduction_Sum_LargeByteArray() // Sum of bytes promotes to int64 var result = np.sum(a); - await Assert.That((long)result).IsEqualTo(LargeSize); + ((long)result).Should().Be(LargeSize); } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Reduction_Min_LargeByteArray() { var a = np.ones(new Shape(LargeSize), NPTypeCode.Byte); @@ -140,10 +137,10 @@ public async Task Reduction_Min_LargeByteArray() var result = np.min(a); - await Assert.That((byte)result).IsEqualTo((byte)0); + ((byte)result).Should().Be((byte)0); } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Reduction_Max_LargeByteArray() { var a = np.zeros(new Shape(LargeSize), NPTypeCode.Byte); @@ -153,10 +150,10 @@ public async Task Reduction_Max_LargeByteArray() var result = np.max(a); - await Assert.That((byte)result).IsEqualTo((byte)255); + ((byte)result).Should().Be((byte)255); } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Reduction_Mean_LargeByteArray() { // All ones - mean should be 1.0 @@ -164,10 +161,10 @@ public async Task Reduction_Mean_LargeByteArray() var result = np.mean(a); - await Assert.That((double)result).IsEqualTo(1.0); + ((double)result).Should().Be(1.0); } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Reduction_Any_LargeByteArray() { var a = np.zeros(new Shape(LargeSize), NPTypeCode.Byte); @@ -177,17 +174,17 @@ public async Task Reduction_Any_LargeByteArray() var result = np.any(a); - await Assert.That((bool)result).IsTrue(); + ((bool)result).Should().BeTrue(); } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Reduction_All_LargeByteArray() { var a = np.ones(new Shape(LargeSize), NPTypeCode.Byte); var result = np.all(a); - await Assert.That((bool)result).IsTrue(); + ((bool)result).Should().BeTrue(); // Now set one element to 0 and verify all returns false long targetIdx = (long)int.MaxValue + 50000; @@ -195,14 +192,14 @@ public async Task Reduction_All_LargeByteArray() result = np.all(a); - await Assert.That((bool)result).IsFalse(); + ((bool)result).Should().BeFalse(); } #endregion #region Comparison Operations - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Comparison_Equal_LargeByteArray() { var a = np.ones(new Shape(DualArraySize), NPTypeCode.Byte); @@ -217,7 +214,7 @@ public async Task Comparison_Equal_LargeByteArray() var result = np.array_equal(a, b); - await Assert.That(result).IsFalse(); + result.Should().BeFalse(); // Fix it and verify equal if (targetIdx < DualArraySize) @@ -227,10 +224,10 @@ public async Task Comparison_Equal_LargeByteArray() result = np.array_equal(a, b); - await Assert.That(result).IsTrue(); + result.Should().BeTrue(); } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Comparison_Greater_LargeByteArray() { var a = np.full(new Shape(DualArraySize), (byte)5, NPTypeCode.Byte); @@ -239,13 +236,13 @@ public async Task Comparison_Greater_LargeByteArray() var result = a > b; // All should be true - await Assert.That((bool)result[0]).IsTrue(); - await Assert.That((bool)result[DualArraySize - 1]).IsTrue(); + ((bool)result[0]).Should().BeTrue(); + ((bool)result[DualArraySize - 1]).Should().BeTrue(); long beyondIntMax = (long)int.MaxValue + 1000; if (beyondIntMax < DualArraySize) { - await Assert.That((bool)result[beyondIntMax]).IsTrue(); + ((bool)result[beyondIntMax]).Should().BeTrue(); } } @@ -253,7 +250,7 @@ public async Task Comparison_Greater_LargeByteArray() #region Clip Operations - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Clip_LargeByteArray() { var a = np.arange(0, 256, 1, NPTypeCode.Byte); @@ -270,20 +267,20 @@ public async Task Clip_LargeByteArray() var result = np.clip(large, (byte)5, (byte)200); // 0 should be clipped to 5 - await Assert.That((byte)result[0]).IsEqualTo((byte)5); + ((byte)result[0]).Should().Be((byte)5); // 10 should stay 10 - await Assert.That((byte)result[idx1]).IsEqualTo((byte)10); + ((byte)result[idx1]).Should().Be((byte)10); // 250 should be clipped to 200 - await Assert.That((byte)result[idx2]).IsEqualTo((byte)200); + ((byte)result[idx2]).Should().Be((byte)200); } #endregion #region Indexing Beyond int.MaxValue - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Indexing_SetGet_BeyondIntMaxValue() { var a = np.zeros(new Shape(LargeSize), NPTypeCode.Byte); @@ -307,7 +304,7 @@ public async Task Indexing_SetGet_BeyondIntMaxValue() // Verify values for (int i = 0; i < testIndices.Length; i++) { - await Assert.That((byte)a[testIndices[i]]).IsEqualTo((byte)(i + 1)); + ((byte)a[testIndices[i]]).Should().Be((byte)(i + 1)); } } @@ -315,7 +312,7 @@ public async Task Indexing_SetGet_BeyondIntMaxValue() #region Slicing with Large Offsets - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Slicing_ViewBeyondIntMaxValue() { var a = np.zeros(new Shape(LargeSize), NPTypeCode.Byte); @@ -331,20 +328,20 @@ public async Task Slicing_ViewBeyondIntMaxValue() var slice = a[$"{start}:{stop}"]; // The target element should be at index 10 in the slice - await Assert.That((byte)slice[10]).IsEqualTo((byte)42); + ((byte)slice[10]).Should().Be((byte)42); // Modify through slice slice[10] = (byte)99; // Verify original array is modified (view semantics) - await Assert.That((byte)a[targetIdx]).IsEqualTo((byte)99); + ((byte)a[targetIdx]).Should().Be((byte)99); } #endregion #region Large Stride Operations (stride > int.MaxValue) - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Reduction_Sum_LargeStride() { // Create a 2D array where stride along axis 0 exceeds int.MaxValue @@ -367,14 +364,14 @@ public async Task Reduction_Sum_LargeStride() var sliced = a[$"0:{LargeSize}:{step}"]; // Should have 3 elements (0, 1B, 2B) - await Assert.That(sliced.size).IsEqualTo(3); + sliced.size.Should().Be(3); // Sum should be 3 var sum = np.sum(sliced); - await Assert.That((long)sum).IsEqualTo(3); + ((long)sum).Should().Be(3); } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Binary_Add_SlicedWithLargeStep() { var a = np.ones(new Shape(LargeSize), NPTypeCode.Byte); @@ -386,16 +383,16 @@ public async Task Binary_Add_SlicedWithLargeStep() var bSliced = b[$"0:{LargeSize}:{step}"]; // Should have 2 elements (0, ~2.1B) - await Assert.That(aSliced.size).IsEqualTo(2); + aSliced.size.Should().Be(2); // Add sliced arrays - tests binary ops with large strides var result = aSliced + bSliced; - await Assert.That((byte)result[0]).IsEqualTo((byte)2); - await Assert.That((byte)result[1]).IsEqualTo((byte)2); + ((byte)result[0]).Should().Be((byte)2); + ((byte)result[1]).Should().Be((byte)2); } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Reduction_Max_SlicedWithLargeStride() { var a = np.zeros(new Shape(LargeSize), NPTypeCode.Byte); @@ -417,14 +414,14 @@ public async Task Reduction_Max_SlicedWithLargeStride() sliced = a[$"0:{LargeSize}:{step}"]; var max = np.max(sliced); - await Assert.That((byte)max).IsEqualTo((byte)99); + ((byte)max).Should().Be((byte)99); } #endregion #region Float/Double Operations (smaller arrays due to element size) - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Binary_Add_LargeFloatArray() { // Float: 4 bytes per element @@ -440,12 +437,12 @@ public async Task Binary_Add_LargeFloatArray() var result = a + b; - await Assert.That((float)result[0]).IsEqualTo(2.0f); - await Assert.That((float)result[floatSize - 1]).IsEqualTo(2.0f); - await Assert.That((float)result[floatSize / 2]).IsEqualTo(2.0f); + ((float)result[0]).Should().Be(2.0f); + ((float)result[floatSize - 1]).Should().Be(2.0f); + ((float)result[floatSize / 2]).Should().Be(2.0f); } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public async Task Reduction_Sum_LargeFloatArray() { long floatSize = 500_000_000L; // 2GB @@ -454,7 +451,7 @@ public async Task Reduction_Sum_LargeFloatArray() var result = np.sum(a); // Due to float precision, just verify it's close - await Assert.That(Math.Abs((double)result - (double)floatSize)).IsLessThan(floatSize * 0.001); + Math.Abs((double)result - ((double)floatSize)).Should().BeLessThan(floatSize * 0.001); } #endregion diff --git a/test/NumSharp.UnitTest/Backends/Kernels/IndexingEdgeCaseTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/IndexingEdgeCaseTests.cs index d11d24a67..cb6945668 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/IndexingEdgeCaseTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/IndexingEdgeCaseTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -10,11 +9,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Edge case tests for array indexing operations. /// All expected values are verified against NumPy 2.x output. /// +[TestClass] public class IndexingEdgeCaseTests { #region Negative Indexing - [Test] + [TestMethod] public void NegativeIndex_Last() { // NumPy: arr[-1] = 5 @@ -23,7 +23,7 @@ public void NegativeIndex_Last() Assert.AreEqual(5, arr[-1].GetInt32(0)); } - [Test] + [TestMethod] public void NegativeIndex_First() { // NumPy: arr[-5] = 1 (same as arr[0] for 5-element array) @@ -32,7 +32,7 @@ public void NegativeIndex_First() Assert.AreEqual(1, arr[-5].GetInt32(0)); } - [Test] + [TestMethod] public void NegativeSlice_LastN() { // NumPy: arr[-3:] = [3, 4, 5] @@ -43,7 +43,7 @@ public void NegativeSlice_LastN() result.Should().BeOfValues(3, 4, 5); } - [Test] + [TestMethod] public void NegativeSlice_ExcludeLastN() { // NumPy: arr[:-3] = [1, 2] @@ -54,7 +54,7 @@ public void NegativeSlice_ExcludeLastN() result.Should().BeOfValues(1, 2); } - [Test] + [TestMethod] public void NegativeSlice_Range() { // NumPy: arr[-4:-1] = [2, 3, 4] @@ -65,7 +65,7 @@ public void NegativeSlice_Range() result.Should().BeOfValues(2, 3, 4); } - [Test] + [TestMethod] public void NegativeSlice_ReversePartial() { // NumPy: arr[-1:-4:-1] = [5, 4, 3] @@ -76,7 +76,7 @@ public void NegativeSlice_ReversePartial() result.Should().BeOfValues(5, 4, 3); } - [Test] + [TestMethod] public void NegativeSlice_2D_Corner() { // NumPy: arr2d[-2:, -2:] = [[6,7], [10,11]] @@ -90,7 +90,7 @@ public void NegativeSlice_2D_Corner() Assert.AreEqual(11L, result.GetInt64(1, 1)); } - [Test] + [TestMethod] public void NegativeSlice_2D_FullReverse() { // NumPy: arr2d[::-1, ::-1] reverses both axes @@ -106,7 +106,7 @@ public void NegativeSlice_2D_FullReverse() #region Boolean Indexing - [Test] + [TestMethod] public void BooleanIndex_Simple() { // NumPy: arr[mask] = [1, 3, 5] @@ -118,7 +118,7 @@ public void BooleanIndex_Simple() result.Should().BeOfValues(1, 3, 5); } - [Test] + [TestMethod] public void BooleanIndex_Condition() { // NumPy: arr[arr > 3] = [4, 5, 6] @@ -129,7 +129,7 @@ public void BooleanIndex_Condition() result.Should().BeOfValues(4, 5, 6); } - [Test] + [TestMethod] public void BooleanIndex_EvenNumbers() { // NumPy: arr[arr % 2 == 0] = [2, 4, 6] @@ -140,7 +140,7 @@ public void BooleanIndex_EvenNumbers() result.Should().BeOfValues(2, 4, 6); } - [Test] + [TestMethod] public void BooleanIndex_2D_Flattens() { // NumPy: arr2d[arr2d > 5] = [6, 7, 8, 9, 10, 11] (flattened!) @@ -153,7 +153,7 @@ public void BooleanIndex_2D_Flattens() Assert.AreEqual(6L, result.GetInt64(0)); } - [Test] + [TestMethod] public void BooleanIndex_RowSelection() { // NumPy: arr2d[[True, False, True]] selects rows 0 and 2 @@ -172,7 +172,7 @@ public void BooleanIndex_RowSelection() #region Fancy Indexing - [Test] + [TestMethod] public void FancyIndex_Simple() { // NumPy: arr[[0, 2, 4]] = [10, 30, 50] @@ -184,7 +184,7 @@ public void FancyIndex_Simple() result.Should().BeOfValues(10, 30, 50); } - [Test] + [TestMethod] public void FancyIndex_NegativeIndices() { // NumPy: arr[[-1, -3, -5]] = [50, 30, 10] @@ -196,7 +196,7 @@ public void FancyIndex_NegativeIndices() result.Should().BeOfValues(50, 30, 10); } - [Test] + [TestMethod] public void FancyIndex_Repeated() { // NumPy: arr[[0, 0, 1, 1, 2]] = [10, 10, 20, 20, 30] @@ -208,7 +208,7 @@ public void FancyIndex_Repeated() result.Should().BeOfValues(10, 10, 20, 20, 30); } - [Test] + [TestMethod] public void FancyIndex_2D_Diagonal() { // NumPy: arr2d[[0,1,2], [0,1,2]] = [0, 5, 10] (diagonal) @@ -225,7 +225,7 @@ public void FancyIndex_2D_Diagonal() #region Ellipsis - [Test] + [TestMethod] public void Ellipsis_3D_Last() { // NumPy: arr3d[..., 0].shape = (2, 3) @@ -238,7 +238,7 @@ public void Ellipsis_3D_Last() Assert.AreEqual(3, result.shape[1]); } - [Test] + [TestMethod] public void Ellipsis_3D_First() { // NumPy: arr3d[0, ...].shape = (3, 4) @@ -255,7 +255,7 @@ public void Ellipsis_3D_First() #region Combined Indexing - [Test] + [TestMethod] public void Combined_SliceAndInteger() { // NumPy: arr2d[1:, 0] = [4, 8] @@ -267,7 +267,7 @@ public void Combined_SliceAndInteger() result.Should().BeOfValues(4, 8); } - [Test] + [TestMethod] public void Combined_IntegerAndSlice() { // NumPy: arr2d[0, 1:3] = [1, 2] @@ -283,7 +283,7 @@ public void Combined_IntegerAndSlice() #region Indexing Assignment - [Test] + [TestMethod] public void Assignment_SingleElement() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -293,7 +293,7 @@ public void Assignment_SingleElement() arr.Should().BeOfValues(1, 2, 100, 4, 5); } - [Test] + [TestMethod] public void Assignment_Slice() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -303,7 +303,7 @@ public void Assignment_Slice() arr.Should().BeOfValues(1, 10, 20, 30, 5); } - [Test] + [TestMethod] public void Assignment_SliceWithScalar() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -313,7 +313,7 @@ public void Assignment_SliceWithScalar() arr.Should().BeOfValues(1, 99, 99, 99, 5); } - [Test] + [TestMethod] public void Assignment_FancyIndex() { // NumPy: arr[[0, 2, 4]] = 99 -> [99, 2, 99, 4, 99] @@ -325,7 +325,7 @@ public void Assignment_FancyIndex() arr.Should().BeOfValues(99, 2, 99, 4, 99); } - [Test] + [TestMethod] public void Assignment_BooleanMask() { // NumPy: arr[arr > 3] = 0 -> [1, 2, 3, 0, 0] @@ -340,7 +340,7 @@ public void Assignment_BooleanMask() #region Edge Cases - [Test] + [TestMethod] public void EmptySlice() { // NumPy: arr[2:2] = [] (empty) @@ -351,7 +351,7 @@ public void EmptySlice() Assert.AreEqual(0, result.size); } - [Test] + [TestMethod] public void StepGreaterThanSize() { // NumPy: arr[::10] = [1] (only first element) @@ -363,7 +363,7 @@ public void StepGreaterThanSize() Assert.AreEqual(1, result.GetInt32(0)); } - [Test] + [TestMethod] public void ReverseWithStep() { // NumPy: arr[4:0:-2] = [5, 3] diff --git a/test/NumSharp.UnitTest/Backends/Kernels/KernelMisalignmentTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/KernelMisalignmentTests.cs index b6826e7f0..bc38097e9 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/KernelMisalignmentTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/KernelMisalignmentTests.cs @@ -1,7 +1,6 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -9,13 +8,14 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Tests documenting NumSharp vs NumPy misalignments in kernel operations. /// These tests verify current NumSharp behavior which differs from NumPy. /// +[TestClass] public class KernelMisalignmentTests { /// /// NumPy: np.square(np.int32(3)) -> int32(9) (preserves dtype) /// NumSharp: np.square(3) -> int32(9) (preserves dtype) - FIXED /// - [Test] + [TestMethod] public void Square_IntegerInput_PreservesDtype() { // NumPy behavior: preserves int32 dtype @@ -35,7 +35,7 @@ public void Square_IntegerInput_PreservesDtype() /// NumPy: np.square([1, 2, 3]) -> array([1, 4, 9], dtype=int32) /// NumSharp: np.square([1, 2, 3]) -> array([1, 4, 9], dtype=int32) - FIXED /// - [Test] + [TestMethod] public void Square_IntegerArray_PreservesDtype() { // NumPy behavior: @@ -58,7 +58,7 @@ public void Square_IntegerArray_PreservesDtype() /// NumPy: np.invert(True) -> False (logical NOT for boolean) /// NumSharp: np.invert(true) -> False (logical NOT) - FIXED /// - [Test] + [TestMethod] public void Invert_Boolean_LogicalNot() { // NumPy behavior: @@ -79,7 +79,7 @@ public void Invert_Boolean_LogicalNot() /// NumPy: np.invert(np.array([True, False])) -> array([False, True]) /// NumSharp: np.invert([true, false]) -> [False, True] - FIXED /// - [Test] + [TestMethod] public void Invert_BooleanArray_LogicalNot() { // NumPy behavior: @@ -99,7 +99,7 @@ public void Invert_BooleanArray_LogicalNot() /// /// Verify np.square works correctly for floating point (no misalignment). /// - [Test] + [TestMethod] public void Square_FloatingPoint_Correct() { // Float input preserves float @@ -116,7 +116,7 @@ public void Square_FloatingPoint_Correct() /// /// Verify np.invert works correctly for integers (no misalignment). /// - [Test] + [TestMethod] public void Invert_Integer_Correct() { // NumPy: np.invert(0) -> -1 @@ -136,7 +136,7 @@ public void Invert_Integer_Correct() /// to floating point for reciprocal, while NumPy preserves integer dtype /// and uses floor division. /// - [Test] + [TestMethod] [Misaligned] public void Reciprocal_Integer_TypePromotion() { @@ -162,7 +162,7 @@ public void Reciprocal_Integer_TypePromotion() /// /// Verify np.reciprocal floating point is correct. /// - [Test] + [TestMethod] public void Reciprocal_FloatingPoint_Correct() { // NumPy: np.reciprocal(2.0) -> 0.5 diff --git a/test/NumSharp.UnitTest/Backends/Kernels/LinearAlgebraTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/LinearAlgebraTests.cs index 95d686d08..01e51a769 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/LinearAlgebraTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/LinearAlgebraTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -10,11 +9,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Tests for linear algebra operations. /// All expected values are verified against NumPy 2.x output. /// +[TestClass] public class LinearAlgebraTests { #region Dot Product - [Test] + [TestMethod] public void Dot_1D_1D() { // NumPy: np.dot([1,2,3], [4,5,6]) = 32 @@ -26,7 +26,7 @@ public void Dot_1D_1D() Assert.AreEqual(32.0, (double)result, 1e-10); } - [Test] + [TestMethod] public void Dot_2D_1D() { // NumPy: np.dot([[1,2],[3,4],[5,6]], [1,2]) = [5, 11, 17] @@ -42,7 +42,7 @@ public void Dot_2D_1D() Assert.AreEqual(17.0, result.GetDouble(2), 1e-10); } - [Test] + [TestMethod] public void Dot_1D_2D() { // NumPy: np.dot([1,2,3], [[1,2],[3,4],[5,6]]) = [22, 28] @@ -57,7 +57,7 @@ public void Dot_1D_2D() Assert.AreEqual(28.0, result.GetDouble(1), 1e-10); } - [Test] + [TestMethod] public void Dot_1D_2D_Float64() { // NumPy: np.dot([1.5, 2.5], [[1,2,3],[4,5,6]]) = [11.5, 15.5, 19.5] @@ -74,7 +74,7 @@ public void Dot_1D_2D_Float64() Assert.AreEqual(19.5, result.GetDouble(2), 1e-10); } - [Test] + [TestMethod] public void Dot_1D_2D_SingleColumn() { // NumPy: np.dot([1,2,3], [[10],[20],[30]]) = [140] @@ -88,7 +88,7 @@ public void Dot_1D_2D_SingleColumn() Assert.AreEqual(140, result.GetInt32(0)); } - [Test] + [TestMethod] public void Dot_1D_2D_ShapeMismatch_Throws() { // NumPy: ValueError: shapes (3,) and (1,3) not aligned @@ -99,7 +99,7 @@ public void Dot_1D_2D_ShapeMismatch_Throws() Assert.IsTrue(ex.Message.Contains("not aligned")); } - [Test] + [TestMethod] public void Dot_1D_2D_NegativeValues() { // NumPy: np.dot([-1,2,-3], [[1,-2],[-3,4],[5,-6]]) = [-22, 28] @@ -112,7 +112,7 @@ public void Dot_1D_2D_NegativeValues() Assert.AreEqual(28, result.GetInt32(1)); } - [Test] + [TestMethod] public void Dot_1D_2D_Larger() { // NumPy: np.dot([1,2,3,4,5], arange(15).reshape(5,3)) = [120, 135, 150] @@ -128,7 +128,7 @@ public void Dot_1D_2D_Larger() Assert.AreEqual(150L, result.GetInt64(2)); } - [Test] + [TestMethod] public void Dot_1D_2D_SingleElement() { // NumPy: np.dot([5], [[1,2,3]]) = [5, 10, 15] @@ -144,7 +144,7 @@ public void Dot_1D_2D_SingleElement() Assert.AreEqual(15, result.GetInt32(2)); } - [Test] + [TestMethod] public void Dot_1D_2D_WithZeros() { // NumPy: np.dot([0,1,0], [[1,2],[3,4],[5,6]]) = [3, 4] @@ -157,7 +157,7 @@ public void Dot_1D_2D_WithZeros() Assert.AreEqual(4, result.GetInt32(1)); } - [Test] + [TestMethod] public void Dot_1D_2D_MixedDtypes_IntFloat() { // NumPy: int32 x float64 -> float64 @@ -171,7 +171,7 @@ public void Dot_1D_2D_MixedDtypes_IntFloat() Assert.AreEqual(16.0, result.GetDouble(1), 1e-10); } - [Test] + [TestMethod] public void Dot_1D_2D_Int64() { // NumPy: int64 x int64 -> int64 @@ -185,7 +185,7 @@ public void Dot_1D_2D_Int64() Assert.AreEqual(16L, result.GetInt64(1)); } - [Test] + [TestMethod] public void Dot_2D_2D() { // NumPy: [[1,2],[3,4],[5,6]] @ [[1,2,3],[4,5,6]] = [[9,12,15],[19,26,33],[29,40,51]] @@ -202,7 +202,7 @@ public void Dot_2D_2D() Assert.AreEqual(51.0, result.GetDouble(2, 2), 1e-10); } - [Test] + [TestMethod] public void Dot_Empty() { // NumPy: np.dot([], []) = 0.0 @@ -218,7 +218,7 @@ public void Dot_Empty() #region Matmul - [Test] + [TestMethod] public void Matmul_2D_2D() { // NumPy: A @ B (same as dot for 2D) @@ -233,7 +233,7 @@ public void Matmul_2D_2D() Assert.AreEqual(50.0, result.GetDouble(1, 1), 1e-10); } - [Test] + [TestMethod] [OpenBugs] // 3D matmul broadcasting fails public void Matmul_3D_2D_Broadcasting() { @@ -254,7 +254,7 @@ public void Matmul_3D_2D_Broadcasting() #region Outer Product - [Test] + [TestMethod] public void Outer_Simple() { // NumPy: np.outer([1,2,3], [10,20]) = [[10,20],[20,40],[30,60]] @@ -275,7 +275,7 @@ public void Outer_Simple() #region Identity and Eye - [Test] + [TestMethod] public void Eye_Square() { // NumPy: np.eye(3) = [[1,0,0],[0,1,0],[0,0,1]] @@ -289,7 +289,7 @@ public void Eye_Square() Assert.AreEqual(1.0, result.GetDouble(2, 2), 1e-10); } - [Test] + [TestMethod] public void Eye_Rectangular() { // NumPy: np.eye(3, 4) @@ -305,7 +305,7 @@ public void Eye_Rectangular() #region Statistics-Based Linear Algebra - [Test] + [TestMethod] public void Mean_2D_Axis0() { // NumPy: np.mean([[1,2,3],[4,5,6]], axis=0) = [2.5, 3.5, 4.5] @@ -320,7 +320,7 @@ public void Mean_2D_Axis0() Assert.AreEqual(4.5, result.GetDouble(2), 1e-10); } - [Test] + [TestMethod] public void Mean_2D_Axis1() { // NumPy: np.mean([[1,2,3],[4,5,6]], axis=1) = [2.0, 5.0] @@ -334,7 +334,7 @@ public void Mean_2D_Axis1() Assert.AreEqual(5.0, result.GetDouble(1), 1e-10); } - [Test] + [TestMethod] public void Std_Sample() { // NumPy: np.std([1, 2, 3, 4, 5]) = 1.4142... (population std) @@ -345,7 +345,7 @@ public void Std_Sample() Assert.AreEqual(Math.Sqrt(2.0), result.GetDouble(0), 1e-10); } - [Test] + [TestMethod] public void Std_WithDdof() { // NumPy: np.std([1, 2, 3, 4, 5], ddof=1) = 1.5811... (sample std) @@ -361,7 +361,7 @@ public void Std_WithDdof() #region Argmax/Argmin with Axis - [Test] + [TestMethod] public void Argmax_NoAxis() { // NumPy: np.argmax([[1,5,3],[4,2,6]]) = 5 (flattened index) @@ -372,7 +372,7 @@ public void Argmax_NoAxis() Assert.AreEqual(5, result); } - [Test] + [TestMethod] public void Argmax_Axis0() { // NumPy: np.argmax([[1,5,3],[4,2,6]], axis=0) = [1, 0, 1] @@ -383,7 +383,7 @@ public void Argmax_Axis0() result.Should().BeOfValues(1, 0, 1); } - [Test] + [TestMethod] public void Argmax_Axis1() { // NumPy: np.argmax([[1,5,3],[4,2,6]], axis=1) = [1, 2] @@ -394,7 +394,7 @@ public void Argmax_Axis1() result.Should().BeOfValues(1, 2); } - [Test] + [TestMethod] public void Argmin_NoAxis() { // NumPy: np.argmin([[1,5,3],[4,2,6]]) = 0 @@ -405,7 +405,7 @@ public void Argmin_NoAxis() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void Argmin_Axis0() { // NumPy: np.argmin([[1,5,3],[4,2,6]], axis=0) = [0, 1, 0] @@ -420,7 +420,7 @@ public void Argmin_Axis0() #region Cumsum with Axis - [Test] + [TestMethod] public void Cumsum_NoAxis_Flattens() { // NumPy: np.cumsum([[1,2,3],[4,5,6]]) = [1,3,6,10,15,21] @@ -433,7 +433,7 @@ public void Cumsum_NoAxis_Flattens() result.Should().BeOfValues(1L, 3L, 6L, 10L, 15L, 21L); } - [Test] + [TestMethod] public void Cumsum_Axis0() { // NumPy: np.cumsum([[1,2,3],[4,5,6]], axis=0) = [[1,2,3],[5,7,9]] @@ -448,7 +448,7 @@ public void Cumsum_Axis0() Assert.AreEqual(9L, result.GetInt64(1, 2)); } - [Test] + [TestMethod] public void Cumsum_Axis1() { // NumPy: np.cumsum([[1,2,3],[4,5,6]], axis=1) = [[1,3,6],[4,9,15]] @@ -467,7 +467,7 @@ public void Cumsum_Axis1() #region Searchsorted - [Test] + [TestMethod] public void Searchsorted_Simple() { // NumPy: np.searchsorted([1,2,3,4,5], 3) = 2 @@ -478,7 +478,7 @@ public void Searchsorted_Simple() Assert.AreEqual(2, result); } - [Test] + [TestMethod] public void Searchsorted_BeforeAll() { // NumPy: np.searchsorted([1,2,3,4,5], 0) = 0 @@ -489,7 +489,7 @@ public void Searchsorted_BeforeAll() Assert.AreEqual(0, result); } - [Test] + [TestMethod] public void Searchsorted_AfterAll() { // NumPy: np.searchsorted([1,2,3,4,5], 10) = 5 diff --git a/test/NumSharp.UnitTest/Backends/Kernels/ManipulationEdgeCaseTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/ManipulationEdgeCaseTests.cs index efdee2bcc..813cc40bf 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/ManipulationEdgeCaseTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/ManipulationEdgeCaseTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -10,11 +9,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Edge case tests for array manipulation operations. /// All expected values are verified against NumPy 2.x output. /// +[TestClass] public class ManipulationEdgeCaseTests { #region Broadcasting Complex Scenarios - [Test] + [TestMethod] public void Broadcast_3D_With_2D() { // NumPy: (2,3,4) + (3,4) = (2,3,4) @@ -30,7 +30,7 @@ public void Broadcast_3D_With_2D() Assert.AreEqual(3.0, result.GetDouble(0, 0, 0)); } - [Test] + [TestMethod] public void Broadcast_3D_With_1D() { // NumPy: (2,3,4) + (4,) = (2,3,4) @@ -45,7 +45,7 @@ public void Broadcast_3D_With_1D() Assert.AreEqual(4, result.shape[2]); } - [Test] + [TestMethod] public void Broadcast_Row_Plus_Column() { // NumPy: (1,3) + (3,1) = (3,3) @@ -62,7 +62,7 @@ public void Broadcast_Row_Plus_Column() Assert.AreEqual(33.0, result.GetDouble(2, 2)); } - [Test] + [TestMethod] public void Broadcast_EmptyArray_WithShape() { // NumPy: np.zeros((0,3)) + np.array([1,2,3]) = shape (0, 3) @@ -81,7 +81,7 @@ public void Broadcast_EmptyArray_WithShape() #region Squeeze Edge Cases - [Test] + [TestMethod] public void Squeeze_RemovesAllOnes() { // NumPy: np.squeeze([[[[1, 2, 3]]]]) = [1, 2, 3] with shape (3,) @@ -93,7 +93,7 @@ public void Squeeze_RemovesAllOnes() Assert.AreEqual(3, result.shape[0]); } - [Test] + [TestMethod] public void Squeeze_SpecificAxis() { // NumPy: np.squeeze(arr, axis=0) where arr.shape = (1, 1, 3) @@ -110,7 +110,7 @@ public void Squeeze_SpecificAxis() #region Expand Dims Edge Cases - [Test] + [TestMethod] public void ExpandDims_NegativeAxis() { // NumPy: np.expand_dims([1,2,3], -1).shape = (3, 1) @@ -123,7 +123,7 @@ public void ExpandDims_NegativeAxis() Assert.AreEqual(1, result.shape[1]); } - [Test] + [TestMethod] public void ExpandDims_Multiple() { // NumPy: np.expand_dims(np.expand_dims(arr, 0), 0).shape = (1, 1, 3) @@ -141,7 +141,7 @@ public void ExpandDims_Multiple() #region Concatenate Edge Cases - [Test] + [TestMethod] public void Concatenate_1D() { // NumPy: np.concatenate([[1,2,3], [4,5,6]]) = [1,2,3,4,5,6] @@ -153,7 +153,7 @@ public void Concatenate_1D() result.Should().BeOfValues(1, 2, 3, 4, 5, 6); } - [Test] + [TestMethod] public void Concatenate_2D_Axis0() { // NumPy: np.concatenate([[[1,2],[3,4]], [[5,6],[7,8]]], axis=0) @@ -167,7 +167,7 @@ public void Concatenate_2D_Axis0() Assert.AreEqual(5, result.GetInt32(2, 0)); } - [Test] + [TestMethod] public void Concatenate_2D_Axis1() { var a = np.array(new[,] { { 1, 2 }, { 3, 4 } }); @@ -180,7 +180,7 @@ public void Concatenate_2D_Axis1() Assert.AreEqual(5, result.GetInt32(0, 2)); } - [Test] + [TestMethod] public void Concatenate_EmptyWithNonEmpty() { // NumPy: np.concatenate([[], [1,2]]) = [1., 2.] @@ -196,7 +196,7 @@ public void Concatenate_EmptyWithNonEmpty() #region Stack Edge Cases - [Test] + [TestMethod] public void Stack_DefaultAxis0() { // NumPy: np.stack([[1,2,3], [4,5,6]]) = [[1,2,3], [4,5,6]] @@ -209,7 +209,7 @@ public void Stack_DefaultAxis0() Assert.AreEqual(3, result.shape[1]); } - [Test] + [TestMethod] public void Stack_Axis1() { // NumPy: np.stack([[1,2,3], [4,5,6]], axis=1) = [[1,4], [2,5], [3,6]] @@ -228,7 +228,7 @@ public void Stack_Axis1() #region VStack/HStack Edge Cases - [Test] + [TestMethod] public void VStack_1D() { // NumPy: np.vstack([[1,2,3], [4,5,6]]) = [[1,2,3], [4,5,6]] @@ -241,7 +241,7 @@ public void VStack_1D() Assert.AreEqual(3, result.shape[1]); } - [Test] + [TestMethod] public void HStack_1D() { // NumPy: np.hstack([[1,2,3], [4,5,6]]) = [1,2,3,4,5,6] @@ -254,7 +254,7 @@ public void HStack_1D() Assert.AreEqual(6, result.size); } - [Test] + [TestMethod] public void HStack_2D() { var a = np.array(new[,] { { 1, 2 }, { 3, 4 } }); @@ -270,7 +270,7 @@ public void HStack_2D() #region Repeat Edge Cases - [Test] + [TestMethod] public void Repeat_Scalar() { // NumPy: np.repeat([1, 2, 3], 3) = [1, 1, 1, 2, 2, 2, 3, 3, 3] @@ -281,7 +281,7 @@ public void Repeat_Scalar() result.Should().BeOfValues(1, 1, 1, 2, 2, 2, 3, 3, 3); } - [Test] + [TestMethod] public void Repeat_PerElement() { // NumPy: np.repeat([1, 2, 3], [1, 2, 3]) = [1, 2, 2, 3, 3, 3] @@ -297,7 +297,7 @@ public void Repeat_PerElement() #region Flatten/Ravel Edge Cases - [Test] + [TestMethod] public void Flatten_ReturnsContiguousCopy() { var arr = np.array(new[,] { { 1, 2 }, { 3, 4 } }); @@ -308,7 +308,7 @@ public void Flatten_ReturnsContiguousCopy() Assert.AreEqual(1, flat.ndim); } - [Test] + [TestMethod] public void Ravel_Returns1D() { var arr = np.array(new[,] { { 1, 2 }, { 3, 4 } }); @@ -319,7 +319,7 @@ public void Ravel_Returns1D() Assert.AreEqual(1, raveled.ndim); } - [Test] + [TestMethod] public void Ravel_SlicedArray() { var arr = np.array(new[] { 1, 2, 3, 4, 5, 6 }); @@ -334,7 +334,7 @@ public void Ravel_SlicedArray() #region Reshape Edge Cases - [Test] + [TestMethod] public void Reshape_InferDimension() { // NumPy: np.reshape([1,2,3,4,5,6], (-1, 2)) = [[1,2],[3,4],[5,6]] @@ -346,7 +346,7 @@ public void Reshape_InferDimension() Assert.AreEqual(2, result.shape[1]); } - [Test] + [TestMethod] public void Reshape_ToScalar() { // NumPy: np.array([5]).reshape(()) = 5 (0D scalar) @@ -358,7 +358,7 @@ public void Reshape_ToScalar() Assert.AreEqual(1, result.size); } - [Test] + [TestMethod] public void Reshape_EmptyArray() { // NumPy: np.array([]).reshape((0, 5)).shape = (0, 5) @@ -375,7 +375,7 @@ public void Reshape_EmptyArray() #region Transpose Edge Cases - [Test] + [TestMethod] public void Transpose_1D_NoOp() { // NumPy: arr1d.T.shape = (3,) (no change for 1D) @@ -387,7 +387,7 @@ public void Transpose_1D_NoOp() Assert.AreEqual(3, transposed.shape[0]); } - [Test] + [TestMethod] public void Transpose_2D() { var arr = np.array(new[,] { { 1, 2, 3 }, { 4, 5, 6 } }); @@ -400,7 +400,7 @@ public void Transpose_2D() Assert.AreEqual(4, transposed.GetInt32(0, 1)); } - [Test] + [TestMethod] public void Transpose_3D() { // NumPy: arr3d.T reverses all axes @@ -417,7 +417,7 @@ public void Transpose_3D() #region Unique Edge Cases - [Test] + [TestMethod] public void Unique_ReturnsSorted() { // NumPy: np.unique([3, 1, 2, 1, 3, 2]) = [1, 2, 3] (sorted!) @@ -428,7 +428,7 @@ public void Unique_ReturnsSorted() result.Should().BeOfValues(1, 2, 3); } - [Test] + [TestMethod] public void Unique_Float_WithNaN() { // NumPy: np.unique([1, nan, 2, nan, 1]) = [1, 2, nan] diff --git a/test/NumSharp.UnitTest/Backends/Kernels/NanReductionTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/NanReductionTests.cs index 478c7c83d..1f25f4f68 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/NanReductionTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/NanReductionTests.cs @@ -2,7 +2,6 @@ using AwesomeAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -10,11 +9,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Tests for NaN-aware reduction operations (nansum, nanprod, nanmin, nanmax). /// All expected values are verified against NumPy 2.4.2. /// +[TestClass] public class NanReductionTests { #region np.nansum Tests - [Test] + [TestMethod] public void NanSum_BasicFloat_IgnoresNaN() { // NumPy: np.nansum([1.0, np.nan, 3.0]) == 4.0 @@ -23,7 +23,7 @@ public void NanSum_BasicFloat_IgnoresNaN() Assert.AreEqual(4.0f, (float)result.GetAtIndex(0), 1e-6f); } - [Test] + [TestMethod] public void NanSum_BasicDouble_IgnoresNaN() { // NumPy: np.nansum([1.0, np.nan, 3.0]) == 4.0 @@ -32,7 +32,7 @@ public void NanSum_BasicDouble_IgnoresNaN() Assert.AreEqual(4.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanSum_AllNaN_ReturnsZero() { // NumPy: np.nansum([np.nan, np.nan]) == 0.0 @@ -41,7 +41,7 @@ public void NanSum_AllNaN_ReturnsZero() Assert.AreEqual(0.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanSum_NoNaN_SameAsSum() { // NumPy: np.nansum([1.0, 2.0, 3.0]) == 6.0 @@ -50,7 +50,7 @@ public void NanSum_NoNaN_SameAsSum() Assert.AreEqual(6.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanSum_MultipleNaN_IgnoresAll() { // NumPy: np.nansum([np.nan, 1.0, np.nan, 2.0, np.nan]) == 3.0 @@ -59,7 +59,7 @@ public void NanSum_MultipleNaN_IgnoresAll() Assert.AreEqual(3.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanSum_LargeArray_SIMD() { // Test SIMD path with large array (> Vector256 count) @@ -78,7 +78,7 @@ public void NanSum_LargeArray_SIMD() #region np.nanprod Tests - [Test] + [TestMethod] public void NanProd_BasicDouble_IgnoresNaN() { // NumPy: np.nanprod([2.0, np.nan, 3.0]) == 6.0 @@ -87,7 +87,7 @@ public void NanProd_BasicDouble_IgnoresNaN() Assert.AreEqual(6.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanProd_AllNaN_ReturnsOne() { // NumPy: np.nanprod([np.nan, np.nan]) == 1.0 @@ -96,7 +96,7 @@ public void NanProd_AllNaN_ReturnsOne() Assert.AreEqual(1.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanProd_NoNaN_SameAsProd() { // NumPy: np.nanprod([2.0, 3.0, 4.0]) == 24.0 @@ -105,7 +105,7 @@ public void NanProd_NoNaN_SameAsProd() Assert.AreEqual(24.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanProd_WithZero_ReturnsZero() { // NumPy: np.nanprod([2.0, 0.0, np.nan, 3.0]) == 0.0 @@ -114,7 +114,7 @@ public void NanProd_WithZero_ReturnsZero() Assert.AreEqual(0.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanProd_Float_IgnoresNaN() { // NumPy: np.nanprod(np.array([2.0, np.nan, 3.0], dtype=np.float32)) == 6.0 @@ -127,7 +127,7 @@ public void NanProd_Float_IgnoresNaN() #region np.nanmin Tests - [Test] + [TestMethod] public void NanMin_BasicDouble_IgnoresNaN() { // NumPy: np.nanmin([1.0, np.nan, 3.0]) == 1.0 @@ -136,7 +136,7 @@ public void NanMin_BasicDouble_IgnoresNaN() Assert.AreEqual(1.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMin_AllNaN_ReturnsNaN() { // NumPy: np.nanmin([np.nan, np.nan]) == nan (with RuntimeWarning) @@ -145,7 +145,7 @@ public void NanMin_AllNaN_ReturnsNaN() Assert.IsTrue(double.IsNaN((double)result.GetAtIndex(0))); } - [Test] + [TestMethod] public void NanMin_NoNaN_SameAsMin() { // NumPy: np.nanmin([5.0, 2.0, 8.0]) == 2.0 @@ -154,7 +154,7 @@ public void NanMin_NoNaN_SameAsMin() Assert.AreEqual(2.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMin_NegativeValues_IgnoresNaN() { // NumPy: np.nanmin([-5.0, np.nan, -2.0]) == -5.0 @@ -163,7 +163,7 @@ public void NanMin_NegativeValues_IgnoresNaN() Assert.AreEqual(-5.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMin_Float_IgnoresNaN() { // NumPy: np.nanmin(np.array([1.0, np.nan, 3.0], dtype=np.float32)) == 1.0 @@ -172,7 +172,7 @@ public void NanMin_Float_IgnoresNaN() Assert.AreEqual(1.0f, (float)result.GetAtIndex(0), 1e-6f); } - [Test] + [TestMethod] public void NanMin_NaNAtStart_IgnoresIt() { // NumPy: np.nanmin([np.nan, 5.0, 2.0]) == 2.0 @@ -181,7 +181,7 @@ public void NanMin_NaNAtStart_IgnoresIt() Assert.AreEqual(2.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMin_NaNAtEnd_IgnoresIt() { // NumPy: np.nanmin([5.0, 2.0, np.nan]) == 2.0 @@ -194,7 +194,7 @@ public void NanMin_NaNAtEnd_IgnoresIt() #region np.nanmax Tests - [Test] + [TestMethod] public void NanMax_BasicDouble_IgnoresNaN() { // NumPy: np.nanmax([1.0, np.nan, 3.0]) == 3.0 @@ -203,7 +203,7 @@ public void NanMax_BasicDouble_IgnoresNaN() Assert.AreEqual(3.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMax_AllNaN_ReturnsNaN() { // NumPy: np.nanmax([np.nan, np.nan]) == nan (with RuntimeWarning) @@ -212,7 +212,7 @@ public void NanMax_AllNaN_ReturnsNaN() Assert.IsTrue(double.IsNaN((double)result.GetAtIndex(0))); } - [Test] + [TestMethod] public void NanMax_NoNaN_SameAsMax() { // NumPy: np.nanmax([5.0, 2.0, 8.0]) == 8.0 @@ -221,7 +221,7 @@ public void NanMax_NoNaN_SameAsMax() Assert.AreEqual(8.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMax_NegativeValues_IgnoresNaN() { // NumPy: np.nanmax([-5.0, np.nan, -2.0]) == -2.0 @@ -230,7 +230,7 @@ public void NanMax_NegativeValues_IgnoresNaN() Assert.AreEqual(-2.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMax_Float_IgnoresNaN() { // NumPy: np.nanmax(np.array([1.0, np.nan, 3.0], dtype=np.float32)) == 3.0 @@ -239,7 +239,7 @@ public void NanMax_Float_IgnoresNaN() Assert.AreEqual(3.0f, (float)result.GetAtIndex(0), 1e-6f); } - [Test] + [TestMethod] public void NanMax_NaNAtStart_IgnoresIt() { // NumPy: np.nanmax([np.nan, 5.0, 2.0]) == 5.0 @@ -248,7 +248,7 @@ public void NanMax_NaNAtStart_IgnoresIt() Assert.AreEqual(5.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMax_NaNAtEnd_IgnoresIt() { // NumPy: np.nanmax([5.0, 2.0, np.nan]) == 5.0 @@ -261,7 +261,7 @@ public void NanMax_NaNAtEnd_IgnoresIt() #region Large Array SIMD Tests - [Test] + [TestMethod] public void NanSum_LargeFloatArray_SIMD() { // Test SIMD path with large float array @@ -284,7 +284,7 @@ public void NanSum_LargeFloatArray_SIMD() Assert.AreEqual(expectedSum, (float)result.GetAtIndex(0), 1e-3f); } - [Test] + [TestMethod] public void NanMin_LargeDoubleArray_SIMD() { // Test SIMD path for nanmin @@ -299,7 +299,7 @@ public void NanMin_LargeDoubleArray_SIMD() Assert.AreEqual(0.5, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMax_LargeDoubleArray_SIMD() { // Test SIMD path for nanmax @@ -314,7 +314,7 @@ public void NanMax_LargeDoubleArray_SIMD() Assert.AreEqual(9999.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanProd_LargeFloatArray_SIMD() { // Test SIMD path for nanprod with small values to avoid overflow @@ -343,7 +343,7 @@ public void NanProd_LargeFloatArray_SIMD() #region Edge Cases - [Test] + [TestMethod] public void NanSum_SingleNaN_ReturnsZero() { var arr = np.array(new double[] { double.NaN }); @@ -351,7 +351,7 @@ public void NanSum_SingleNaN_ReturnsZero() Assert.AreEqual(0.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanProd_SingleNaN_ReturnsOne() { var arr = np.array(new double[] { double.NaN }); @@ -359,7 +359,7 @@ public void NanProd_SingleNaN_ReturnsOne() Assert.AreEqual(1.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMin_SingleNaN_ReturnsNaN() { var arr = np.array(new double[] { double.NaN }); @@ -367,7 +367,7 @@ public void NanMin_SingleNaN_ReturnsNaN() Assert.IsTrue(double.IsNaN((double)result.GetAtIndex(0))); } - [Test] + [TestMethod] public void NanMax_SingleNaN_ReturnsNaN() { var arr = np.array(new double[] { double.NaN }); @@ -375,7 +375,7 @@ public void NanMax_SingleNaN_ReturnsNaN() Assert.IsTrue(double.IsNaN((double)result.GetAtIndex(0))); } - [Test] + [TestMethod] public void NanSum_SingleValue_ReturnsThatValue() { var arr = np.array(new double[] { 42.0 }); @@ -383,7 +383,7 @@ public void NanSum_SingleValue_ReturnsThatValue() Assert.AreEqual(42.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMin_WithInfinity_IgnoresNaN() { // NumPy: np.nanmin([np.nan, np.inf, 1.0]) == 1.0 @@ -392,7 +392,7 @@ public void NanMin_WithInfinity_IgnoresNaN() Assert.AreEqual(1.0, (double)result.GetAtIndex(0), 1e-10); } - [Test] + [TestMethod] public void NanMax_WithNegInfinity_IgnoresNaN() { // NumPy: np.nanmax([np.nan, -np.inf, 1.0]) == 1.0 @@ -405,7 +405,7 @@ public void NanMax_WithNegInfinity_IgnoresNaN() #region Keepdims Tests - [Test] + [TestMethod] public void NanSum_Keepdims_PreservesShape() { var arr = np.array(new double[] { 1.0, double.NaN, 3.0 }).reshape(1, 3); @@ -415,7 +415,7 @@ public void NanSum_Keepdims_PreservesShape() Assert.AreEqual(1, result.shape[1]); } - [Test] + [TestMethod] public void NanProd_Keepdims_PreservesShape() { var arr = np.array(new double[] { 2.0, double.NaN, 3.0 }).reshape(1, 3); @@ -429,7 +429,7 @@ public void NanProd_Keepdims_PreservesShape() #region Axis Reduction Tests - [Test] + [TestMethod] public void NanSum_Axis0_2D_IgnoresNaN() { // NumPy: np.nansum([[1, np.nan], [np.nan, 4]], axis=0) == [1, 4] @@ -441,7 +441,7 @@ public void NanSum_Axis0_2D_IgnoresNaN() Assert.AreEqual(4.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanSum_Axis1_2D_IgnoresNaN() { // NumPy: np.nansum([[1, np.nan], [np.nan, 4]], axis=1) == [1, 4] @@ -453,7 +453,7 @@ public void NanSum_Axis1_2D_IgnoresNaN() Assert.AreEqual(4.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanSum_Axis_AllNaNRow_ReturnsZero() { // NumPy: np.nansum([[np.nan, np.nan], [1.0, 2.0]], axis=1) == [0.0, 3.0] @@ -463,7 +463,7 @@ public void NanSum_Axis_AllNaNRow_ReturnsZero() Assert.AreEqual(3.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanProd_Axis0_2D_IgnoresNaN() { // NumPy: np.nanprod([[1, np.nan], [np.nan, 4]], axis=0) == [1, 4] @@ -475,7 +475,7 @@ public void NanProd_Axis0_2D_IgnoresNaN() Assert.AreEqual(4.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanProd_Axis1_2D_IgnoresNaN() { // NumPy: np.nanprod([[2, np.nan], [np.nan, 3]], axis=1) == [2, 3] @@ -485,7 +485,7 @@ public void NanProd_Axis1_2D_IgnoresNaN() Assert.AreEqual(3.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanProd_Axis_AllNaNRow_ReturnsOne() { // NumPy: np.nanprod([[np.nan, np.nan], [1.0, 2.0]], axis=1) == [1.0, 2.0] @@ -495,7 +495,7 @@ public void NanProd_Axis_AllNaNRow_ReturnsOne() Assert.AreEqual(2.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanMin_Axis0_2D_IgnoresNaN() { // NumPy: np.nanmin([[1, np.nan], [np.nan, 4]], axis=0) == [1, 4] @@ -507,7 +507,7 @@ public void NanMin_Axis0_2D_IgnoresNaN() Assert.AreEqual(4.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanMin_Axis1_2D_IgnoresNaN() { // NumPy: np.nanmin([[5, np.nan, 2], [np.nan, 3, 1]], axis=1) == [2, 1] @@ -517,7 +517,7 @@ public void NanMin_Axis1_2D_IgnoresNaN() Assert.AreEqual(1.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanMin_Axis_AllNaNRow_ReturnsNaN() { // NumPy: np.nanmin([[np.nan, np.nan], [1.0, 2.0]], axis=1) == [nan, 1.0] @@ -527,7 +527,7 @@ public void NanMin_Axis_AllNaNRow_ReturnsNaN() Assert.AreEqual(1.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanMax_Axis0_2D_IgnoresNaN() { // NumPy: np.nanmax([[1, np.nan], [np.nan, 4]], axis=0) == [1, 4] @@ -539,7 +539,7 @@ public void NanMax_Axis0_2D_IgnoresNaN() Assert.AreEqual(4.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanMax_Axis1_2D_IgnoresNaN() { // NumPy: np.nanmax([[5, np.nan, 2], [np.nan, 3, 1]], axis=1) == [5, 3] @@ -549,7 +549,7 @@ public void NanMax_Axis1_2D_IgnoresNaN() Assert.AreEqual(3.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanMax_Axis_AllNaNRow_ReturnsNaN() { // NumPy: np.nanmax([[np.nan, np.nan], [1.0, 2.0]], axis=1) == [nan, 2.0] @@ -559,7 +559,7 @@ public void NanMax_Axis_AllNaNRow_ReturnsNaN() Assert.AreEqual(2.0, (double)result.GetAtIndex(1), 1e-10); } - [Test] + [TestMethod] public void NanSum_Axis_Keepdims_PreservesShape() { // NumPy: np.nansum([[1, np.nan], [np.nan, 4]], axis=0, keepdims=True).shape == (1, 2) @@ -570,7 +570,7 @@ public void NanSum_Axis_Keepdims_PreservesShape() Assert.AreEqual(2, result.shape[1]); } - [Test] + [TestMethod] public void NanSum_Axis_Float_IgnoresNaN() { // Same as double but with float32 @@ -580,7 +580,7 @@ public void NanSum_Axis_Float_IgnoresNaN() Assert.AreEqual(4.0f, (float)result.GetAtIndex(1), 1e-6f); } - [Test] + [TestMethod] public void NanMin_Axis_Float_IgnoresNaN() { var arr = np.array(new float[,] { { 5.0f, float.NaN }, { float.NaN, 2.0f } }); @@ -589,7 +589,7 @@ public void NanMin_Axis_Float_IgnoresNaN() Assert.AreEqual(2.0f, (float)result.GetAtIndex(1), 1e-6f); } - [Test] + [TestMethod] public void NanMax_Axis_Float_IgnoresNaN() { var arr = np.array(new float[,] { { 5.0f, float.NaN }, { float.NaN, 2.0f } }); @@ -598,7 +598,7 @@ public void NanMax_Axis_Float_IgnoresNaN() Assert.AreEqual(2.0f, (float)result.GetAtIndex(1), 1e-6f); } - [Test] + [TestMethod] public void NanSum_3D_Axis1() { // 3D array with NaN, reduce along middle axis @@ -626,7 +626,7 @@ public void NanSum_3D_Axis1() Assert.AreEqual(6.0, (double)result[1, 1], 1e-10); } - [Test] + [TestMethod] public void NanSum_NegativeAxis() { // NumPy: np.nansum([[1, np.nan], [np.nan, 4]], axis=-1) == [1, 4] diff --git a/test/NumSharp.UnitTest/Backends/Kernels/NonContiguousTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/NonContiguousTests.cs index 4664f9550..4e1478909 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/NonContiguousTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/NonContiguousTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -13,11 +12,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// /// This complements SlicedArrayOpTests.cs which focuses on step-based slices. /// +[TestClass] public class NonContiguousTests { #region Transposed Array Operations - [Test] + [TestMethod] public void Transpose_2D_Sqrt() { // NumPy: np.sqrt(arr.T) where arr = [[1, 4], [9, 16], [25, 36]] @@ -39,7 +39,7 @@ public void Transpose_2D_Sqrt() Assert.AreEqual(6.0, result.GetDouble(1, 2), 1e-10); } - [Test] + [TestMethod] public void Transpose_2D_Add() { // NumPy: arr.T + arr.T where arr = [[1, 2], [3, 4]] @@ -56,7 +56,7 @@ public void Transpose_2D_Add() Assert.AreEqual(8.0, result.GetDouble(1, 1), 1e-10); } - [Test] + [TestMethod] public void Transpose_2D_Sum() { // NumPy: np.sum(arr.T) where arr = [[1, 2, 3], [4, 5, 6]] @@ -70,7 +70,7 @@ public void Transpose_2D_Sum() Assert.AreEqual(21.0, result.GetDouble(0), 1e-10); } - [Test] + [TestMethod] public void Transpose_2D_Multiply() { // arr * arr.T (both 2x2) @@ -86,7 +86,7 @@ public void Transpose_2D_Multiply() Assert.AreEqual(16.0, result.GetDouble(1, 1), 1e-10); } - [Test] + [TestMethod] public void Transpose_3D_Sum() { // NumPy: np.sum(arr.T) where arr has shape (2, 3, 4) @@ -106,7 +106,7 @@ public void Transpose_3D_Sum() #region Broadcast View Operations - [Test] + [TestMethod] public void BroadcastTo_Scalar_Sum() { // NumPy: np.sum(np.broadcast_to(5, (3, 3))) @@ -123,7 +123,7 @@ public void BroadcastTo_Scalar_Sum() Assert.AreEqual(45.0, (double)result, 1e-10); } - [Test] + [TestMethod] public void BroadcastTo_1D_Sqrt() { // NumPy: np.sqrt(np.broadcast_to([1, 4, 9], (3, 3))) @@ -142,7 +142,7 @@ public void BroadcastTo_1D_Sqrt() } } - [Test] + [TestMethod] public void BroadcastTo_Column_Add() { // NumPy: np.broadcast_to([[1], [2], [3]], (3, 3)) + np.broadcast_to([10, 20, 30], (3, 3)) @@ -162,7 +162,7 @@ public void BroadcastTo_Column_Add() Assert.AreEqual(33.0, result.GetDouble(2, 2), 1e-10); } - [Test] + [TestMethod] public void BroadcastTo_Mean() { // NumPy: np.mean(np.broadcast_to([1, 2, 3], (4, 3))) @@ -179,7 +179,7 @@ public void BroadcastTo_Mean() #region Reversed Array Operations - [Test] + [TestMethod] public void Reversed_Sqrt() { // NumPy: np.sqrt(arr[::-1]) where arr = [1, 4, 9, 16, 25] @@ -197,7 +197,7 @@ public void Reversed_Sqrt() Assert.AreEqual(1.0, result.GetDouble(4), 1e-10); } - [Test] + [TestMethod] public void Reversed_Add_WithOriginal() { // NumPy: arr + arr[::-1] where arr = [1, 2, 3, 4, 5] @@ -212,7 +212,7 @@ public void Reversed_Add_WithOriginal() } } - [Test] + [TestMethod] public void Reversed_2D_Rows() { // NumPy: np.sum(arr[::-1, :]) where arr = [[1,2,3], [4,5,6]] @@ -228,7 +228,7 @@ public void Reversed_2D_Rows() Assert.AreEqual(21.0, result.GetDouble(0), 1e-10); } - [Test] + [TestMethod] public void Reversed_2D_Cols() { // NumPy: arr[:, ::-1] where arr = [[1,2,3], [4,5,6]] @@ -246,7 +246,7 @@ public void Reversed_2D_Cols() #region Multi-Dimensional Slice Operations - [Test] + [TestMethod] public void Slice3D_Sum() { // NumPy: np.sum(arr[::, ::2, ::]) where arr has shape (2, 3, 4) @@ -263,7 +263,7 @@ public void Slice3D_Sum() Assert.AreEqual(184.0, (double)result, 1e-10); } - [Test] + [TestMethod] public void Slice3D_Sqrt() { // Create array with perfect squares for testing @@ -283,7 +283,7 @@ public void Slice3D_Sqrt() #region ATan2 on Non-Contiguous Arrays (Task #73 fix verification) - [Test] + [TestMethod] public void ATan2_SlicedArrays() { // NumPy: np.arctan2(y[::2], x[::2]) @@ -300,7 +300,7 @@ public void ATan2_SlicedArrays() Assert.AreEqual(Math.PI, result.GetDouble(2), 1e-10); } - [Test] + [TestMethod] public void ATan2_TransposedArrays() { // NumPy: np.arctan2(y.T, x.T) @@ -317,7 +317,7 @@ public void ATan2_TransposedArrays() Assert.AreEqual(Math.PI, result.GetDouble(1, 1), 1e-10); } - [Test] + [TestMethod] public void ATan2_ReversedArrays() { // NumPy: np.arctan2(y[::-1], x[::-1]) @@ -337,7 +337,7 @@ public void ATan2_ReversedArrays() #region Negate Boolean on Non-Contiguous Arrays (Task #74 fix verification) - [Test] + [TestMethod] [OpenBugs] // Remove when Task #74 is fixed public void NegateBoolean_SlicedArray() { @@ -355,7 +355,7 @@ public void NegateBoolean_SlicedArray() Assert.AreEqual(-1, result.GetInt32(2)); } - [Test] + [TestMethod] [OpenBugs] // Remove when Task #74 is fixed public void NegateBoolean_ReversedArray() { @@ -376,7 +376,7 @@ public void NegateBoolean_ReversedArray() #region Combined Non-Contiguous Patterns - [Test] + [TestMethod] public void TransposedSlice_Sum() { // NumPy: np.sum(arr.T[::2, :]) @@ -392,7 +392,7 @@ public void TransposedSlice_Sum() Assert.AreEqual(16.0, result.GetDouble(0), 1e-10); // 1+5+3+7=16 } - [Test] + [TestMethod] public void SlicedTransposed_Multiply() { // Slice first, then transpose @@ -414,7 +414,7 @@ public void SlicedTransposed_Multiply() Assert.AreEqual(100.0, result.GetDouble(1, 1), 1e-10); } - [Test] + [TestMethod] public void ReversedTransposed_Add() { var arr = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -436,7 +436,7 @@ public void ReversedTransposed_Add() #region All/Any on Non-Contiguous Arrays - [Test] + [TestMethod] public void All_SlicedBoolArray() { // NumPy: np.all(arr[::2]) where arr = [True, False, True, False, True] @@ -450,7 +450,7 @@ public void All_SlicedBoolArray() Assert.IsTrue(result); } - [Test] + [TestMethod] public void All_SlicedBoolArray_False() { // NumPy: np.all(arr[1::2]) where arr = [True, False, True, False, True] @@ -464,7 +464,7 @@ public void All_SlicedBoolArray_False() Assert.IsFalse(result); } - [Test] + [TestMethod] public void Any_SlicedBoolArray() { // NumPy: np.any(arr[::2]) where arr = [False, True, False, True, False] @@ -478,7 +478,7 @@ public void Any_SlicedBoolArray() Assert.IsFalse(result); } - [Test] + [TestMethod] public void Any_TransposedBoolArray() { // NumPy: np.any(arr.T) where arr = [[False, False], [True, False]] @@ -496,7 +496,7 @@ public void Any_TransposedBoolArray() #region ArgMax/ArgMin on Non-Contiguous Arrays - [Test] + [TestMethod] public void ArgMax_SlicedArray() { // NumPy: np.argmax(arr[::2]) where arr = [1, 999, 5, 999, 3, 999, 7, 999] @@ -510,7 +510,7 @@ public void ArgMax_SlicedArray() Assert.AreEqual(3, result); } - [Test] + [TestMethod] public void ArgMin_ReversedArray() { // NumPy: np.argmin(arr[::-1]) where arr = [5, 2, 8, 1, 9] @@ -524,7 +524,7 @@ public void ArgMin_ReversedArray() Assert.AreEqual(1, result); } - [Test] + [TestMethod] public void ArgMax_TransposedArray() { // NumPy: np.argmax(arr.T) where arr = [[1, 2], [9, 4]] @@ -543,7 +543,7 @@ public void ArgMax_TransposedArray() #region Power on Non-Contiguous Arrays - [Test] + [TestMethod] public void Power_SlicedArrays() { // NumPy: np.power(base[::2], exp[::2]) @@ -560,7 +560,7 @@ public void Power_SlicedArrays() Assert.AreEqual(64.0, result.GetDouble(2), 1e-10); } - [Test] + [TestMethod] public void Power_TransposedArrays() { // NumPy: np.power(base.T, exp.T) @@ -581,7 +581,7 @@ public void Power_TransposedArrays() #region FloorDivide on Non-Contiguous Arrays - [Test] + [TestMethod] public void FloorDivide_SlicedArrays() { // NumPy: np.floor_divide(a[::2], b[::2]) diff --git a/test/NumSharp.UnitTest/Backends/Kernels/NumpyAlignmentBugTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/NumpyAlignmentBugTests.cs index 9605ea599..3243a1711 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/NumpyAlignmentBugTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/NumpyAlignmentBugTests.cs @@ -3,7 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -37,13 +36,14 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// - BUG-25: np.power(int, float) returns int instead of float64 (MEDIUM) - FIXED /// - BUG-32: np.random.choice replace=False parameter ignored (HIGH) /// +[TestClass] public class NumpyAlignmentBugTests { private const double Tolerance = 1e-10; #region BUG-1: Boolean Indexing Setter Throws NotImplementedException (CRITICAL) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug1_BooleanMask_ReturnsCorrectValues() { // NUMPY 2.4.2: @@ -63,7 +63,7 @@ public void Bug1_BooleanMask_ReturnsCorrectValues() Assert.AreEqual(50, result.GetInt32(2)); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug1_BooleanMask_AllFalse_ReturnsEmpty() { var arr = np.array(new[] { 1, 2, 3 }); @@ -74,7 +74,7 @@ public void Bug1_BooleanMask_AllFalse_ReturnsEmpty() Assert.AreEqual(0, result.size, "all False mask should return empty array"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug1_BooleanMask_AllTrue_ReturnsAll() { var arr = np.array(new[] { 1, 2, 3 }); @@ -88,7 +88,7 @@ public void Bug1_BooleanMask_AllTrue_ReturnsAll() Assert.AreEqual(3, result.GetInt32(2)); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void BooleanMask_FromComparison_Works() { // Using comparison result directly as mask @@ -104,7 +104,7 @@ public void BooleanMask_FromComparison_Works() Assert.AreEqual(5, result.GetInt32(2)); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug1_BooleanMask_Assignment_ThrowsNotImplementedException() { // This is the actual bug - setter throws NotImplementedException @@ -126,7 +126,7 @@ public void Bug1_BooleanMask_Assignment_ThrowsNotImplementedException() #region BUG-2: np.nonzero 1-D Shape Wrong (HIGH) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug2_Nonzero_1D_ReturnsCorrectShape() { // NUMPY 2.4.2: @@ -142,7 +142,7 @@ public void Bug2_Nonzero_1D_ReturnsCorrectShape() CollectionAssert.AreEqual(new long[] { 0, 2, 4 }, result[0].ToArray()); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug2_Nonzero_EmptyArray() { var empty = np.array(Array.Empty()); @@ -158,7 +158,7 @@ public void Bug2_Nonzero_EmptyArray() #region BUG-3: np.all/np.any with axis Throws (HIGH) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug3_All_Axis0() { // NUMPY 2.4.2: @@ -175,7 +175,7 @@ public void Bug3_All_Axis0() Assert.IsTrue(result.GetBoolean(2)); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug3_All_Axis1() { var arr = np.array(new[,] { { true, false, true }, { true, true, true } }); @@ -188,7 +188,7 @@ public void Bug3_All_Axis1() Assert.IsTrue(result.GetBoolean(1)); // second row all True } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug3_Any_Axis0() { // NUMPY 2.4.2: @@ -205,7 +205,7 @@ public void Bug3_Any_Axis0() Assert.IsTrue(result.GetBoolean(2)); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug3_Any_Axis1() { var arr = np.array(new[,] { { false, false, false }, { false, true, false } }); @@ -222,7 +222,7 @@ public void Bug3_Any_Axis1() #region BUG-4: np.std/np.var ddof Ignored (MEDIUM) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug4_Std_Ddof1() { // NUMPY 2.4.2: @@ -240,7 +240,7 @@ public void Bug4_Std_Ddof1() "ddof=1 should give sample std dev, not population"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug4_Var_Ddof1() { // NUMPY 2.4.2: @@ -259,7 +259,7 @@ public void Bug4_Var_Ddof1() #region BUG-5: np.std/np.var Empty Array Returns NaN (MEDIUM) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug5_Std_EmptyArray_ReturnsNaN() { // NUMPY 2.4.2 returns nan for empty array (with RuntimeWarning) @@ -271,7 +271,7 @@ public void Bug5_Std_EmptyArray_ReturnsNaN() Assert.IsTrue(double.IsNaN(result.GetDouble(0)), "empty array should return NaN"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug5_Var_EmptyArray_ReturnsNaN() { var empty = np.array(Array.Empty()); @@ -286,7 +286,7 @@ public void Bug5_Var_EmptyArray_ReturnsNaN() #region BUG-6: np.sum Empty 2D Returns Scalar (MEDIUM) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug6_Sum_Empty2D_Axis0_ReturnsArray() { // NUMPY 2.4.2: @@ -304,7 +304,7 @@ public void Bug6_Sum_Empty2D_Axis0_ReturnsArray() #region BUG-7: sbyte (int8) Not Supported (LOW) - [Test] + [TestMethod] [OpenBugs] // sbyte (int8) is not supported by NumSharp - requires adding NPTypeCode.SByte public void Bug7_SByte_ArrayCreation() { @@ -324,7 +324,7 @@ public void Bug7_SByte_ArrayCreation() #region BUG-9: np.unique Returns Unsorted (MEDIUM) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug9_Unique_ReturnsSorted() { // NUMPY 2.4.2: @@ -344,7 +344,7 @@ public void Bug9_Unique_ReturnsSorted() Assert.AreEqual(4, result.GetInt32(3)); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug9_Unique_Float64_Sorted() { // NUMPY: np.unique([3.5, 1.5, 2.5]) = [1.5, 2.5, 3.5] @@ -358,7 +358,7 @@ public void Bug9_Unique_Float64_Sorted() Assert.AreEqual(3.5, result.GetDouble(2), Tolerance); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug9_Unique_WithDuplicates() { // NUMPY: np.unique([5, 5, 5, 1, 1, 3]) = [1, 3, 5] @@ -376,7 +376,7 @@ public void Bug9_Unique_WithDuplicates() #region BUG-10: np.repeat with Array Repeats Fails (MEDIUM) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug10_Repeat_ArrayRepeats() { // NUMPY 2.4.2: @@ -395,7 +395,7 @@ public void Bug10_Repeat_ArrayRepeats() result.ToArray()); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug10_Repeat_ArrayRepeats_DifferentCounts() { // NUMPY: np.repeat([10, 20], [1, 3]) = [10, 20, 20, 20] @@ -409,7 +409,7 @@ public void Bug10_Repeat_ArrayRepeats_DifferentCounts() result.ToArray()); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug10_Repeat_ArrayRepeats_WithZero() { // NUMPY: np.repeat([1, 2, 3], [0, 2, 0]) = [2, 2] @@ -430,7 +430,7 @@ public void Bug10_Repeat_ArrayRepeats_WithZero() // Commenting out until the parameter is added /* - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug11_Repeat_2D_Axis0() { // NUMPY 2.4.2: @@ -452,7 +452,7 @@ public void Bug11_Repeat_2D_Axis0() Assert.AreEqual(3, result.GetInt32(3, 0)); // repeated } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug11_Repeat_2D_Axis1() { // NUMPY 2.4.2: @@ -472,7 +472,7 @@ public void Bug11_Repeat_2D_Axis1() Assert.AreEqual(2, result.GetInt32(0, 3)); // repeated } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug11_Repeat_2D_Axis_NegativeAxis() { // NUMPY: np.repeat(arr, 3, axis=-1) same as axis=1 for 2D @@ -490,7 +490,7 @@ public void Bug11_Repeat_2D_Axis_NegativeAxis() #region BUG-12: np.searchsorted Scalar Input Throws (MEDIUM) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug12_Searchsorted_ScalarInput() { // NUMPY 2.4.2: @@ -505,7 +505,7 @@ public void Bug12_Searchsorted_ScalarInput() Assert.AreEqual(2, result); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug12_Searchsorted_ScalarInput_NotFound() { // NUMPY: np.searchsorted([1, 3, 5], 4) = 2 @@ -516,7 +516,7 @@ public void Bug12_Searchsorted_ScalarInput_NotFound() Assert.AreEqual(2, result); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug12_Searchsorted_ArrayInput_WrongResults() { // NUMPY 2.4.2: @@ -537,7 +537,7 @@ public void Bug12_Searchsorted_ArrayInput_WrongResults() #region BUG-13: np.linspace Returns float32 Instead of float64 (LOW) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug13_Linspace_ReturnsDtype() { // NUMPY 2.4.2: @@ -550,7 +550,7 @@ public void Bug13_Linspace_ReturnsDtype() "np.linspace should return float64, not float32"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug13_Linspace_Values() { // NUMPY: np.linspace(0, 10, 5) = [0, 2.5, 5, 7.5, 10] @@ -568,7 +568,7 @@ public void Bug13_Linspace_Values() #region BUG-14: np.abs Changes int dtype to Double (MEDIUM) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug14_Abs_PreservesIntDtype() { // NUMPY 2.4.2: @@ -586,7 +586,7 @@ public void Bug14_Abs_PreservesIntDtype() absArr.ToArray()); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug14_Abs_Float64_PreservesDtype() { // NUMPY: np.abs([-3.5, 2.5]).dtype = float64 @@ -603,7 +603,7 @@ public void Bug14_Abs_Float64_PreservesDtype() #region BUG-15: np.moveaxis Returns Wrong Shape (MEDIUM) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug15_Moveaxis_3D() { // NUMPY 2.4.2: @@ -621,7 +621,7 @@ public void Bug15_Moveaxis_3D() Assert.AreEqual(3, moved.shape[2], "axis 2 should become 3 (original axis 0)"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug15_Moveaxis_ToFirst() { // NUMPY: np.moveaxis(arr, -1, 0).shape on (3,4,5) -> (5,3,4) @@ -638,7 +638,7 @@ public void Bug15_Moveaxis_ToFirst() #region BUG-16: nd.astype(int) Uses Rounding Instead of Truncation (MEDIUM) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug16_Astype_FloatToInt_ShouldTruncate() { // NUMPY 2.4.2: @@ -656,7 +656,7 @@ public void Bug16_Astype_FloatToInt_ShouldTruncate() "astype(int) should truncate, not round"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug16_Astype_NegativeFloatToInt() { // NUMPY: np.array([-1.7, -2.3, -3.9]).astype(int) = [-1, -2, -3] @@ -674,7 +674,7 @@ public void Bug16_Astype_NegativeFloatToInt() #region BUG-17: np.convolve Throws NullReferenceException (HIGH) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug17_Convolve_Basic() { // NUMPY 2.4.2: @@ -695,7 +695,7 @@ public void Bug17_Convolve_Basic() Assert.AreEqual(1.5, result.GetDouble(4), 1e-10); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug17_Convolve_IntArrays() { // NUMPY: np.convolve([1, 2, 3], [1, 1]) = [1, 3, 5, 3] @@ -712,7 +712,7 @@ public void Bug17_Convolve_IntArrays() #region BUG-18: np.negative Applies abs() Then Negates (HIGH) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug18_Negative_ShouldJustNegate() { // NUMPY 2.4.2: @@ -731,7 +731,7 @@ public void Bug18_Negative_ShouldJustNegate() Assert.AreEqual(4, neg.GetInt32(3), "negative of -4 should be 4"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug18_Negative_Float64() { // NUMPY: np.negative([-1.5, 2.5]) = [1.5, -2.5] @@ -743,7 +743,7 @@ public void Bug18_Negative_Float64() Assert.AreEqual(-2.5, neg.GetDouble(1), 1e-10); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug18_Negative_Zero() { // NUMPY: np.negative([0]) = [0] (or -0.0 for float) @@ -758,7 +758,7 @@ public void Bug18_Negative_Zero() #region BUG-19: np.positive Applies abs() Instead of Identity (HIGH) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug19_Positive_ShouldBeIdentity() { // NUMPY 2.4.2: @@ -777,7 +777,7 @@ public void Bug19_Positive_ShouldBeIdentity() Assert.AreEqual(-4, pos.GetInt32(3), "positive should preserve -4"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug19_Positive_Float64() { // NUMPY: np.positive([-1.5, 2.5]) = [-1.5, 2.5] @@ -796,7 +796,7 @@ public void Bug19_Positive_Float64() // A) np.arange returns int32 instead of int64 on 64-bit systems // B) np.sum doesn't auto-promote to int64 to prevent overflow - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug20_Arange_ShouldReturnInt64() { // NUMPY 2.4.2: @@ -812,7 +812,7 @@ public void Bug20_Arange_ShouldReturnInt64() "np.arange should return int64 on 64-bit systems, not int32"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug20_Sum_ShouldAutoPromoteToPreventOverflow() { // NUMPY 2.4.2: @@ -834,7 +834,7 @@ public void Bug20_Sum_ShouldAutoPromoteToPreventOverflow() $"Sum should be {expected}, got {actual}. NumPy auto-promotes to int64."); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug20_Sum_SmallArray_NoOverflow() { // Verify small arrays work correctly (no overflow) @@ -847,7 +847,7 @@ public void Bug20_Sum_SmallArray_NoOverflow() "Sum of arange(50000) should be 1,249,975,000"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug20_Sum_LargeArray_Overflow() { // 100000 * 99999 / 2 = 4,999,950,000 (exceeds int32) @@ -862,7 +862,7 @@ public void Bug20_Sum_LargeArray_Overflow() $"Sum should be {expected}, got {actual}."); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug20_Sum_Float64_Workaround() { // Workaround: convert to float64 to avoid overflow @@ -879,7 +879,7 @@ public void Bug20_Sum_Float64_Workaround() #region BUG-21: np.amax Empty Array Returns -Inf (MEDIUM) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug21_Amax_EmptyArray_ShouldThrow() { // NUMPY 2.4.2: @@ -909,7 +909,7 @@ public void Bug21_Amax_EmptyArray_ShouldThrow() #region BUG-22: np.amin Empty Array Returns +Inf (MEDIUM) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug22_Amin_EmptyArray_ShouldThrow() { // NUMPY 2.4.2: @@ -937,7 +937,7 @@ public void Bug22_Amin_EmptyArray_ShouldThrow() #region BUG-32: np.random.choice replace=False Parameter Ignored (HIGH) - [Test] + [TestMethod] [OpenBugs] public void Bug32_Choice_ReplaceFalse_NoDuplicates() { @@ -960,7 +960,7 @@ public void Bug32_Choice_ReplaceFalse_NoDuplicates() "NumSharp ignores the replace parameter."); } - [Test] + [TestMethod] [OpenBugs] public void Bug32_Choice_ReplaceFalse_SizeExceedsPopulation_ShouldThrow() { @@ -990,7 +990,7 @@ public void Bug32_Choice_ReplaceFalse_SizeExceedsPopulation_ShouldThrow() } } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug32_Choice_ReplaceTrue_AllowsDuplicates() { // NUMPY: replace=True (default) allows duplicates @@ -1007,7 +1007,7 @@ public void Bug32_Choice_ReplaceTrue_AllowsDuplicates() Assert.AreEqual(100, values.Length, "Should return 100 samples"); } - [Test] + [TestMethod] public void Bug32_Choice_NDArray_ReplaceFalse() { // NUMPY: np.random.choice(['a','b','c','d','e'], 3, replace=False) @@ -1034,7 +1034,7 @@ public void Bug32_Choice_NDArray_ReplaceFalse() #region Verified Working: np.modf - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Modf_Works() { // NUMPY: np.modf([1.5, 2.7, -3.2]) = ([0.5, 0.7, -0.2], [1.0, 2.0, -3.0]) @@ -1056,7 +1056,7 @@ public void Modf_Works() #region Verified Working: Negative Axis - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Sum_NegativeAxis_Works() { // NUMPY: np.sum([[1,2],[3,4]], axis=-1) = [3, 7] @@ -1075,7 +1075,7 @@ public void Sum_NegativeAxis_Works() #region Verified Working: 3D Sum with Axis - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Sum_3D_Axis1_Works() { // NUMPY: np.sum(arr, axis=1) on (2,3,4) -> (2,4) @@ -1092,7 +1092,7 @@ public void Sum_3D_Axis1_Works() #region Verified Working: np.repeat with Scalar - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Repeat_Scalar_Works() { // This works correctly @@ -1108,7 +1108,7 @@ public void Repeat_Scalar_Works() #region Verified Working: np.clip - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Clip_Works() { // np.clip verified working @@ -1124,7 +1124,7 @@ public void Clip_Works() #region Verified Working: np.roll - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Roll_1D_Positive() { // NUMPY: np.roll([1,2,3,4,5], 2) = [4,5,1,2,3] @@ -1136,7 +1136,7 @@ public void Roll_1D_Positive() result.ToArray()); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Roll_1D_Negative() { // NUMPY: np.roll([1,2,3,4,5], -2) = [3,4,5,1,2] @@ -1152,7 +1152,7 @@ public void Roll_1D_Negative() #region Verified Working: np.argsort - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Argsort_1D_Int32() { // NUMPY: np.argsort([3,1,4,1,5]) = [1,3,0,2,4] @@ -1169,7 +1169,7 @@ public void Argsort_1D_Int32() #region Verified Working: np.cumsum - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Cumsum_1D() { // NUMPY: np.cumsum([1,2,3,4,5]) = [1,3,6,10,15] @@ -1182,7 +1182,7 @@ public void Cumsum_1D() result.ToArray()); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Cumsum_2D_Flat() { // NUMPY: np.cumsum([[1,2],[3,4]]) = [1,3,6,10] @@ -1199,7 +1199,7 @@ public void Cumsum_2D_Flat() #region Verified Working: NaN in Reductions - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Sum_WithNaN_ReturnsNaN() { // NUMPY: np.sum([1, 2, NaN, 4]) = NaN @@ -1210,7 +1210,7 @@ public void Sum_WithNaN_ReturnsNaN() "Sum with NaN should return NaN"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Max_WithNaN_ReturnsNaN() { // NUMPY: np.max([1, 2, NaN, 4]) = NaN @@ -1221,7 +1221,7 @@ public void Max_WithNaN_ReturnsNaN() "Max with NaN should return NaN"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Min_WithNaN_ReturnsNaN() { // NUMPY: np.min([1, 2, NaN, 4]) = NaN @@ -1232,7 +1232,7 @@ public void Min_WithNaN_ReturnsNaN() "Min with NaN should return NaN"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void ArgMax_WithNaN_ReturnsNaNIndex() { // NUMPY: np.argmax([1, 2, NaN, 4]) = 2 (index of NaN) @@ -1243,7 +1243,7 @@ public void ArgMax_WithNaN_ReturnsNaNIndex() "ArgMax with NaN should return index of NaN"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void ArgMin_WithNaN_ReturnsNaNIndex() { // NUMPY: np.argmin([1, 2, NaN, 4]) = 2 (index of NaN) @@ -1258,7 +1258,7 @@ public void ArgMin_WithNaN_ReturnsNaNIndex() #region Verified Working: Double Array Reductions (BUG-26 Fix Verification) - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug26_Sum_DoubleArray_Works() { // BUG-26 FIX VERIFICATION: np.sum on double arrays @@ -1269,7 +1269,7 @@ public void Bug26_Sum_DoubleArray_Works() "sum(double[]) should return 15.0"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug26_Prod_DoubleArray_Works() { // BUG-26 FIX VERIFICATION: np.prod on double arrays @@ -1280,7 +1280,7 @@ public void Bug26_Prod_DoubleArray_Works() "prod(double[]) should return 120.0"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug26_Cumsum_DoubleArray_Works() { // BUG-26 FIX VERIFICATION: np.cumsum on double arrays @@ -1299,7 +1299,7 @@ public void Bug26_Cumsum_DoubleArray_Works() #region Verified Working: Empty Array Reductions - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Sum_EmptyArray_ReturnsZero() { // NUMPY: np.sum([]) = 0.0 @@ -1310,7 +1310,7 @@ public void Sum_EmptyArray_ReturnsZero() "Sum of empty array should be 0"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Prod_EmptyArray_ReturnsOne() { // NUMPY: np.prod([]) = 1.0 @@ -1321,7 +1321,7 @@ public void Prod_EmptyArray_ReturnsOne() "Prod of empty array should be 1"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Mean_EmptyArray_ReturnsNaN() { // NUMPY: np.mean([]) = NaN (with RuntimeWarning) @@ -1336,7 +1336,7 @@ public void Mean_EmptyArray_ReturnsNaN() #region Verified Working: Type Promotion - [Test, OpenBugs] + [TestMethod, OpenBugs] public void TypePromotion_Int32_Float64() { // NUMPY: int32 + float64 = float64 @@ -1349,7 +1349,7 @@ public void TypePromotion_Int32_Float64() Assert.AreEqual(1.5, result.GetDouble(0), 1e-10); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void TypePromotion_Bool_Int32() { // NUMPY: bool + int32 = int32 @@ -1364,7 +1364,7 @@ public void TypePromotion_Bool_Int32() Assert.AreEqual(4, result.GetInt32(2)); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug25_Power_FloatExponent_ReturnsFloat64() { // BUG-25 FIX VERIFICATION: @@ -1381,7 +1381,7 @@ public void Bug25_Power_FloatExponent_ReturnsFloat64() Assert.AreEqual(9.0, result.GetDouble(2), 1e-10); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Power_IntExponent_PreservesIntType() { // NUMPY: np.power(int32, int) returns int32 @@ -1401,7 +1401,7 @@ public void Power_IntExponent_PreservesIntType() #region Verified Working: All/Any with Axis and Keepdims - [Test, OpenBugs] + [TestMethod, OpenBugs] public void All_3D_Axis0() { // NUMPY: np.all(arr, axis=0) on (2,2,2) -> (2,2) @@ -1417,7 +1417,7 @@ public void All_3D_Axis0() Assert.AreEqual(2, result.shape[1]); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void All_3D_Axis1() { // NUMPY: np.all(arr, axis=1) on (2,2,2) -> (2,2) @@ -1433,7 +1433,7 @@ public void All_3D_Axis1() Assert.AreEqual(2, result.shape[1]); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void All_Keepdims() { // NUMPY: np.all([[True,False],[True,True]], axis=1, keepdims=True) -> [[False],[True]] @@ -1455,9 +1455,10 @@ public void All_Keepdims() /// Tests documenting missing or dead-code NumPy functions. /// Note: IsNaN and IsFinite have been fixed and moved to np.isnan.Test.cs and np.isfinite.Test.cs /// +[TestClass] public class MissingFunctionTests { - [Test, OpenBugs] + [TestMethod, OpenBugs] public void IsClose_DeadCode() { var a = np.array(new[] { 1.0, 1.0001 }); @@ -1496,9 +1497,10 @@ public void IsClose_DeadCode() /// /// Tests documenting type promotion differences between NumSharp and NumPy. /// +[TestClass] public class TypePromotionDifferenceTests { - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Sum_Int32_OutputType_NowAligned() { // After BUG-21 fix: NumSharp now matches NumPy 2.x behavior @@ -1510,7 +1512,7 @@ public void Sum_Int32_OutputType_NowAligned() "NumPy 2.x: int32 sum returns int64. NumSharp now aligned."); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Max_EmptyArray_ThrowsException() { // NumPy: np.max([]) raises ValueError @@ -1521,7 +1523,7 @@ public void Max_EmptyArray_ThrowsException() "NumSharp now raises ArgumentException matching NumPy's ValueError."); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Min_EmptyArray_ThrowsException() { // NumPy: np.min([]) raises ValueError diff --git a/test/NumSharp.UnitTest/Backends/Kernels/ReductionOpTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/ReductionOpTests.cs index 997e3584d..b361d1d26 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/ReductionOpTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/ReductionOpTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -12,13 +11,14 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// These tests validate existing reduction functionality and serve as /// regression tests for future IL kernel Phase 5 implementation. /// +[TestClass] public class ReductionOpTests { private const double Tolerance = 1e-10; #region Basic 1D Sum Tests - [Test] + [TestMethod] public void Sum_Float64_1D() { // NumPy: sum([1.0, 2.0, 3.0, 4.0, 5.0]) = 15.0 @@ -28,7 +28,7 @@ public void Sum_Float64_1D() Assert.AreEqual(15.0, result.GetDouble(0)); } - [Test] + [TestMethod] public void Sum_Int32_1D() { var a = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -41,7 +41,7 @@ public void Sum_Int32_1D() #region Basic 1D Prod Tests - [Test] + [TestMethod] public void Prod_Float64_1D() { // NumPy: prod([1.0, 2.0, 3.0, 4.0, 5.0]) = 120.0 @@ -55,7 +55,7 @@ public void Prod_Float64_1D() #region Basic 1D Max/Min Tests - [Test] + [TestMethod] public void Max_Float64_1D() { // NumPy: max([1.0, 2.0, 3.0, 4.0, 5.0]) = 5.0 @@ -65,7 +65,7 @@ public void Max_Float64_1D() Assert.AreEqual(5.0, result.GetDouble(0)); } - [Test] + [TestMethod] public void Min_Float64_1D() { // NumPy: min([1.0, 2.0, 3.0, 4.0, 5.0]) = 1.0 @@ -79,7 +79,7 @@ public void Min_Float64_1D() #region Basic 1D ArgMax/ArgMin Tests - [Test] + [TestMethod] public void ArgMax_Float64_1D() { // NumPy: argmax([1.0, 2.0, 3.0, 4.0, 5.0]) = 4 @@ -89,7 +89,7 @@ public void ArgMax_Float64_1D() Assert.AreEqual(4, result); } - [Test] + [TestMethod] public void ArgMin_Float64_1D() { // NumPy: argmin([1.0, 2.0, 3.0, 4.0, 5.0]) = 0 @@ -103,7 +103,7 @@ public void ArgMin_Float64_1D() #region Basic 1D Mean/Std/Var Tests - [Test] + [TestMethod] public void Mean_Float64_1D() { // NumPy: mean([1.0, 2.0, 3.0, 4.0, 5.0]) = 3.0 @@ -113,7 +113,7 @@ public void Mean_Float64_1D() Assert.AreEqual(3.0, result.GetDouble(0)); } - [Test] + [TestMethod] public void Std_Float64_1D() { // NumPy: std([1.0, 2.0, 3.0, 4.0, 5.0]) = 1.4142135623730951 @@ -123,7 +123,7 @@ public void Std_Float64_1D() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 1.4142135623730951) < Tolerance); } - [Test] + [TestMethod] public void Var_Float64_1D() { // NumPy: var([1.0, 2.0, 3.0, 4.0, 5.0]) = 2.0 @@ -137,7 +137,7 @@ public void Var_Float64_1D() #region Basic 1D CumSum Tests - [Test] + [TestMethod] public void CumSum_Float64_1D() { // NumPy: cumsum([1.0, 2.0, 3.0, 4.0, 5.0]) = [1.0, 3.0, 6.0, 10.0, 15.0] @@ -151,7 +151,7 @@ public void CumSum_Float64_1D() #region 2D Sum with Axis Tests - [Test] + [TestMethod] public void Sum_2D_NoAxis() { // NumPy: sum([[1,2,3],[4,5,6]]) = 21.0 @@ -161,7 +161,7 @@ public void Sum_2D_NoAxis() Assert.AreEqual(21.0, result.GetDouble(0)); } - [Test] + [TestMethod] public void Sum_2D_Axis0() { // NumPy: sum([[1,2,3],[4,5,6]], axis=0) = [5, 7, 9] @@ -172,7 +172,7 @@ public void Sum_2D_Axis0() result.Should().BeOfValues(5.0, 7.0, 9.0); } - [Test] + [TestMethod] public void Sum_2D_Axis1() { // NumPy: sum([[1,2,3],[4,5,6]], axis=1) = [6, 15] @@ -187,7 +187,7 @@ public void Sum_2D_Axis1() #region 2D Mean with Axis Tests - [Test] + [TestMethod] public void Mean_2D_Axis0() { // NumPy: mean([[1,2,3],[4,5,6]], axis=0) = [2.5, 3.5, 4.5] @@ -198,7 +198,7 @@ public void Mean_2D_Axis0() result.Should().BeOfValues(2.5, 3.5, 4.5); } - [Test] + [TestMethod] public void Mean_2D_Axis1() { // NumPy: mean([[1,2,3],[4,5,6]], axis=1) = [2.0, 5.0] @@ -213,7 +213,7 @@ public void Mean_2D_Axis1() #region 2D Max/Min with Axis Tests - [Test] + [TestMethod] public void Max_2D_Axis0() { // NumPy: max([[1,2,3],[4,5,6]], axis=0) = [4, 5, 6] @@ -224,7 +224,7 @@ public void Max_2D_Axis0() result.Should().BeOfValues(4.0, 5.0, 6.0); } - [Test] + [TestMethod] public void Max_2D_Axis1() { // NumPy: max([[1,2,3],[4,5,6]], axis=1) = [3, 6] @@ -235,7 +235,7 @@ public void Max_2D_Axis1() result.Should().BeOfValues(3.0, 6.0); } - [Test] + [TestMethod] public void Min_2D_Axis0() { // NumPy: min([[1,2,3],[4,5,6]], axis=0) = [1, 2, 3] @@ -246,7 +246,7 @@ public void Min_2D_Axis0() result.Should().BeOfValues(1.0, 2.0, 3.0); } - [Test] + [TestMethod] public void Min_2D_Axis1() { // NumPy: min([[1,2,3],[4,5,6]], axis=1) = [1, 4] @@ -261,7 +261,7 @@ public void Min_2D_Axis1() #region 2D ArgMax/ArgMin with Axis Tests - [Test] + [TestMethod] public void ArgMax_2D_Axis0() { // NumPy: argmax([[1,2,3],[4,5,6]], axis=0) = [1, 1, 1] @@ -272,7 +272,7 @@ public void ArgMax_2D_Axis0() result.Should().BeOfValues(1L, 1L, 1L); } - [Test] + [TestMethod] public void ArgMax_2D_Axis1() { // NumPy: argmax([[1,2,3],[4,5,6]], axis=1) = [2, 2] @@ -287,7 +287,7 @@ public void ArgMax_2D_Axis1() #region keepdims Tests - [Test] + [TestMethod] public void Sum_2D_Axis0_Keepdims() { // NumPy: sum([[1,2,3],[4,5,6]], axis=0, keepdims=True) = [[5, 7, 9]], shape=(1,3) @@ -298,7 +298,7 @@ public void Sum_2D_Axis0_Keepdims() result.Should().BeOfValues(5.0, 7.0, 9.0); } - [Test] + [TestMethod] public void Sum_2D_Axis1_Keepdims() { // NumPy: sum([[1,2,3],[4,5,6]], axis=1, keepdims=True) = [[6], [15]], shape=(2,1) @@ -309,7 +309,7 @@ public void Sum_2D_Axis1_Keepdims() result.Should().BeOfValues(6.0, 15.0); } - [Test] + [TestMethod] public void Mean_2D_Axis0_Keepdims() { var a = np.array(new[,] { { 1.0, 2.0, 3.0 }, { 4.0, 5.0, 6.0 } }); @@ -323,7 +323,7 @@ public void Mean_2D_Axis0_Keepdims() #region Edge Cases - Infinity - [Test] + [TestMethod] public void Sum_WithInfinity() { // NumPy: sum([1.0, inf, 3.0]) = inf @@ -333,7 +333,7 @@ public void Sum_WithInfinity() Assert.IsTrue(double.IsPositiveInfinity(result.GetDouble(0))); } - [Test] + [TestMethod] public void Mean_WithInfinity() { // NumPy: mean([1.0, inf, 3.0]) = inf @@ -347,7 +347,7 @@ public void Mean_WithInfinity() #region Edge Cases - NaN - [Test] + [TestMethod] public void Sum_WithNaN() { // NumPy: sum([1.0, nan, 3.0]) = nan @@ -357,7 +357,7 @@ public void Sum_WithNaN() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Mean_WithNaN() { // NumPy: mean([1.0, nan, 3.0]) = nan @@ -367,7 +367,7 @@ public void Mean_WithNaN() Assert.IsTrue(double.IsNaN(result.GetDouble(0))); } - [Test] + [TestMethod] public void Max_WithNaN() { // NumPy: max([1.0, nan, 3.0]) = nan @@ -381,7 +381,7 @@ public void Max_WithNaN() #region Edge Cases - Empty Array - [Test] + [TestMethod] public void Sum_EmptyArray() { // NumPy: sum([]) = 0.0 @@ -391,7 +391,7 @@ public void Sum_EmptyArray() Assert.AreEqual(0.0, result.GetDouble(0)); } - [Test] + [TestMethod] public void Prod_EmptyArray() { // NumPy: prod([]) = 1.0 @@ -405,7 +405,7 @@ public void Prod_EmptyArray() #region Edge Cases - 0D Scalar - [Test] + [TestMethod] public void Sum_0DScalar() { // NumPy: sum(np.array(5.0)) = 5.0, shape=() @@ -420,7 +420,7 @@ public void Sum_0DScalar() #region CumSum with Axis Tests - [Test] + [TestMethod] public void CumSum_2D_NoAxis() { // NumPy: cumsum([[1,2,3],[4,5,6]]) = [1, 3, 6, 10, 15, 21] @@ -430,7 +430,7 @@ public void CumSum_2D_NoAxis() result.Should().BeOfValues(1, 3, 6, 10, 15, 21); } - [Test] + [TestMethod] public void CumSum_2D_Axis0() { // NumPy: cumsum([[1,2,3],[4,5,6]], axis=0) = [[1, 2, 3], [5, 7, 9]] @@ -441,7 +441,7 @@ public void CumSum_2D_Axis0() result.Should().BeOfValues(1, 2, 3, 5, 7, 9); } - [Test] + [TestMethod] public void CumSum_2D_Axis1() { // NumPy: cumsum([[1,2,3],[4,5,6]], axis=1) = [[1, 3, 6], [4, 9, 15]] @@ -456,7 +456,7 @@ public void CumSum_2D_Axis1() #region Boolean Reduction Tests - [Test] + [TestMethod] public void Sum_Bool() { // NumPy: sum([True, False, True, True]) = 3 @@ -466,7 +466,7 @@ public void Sum_Bool() Assert.AreEqual(3L, result.GetInt64(0)); } - [Test] + [TestMethod] public void All_Bool() { // NumPy: all([True, False, True, True]) = False @@ -476,7 +476,7 @@ public void All_Bool() Assert.IsFalse(result); } - [Test] + [TestMethod] public void All_Bool_AllTrue() { var a = np.array(new[] { true, true, true, true }); @@ -489,7 +489,7 @@ public void All_Bool_AllTrue() #region Integer Type Tests - [Test] + [TestMethod] public void Sum_Int32_PromotesToInt64() { // NumPy: int32 sum returns int64 @@ -500,7 +500,7 @@ public void Sum_Int32_PromotesToInt64() Assert.AreEqual(NPTypeCode.Int64, result.typecode); } - [Test] + [TestMethod] public void Mean_Int32_ReturnsFloat64() { // NumPy: int32 mean returns float64 @@ -511,7 +511,7 @@ public void Mean_Int32_ReturnsFloat64() Assert.AreEqual(NPTypeCode.Double, result.typecode); } - [Test] + [TestMethod] public void Max_Int32_PreservesType() { // NumPy: int32 max returns int32 @@ -526,7 +526,7 @@ public void Max_Int32_PreservesType() #region Sliced Array Tests - [Test] + [TestMethod] public void Sum_SlicedArray() { var a = np.array(new[] { 1, 2, 3, 4, 5, 6 }); @@ -536,7 +536,7 @@ public void Sum_SlicedArray() Assert.AreEqual(9L, result.GetInt64(0)); } - [Test] + [TestMethod] public void Mean_SlicedArray() { var a = np.array(new double[] { 1, 2, 3, 4, 5, 6 }); diff --git a/test/NumSharp.UnitTest/Backends/Kernels/ShiftOpTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/ShiftOpTests.cs index f5732a94b..b9ae1c2d7 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/ShiftOpTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/ShiftOpTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -10,11 +9,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Tests for bit shift operations (left_shift, right_shift). /// All expected values are verified against NumPy 2.x output. /// +[TestClass] public class ShiftOpTests { #region Left Shift Tests - [Test] + [TestMethod] public void LeftShift_Int32_Scalar() { // NumPy: np.left_shift([5, 10, 15], 2) = [20, 40, 60] @@ -24,7 +24,7 @@ public void LeftShift_Int32_Scalar() result.Should().BeOfValues(20, 40, 60).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void LeftShift_Int32_Array() { // NumPy: np.left_shift([1, 2, 4], [1, 2, 3]) = [2, 8, 32] @@ -35,7 +35,7 @@ public void LeftShift_Int32_Array() result.Should().BeOfValues(2, 8, 32).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void LeftShift_Byte() { // NumPy: np.left_shift(np.array([1, 2, 4], dtype=np.uint8), 2) = [4, 8, 16] @@ -45,7 +45,7 @@ public void LeftShift_Byte() result.Should().BeOfValues(4, 8, 16).And.BeOfType(NPTypeCode.Byte); } - [Test] + [TestMethod] public void LeftShift_Int64() { // NumPy: np.left_shift(np.array([1, 2, 4], dtype=np.int64), 32) = [4294967296, 8589934592, 17179869184] @@ -55,7 +55,7 @@ public void LeftShift_Int64() result.Should().BeOfValues(4294967296L, 8589934592L, 17179869184L).And.BeOfType(NPTypeCode.Int64); } - [Test] + [TestMethod] public void LeftShift_Overflow() { // NumPy: np.left_shift(np.array([128], dtype=np.uint8), 1) = [0] (overflow wraps) @@ -69,7 +69,7 @@ public void LeftShift_Overflow() #region Right Shift Tests - [Test] + [TestMethod] public void RightShift_Int32_Scalar() { // NumPy: np.right_shift([20, 40, 60], 2) = [5, 10, 15] @@ -79,7 +79,7 @@ public void RightShift_Int32_Scalar() result.Should().BeOfValues(5, 10, 15).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void RightShift_Int32_Array() { // NumPy: np.right_shift([16, 32, 64], [1, 2, 3]) = [8, 8, 8] @@ -90,7 +90,7 @@ public void RightShift_Int32_Array() result.Should().BeOfValues(8, 8, 8).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void RightShift_Byte() { // NumPy: np.right_shift(np.array([16, 32, 64], dtype=np.uint8), 2) = [4, 8, 16] @@ -100,7 +100,7 @@ public void RightShift_Byte() result.Should().BeOfValues(4, 8, 16).And.BeOfType(NPTypeCode.Byte); } - [Test] + [TestMethod] public void RightShift_SignedArithmetic() { // NumPy: np.right_shift(np.array([-8], dtype=np.int32), 1) = [-4] @@ -111,7 +111,7 @@ public void RightShift_SignedArithmetic() result.Should().BeOfValues(-4).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void RightShift_UnsignedLogical() { // NumPy: np.right_shift(np.array([255], dtype=np.uint8), 1) = [127] @@ -122,7 +122,7 @@ public void RightShift_UnsignedLogical() result.Should().BeOfValues(127).And.BeOfType(NPTypeCode.Byte); } - [Test] + [TestMethod] public void RightShift_Int64() { // NumPy: np.right_shift(np.array([4294967296], dtype=np.int64), 32) = [1] @@ -136,7 +136,7 @@ public void RightShift_Int64() #region Broadcasting Tests - [Test] + [TestMethod] public void LeftShift_Broadcasting() { // NumPy: np.left_shift([[1], [2], [4]], [1, 2, 3]) = [[2, 4, 8], [4, 8, 16], [8, 16, 32]] @@ -152,14 +152,14 @@ public void LeftShift_Broadcasting() #region Error Cases - [Test] + [TestMethod] public void LeftShift_Float_ThrowsNotSupported() { var arr = np.array(new float[] { 1.0f, 2.0f }); Assert.ThrowsException(() => np.left_shift(arr, 1)); } - [Test] + [TestMethod] public void RightShift_Double_ThrowsNotSupported() { var arr = np.array(new double[] { 1.0, 2.0 }); @@ -170,7 +170,7 @@ public void RightShift_Double_ThrowsNotSupported() #region UInt Types Tests - [Test] + [TestMethod] public void LeftShift_UInt16() { var arr = np.array(new ushort[] { 1, 2, 4 }); @@ -179,7 +179,7 @@ public void LeftShift_UInt16() result.Should().BeOfValues(16, 32, 64).And.BeOfType(NPTypeCode.UInt16); } - [Test] + [TestMethod] public void LeftShift_UInt32() { var arr = np.array(new uint[] { 1, 2, 4 }); @@ -188,7 +188,7 @@ public void LeftShift_UInt32() result.Should().BeOfValues(256u, 512u, 1024u).And.BeOfType(NPTypeCode.UInt32); } - [Test] + [TestMethod] public void LeftShift_UInt64() { var arr = np.array(new ulong[] { 1, 2, 4 }); diff --git a/test/NumSharp.UnitTest/Backends/Kernels/SimdOptimizationTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/SimdOptimizationTests.cs index 9b2f10aa0..ae572a75b 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/SimdOptimizationTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/SimdOptimizationTests.cs @@ -3,7 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -16,11 +15,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// - src/numpy/numpy/_core/tests/test_multiarray.py (argmax/argmin, masking) /// - src/numpy/numpy/_core/tests/test_indexing.py (boolean indexing) /// +[TestClass] public class SimdOptimizationTests { #region NonZero Tests (from NumPy test_numeric.py) - [Test] + [TestMethod] public void NonZero_1D_Basic() { // NumPy: np.nonzero([0, 1, 0, 3, 0, 5]) = [[1, 3, 5]] @@ -31,7 +31,7 @@ public void NonZero_1D_Basic() result[0].Should().BeOfValues(1, 3, 5); } - [Test] + [TestMethod] public void NonZero_2D_Basic() { // NumPy: np.nonzero([[0, 1, 0], [3, 0, 5]]) = [[0, 1, 1], [1, 0, 2]] @@ -43,7 +43,7 @@ public void NonZero_2D_Basic() result[1].Should().BeOfValues(1, 0, 2); // col indices } - [Test] + [TestMethod] public void NonZero_AllZeros() { // NumPy: np.nonzero(zeros(5)) = [[]] @@ -54,7 +54,7 @@ public void NonZero_AllZeros() Assert.AreEqual(0, result[0].size); } - [Test] + [TestMethod] public void NonZero_AllNonzero() { // NumPy: np.nonzero([1, 2, 3, 4, 5]) = [[0, 1, 2, 3, 4]] @@ -65,7 +65,7 @@ public void NonZero_AllNonzero() result[0].Should().BeOfValues(0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void NonZero_Boolean() { // NumPy: np.nonzero([True, False, True, False, True]) = [[0, 2, 4]] @@ -76,7 +76,7 @@ public void NonZero_Boolean() result[0].Should().BeOfValues(0, 2, 4); } - [Test] + [TestMethod] public void NonZero_Float() { // NumPy: np.nonzero([0.0, 1.5, 0.0, -2.5, 0.0]) = [[1, 3]] @@ -87,7 +87,7 @@ public void NonZero_Float() result[0].Should().BeOfValues(1, 3); } - [Test] + [TestMethod] public void NonZero_Large_SparseValues() { // NumPy: Large array with sparse nonzero values (tests SIMD path) @@ -101,7 +101,7 @@ public void NonZero_Large_SparseValues() result[0].Should().BeOfValues(100, 500, 999); } - [Test] + [TestMethod] public void NonZero_Empty() { // NumPy: np.nonzero([]) = [[]] @@ -112,7 +112,7 @@ public void NonZero_Empty() Assert.AreEqual(0, result[0].size); } - [Test] + [TestMethod] public void NonZero_3D() { // NumPy: 3D array with sparse nonzero values @@ -128,7 +128,7 @@ public void NonZero_3D() result[2].Should().BeOfValues(2, 3); // dim 2 indices } - [Test] + [TestMethod] public void NonZero_NaN_IsNonzero() { // NumPy: NaN is considered non-zero @@ -140,7 +140,7 @@ public void NonZero_NaN_IsNonzero() result[0].Should().BeOfValues(1, 2, 3); } - [Test] + [TestMethod] public void NonZero_EyeMatrix() { // NumPy: np.nonzero(eye(3)) = [[0, 1, 2], [0, 1, 2]] @@ -152,7 +152,7 @@ public void NonZero_EyeMatrix() result[1].Should().BeOfValues(0, 1, 2); } - [Test] + [TestMethod] public void NonZero_Int16() { // NumPy: dtype=int16, result = [[0, 2, 3, 6]] @@ -164,7 +164,7 @@ public void NonZero_Int16() result[0].Should().BeOfValues(0, 2, 3, 6); } - [Test] + [TestMethod] public void NonZero_UInt16() { // NumPy: dtype=uint16, result = [[1, 3]] @@ -175,7 +175,7 @@ public void NonZero_UInt16() result[0].Should().BeOfValues(1, 3); } - [Test] + [TestMethod] public void NonZero_SparsePattern() { // From NumPy test_sparse: sparse boolean pattern @@ -187,7 +187,7 @@ public void NonZero_SparsePattern() result[0].Should().BeOfValues(0, 20, 40, 60, 80, 100, 120, 140, 160, 180); } - [Test] + [TestMethod] public void NonZero_FromNumPyTest_Onedim() { // NumPy test_nonzero_onedim: x = [1, 0, 2, -1, 0, 0, 8] @@ -197,7 +197,7 @@ public void NonZero_FromNumPyTest_Onedim() result[0].Should().BeOfValues(0, 2, 3, 6); } - [Test] + [TestMethod] public void NonZero_FromNumPyTest_Twodim() { // NumPy test_nonzero_twodim: x = [[0, 1, 0], [2, 0, 3]] @@ -212,7 +212,7 @@ public void NonZero_FromNumPyTest_Twodim() #region ArgMax/ArgMin Tests (from NumPy test_multiarray.py, test_regression.py) - [Test] + [TestMethod] public void ArgMax_1D_Basic() { // NumPy: np.argmax([3, 1, 4, 1, 5, 9, 2, 6]) = 5 @@ -221,7 +221,7 @@ public void ArgMax_1D_Basic() Assert.AreEqual(5, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_1D_Basic() { // NumPy: np.argmin([3, 1, 4, 1, 5, 9, 2, 6]) = 1 @@ -230,7 +230,7 @@ public void ArgMin_1D_Basic() Assert.AreEqual(1, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_Ties_ReturnsFirstOccurrence() { // NumPy: np.argmax([5, 1, 5, 1, 5]) = 0 (first occurrence) @@ -239,7 +239,7 @@ public void ArgMax_Ties_ReturnsFirstOccurrence() Assert.AreEqual(0, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_Ties_ReturnsFirstOccurrence() { // NumPy: np.argmin([5, 1, 5, 1, 5]) = 1 (first occurrence of min) @@ -248,7 +248,7 @@ public void ArgMin_Ties_ReturnsFirstOccurrence() Assert.AreEqual(1, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_SingleElement() { // NumPy: np.argmax([42]) = 0 @@ -257,7 +257,7 @@ public void ArgMax_SingleElement() Assert.AreEqual(0, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_SingleElement() { // NumPy: np.argmin([42]) = 0 @@ -266,7 +266,7 @@ public void ArgMin_SingleElement() Assert.AreEqual(0, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_NegativeValues() { // NumPy: np.argmax([-5, -1, -3, -2, -4]) = 1 @@ -275,7 +275,7 @@ public void ArgMax_NegativeValues() Assert.AreEqual(1, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_NegativeValues() { // NumPy: np.argmin([-5, -1, -3, -2, -4]) = 0 @@ -284,7 +284,7 @@ public void ArgMin_NegativeValues() Assert.AreEqual(0, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_Infinity() { // NumPy: np.argmax([1.0, inf, -inf, 0.0]) = 1 @@ -293,7 +293,7 @@ public void ArgMax_Infinity() Assert.AreEqual(1, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_Infinity() { // NumPy: np.argmin([1.0, inf, -inf, 0.0]) = 2 @@ -302,7 +302,7 @@ public void ArgMin_Infinity() Assert.AreEqual(2, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_NaN_FirstNaNWins() { // NumPy: np.argmax([1.0, nan, 3.0, nan]) = 1 (NaN propagates, first NaN index) @@ -311,7 +311,7 @@ public void ArgMax_NaN_FirstNaNWins() Assert.AreEqual(1, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_NaN_FirstNaNWins() { // NumPy: np.argmin([1.0, nan, 3.0, nan]) = 1 (NaN propagates, first NaN index) @@ -320,7 +320,7 @@ public void ArgMin_NaN_FirstNaNWins() Assert.AreEqual(1, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_2D_Flattened() { // NumPy: np.argmax([[1, 2, 3], [4, 5, 6]]) = 5 (flat index) @@ -329,7 +329,7 @@ public void ArgMax_2D_Flattened() Assert.AreEqual(5, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_2D_Flattened() { // NumPy: np.argmin([[1, 2, 3], [4, 5, 6]]) = 0 (flat index) @@ -338,7 +338,7 @@ public void ArgMin_2D_Flattened() Assert.AreEqual(0, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_2D_Axis0() { // NumPy: np.argmax([[1, 5, 3], [4, 2, 6]], axis=0) = [1, 0, 1] @@ -349,7 +349,7 @@ public void ArgMax_2D_Axis0() result.Should().BeOfValues(1, 0, 1); } - [Test] + [TestMethod] public void ArgMin_2D_Axis0() { // NumPy: np.argmin([[1, 5, 3], [4, 2, 6]], axis=0) = [0, 1, 0] @@ -360,7 +360,7 @@ public void ArgMin_2D_Axis0() result.Should().BeOfValues(0, 1, 0); } - [Test] + [TestMethod] public void ArgMax_2D_Axis1() { // NumPy: np.argmax([[1, 5, 3], [4, 2, 6]], axis=1) = [1, 2] @@ -371,7 +371,7 @@ public void ArgMax_2D_Axis1() result.Should().BeOfValues(1, 2); } - [Test] + [TestMethod] public void ArgMin_2D_Axis1() { // NumPy: np.argmin([[1, 5, 3], [4, 2, 6]], axis=1) = [0, 1] @@ -382,7 +382,7 @@ public void ArgMin_2D_Axis1() result.Should().BeOfValues(0, 1); } - [Test] + [TestMethod] public void ArgMax_Large_SIMDPath() { // NumPy: Large array (tests SIMD path), max at end @@ -391,7 +391,7 @@ public void ArgMax_Large_SIMDPath() Assert.AreEqual(9999, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_Large_SIMDPath() { // NumPy: Large array (tests SIMD path), min at start @@ -400,7 +400,7 @@ public void ArgMin_Large_SIMDPath() Assert.AreEqual(0, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_Large_MaxInMiddle() { // NumPy: Large array with max in middle @@ -410,7 +410,7 @@ public void ArgMax_Large_MaxInMiddle() Assert.AreEqual(5000, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMax_UInt8() { // NumPy: np.argmax([255, 0, 128, 64], dtype=uint8) = 0 @@ -419,7 +419,7 @@ public void ArgMax_UInt8() Assert.AreEqual(0, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_UInt8() { // NumPy: np.argmin([255, 0, 128, 64], dtype=uint8) = 1 @@ -428,7 +428,7 @@ public void ArgMin_UInt8() Assert.AreEqual(1, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_Boolean() { // NumPy: np.argmax([False, True, False, True]) = 1 @@ -437,7 +437,7 @@ public void ArgMax_Boolean() Assert.AreEqual(1, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_Boolean() { // NumPy: np.argmin([False, True, False, True]) = 0 @@ -446,7 +446,7 @@ public void ArgMin_Boolean() Assert.AreEqual(0, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_Int16() { // NumPy: np.argmax([100, -200, 300, -400, 500], dtype=int16) = 4 @@ -455,7 +455,7 @@ public void ArgMax_Int16() Assert.AreEqual(4, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_Int16() { // NumPy: np.argmin([100, -200, 300, -400, 500], dtype=int16) = 3 @@ -464,7 +464,7 @@ public void ArgMin_Int16() Assert.AreEqual(3, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_Int64() { // NumPy: np.argmax([1000000000000, -2000000000000, 3000000000000], dtype=int64) = 2 @@ -473,7 +473,7 @@ public void ArgMax_Int64() Assert.AreEqual(2, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_Int64() { // NumPy: np.argmin([1000000000000, -2000000000000, 3000000000000], dtype=int64) = 1 @@ -482,7 +482,7 @@ public void ArgMin_Int64() Assert.AreEqual(1, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_Float32() { // NumPy: np.argmax([1.5, 2.5, 0.5, 3.5], dtype=float32) = 3 @@ -491,7 +491,7 @@ public void ArgMax_Float32() Assert.AreEqual(3, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_Float32() { // NumPy: np.argmin([1.5, 2.5, 0.5, 3.5], dtype=float32) = 2 @@ -500,7 +500,7 @@ public void ArgMin_Float32() Assert.AreEqual(2, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_2D_NegativeAxis() { // NumPy: np.argmax([[1, 5, 3], [4, 2, 6]], axis=-1) = [1, 2] @@ -511,7 +511,7 @@ public void ArgMax_2D_NegativeAxis() result.Should().BeOfValues(1, 2); } - [Test] + [TestMethod] public void ArgMin_2D_NegativeAxis() { // NumPy: np.argmin([[1, 5, 3], [4, 2, 6]], axis=-1) = [0, 1] @@ -522,7 +522,7 @@ public void ArgMin_2D_NegativeAxis() result.Should().BeOfValues(0, 1); } - [Test] + [TestMethod] public void ArgMax_AllSameValues() { // NumPy: np.argmax([7, 7, 7, 7, 7]) = 0 (returns first) @@ -531,7 +531,7 @@ public void ArgMax_AllSameValues() Assert.AreEqual(0, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_AllSameValues() { // NumPy: np.argmin([7, 7, 7, 7, 7]) = 0 (returns first) @@ -540,7 +540,7 @@ public void ArgMin_AllSameValues() Assert.AreEqual(0, np.argmin(a)); } - [Test] + [TestMethod] public void ArgMax_DecreasingOrder() { // NumPy: np.argmax([9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) = 0 @@ -549,7 +549,7 @@ public void ArgMax_DecreasingOrder() Assert.AreEqual(0, np.argmax(a)); } - [Test] + [TestMethod] public void ArgMin_DecreasingOrder() { // NumPy: np.argmin([9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) = 9 @@ -562,7 +562,7 @@ public void ArgMin_DecreasingOrder() #region Boolean Masking Tests (from NumPy test_indexing.py, test_multiarray.py) - [Test] + [TestMethod] public void BooleanMask_1D_Basic() { // NumPy: a[[T,F,T,F,T,F]] = [1, 3, 5] @@ -574,7 +574,7 @@ public void BooleanMask_1D_Basic() result.Should().BeOfValues(1, 3, 5); } - [Test] + [TestMethod] public void BooleanMask_Condition() { // NumPy: a[a > 3] = [4, 5, 6] @@ -585,7 +585,7 @@ public void BooleanMask_Condition() result.Should().BeOfValues(4, 5, 6); } - [Test] + [TestMethod] public void BooleanMask_AllTrue() { // NumPy: a[[T, T, T]] = [1, 2, 3] @@ -597,7 +597,7 @@ public void BooleanMask_AllTrue() result.Should().BeOfValues(1, 2, 3); } - [Test] + [TestMethod] public void BooleanMask_AllFalse() { // NumPy: a[[F, F, F]] = [] @@ -609,7 +609,7 @@ public void BooleanMask_AllFalse() Assert.AreEqual(0, result.size); } - [Test] + [TestMethod] public void BooleanMask_EmptyResult_Shape() { // NumPy: Empty result has shape (0,) and preserves dtype @@ -622,7 +622,7 @@ public void BooleanMask_EmptyResult_Shape() Assert.AreEqual(0, result.shape[0]); } - [Test] + [TestMethod] public void BooleanMask_2D_RowSelection() { // NumPy: arr2d[[T, F, T]] selects rows 0 and 2 -> [[1,2,3], [7,8,9]] @@ -637,7 +637,7 @@ public void BooleanMask_2D_RowSelection() Assert.AreEqual(7, result.GetInt32(1, 0)); } - [Test] + [TestMethod] public void BooleanMask_2D_Flattens() { // NumPy: 2D mask flattens result: [[T,F],[F,T]] on [[1,2],[3,4]] -> [1, 4] @@ -650,7 +650,7 @@ public void BooleanMask_2D_Flattens() result.Should().BeOfValues(1, 4); } - [Test] + [TestMethod] public void BooleanMask_Float() { // NumPy: a[a > 2.0] = [2.5, 3.5, 4.5] @@ -662,7 +662,7 @@ public void BooleanMask_Float() result.Should().BeOfValues(2.5, 3.5, 4.5); } - [Test] + [TestMethod] public void BooleanMask_Large_SIMDPath() { // NumPy: Large array (tests SIMD path) @@ -674,7 +674,7 @@ public void BooleanMask_Large_SIMDPath() result.Should().BeOfValues(0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000); } - [Test] + [TestMethod] public void BooleanMask_Int16_PreservesDtype() { // NumPy: Result preserves dtype @@ -687,7 +687,7 @@ public void BooleanMask_Int16_PreservesDtype() result.Should().BeOfValues((short)1, (short)3); } - [Test] + [TestMethod] public void BooleanMask_ComplexCondition() { // NumPy: a[(a > 3) & (a < 8)] = [4, 5, 6, 7] @@ -699,7 +699,7 @@ public void BooleanMask_ComplexCondition() result.Should().BeOfValues(4, 5, 6, 7); } - [Test] + [TestMethod] public void BooleanMask_FromNumPyTest_Basic() { // From NumPy test_mask: x = [1, 2, 3, 4], m = [F, T, F, F] -> [2] @@ -711,7 +711,7 @@ public void BooleanMask_FromNumPyTest_Basic() result.Should().BeOfValues(2); } - [Test] + [TestMethod] public void BooleanMask_FromNumPyTest_2D_RowMask() { // From NumPy test_mask2: x = [[1,2,3,4],[5,6,7,8]], m = [F, T] -> [[5,6,7,8]] @@ -725,7 +725,7 @@ public void BooleanMask_FromNumPyTest_2D_RowMask() result["0, :"].Should().BeOfValues(5, 6, 7, 8); } - [Test] + [TestMethod] public void BooleanMask_FromNumPyTest_2D_ElementMask() { // From NumPy test_mask2: 2D element mask flattens @@ -738,7 +738,7 @@ public void BooleanMask_FromNumPyTest_2D_ElementMask() result.Should().BeOfValues(2, 5); } - [Test] + [TestMethod] public void BooleanMask_UInt8() { // NumPy: uint8 dtype preserved @@ -751,7 +751,7 @@ public void BooleanMask_UInt8() result.Should().BeOfValues((byte)10, (byte)30, (byte)50); } - [Test] + [TestMethod] public void BooleanMask_Int32_Condition() { // NumPy: a[a > 250] = [300, 400, 500] @@ -763,7 +763,7 @@ public void BooleanMask_Int32_Condition() result.Should().BeOfValues(300, 400, 500); } - [Test] + [TestMethod] public void BooleanMask_Float64_Condition() { // NumPy: a[a < 3.5] = [1.1, 2.2, 3.3] @@ -775,7 +775,7 @@ public void BooleanMask_Float64_Condition() result.Should().BeOfValuesApproximately(0.001, 1.1, 2.2, 3.3); } - [Test] + [TestMethod] public void BooleanMask_EvenNumbers() { // NumPy: a[a % 2 == 0] = [2, 4, 6] @@ -786,7 +786,7 @@ public void BooleanMask_EvenNumbers() result.Should().BeOfValues(2, 4, 6); } - [Test] + [TestMethod] public void BooleanMask_2D_Condition_Flattens() { // NumPy: arr2d[arr2d > 5] = [6, 7, 8, 9, 10, 11] (flattened) diff --git a/test/NumSharp.UnitTest/Backends/Kernels/SlicedArrayOpTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/SlicedArrayOpTests.cs index 28969f019..7cac1240c 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/SlicedArrayOpTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/SlicedArrayOpTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -11,11 +10,12 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// All expected values are verified against NumPy 2.x output. /// Sliced arrays test the strided path of IL kernels rather than the SIMD contiguous path. /// +[TestClass] public class SlicedArrayOpTests { #region Binary Operations on Sliced Arrays - [Test] + [TestMethod] public void Add_SlicedArrays_Int32() { // NumPy: a[::2] + b[::2] where a=[1,2,3,4,5,6,7,8], b=[10,20,30,40,50,60,70,80] @@ -29,7 +29,7 @@ public void Add_SlicedArrays_Int32() result.Should().BeOfValues(11, 33, 55, 77).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Add_SlicedArrays_SameSource() { // NumPy: a[::2] + a[1::2] where a=[1,2,3,4,5,6,7,8] @@ -42,7 +42,7 @@ public void Add_SlicedArrays_SameSource() result.Should().BeOfValues(3, 7, 11, 15).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Subtract_SlicedArrays_Float64() { // a[::2] - a[1::2] @@ -57,7 +57,7 @@ public void Subtract_SlicedArrays_Float64() Assert.AreEqual(44.0, result.GetDouble(2), 1e-10); } - [Test] + [TestMethod] public void Multiply_SlicedArrays_Int32() { var a = np.array(new[] { 1, 2, 3, 4, 5, 6 }); @@ -69,7 +69,7 @@ public void Multiply_SlicedArrays_Int32() result.Should().BeOfValues(2, 12, 30).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Divide_SlicedArrays_Float64() { var a = np.array(new[] { 10.0, 2.0, 30.0, 5.0, 60.0, 6.0 }); @@ -83,7 +83,7 @@ public void Divide_SlicedArrays_Float64() Assert.AreEqual(10.0, result.GetDouble(2), 1e-10); } - [Test] + [TestMethod] public void Add_SlicedWithScalar() { // NumPy: j[::2] + 5 where j=[10, 20, 30, 40, 50] @@ -96,7 +96,7 @@ public void Add_SlicedWithScalar() result.Should().BeOfValues(15, 35, 55).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Multiply_SlicedWithScalar() { // NumPy: j[1::2] * 2 where j=[10, 20, 30, 40, 50] @@ -113,7 +113,7 @@ public void Multiply_SlicedWithScalar() #region 2D Sliced Operations - [Test] + [TestMethod] public void Add_2DSliced_Rows() { // c[::2, :] + c[1::1, :] for 3x3 array @@ -129,7 +129,7 @@ public void Add_2DSliced_Rows() Assert.AreEqual(7.0, sliced.GetDouble(1, 0), 1e-10); } - [Test] + [TestMethod] public void Add_2DSliced_Cols() { var c = np.array(new double[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }); @@ -144,7 +144,7 @@ public void Add_2DSliced_Cols() Assert.AreEqual(6.0, sliced.GetDouble(1, 1), 1e-10); } - [Test] + [TestMethod] public void Add_2DSliced_Corners() { var c = np.array(new double[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }); @@ -164,7 +164,7 @@ public void Add_2DSliced_Corners() #region Unary Operations on Sliced Arrays - [Test] + [TestMethod] public void Sin_SlicedArray() { // NumPy: np.sin(d[::2]) where d=[0, 1, 2, 3, 4, 5] @@ -179,7 +179,7 @@ public void Sin_SlicedArray() Assert.AreEqual(-0.7568025, result.GetDouble(2), 1e-7); } - [Test] + [TestMethod] public void Sqrt_SlicedArray() { // NumPy: np.sqrt(d[1::2]) where d=[0, 1, 2, 3, 4, 5] @@ -194,7 +194,7 @@ public void Sqrt_SlicedArray() Assert.AreEqual(2.23606798, result.GetDouble(2), 1e-7); } - [Test] + [TestMethod] public void Cos_SlicedArray() { var d = np.array(new[] { 0.0, Math.PI / 2, Math.PI, Math.PI * 1.5, Math.PI * 2 }); @@ -208,7 +208,7 @@ public void Cos_SlicedArray() Assert.AreEqual(1.0, result.GetDouble(2), 1e-10); } - [Test] + [TestMethod] public void Exp_SlicedArray() { var d = np.array(new[] { 0.0, 1.0, 2.0, 3.0 }); @@ -221,7 +221,7 @@ public void Exp_SlicedArray() Assert.AreEqual(Math.Exp(2.0), result.GetDouble(1), 1e-10); } - [Test] + [TestMethod] public void Log_SlicedArray() { var d = np.array(new[] { 1.0, 2.0, Math.E, 4.0, Math.E * Math.E }); @@ -235,7 +235,7 @@ public void Log_SlicedArray() Assert.AreEqual(2.0, result.GetDouble(2), 1e-10); } - [Test] + [TestMethod] public void Abs_SlicedArray() { var d = np.array(new[] { -5.0, 3.0, -2.0, 7.0, -1.0, 9.0 }); @@ -253,7 +253,7 @@ public void Abs_SlicedArray() #region Comparison Operations on Sliced Arrays - [Test] + [TestMethod] public void LessThan_SlicedArrays() { // NumPy: e[::2] < e[1::2] where e=[1, 5, 2, 6, 3, 7] @@ -268,7 +268,7 @@ public void LessThan_SlicedArrays() Assert.IsTrue(result.GetBoolean(2)); } - [Test] + [TestMethod] public void GreaterThan_SlicedWithScalar() { // NumPy: e[::2] > 2 where e=[1, 5, 2, 6, 3, 7] @@ -283,7 +283,7 @@ public void GreaterThan_SlicedWithScalar() Assert.IsTrue(result.GetBoolean(2)); } - [Test] + [TestMethod] public void Equal_SlicedArrays() { var a = np.array(new[] { 1, 2, 3, 2, 5, 2 }); @@ -301,7 +301,7 @@ public void Equal_SlicedArrays() #region Bitwise Operations on Sliced Arrays - [Test] + [TestMethod] public void BitwiseAnd_SlicedBoolArrays() { // NumPy: f[::2] & g[::2] @@ -318,7 +318,7 @@ public void BitwiseAnd_SlicedBoolArrays() Assert.IsFalse(result.GetBoolean(2)); } - [Test] + [TestMethod] public void BitwiseOr_SlicedBoolArrays() { // NumPy: f[::2] | g[::2] @@ -334,7 +334,7 @@ public void BitwiseOr_SlicedBoolArrays() Assert.IsTrue(result.GetBoolean(2)); } - [Test] + [TestMethod] public void BitwiseXor_SlicedIntArrays() { var a = np.array(new[] { 0b1010, 0b0000, 0b1111, 0b0000, 0b0101 }); @@ -357,7 +357,7 @@ public void BitwiseXor_SlicedIntArrays() #region Reduction Operations on Sliced Arrays - [Test] + [TestMethod] public void Sum_SlicedArray() { // NumPy: np.sum(h[::2]) where h=[1, 2, 3, 4, 5, 6, 7, 8] @@ -370,7 +370,7 @@ public void Sum_SlicedArray() Assert.AreEqual(16.0, result.GetDouble(0), 1e-10); } - [Test] + [TestMethod] public void Mean_SlicedArray() { // NumPy: np.mean(h[1::2]) where h=[1, 2, 3, 4, 5, 6, 7, 8] @@ -383,7 +383,7 @@ public void Mean_SlicedArray() Assert.AreEqual(5.0, result.GetDouble(0), 1e-10); } - [Test] + [TestMethod] public void Max_SlicedArray() { // NumPy: np.max(h[::3]) where h=[1, 2, 3, 4, 5, 6, 7, 8] @@ -396,7 +396,7 @@ public void Max_SlicedArray() Assert.AreEqual(7.0, result.GetDouble(0), 1e-10); } - [Test] + [TestMethod] public void Min_SlicedArray() { var h = np.array(new[] { 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 }); @@ -408,7 +408,7 @@ public void Min_SlicedArray() Assert.AreEqual(2.0, result.GetDouble(0), 1e-10); } - [Test] + [TestMethod] public void Sum_2DSliced() { // NumPy: np.sum(c[::2, :]) where c=[[1,2,3],[4,5,6],[7,8,9]] @@ -421,7 +421,7 @@ public void Sum_2DSliced() Assert.AreEqual(30.0, result.GetDouble(0), 1e-10); } - [Test] + [TestMethod] public void Sum_2DSlicedCols() { // NumPy: np.sum(c[:, ::2]) where c=[[1,2,3],[4,5,6],[7,8,9]] @@ -438,7 +438,7 @@ public void Sum_2DSlicedCols() #region Reversed Slice Operations - [Test] + [TestMethod] public void Add_ReversedSlice() { // NumPy: i[::-1] + i where i=[1, 2, 3, 4, 5] @@ -455,7 +455,7 @@ public void Add_ReversedSlice() Assert.AreEqual(6.0, result.GetDouble(4), 1e-10); } - [Test] + [TestMethod] public void Sum_ReversedSlice() { // NumPy: np.sum(i[::-1]) = 15 (same as forward) @@ -466,7 +466,7 @@ public void Sum_ReversedSlice() Assert.AreEqual(15.0, result.GetDouble(0), 1e-10); } - [Test] + [TestMethod] public void Sin_ReversedStridedSlice() { // NumPy: np.sin(i[::-2]) where i=[1, 2, 3, 4, 5] @@ -481,7 +481,7 @@ public void Sin_ReversedStridedSlice() Assert.AreEqual(0.84147098, result.GetDouble(2), 1e-7); } - [Test] + [TestMethod] public void Multiply_ReversedSlice() { var a = np.array(new[] { 1, 2, 3, 4 }); @@ -497,7 +497,7 @@ public void Multiply_ReversedSlice() #region Mixed Contiguous and Sliced Operations - [Test] + [TestMethod] public void Add_ContiguousWithSliced() { // Contiguous + Sliced @@ -509,7 +509,7 @@ public void Add_ContiguousWithSliced() result.Should().BeOfValues(11, 32, 53, 74).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Multiply_SlicedWithContiguous() { // Sliced * Contiguous @@ -525,7 +525,7 @@ public void Multiply_SlicedWithContiguous() #region Type Preservation on Sliced Arrays - [Test] + [TestMethod] public void Add_SlicedByte() { var a = np.array(new byte[] { 1, 2, 3, 4, 5, 6 }); @@ -536,7 +536,7 @@ public void Add_SlicedByte() result.Should().BeOfValues(11, 33, 55).And.BeOfType(NPTypeCode.Byte); } - [Test] + [TestMethod] public void Add_SlicedFloat32() { var a = np.array(new float[] { 1.5f, 2.5f, 3.5f, 4.5f }); @@ -549,7 +549,7 @@ public void Add_SlicedFloat32() Assert.AreEqual(5.0f, result.GetSingle(1), 1e-5f); } - [Test] + [TestMethod] public void Add_SlicedInt64() { var a = np.array(new long[] { 1000000000000L, 2, 3000000000000L, 4 }); @@ -566,7 +566,7 @@ public void Add_SlicedInt64() #region Edge Cases - [Test] + [TestMethod] public void SingleElement_Slice() { var a = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -579,7 +579,7 @@ public void SingleElement_Slice() Assert.AreEqual(3, sliced.GetInt32(0)); } - [Test] + [TestMethod] public void Step_GreaterThanSize() { var a = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -591,7 +591,7 @@ public void Step_GreaterThanSize() Assert.AreEqual(1, sliced.GetInt32(0)); } - [Test] + [TestMethod] public void NegativeStep_FullReverse() { var a = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -606,7 +606,7 @@ public void NegativeStep_FullReverse() Assert.AreEqual(1, sliced.GetInt32(4)); } - [Test] + [TestMethod] public void SliceOfSlice() { var a = np.array(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); @@ -621,7 +621,7 @@ public void SliceOfSlice() Assert.AreEqual(9, sliced.GetInt32(2)); } - [Test] + [TestMethod] public void SliceOfSlice_Operations() { var a = np.array(new[] { 1, 2, 3, 4, 5, 6, 7, 8 }); diff --git a/test/NumSharp.UnitTest/Backends/Kernels/TypePromotionTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/TypePromotionTests.cs index 608419c81..8412bf157 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/TypePromotionTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/TypePromotionTests.cs @@ -1,7 +1,6 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -17,6 +16,7 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// - Division always returns float64 (true division) /// - Floor division preserves integer type /// +[TestClass] public class TypePromotionTests { #region Reduction Promotion Tests @@ -24,7 +24,7 @@ public class TypePromotionTests /// /// NumPy: np.sum(np.int32([1,2,3])).dtype -> int64 /// - [Test] + [TestMethod] public void Sum_Int32_ReturnsInt64() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -39,7 +39,7 @@ public void Sum_Int32_ReturnsInt64() /// /// NumPy: np.prod(np.int32([2,3,4])).dtype -> int64 /// - [Test] + [TestMethod] public void Prod_Int32_ReturnsInt64() { var arr = np.array(new int[] { 2, 3, 4 }); @@ -54,7 +54,7 @@ public void Prod_Int32_ReturnsInt64() /// /// NumPy: np.cumsum(np.int32([1,2,3])).dtype -> int64 /// - [Test] + [TestMethod] public void Cumsum_Int32_ReturnsInt64() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -73,7 +73,7 @@ public void Cumsum_Int32_ReturnsInt64() /// /// NumPy: np.max(np.int32([1,2,3])).dtype -> int32 (preserves) /// - [Test] + [TestMethod] public void Max_Int32_PreservesType() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -88,7 +88,7 @@ public void Max_Int32_PreservesType() /// /// NumPy: np.min(np.int32([1,2,3])).dtype -> int32 (preserves) /// - [Test] + [TestMethod] public void Min_Int32_PreservesType() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -103,7 +103,7 @@ public void Min_Int32_PreservesType() /// /// NumPy: np.mean(np.int32([1,2,3])).dtype -> float64 /// - [Test] + [TestMethod] public void Mean_Int32_ReturnsFloat64() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -118,7 +118,7 @@ public void Mean_Int32_ReturnsFloat64() /// /// NumPy: np.std(np.int32([1,2,3])).dtype -> float64 /// - [Test] + [TestMethod] public void Std_Int32_ReturnsFloat64() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -132,7 +132,7 @@ public void Std_Int32_ReturnsFloat64() /// /// NumPy: np.var(np.int32([1,2,3])).dtype -> float64 /// - [Test] + [TestMethod] public void Var_Int32_ReturnsFloat64() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -150,7 +150,7 @@ public void Var_Int32_ReturnsFloat64() /// /// NumPy: (int32 + int32).dtype -> int32 /// - [Test] + [TestMethod] public void Add_Int32_Int32_PreservesType() { var a = np.array(new int[] { 1, 2, 3 }); @@ -164,7 +164,7 @@ public void Add_Int32_Int32_PreservesType() /// /// NumPy: (int32 + int64).dtype -> int64 /// - [Test] + [TestMethod] public void Add_Int32_Int64_ReturnsInt64() { var a = np.array(new int[] { 1, 2, 3 }); @@ -178,7 +178,7 @@ public void Add_Int32_Int64_ReturnsInt64() /// /// NumPy: (int32 + float32).dtype -> float64 /// - [Test] + [TestMethod] public void Add_Int32_Float32_ReturnsFloat64() { var a = np.array(new int[] { 1, 2, 3 }); @@ -193,7 +193,7 @@ public void Add_Int32_Float32_ReturnsFloat64() /// /// NumPy: (int64 + float32).dtype -> float64 /// - [Test] + [TestMethod] public void Add_Int64_Float32_ReturnsFloat64() { var a = np.array(new long[] { 1L, 2L, 3L }); @@ -208,7 +208,7 @@ public void Add_Int64_Float32_ReturnsFloat64() /// /// NumPy: (float32 + float64).dtype -> float64 /// - [Test] + [TestMethod] public void Add_Float32_Float64_ReturnsFloat64() { var a = np.array(new float[] { 1.0f, 2.0f, 3.0f }); @@ -226,7 +226,7 @@ public void Add_Float32_Float64_ReturnsFloat64() /// /// NumPy: (int32 / int32).dtype -> float64 (true division) /// - [Test] + [TestMethod] public void Divide_Int32_Int32_ReturnsFloat64() { var a = np.array(new int[] { 4, 5, 6 }); @@ -247,7 +247,7 @@ public void Divide_Int32_Int32_ReturnsFloat64() /// NumPy: (int32 // int32).dtype -> int32 (floor division) /// Note: NumSharp may not have floor division operator /// - [Test] + [TestMethod] public void FloorDivide_Int32_Int32_PreservesType() { var a = np.array(new int[] { 5, 7, 9 }); @@ -273,7 +273,7 @@ public void FloorDivide_Int32_Int32_PreservesType() /// /// NumPy: np.power(int32, 2).dtype -> int32 /// - [Test] + [TestMethod] public void Power_Int32_Int_PreservesType() { var a = np.array(new int[] { 2, 3, 4 }); @@ -292,7 +292,7 @@ public void Power_Int32_Int_PreservesType() /// /// NumPy: np.power(int32, 2.0).dtype -> float64 /// - [Test] + [TestMethod] public void Power_Int32_Float_ReturnsFloat64() { var a = np.array(new int[] { 2, 3, 4 }); @@ -315,7 +315,7 @@ public void Power_Int32_Float_ReturnsFloat64() /// /// NumPy: np.sqrt(int32).dtype -> float64 /// - [Test] + [TestMethod] public void Sqrt_Int32_ReturnsFloat64() { var arr = np.array(new int[] { 4, 9, 16 }); @@ -334,7 +334,7 @@ public void Sqrt_Int32_ReturnsFloat64() /// /// NumPy: np.abs(int32).dtype -> int32 (preserves) /// - [Test] + [TestMethod] public void Abs_Int32_PreservesType() { var arr = np.array(new int[] { -1, -2, 3 }); @@ -353,7 +353,7 @@ public void Abs_Int32_PreservesType() /// /// NumPy: np.sign(int32).dtype -> int32 (preserves) /// - [Test] + [TestMethod] public void Sign_Int32_PreservesType() { var arr = np.array(new int[] { -5, 0, 5 }); @@ -372,7 +372,7 @@ public void Sign_Int32_PreservesType() /// /// NumPy: np.square(int32).dtype -> int32 (preserves) /// - [Test] + [TestMethod] public void Square_Int32_PreservesType() { var arr = np.array(new int[] { 2, 3, 4 }); @@ -391,7 +391,7 @@ public void Square_Int32_PreservesType() /// /// NumPy: np.negative(int32).dtype -> int32 (preserves) /// - [Test] + [TestMethod] public void Negative_Int32_PreservesType() { var arr = np.array(new int[] { 1, -2, 3 }); @@ -415,7 +415,7 @@ public void Negative_Int32_PreservesType() /// NumPy: np.argmax([1,2,3]) -> 2 (returns int64 scalar) /// NumSharp: np.argmax now returns long (C# long = int64) - aligned with NumPy /// - [Test] + [TestMethod] public void ArgMax_ReturnsCorrectIndex() { var arr = np.array(new int[] { 1, 3, 2 }); @@ -429,7 +429,7 @@ public void ArgMax_ReturnsCorrectIndex() /// NumPy: np.argmin([1,2,3]) -> 0 (returns int64 scalar) /// NumSharp: np.argmin now returns long (C# long = int64) - aligned with NumPy /// - [Test] + [TestMethod] public void ArgMin_ReturnsCorrectIndex() { var arr = np.array(new int[] { 3, 1, 2 }); @@ -442,7 +442,7 @@ public void ArgMin_ReturnsCorrectIndex() /// /// NumPy: np.argmax(arr, axis=0) returns NDArray with dtype int64 /// - [Test] + [TestMethod] public void ArgMax_WithAxis_ReturnsInt64Array() { var arr = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); @@ -460,7 +460,7 @@ public void ArgMax_WithAxis_ReturnsInt64Array() /// /// NumPy: np.argmin(arr, axis=0) returns NDArray with dtype int64 /// - [Test] + [TestMethod] public void ArgMin_WithAxis_ReturnsInt64Array() { var arr = np.array(new int[,] { { 3, 4 }, { 1, 2 } }); @@ -483,7 +483,7 @@ public void ArgMin_WithAxis_ReturnsInt64Array() /// Test reduction along axis maintains correct shape and dtype. /// NumPy: np.sum([[1,2],[3,4]], axis=0) -> [4, 6] with dtype int64 /// - [Test] + [TestMethod] public void Sum_WithAxis_CorrectShapeAndType() { var arr = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); @@ -506,7 +506,7 @@ public void Sum_WithAxis_CorrectShapeAndType() /// Test keepdims parameter with reduction. /// NumPy: np.sum([[1,2],[3,4]], axis=0, keepdims=True) -> [[4, 6]] /// - [Test] + [TestMethod] public void Sum_WithKeepdims_CorrectShape() { var arr = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); @@ -525,7 +525,7 @@ public void Sum_WithKeepdims_CorrectShape() /// /// NumPy: byte + int32 -> int32 /// - [Test] + [TestMethod] public void Add_Byte_Int32_ReturnsInt32() { var a = np.array(new byte[] { 1, 2, 3 }); @@ -539,7 +539,7 @@ public void Add_Byte_Int32_ReturnsInt32() /// /// NumPy: uint32 + int32 -> int64 (to avoid overflow) /// - [Test] + [TestMethod] public void Add_UInt32_Int32_ReturnsInt64() { var a = np.array(new uint[] { 1, 2, 3 }); @@ -559,7 +559,7 @@ public void Add_UInt32_Int32_ReturnsInt64() /// NumPy: np.max(np.array([])) raises ValueError /// "zero-size array to reduction operation maximum which has no identity" /// - [Test] + [TestMethod] public void Max_EmptyArray_ThrowsArgumentException() { var empty = np.array(new double[0]); @@ -570,7 +570,7 @@ public void Max_EmptyArray_ThrowsArgumentException() /// NumPy: np.min(np.array([])) raises ValueError /// "zero-size array to reduction operation minimum which has no identity" /// - [Test] + [TestMethod] public void Min_EmptyArray_ThrowsArgumentException() { var empty = np.array(new double[0]); @@ -581,7 +581,7 @@ public void Min_EmptyArray_ThrowsArgumentException() /// NumPy: np.argmax(np.array([])) raises ValueError /// "attempt to get argmax of an empty sequence" /// - [Test] + [TestMethod] public void ArgMax_EmptyArray_ThrowsArgumentException() { var empty = np.array(new double[0]); @@ -592,7 +592,7 @@ public void ArgMax_EmptyArray_ThrowsArgumentException() /// NumPy: np.argmin(np.array([])) raises ValueError /// "attempt to get argmin of an empty sequence" /// - [Test] + [TestMethod] public void ArgMin_EmptyArray_ThrowsArgumentException() { var empty = np.array(new double[0]); diff --git a/test/NumSharp.UnitTest/Backends/Kernels/UnaryOpTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/UnaryOpTests.cs index b49d0c281..06c6990a3 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/UnaryOpTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/UnaryOpTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -10,6 +9,7 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// Comprehensive tests for unary operations. /// All expected values are verified against NumPy 2.x output. /// +[TestClass] public class UnaryOpTests { private const double Tolerance = 1e-10; @@ -17,7 +17,7 @@ public class UnaryOpTests #region Trigonometric Functions - [Test] + [TestMethod] public void Sin_Float64() { // NumPy: sin([0, π/6, π/4, π/2, π]) @@ -31,7 +31,7 @@ public void Sin_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(4)) < Tolerance); // sin(π) ≈ 0 } - [Test] + [TestMethod] public void Cos_Float64() { // NumPy: cos([0, π/6, π/4, π/2, π]) @@ -45,7 +45,7 @@ public void Cos_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(4) - (-1.0)) < Tolerance); } - [Test] + [TestMethod] public void Tan_Float64() { // NumPy: tan([0, π/4, -π/4]) @@ -61,7 +61,7 @@ public void Tan_Float64() #region Inverse Trigonometric Functions - [Test] + [TestMethod] public void ASin_Float64() { // NumPy: arcsin([-1, -0.5, 0, 0.5, 1]) @@ -75,7 +75,7 @@ public void ASin_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(4) - (Pi / 2)) < Tolerance); } - [Test] + [TestMethod] public void ACos_Float64() { // NumPy: arccos([-1, -0.5, 0, 0.5, 1]) @@ -89,7 +89,7 @@ public void ACos_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(4) - 0.0) < Tolerance); } - [Test] + [TestMethod] public void ATan_Float64() { // NumPy: arctan([-1, -0.5, 0, 0.5, 1]) @@ -107,7 +107,7 @@ public void ATan_Float64() #region Hyperbolic Functions - [Test] + [TestMethod] public void Sinh_Float64() { // NumPy: sinh([-2, -1, 0, 1, 2]) @@ -121,7 +121,7 @@ public void Sinh_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(4) - 3.6268604078470186) < Tolerance); } - [Test] + [TestMethod] public void Cosh_Float64() { // NumPy: cosh([-2, -1, 0, 1, 2]) @@ -135,7 +135,7 @@ public void Cosh_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(4) - 3.7621956910836314) < Tolerance); } - [Test] + [TestMethod] public void Tanh_Float64() { // NumPy: tanh([-2, -1, 0, 1, 2]) @@ -153,7 +153,7 @@ public void Tanh_Float64() #region Logarithmic Functions - [Test] + [TestMethod] public void Log_Float64() { // NumPy: log([0.001, 0.5, 1, e, 10, 100]) @@ -168,7 +168,7 @@ public void Log_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(5) - 4.605170185988092) < Tolerance); } - [Test] + [TestMethod] public void Log2_Float64() { var input = np.array(new double[] { 0.5, 1, 2, 4, 8, 1024 }); @@ -182,7 +182,7 @@ public void Log2_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(5) - 10.0) < Tolerance); } - [Test] + [TestMethod] public void Log10_Float64() { var input = np.array(new double[] { 0.001, 0.1, 1, 10, 100 }); @@ -195,7 +195,7 @@ public void Log10_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(4) - 2.0) < Tolerance); } - [Test] + [TestMethod] public void Log1p_Float64() { // NumPy: log1p([0, 0.5, 1, e-1, 9, 99]) @@ -214,7 +214,7 @@ public void Log1p_Float64() #region Exponential Functions - [Test] + [TestMethod] public void Exp_Float64() { // NumPy: exp([0, 0.5, 1, 2]) @@ -227,7 +227,7 @@ public void Exp_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(3) - 7.38905609893065) < Tolerance); } - [Test] + [TestMethod] public void Exp2_Float64() { // NumPy: exp2([0, 1, 2, 3, 10]) @@ -241,7 +241,7 @@ public void Exp2_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(4) - 1024.0) < Tolerance); } - [Test] + [TestMethod] public void Expm1_Float64() { // NumPy: expm1([0, 0.5, 1, 2]) @@ -258,7 +258,7 @@ public void Expm1_Float64() #region General Operations - [Test] + [TestMethod] public void Abs_Float64() { // NumPy: abs([-5.5, -1, 0, 1, 2.5, 100]) @@ -268,7 +268,7 @@ public void Abs_Float64() result.Should().BeOfValues(5.5, 1.0, 0.0, 1.0, 2.5, 100.0); } - [Test] + [TestMethod] public void Abs_Int32() { var input = np.array(new[] { -5, -1, 0, 1, 5 }); @@ -277,7 +277,7 @@ public void Abs_Int32() result.Should().BeOfValues(5, 1, 0, 1, 5).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] public void Negative_Float64() { // NumPy: negative([-5.5, -1, 0, 1, 2.5]) @@ -287,7 +287,7 @@ public void Negative_Float64() result.Should().BeOfValues(5.5, 1.0, 0.0, -1.0, -2.5); } - [Test] + [TestMethod] public void Negative_Int32() { var input = np.array(new[] { -5, -1, 0, 1, 5 }); @@ -296,7 +296,7 @@ public void Negative_Int32() result.Should().BeOfValues(5, 1, 0, -1, -5).And.BeOfType(NPTypeCode.Int32); } - [Test] + [TestMethod] [OpenBugs] // NumSharp throws NotSupportedException for unsigned negative public void Negative_Byte_Overflow() { @@ -307,7 +307,7 @@ public void Negative_Byte_Overflow() result.Should().BeOfValues(255, 254, 253, 252, 251).And.BeOfType(NPTypeCode.Byte); } - [Test] + [TestMethod] public void Sqrt_Float64() { var input = np.array(new double[] { 0, 1, 4, 9, 100 }); @@ -320,7 +320,7 @@ public void Sqrt_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(4) - 10.0) < Tolerance); } - [Test] + [TestMethod] public void Sign_Float64() { // NumPy: sign([-5.5, -1, 0, 1, 2.5]) @@ -330,7 +330,7 @@ public void Sign_Float64() result.Should().BeOfValues(-1.0, -1.0, 0.0, 1.0, 1.0); } - [Test] + [TestMethod] public void Sign_Int32() { var input = np.array(new[] { -5, -1, 0, 1, 5 }); @@ -343,7 +343,8 @@ public void Sign_Int32() #region Rounding Operations - Banker's Rounding - [Test] + [TestMethod] + [OpenBugs] // Vector512 SIMD: "Could not find Round for Vector512" on AVX-512 capable runners public void Round_BankersRounding() { // NumPy uses banker's rounding (round half to even) @@ -363,7 +364,7 @@ public void Round_BankersRounding() Assert.AreEqual(-2.0, result.GetDouble(8)); // -2.5 rounds to -2 (even) } - [Test] + [TestMethod] public void Floor_Float64() { // NumPy: floor([0.0, 0.49, 0.5, 0.51, 1.5, 2.5, -0.5, -1.5, -2.5]) @@ -373,7 +374,7 @@ public void Floor_Float64() result.Should().BeOfValues(0.0, 0.0, 0.0, 0.0, 1.0, 2.0, -1.0, -2.0, -3.0); } - [Test] + [TestMethod] public void Ceil_Float64() { // NumPy: ceil([0.0, 0.49, 0.5, 0.51, 1.5, 2.5, -0.5, -1.5, -2.5]) @@ -387,7 +388,7 @@ public void Ceil_Float64() #region Edge Cases - Special Values - [Test] + [TestMethod] public void Sin_EdgeCases() { // NumPy: sin([0, -0, inf, -inf, nan]) = [0, -0, nan, nan, nan] @@ -401,7 +402,7 @@ public void Sin_EdgeCases() Assert.IsTrue(double.IsNaN(result.GetDouble(4))); } - [Test] + [TestMethod] public void Exp_EdgeCases() { // NumPy: exp([0, -0, inf, -inf, nan]) = [1, 1, inf, 0, nan] @@ -415,7 +416,7 @@ public void Exp_EdgeCases() Assert.IsTrue(double.IsNaN(result.GetDouble(4))); } - [Test] + [TestMethod] public void Log_EdgeCases() { // NumPy: log([0, -0, inf, -inf, nan]) = [-inf, -inf, inf, nan, nan] @@ -429,7 +430,7 @@ public void Log_EdgeCases() Assert.IsTrue(double.IsNaN(result.GetDouble(4))); } - [Test] + [TestMethod] public void Sqrt_EdgeCases() { // NumPy: sqrt([0, -0, inf, -inf, nan]) = [0, -0, inf, nan, nan] @@ -443,7 +444,7 @@ public void Sqrt_EdgeCases() Assert.IsTrue(double.IsNaN(result.GetDouble(4))); } - [Test] + [TestMethod] public void Sign_EdgeCases() { // NumPy: sign([0, -0, inf, -inf, nan]) = [0, 0, 1, -1, nan] @@ -461,7 +462,7 @@ public void Sign_EdgeCases() #region Float32 Tests - [Test] + [TestMethod] public void Sin_Float32() { var input = np.array(new float[] { 0f, 0.5f, 1f, 1.5f, 2f }); @@ -473,7 +474,7 @@ public void Sin_Float32() Assert.IsTrue(Math.Abs(result.GetSingle(2) - 0.8414710164070129f) < 1e-6f); } - [Test] + [TestMethod] public void Cos_Float32() { var input = np.array(new float[] { 0f, 0.5f, 1f, 1.5f, 2f }); @@ -484,7 +485,7 @@ public void Cos_Float32() Assert.IsTrue(Math.Abs(result.GetSingle(2) - 0.5403022766113281f) < 1e-6f); } - [Test] + [TestMethod] public void Exp_Float32() { var input = np.array(new float[] { 0f, 0.5f, 1f, 1.5f, 2f }); @@ -499,7 +500,7 @@ public void Exp_Float32() #region Sliced Array Tests - [Test] + [TestMethod] public void Sin_SlicedArray() { // Test that unary ops work correctly on sliced/strided arrays @@ -513,7 +514,7 @@ public void Sin_SlicedArray() Assert.IsTrue(Math.Abs(result.GetDouble(2) - 1.0) < Tolerance); } - [Test] + [TestMethod] public void Abs_2DArray() { var input = np.array(new[,] { { -1.0, 2.0 }, { -3.0, 4.0 } }); diff --git a/test/NumSharp.UnitTest/Backends/Kernels/UnarySpecialValuesTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/UnarySpecialValuesTests.cs index d46c52095..cb1677bf2 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/UnarySpecialValuesTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/UnarySpecialValuesTests.cs @@ -8,6 +8,7 @@ namespace NumSharp.UnitTest.Backends.Kernels /// Tests for unary operations with special IEEE 754 float values. /// Verifies correct handling of: 0.0, -0.0, +inf, -inf, NaN /// + [TestClass] public class UnarySpecialValuesTests { // Helper to check if a value is negative zero @@ -15,7 +16,7 @@ public class UnarySpecialValuesTests #region np.sqrt - [Test] + [TestMethod] public void Sqrt_SpecialValues() { // NumPy: np.sqrt([0, -0, inf, -inf, nan]) = [0, -0, inf, nan, nan] @@ -33,7 +34,7 @@ public void Sqrt_SpecialValues() #region np.log - [Test] + [TestMethod] public void Log_SpecialValues() { // NumPy: np.log([0, -0, inf, -inf, nan]) = [-inf, -inf, inf, nan, nan] @@ -51,7 +52,7 @@ public void Log_SpecialValues() #region np.exp - [Test] + [TestMethod] public void Exp_SpecialValues() { // NumPy: np.exp([0, -0, inf, -inf, nan]) = [1, 1, inf, 0, nan] @@ -69,7 +70,7 @@ public void Exp_SpecialValues() #region np.sin - [Test] + [TestMethod] public void Sin_SpecialValues() { // NumPy: np.sin([0, -0, inf, -inf, nan]) = [0, -0, nan, nan, nan] @@ -87,7 +88,7 @@ public void Sin_SpecialValues() #region np.cos - [Test] + [TestMethod] public void Cos_SpecialValues() { // NumPy: np.cos([0, -0, inf, -inf, nan]) = [1, 1, nan, nan, nan] @@ -105,7 +106,7 @@ public void Cos_SpecialValues() #region np.tan - [Test] + [TestMethod] public void Tan_SpecialValues() { // NumPy: np.tan([0, -0, inf, -inf, nan]) = [0, -0, nan, nan, nan] @@ -123,7 +124,7 @@ public void Tan_SpecialValues() #region np.sign - [Test] + [TestMethod] public void Sign_SpecialValues() { // NumPy: np.sign([0, -0, inf, -inf, nan]) = [0, 0, 1, -1, nan] @@ -141,7 +142,7 @@ public void Sign_SpecialValues() #region np.negative - [Test] + [TestMethod] public void Negative_SpecialValues() { // NumPy: np.negative([0, -0, inf, -inf, nan]) = [-0, 0, -inf, inf, nan] @@ -160,7 +161,7 @@ public void Negative_SpecialValues() #region np.reciprocal - [Test] + [TestMethod] public void Reciprocal_SpecialValues() { // NumPy: np.reciprocal([0, -0, inf, -inf, nan]) = [inf, -inf, 0, -0, nan] @@ -178,7 +179,7 @@ public void Reciprocal_SpecialValues() #region Float32 tests - [Test] + [TestMethod] public void Sqrt_Float32_SpecialValues() { // Same behavior for float32 @@ -192,7 +193,7 @@ public void Sqrt_Float32_SpecialValues() Assert.IsTrue(float.IsNaN(result.GetSingle(4))); } - [Test] + [TestMethod] public void Exp_Float32_SpecialValues() { var input = np.array(new float[] { 0.0f, -0.0f, float.PositiveInfinity, float.NegativeInfinity, float.NaN }); @@ -209,7 +210,7 @@ public void Exp_Float32_SpecialValues() #region NaN propagation - [Test] + [TestMethod] public void NaN_Propagates_Through_All_Operations() { // NaN should propagate through all unary operations diff --git a/test/NumSharp.UnitTest/Backends/Kernels/VarStdComprehensiveTests.cs b/test/NumSharp.UnitTest/Backends/Kernels/VarStdComprehensiveTests.cs index fd6419e02..c7ba79d95 100644 --- a/test/NumSharp.UnitTest/Backends/Kernels/VarStdComprehensiveTests.cs +++ b/test/NumSharp.UnitTest/Backends/Kernels/VarStdComprehensiveTests.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Backends.Kernels; @@ -18,13 +17,14 @@ namespace NumSharp.UnitTest.Backends.Kernels; /// - Edge cases (single element, identical values, NaN handling) /// - Shape variations (square, rectangular, higher dimensional) /// +[TestClass] public class VarStdComprehensiveTests { private const double Tolerance = 1e-10; #region Var 1D Tests - [Test] + [TestMethod] public void Var_1D_Float64() { // NumPy: np.var([1.0, 2.0, 3.0, 4.0, 5.0]) = 2.0 @@ -33,7 +33,7 @@ public void Var_1D_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 2.0) < Tolerance); } - [Test] + [TestMethod] public void Var_1D_Float64_Ddof0() { // NumPy: np.var([1.0, 2.0, 3.0, 4.0, 5.0], ddof=0) = 2.0 @@ -42,7 +42,7 @@ public void Var_1D_Float64_Ddof0() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 2.0) < Tolerance); } - [Test] + [TestMethod] public void Var_1D_Float64_Ddof1() { // NumPy: np.var([1.0, 2.0, 3.0, 4.0, 5.0], ddof=1) = 2.5 @@ -51,7 +51,7 @@ public void Var_1D_Float64_Ddof1() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 2.5) < Tolerance); } - [Test] + [TestMethod] public void Var_1D_Int32() { // NumPy: np.var([1, 2, 3, 4, 5]) = 2.0 (returns float64) @@ -60,7 +60,7 @@ public void Var_1D_Int32() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 2.0) < Tolerance); } - [Test] + [TestMethod] public void Var_1D_Int64() { // NumPy: np.var([1, 2, 3, 4, 5], dtype=int64) = 2.0 (returns float64) @@ -69,7 +69,7 @@ public void Var_1D_Int64() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 2.0) < Tolerance); } - [Test] + [TestMethod] public void Var_1D_Float32() { // NumPy: np.var([1.0, 2.0, 3.0, 4.0, 5.0], dtype=float32) = 2.0 (returns float32) @@ -83,7 +83,7 @@ public void Var_1D_Float32() #region Var 2D Tests - [Test] + [TestMethod] public void Var_2D_NoAxis() { // NumPy: np.var([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]) = 6.666666666666667 @@ -92,7 +92,7 @@ public void Var_2D_NoAxis() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 6.666666666666667) < Tolerance); } - [Test] + [TestMethod] public void Var_2D_Axis0() { // NumPy: np.var([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], axis=0) = [6.0, 6.0, 6.0] @@ -102,7 +102,7 @@ public void Var_2D_Axis0() result.Should().BeOfValuesApproximately(Tolerance, 6.0, 6.0, 6.0); } - [Test] + [TestMethod] public void Var_2D_Axis1() { // NumPy: np.var([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], axis=1) = [0.666..., 0.666..., 0.666...] @@ -112,7 +112,7 @@ public void Var_2D_Axis1() result.Should().BeOfValuesApproximately(Tolerance, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666); } - [Test] + [TestMethod] public void Var_2D_AxisNeg1() { // NumPy: np.var([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], axis=-1) = [0.666..., 0.666..., 0.666...] @@ -122,7 +122,7 @@ public void Var_2D_AxisNeg1() result.Should().BeOfValuesApproximately(Tolerance, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666); } - [Test] + [TestMethod] public void Var_2D_Axis0_Ddof1() { // NumPy: np.var([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], axis=0, ddof=1) = [9.0, 9.0, 9.0] @@ -136,7 +136,7 @@ public void Var_2D_Axis0_Ddof1() #region Var 3D Tests - [Test] + [TestMethod] public void Var_3D_NoAxis() { // NumPy: np.var([[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]]) = 5.25 @@ -145,7 +145,7 @@ public void Var_3D_NoAxis() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 5.25) < Tolerance); } - [Test] + [TestMethod] public void Var_3D_Axis0() { // NumPy: np.var([[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]], axis=0) = [[4.0, 4.0], [4.0, 4.0]] @@ -155,7 +155,7 @@ public void Var_3D_Axis0() result.Should().BeOfValuesApproximately(Tolerance, 4.0, 4.0, 4.0, 4.0); } - [Test] + [TestMethod] public void Var_3D_Axis1() { // NumPy: np.var([[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]], axis=1) = [[1.0, 1.0], [1.0, 1.0]] @@ -165,7 +165,7 @@ public void Var_3D_Axis1() result.Should().BeOfValuesApproximately(Tolerance, 1.0, 1.0, 1.0, 1.0); } - [Test] + [TestMethod] public void Var_3D_Axis2() { // NumPy: np.var([[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]], axis=2) = [[0.25, 0.25], [0.25, 0.25]] @@ -179,7 +179,7 @@ public void Var_3D_Axis2() #region Var Edge Cases - [Test] + [TestMethod] public void Var_SingleElement() { // NumPy: np.var([42.0]) = 0.0 @@ -188,7 +188,7 @@ public void Var_SingleElement() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 0.0) < Tolerance); } - [Test] + [TestMethod] public void Var_IdenticalValues() { // NumPy: np.var([5.0, 5.0, 5.0, 5.0]) = 0.0 @@ -197,7 +197,7 @@ public void Var_IdenticalValues() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 0.0) < Tolerance); } - [Test] + [TestMethod] public void Var_Rectangular_2x5_Axis0() { // NumPy: np.var([[1.0, 2.0, 3.0, 4.0, 5.0], [6.0, 7.0, 8.0, 9.0, 10.0]], axis=0) = [6.25, 6.25, 6.25, 6.25, 6.25] @@ -207,7 +207,7 @@ public void Var_Rectangular_2x5_Axis0() result.Should().BeOfValuesApproximately(Tolerance, 6.25, 6.25, 6.25, 6.25, 6.25); } - [Test] + [TestMethod] public void Var_Rectangular_2x5_Axis1() { // NumPy: np.var([[1.0, 2.0, 3.0, 4.0, 5.0], [6.0, 7.0, 8.0, 9.0, 10.0]], axis=1) = [2.0, 2.0] @@ -221,7 +221,7 @@ public void Var_Rectangular_2x5_Axis1() #region Std 1D Tests - [Test] + [TestMethod] public void Std_1D_Float64() { // NumPy: np.std([1.0, 2.0, 3.0, 4.0, 5.0]) = 1.4142135623730951 @@ -230,7 +230,7 @@ public void Std_1D_Float64() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 1.4142135623730951) < Tolerance); } - [Test] + [TestMethod] public void Std_1D_Float64_Ddof0() { // NumPy: np.std([1.0, 2.0, 3.0, 4.0, 5.0], ddof=0) = 1.4142135623730951 @@ -239,7 +239,7 @@ public void Std_1D_Float64_Ddof0() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 1.4142135623730951) < Tolerance); } - [Test] + [TestMethod] public void Std_1D_Float64_Ddof1() { // NumPy: np.std([1.0, 2.0, 3.0, 4.0, 5.0], ddof=1) = 1.5811388300841898 @@ -248,7 +248,7 @@ public void Std_1D_Float64_Ddof1() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 1.5811388300841898) < Tolerance); } - [Test] + [TestMethod] public void Std_1D_Int32() { // NumPy: np.std([1, 2, 3, 4, 5]) = 1.4142135623730951 (returns float64) @@ -257,7 +257,7 @@ public void Std_1D_Int32() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 1.4142135623730951) < Tolerance); } - [Test] + [TestMethod] public void Std_1D_Int64() { // NumPy: np.std([1, 2, 3, 4, 5], dtype=int64) = 1.4142135623730951 (returns float64) @@ -266,7 +266,7 @@ public void Std_1D_Int64() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 1.4142135623730951) < Tolerance); } - [Test] + [TestMethod] public void Std_1D_Float32() { // NumPy: np.std([1.0, 2.0, 3.0, 4.0, 5.0], dtype=float32) = 1.4142135381698608 (returns float32) @@ -280,7 +280,7 @@ public void Std_1D_Float32() #region Std 2D Tests - [Test] + [TestMethod] public void Std_2D_NoAxis() { // NumPy: np.std([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]) = 2.581988897471611 @@ -289,7 +289,7 @@ public void Std_2D_NoAxis() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 2.581988897471611) < Tolerance); } - [Test] + [TestMethod] public void Std_2D_Axis0() { // NumPy: np.std([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], axis=0) = [2.449..., 2.449..., 2.449...] @@ -299,7 +299,7 @@ public void Std_2D_Axis0() result.Should().BeOfValuesApproximately(Tolerance, 2.449489742783178, 2.449489742783178, 2.449489742783178); } - [Test] + [TestMethod] public void Std_2D_Axis1() { // NumPy: np.std([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], axis=1) = [0.816..., 0.816..., 0.816...] @@ -309,7 +309,7 @@ public void Std_2D_Axis1() result.Should().BeOfValuesApproximately(Tolerance, 0.816496580927726, 0.816496580927726, 0.816496580927726); } - [Test] + [TestMethod] public void Std_2D_AxisNeg1() { // NumPy: np.std([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], axis=-1) = [0.816..., 0.816..., 0.816...] @@ -319,7 +319,7 @@ public void Std_2D_AxisNeg1() result.Should().BeOfValuesApproximately(Tolerance, 0.816496580927726, 0.816496580927726, 0.816496580927726); } - [Test] + [TestMethod] public void Std_2D_Axis0_Ddof1() { // NumPy: np.std([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], axis=0, ddof=1) = [3.0, 3.0, 3.0] @@ -333,7 +333,7 @@ public void Std_2D_Axis0_Ddof1() #region Std 3D Tests - [Test] + [TestMethod] public void Std_3D_NoAxis() { // NumPy: np.std([[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]]) = 2.29128784747792 @@ -342,7 +342,7 @@ public void Std_3D_NoAxis() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 2.29128784747792) < Tolerance); } - [Test] + [TestMethod] public void Std_3D_Axis0() { // NumPy: np.std([[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]], axis=0) = [[2.0, 2.0], [2.0, 2.0]] @@ -352,7 +352,7 @@ public void Std_3D_Axis0() result.Should().BeOfValuesApproximately(Tolerance, 2.0, 2.0, 2.0, 2.0); } - [Test] + [TestMethod] public void Std_3D_Axis1() { // NumPy: np.std([[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]], axis=1) = [[1.0, 1.0], [1.0, 1.0]] @@ -362,7 +362,7 @@ public void Std_3D_Axis1() result.Should().BeOfValuesApproximately(Tolerance, 1.0, 1.0, 1.0, 1.0); } - [Test] + [TestMethod] public void Std_3D_Axis2() { // NumPy: np.std([[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]], axis=2) = [[0.5, 0.5], [0.5, 0.5]] @@ -376,7 +376,7 @@ public void Std_3D_Axis2() #region Std Edge Cases - [Test] + [TestMethod] public void Std_SingleElement() { // NumPy: np.std([42.0]) = 0.0 @@ -385,7 +385,7 @@ public void Std_SingleElement() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 0.0) < Tolerance); } - [Test] + [TestMethod] public void Std_IdenticalValues() { // NumPy: np.std([5.0, 5.0, 5.0, 5.0]) = 0.0 @@ -394,7 +394,7 @@ public void Std_IdenticalValues() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 0.0) < Tolerance); } - [Test] + [TestMethod] public void Std_Rectangular_2x5_Axis0() { // NumPy: np.std([[1.0, 2.0, 3.0, 4.0, 5.0], [6.0, 7.0, 8.0, 9.0, 10.0]], axis=0) = [2.5, 2.5, 2.5, 2.5, 2.5] @@ -404,7 +404,7 @@ public void Std_Rectangular_2x5_Axis0() result.Should().BeOfValuesApproximately(Tolerance, 2.5, 2.5, 2.5, 2.5, 2.5); } - [Test] + [TestMethod] public void Std_Rectangular_2x5_Axis1() { // NumPy: np.std([[1.0, 2.0, 3.0, 4.0, 5.0], [6.0, 7.0, 8.0, 9.0, 10.0]], axis=1) = [1.414..., 1.414...] @@ -418,7 +418,7 @@ public void Std_Rectangular_2x5_Axis1() #region keepdims Tests - [Test] + [TestMethod] public void Var_2D_Axis0_Keepdims() { // NumPy: np.var([[1, 2, 3], [4, 5, 6]], axis=0, keepdims=True).shape = (1, 3) @@ -427,7 +427,7 @@ public void Var_2D_Axis0_Keepdims() result.Should().BeShaped(1, 3); } - [Test] + [TestMethod] public void Std_2D_Axis0_Keepdims() { // NumPy: np.std([[1, 2, 3], [4, 5, 6]], axis=0, keepdims=True).shape = (1, 3) @@ -440,7 +440,7 @@ public void Std_2D_Axis0_Keepdims() #region Large Values (Numerical Stability) - [Test] + [TestMethod] public void Var_LargeValues() { // NumPy: np.var([1e15, 2e15, 3e15]) = 6.666666666666666e+29 @@ -449,7 +449,7 @@ public void Var_LargeValues() Assert.IsTrue(Math.Abs(result.GetDouble(0) - 6.666666666666666e+29) / 6.666666666666666e+29 < 1e-10); } - [Test] + [TestMethod] public void Std_LargeValues() { // NumPy: np.std([1e15, 2e15, 3e15]) = 816496580927726.0 diff --git a/test/NumSharp.UnitTest/Backends/NDArray.Base.MemoryLeakTest.cs b/test/NumSharp.UnitTest/Backends/NDArray.Base.MemoryLeakTest.cs index a01b5deed..f85823593 100644 --- a/test/NumSharp.UnitTest/Backends/NDArray.Base.MemoryLeakTest.cs +++ b/test/NumSharp.UnitTest/Backends/NDArray.Base.MemoryLeakTest.cs @@ -13,6 +13,7 @@ namespace NumSharp.UnitTest.Backends /// 2. Originals aren't collected while views exist /// 3. Circular reference scenarios are handled /// + [TestClass] public class NDArray_Base_MemoryLeakTest { #region Memory Pressure Tests @@ -20,7 +21,7 @@ public class NDArray_Base_MemoryLeakTest /// /// Create many views, verify they don't leak when original lives. /// - [Test] + [TestMethod] public void MemoryLeak_ManyViews_NoLeak() { var original = np.arange(1000); @@ -48,7 +49,7 @@ public void MemoryLeak_ManyViews_NoLeak() /// /// Stress test: many nested views don't leak. /// - [Test] + [TestMethod] public void MemoryLeak_DeepNesting_NoLeak() { var original = np.arange(10000); @@ -72,7 +73,7 @@ public void MemoryLeak_DeepNesting_NoLeak() /// /// Multiple independent chains don't interfere. /// - [Test] + [TestMethod] public void MemoryLeak_IndependentChains_NoInterference() { var chains = new List<(NDArray original, List views)>(); @@ -114,7 +115,7 @@ public void MemoryLeak_IndependentChains_NoInterference() /// /// View survives when original reference is dropped (but memory is kept alive). /// - [Test] + [TestMethod] public void Lifecycle_ViewSurvivesDroppedOriginalReference() { var view = CreateViewAndDropOriginal(); @@ -141,7 +142,7 @@ private NDArray CreateViewAndDropOriginal() /// /// Multiple views survive when original reference is dropped. /// - [Test] + [TestMethod] public void Lifecycle_MultipleViewsSurvive() { var views = CreateMultipleViewsAndDropOriginal(); @@ -185,7 +186,7 @@ private List CreateMultipleViewsAndDropOriginal() /// /// Large array views work correctly. /// - [Test] + [TestMethod] public void LargeArray_ViewsWork() { // 10 million elements @@ -217,7 +218,7 @@ public void LargeArray_ViewsWork() /// /// Mix of copies and views works correctly. /// - [Test] + [TestMethod] public void MixedOperations_CopiesAndViews() { var a = np.arange(100); @@ -250,7 +251,7 @@ public void MixedOperations_CopiesAndViews() /// Note: In NumSharp, slicing a broadcast array materializes the data (copies it), /// so the slice does NOT chain to the original. This differs from NumPy. /// - [Test] + [TestMethod] [Misaligned] public void MixedOperations_BroadcastThenSlice() { @@ -276,7 +277,7 @@ public void MixedOperations_BroadcastThenSlice() /// This test creates a scenario where the original array's CLR object /// is collected but the view keeps the data alive. /// - [Test] + [TestMethod] public void Finalization_OriginalCollected_ViewStillWorks() { WeakReference? weakOriginal; @@ -316,7 +317,7 @@ private void CreateAndGetReferences(out WeakReference weakOriginal, out /// /// Views created from multiple threads all chain correctly. /// - [Test] + [TestMethod] public void Concurrent_MultipleThreads_ViewsChainCorrectly() { var original = np.arange(1000); diff --git a/test/NumSharp.UnitTest/Backends/NDArray.Base.Test.cs b/test/NumSharp.UnitTest/Backends/NDArray.Base.Test.cs index 5559e6983..4d16e3c32 100644 --- a/test/NumSharp.UnitTest/Backends/NDArray.Base.Test.cs +++ b/test/NumSharp.UnitTest/Backends/NDArray.Base.Test.cs @@ -12,6 +12,7 @@ namespace NumSharp.UnitTest.Backends /// - numpy/_core/tests/test_multiarray.py /// - numpy/_core/tests/test_indexing.py /// + [TestClass] public class NDArray_Base_Test { #region NumPy Behavior Tests (Ported) @@ -20,7 +21,7 @@ public class NDArray_Base_Test /// NumPy: a = np.arange(10); a.base is None /// Original array owns its data. /// - [Test] + [TestMethod] public void Base_OriginalArray_IsNull() { var a = np.arange(10); @@ -31,7 +32,7 @@ public void Base_OriginalArray_IsNull() /// NumPy: b = a[2:5]; b.base is a /// Slice creates a view pointing to original. /// - [Test] + [TestMethod] public void Base_Slice_PointsToOriginal() { var a = np.arange(10); @@ -45,7 +46,7 @@ public void Base_Slice_PointsToOriginal() /// NumPy: c = b[1:2]; c.base is a (chains to ORIGINAL, not b) /// Slice of slice chains to ultimate owner. /// - [Test] + [TestMethod] public void Base_SliceOfSlice_ChainsToOriginal() { var a = np.arange(10); @@ -65,7 +66,7 @@ public void Base_SliceOfSlice_ChainsToOriginal() /// NumPy: d = a.copy(); d.base is None /// Copy owns its data. /// - [Test] + [TestMethod] public void Base_Copy_IsNull() { var a = np.arange(10); @@ -78,7 +79,7 @@ public void Base_Copy_IsNull() /// NumPy: d = a.reshape(2,5); d.base is a /// Reshape returns view with base. /// - [Test] + [TestMethod] public void Base_Reshape_PointsToOriginal() { var a = np.arange(10); @@ -92,7 +93,7 @@ public void Base_Reshape_PointsToOriginal() /// NumPy: f = e.T; f.base is a (still chains to original) /// Transpose of reshape chains to original. /// - [Test] + [TestMethod] public void Base_TransposeOfReshape_ChainsToOriginal() { var a = np.arange(10); @@ -107,7 +108,7 @@ public void Base_TransposeOfReshape_ChainsToOriginal() /// NumPy: g = np.broadcast_to(a, (3, 10)); g.base is a /// Broadcast creates view with base. /// - [Test] + [TestMethod] public void Base_Broadcast_PointsToOriginal() { var a = np.arange(10); @@ -121,7 +122,7 @@ public void Base_Broadcast_PointsToOriginal() /// NumPy: h = np.expand_dims(a, 0); h.base is a /// expand_dims creates view with base. /// - [Test] + [TestMethod] public void Base_ExpandDims_PointsToOriginal() { var a = np.arange(10); @@ -135,7 +136,7 @@ public void Base_ExpandDims_PointsToOriginal() /// NumPy: a[...].base is a /// Ellipsis subscript creates a view. /// - [Test] + [TestMethod] public void Base_EllipsisSubscript_PointsToOriginal() { var a = np.arange(10); @@ -149,7 +150,7 @@ public void Base_EllipsisSubscript_PointsToOriginal() /// NumPy: a[:].base is a /// Full slice creates a view. /// - [Test] + [TestMethod] public void Base_FullSlice_PointsToOriginal() { var a = np.arange(10); @@ -163,7 +164,7 @@ public void Base_FullSlice_PointsToOriginal() /// NumPy: a.view().base is a /// view() creates a view with base. /// - [Test] + [TestMethod] public void Base_View_PointsToOriginal() { var a = np.arange(10); @@ -177,7 +178,7 @@ public void Base_View_PointsToOriginal() /// NumPy: a.flatten().base is None /// flatten() creates a copy. /// - [Test] + [TestMethod] public void Base_Flatten_IsNull() { var a = np.arange(12).reshape(3, 4); @@ -190,7 +191,7 @@ public void Base_Flatten_IsNull() /// NumPy: a.ravel().base is a (when contiguous) /// ravel() returns view when possible. /// - [Test] + [TestMethod] public void Base_Ravel_Contiguous_PointsToOriginal() { // Start with an owned array (not a view) @@ -213,7 +214,7 @@ public void Base_Ravel_Contiguous_PointsToOriginal() /// /// Test a chain of operations all pointing to original. /// - [Test] + [TestMethod] public void Base_ChainedOperations_AllPointToOriginal() { var original = np.arange(24); @@ -232,7 +233,7 @@ public void Base_ChainedOperations_AllPointToOriginal() /// /// Test that copies break the chain. /// - [Test] + [TestMethod] public void Base_CopyBreaksChain() { var a = np.arange(10); @@ -259,7 +260,7 @@ public void Base_CopyBreaksChain() /// Verify that views keep the original data alive. /// This tests that the shared memory isn't prematurely freed. /// - [Test] + [TestMethod] public void Base_ViewKeepsDataAlive() { NDArray view; @@ -284,7 +285,7 @@ public void Base_ViewKeepsDataAlive() /// /// Verify nested views keep data alive through the chain. /// - [Test] + [TestMethod] public void Base_NestedViews_KeepDataAlive() { NDArray deepView; @@ -308,7 +309,7 @@ public void Base_NestedViews_KeepDataAlive() /// /// Verify broadcast views keep original data alive. /// - [Test] + [TestMethod] public void Base_BroadcastView_KeepsDataAlive() { NDArray broadcasted; @@ -337,7 +338,7 @@ public void Base_BroadcastView_KeepsDataAlive() /// /// Verify reshape views keep original data alive. /// - [Test] + [TestMethod] public void Base_ReshapeView_KeepsDataAlive() { NDArray reshaped; @@ -365,7 +366,7 @@ public void Base_ReshapeView_KeepsDataAlive() /// /// Verify transpose views keep original data alive. /// - [Test] + [TestMethod] public void Base_TransposeView_KeepsDataAlive() { NDArray transposed; @@ -394,7 +395,7 @@ public void Base_TransposeView_KeepsDataAlive() /// /// Test that we can detect if an array is a view using .base /// - [Test] + [TestMethod] public void Base_CanDetectView() { var owner = np.arange(10); @@ -415,7 +416,7 @@ public void Base_CanDetectView() /// /// Test broadcast_arrays returns views with proper base. /// - [Test] + [TestMethod] public void Base_BroadcastArrays_ReturnViews() { var a = np.array(new[] { 1, 2, 3 }); @@ -442,7 +443,7 @@ public void Base_BroadcastArrays_ReturnViews() /// When reduction with keepdims on axis with size 1, returns view. /// NumPy optimizes this case to return a view, NumSharp creates a new array. /// - [Test] + [TestMethod] [OpenBugs] // NumSharp always creates new array for reductions - view optimization not implemented public void Base_ReductionKeepdims_Size1Axis_ReturnsView() { @@ -465,7 +466,7 @@ public void Base_ReductionKeepdims_Size1Axis_ReturnsView() /// /// Verify _baseStorage is set correctly at storage level. /// - [Test] + [TestMethod] public void BaseStorage_Alias_SetsBaseStorage() { var original = np.arange(10); @@ -477,7 +478,7 @@ public void BaseStorage_Alias_SetsBaseStorage() /// /// Verify _baseStorage chains correctly through multiple aliases. /// - [Test] + [TestMethod] public void BaseStorage_MultipleAliases_ChainToOriginal() { var original = np.arange(10); @@ -494,7 +495,7 @@ public void BaseStorage_MultipleAliases_ChainToOriginal() /// /// Verify Clone does not set _baseStorage. /// - [Test] + [TestMethod] public void BaseStorage_Clone_IsNull() { var original = np.arange(10); @@ -506,7 +507,7 @@ public void BaseStorage_Clone_IsNull() /// /// Verify broadcast_to uses CreateBroadcastedUnsafe which sets _baseStorage. /// - [Test] + [TestMethod] public void BaseStorage_BroadcastTo_SetsBaseStorage() { var original = np.arange(3); @@ -523,7 +524,7 @@ public void BaseStorage_BroadcastTo_SetsBaseStorage() /// /// Scalar arrays should work correctly. /// - [Test] + [TestMethod] public void Base_Scalar_Works() { var scalar = NDArray.Scalar(42); @@ -538,7 +539,7 @@ public void Base_Scalar_Works() /// /// Empty array handling. /// - [Test] + [TestMethod] public void Base_EmptyArray_Works() { var empty = np.empty(new Shape(0)); @@ -549,7 +550,7 @@ public void Base_EmptyArray_Works() /// /// 0-size dimension handling. /// - [Test] + [TestMethod] public void Base_ZeroSizeDimension_Works() { var a = np.empty(new Shape(3, 0, 4)); @@ -564,14 +565,14 @@ public void Base_ZeroSizeDimension_Works() /// /// Test with various dtypes. /// - [Test] - [Arguments(NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Byte)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] + [TestMethod] + [DataRow(NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Byte)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] public void Base_AllDTypes_Work(NPTypeCode dtype) { var a = np.zeros(new Shape(10), dtype); @@ -588,7 +589,7 @@ public void Base_AllDTypes_Work(NPTypeCode dtype) /// /// Reversed array creates view. /// - [Test] + [TestMethod] public void Base_ReversedArray_PointsToOriginal() { var a = np.arange(10); @@ -601,7 +602,7 @@ public void Base_ReversedArray_PointsToOriginal() /// /// Step slicing creates view. /// - [Test] + [TestMethod] public void Base_StepSlice_PointsToOriginal() { var a = np.arange(20); diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/AllocationTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/AllocationTests.cs index 3bd34dfbc..28660d2e4 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/AllocationTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/AllocationTests.cs @@ -14,7 +14,7 @@ public class AllocationTests private const long onegb = 1_073_741_824; private static readonly object _lock = new Object(); - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public void Allocate_1GB() { lock (_lock) @@ -25,7 +25,7 @@ public void Allocate_1GB() } } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public void Allocate_2GB() { lock (_lock) @@ -36,7 +36,7 @@ public void Allocate_2GB() } } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public void Allocate_4GB() { lock (_lock) @@ -47,7 +47,7 @@ public void Allocate_4GB() } } - [Test, LargeMemoryTest] + [TestMethod, LargeMemoryTest] public void Allocate_44GB() { lock (_lock) diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/DeallocationTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/DeallocationTests.cs index c78f87e47..3e44ba427 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/DeallocationTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/DeallocationTests.cs @@ -10,9 +10,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged { + [TestClass] public class DeallocationTests { - [Test] + [TestMethod] public unsafe void DisposerCopiedAcrossStructCopy() { var newMem = new UnmanagedMemoryBlock(5); @@ -23,7 +24,7 @@ public unsafe void DisposerCopiedAcrossStructCopy() mem2.GetType().GetField("_disposer", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(newMem)); } - [Test] + [TestMethod] public unsafe void GcDoesntCollectArraySliceAlone() { //this test should be churned. diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/Reduction/ReduceAddTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/Reduction/ReduceAddTests.cs index fd56aa9ef..3898e59ab 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/Reduction/ReduceAddTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/Reduction/ReduceAddTests.cs @@ -7,15 +7,16 @@ namespace NumSharp.UnitTest.Backends.Unmanaged.Math.Reduction { + [TestClass] public class ReduceAddTests { - [Test] + [TestMethod] public void EmptyArray() { np.sum(np.array(new int[0])).Should().BeScalar(0); } - [Test] + [TestMethod] public void Case1_Elementwise_keepdims() { var np1 = np.array(new double[] {1, 2, 3, 4, 5, 6}).reshape(3, 2); @@ -25,7 +26,7 @@ public void Case1_Elementwise_keepdims() mean.GetValue(0).Should().BeEquivalentTo(21); } - [Test] + [TestMethod] public void Case0_Scalar() { var a = NDArray.Scalar(1); @@ -34,7 +35,7 @@ public void Case0_Scalar() ret.GetInt32(0).Should().Be(1); } - [Test] + [TestMethod] public void Case0_Scalar_Axis0() { var a = NDArray.Scalar(1); @@ -43,7 +44,7 @@ public void Case0_Scalar_Axis0() ret.GetInt32(0).Should().Be(1); } - [Test] + [TestMethod] public void Case1_Elementwise() { var a = np.ones((3, 3, 3), NPTypeCode.Int32); @@ -52,7 +53,7 @@ public void Case1_Elementwise() ret.GetInt64(0).Should().Be(3 * 3 * 3); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case1_Axis0() { var a = np.ones((3, 3, 3), NPTypeCode.Int32); @@ -64,7 +65,7 @@ public void Case1_Axis0() ret.flat.Cast().Should().AllBeEquivalentTo(3); } - [Test] + [TestMethod] public void Case1_Axis1() { var a = np.ones((3, 3, 3), NPTypeCode.Int32); @@ -75,7 +76,7 @@ public void Case1_Axis1() ret.flat.Cast().Should().AllBeEquivalentTo(3); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case1_Axis2() { var a = np.ones((3, 3, 3), NPTypeCode.Int32); @@ -86,7 +87,7 @@ public void Case1_Axis2() ret.flat.Cast().Should().AllBeEquivalentTo(3); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case1_Axis_minus1() { var a = np.ones((3, 3, 3), NPTypeCode.Int32); @@ -97,7 +98,7 @@ public void Case1_Axis_minus1() ret.flat.Cast().Should().AllBeEquivalentTo(3); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case1_Axis2_keepdims() { var a = np.ones((3, 3, 3), NPTypeCode.Int32); @@ -108,7 +109,7 @@ public void Case1_Axis2_keepdims() ret.flat.Cast().Should().AllBeEquivalentTo(3); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case1_Axis_minus1_keepdims() { var a = np.ones((3, 3, 3), NPTypeCode.Int32); @@ -119,7 +120,7 @@ public void Case1_Axis_minus1_keepdims() ret.flat.Cast().Should().AllBeEquivalentTo(3); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case1_Axis_1_keepdims() { var a = np.ones((3, 3, 3), NPTypeCode.Int32); @@ -131,7 +132,7 @@ public void Case1_Axis_1_keepdims() } - [Test] + [TestMethod] public void Case2_Elementwise() { var a = np.ones((2, 1, 3, 5, 1), np.int32); @@ -141,7 +142,7 @@ public void Case2_Elementwise() ret.GetInt64(0).Should().Be(2 * 1 * 3 * 5 * 1); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case2_Axis0() { var a = np.ones((2, 1, 3, 5, 1), np.int32); @@ -152,7 +153,7 @@ public void Case2_Axis0() ret.flat.Cast().Should().AllBeEquivalentTo(2); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case2_Axis1() { var a = np.ones((2, 1, 3, 5, 1), np.int32); @@ -163,7 +164,7 @@ public void Case2_Axis1() ret.flat.Cast().Should().AllBeEquivalentTo(1); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case2_Axis2() { var a = np.ones((2, 1, 3, 5, 1), np.int32); @@ -174,7 +175,7 @@ public void Case2_Axis2() ret.flat.Cast().Should().AllBeEquivalentTo(3); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case2_Axis4() { var a = np.ones((2, 1, 3, 5, 1), np.int32); @@ -185,7 +186,7 @@ public void Case2_Axis4() ret.flat.Cast().Should().AllBeEquivalentTo(1); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case2_Axis_minus1() { var a = np.ones((2, 1, 3, 5, 1), np.int32); @@ -196,7 +197,7 @@ public void Case2_Axis_minus1() ret.flat.Cast().Should().AllBeEquivalentTo(1); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case2_Axis2_keepdims() { var a = np.ones((2, 1, 3, 5, 1), np.int32); @@ -207,7 +208,7 @@ public void Case2_Axis2_keepdims() ret.flat.Cast().Should().AllBeEquivalentTo(3); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case2_Axis_minus1_keepdims() { var a = np.ones((2, 1, 3, 5, 1), np.int32); @@ -218,7 +219,7 @@ public void Case2_Axis_minus1_keepdims() ret.flat.Cast().Should().AllBeEquivalentTo(1); // NEP50: int32 sum returns int64 } - [Test] + [TestMethod] public void Case3_TurnIntoScalar() { NDArray a; @@ -242,13 +243,13 @@ public void Case3_TurnIntoScalar() /// for all supported numeric dtypes. NumPy behavior: shape (M, N) with keepdims=true /// should return shape (1, 1), not (1) or (). /// - [Test] - [Arguments(NPTypeCode.Int32)] - [Arguments(NPTypeCode.Int64)] - [Arguments(NPTypeCode.Single)] - [Arguments(NPTypeCode.Double)] - [Arguments(NPTypeCode.Int16)] - [Arguments(NPTypeCode.Byte)] + [TestMethod] + [DataRow(NPTypeCode.Int32)] + [DataRow(NPTypeCode.Int64)] + [DataRow(NPTypeCode.Single)] + [DataRow(NPTypeCode.Double)] + [DataRow(NPTypeCode.Int16)] + [DataRow(NPTypeCode.Byte)] public void Keepdims_AllReductions_PreservesDimensions(NPTypeCode dtype) { // Create 2D array with specific dtype @@ -288,7 +289,7 @@ public void Keepdims_AllReductions_PreservesDimensions(NPTypeCode dtype) /// /// Tests that keepdims=true works correctly for 3D arrays /// - [Test] + [TestMethod] public void Keepdims_3D_PreservesThreeDimensions() { var arr = np.arange(24).reshape(2, 3, 4); diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np.prod.tests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np.prod.tests.cs index 3b423808e..42c0ace1d 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np.prod.tests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np.prod.tests.cs @@ -8,16 +8,17 @@ namespace NumSharp.UnitTest.LinearAlgebra { + [TestClass] public class np_prod_tests { - [Test] + [TestMethod] public void EmptyArray() { np.prod(np.array(new int[0])).Should().BeScalar(1); } - [Test] + [TestMethod] public void Case1() { var a = np.prod(np.array(1f, 2f)); @@ -25,7 +26,7 @@ public void Case1() a.Shape.IsScalar.Should().BeTrue(); } - [Test] + [TestMethod] public void Case1_double() { var a = np.prod(np.array(1d, 2d)); @@ -33,7 +34,7 @@ public void Case1_double() a.Shape.IsScalar.Should().BeTrue(); } - [Test] + [TestMethod] public void Case2() { var a = np.prod(np.array(1f, 2f, 3, 4).reshape(2, 2)); @@ -41,7 +42,7 @@ public void Case2() a.Shape.IsScalar.Should().BeTrue(); } - [Test] + [TestMethod] public void Case3() { var a = np.prod(np.array(1f, 2f, 3, 4).reshape(2, 2), axis: 1); @@ -50,7 +51,7 @@ public void Case3() a.shape.Should().HaveCount(1).And.ContainInOrder(2); } - [Test] + [TestMethod] public void Case4() { var a = np.prod(np.array(1f, 2f, 3, 4).reshape(2, 2), axis: 1); @@ -59,7 +60,7 @@ public void Case4() a.shape.Should().HaveCount(1).And.ContainInOrder(2); } - [Test] + [TestMethod] public void Case4_dtype() { var a = np.prod(np.array(1f, 2f, 3, 4).reshape(2, 2), axis: 1, dtype: np.uint8); @@ -75,7 +76,7 @@ public void Case4_dtype() /// NumPy: prod([True, True, True, True]) = 1 /// Return type is int64 (NumPy 2.x behavior). /// - [Test] + [TestMethod] public void BooleanArray_TreatsAsIntAndReturnsInt64() { // Array with False - product is 0 diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_add_tests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_add_tests.cs index 2f0bafee5..a68e9ccca 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_add_tests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_add_tests.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged.Math { + [TestClass] public class np_add_tests { - [Test] + [TestMethod] public void UInt8AddTest1() { var nd1 = np.arange(3).astype(np.uint8); @@ -19,7 +20,7 @@ public void UInt8AddTest1() nd2.array_equal(new byte[] {2, 3, 4}).Should().BeTrue(); } - [Test] + [TestMethod] public void UInt16AddTest1() { var nd1 = np.arange(3).astype(np.uint16); @@ -28,7 +29,7 @@ public void UInt16AddTest1() nd2.array_equal(new ushort[] {2, 3, 4}).Should().BeTrue(); } - [Test] + [TestMethod] public void Add() { var left = np.zeros(new Shape(5, 5)) + 5d; @@ -44,22 +45,22 @@ public void Add() #if _REGEN %a = except(supported_dtypes, "NDArray", "Boolean") %foreach a - [Arguments(NPTypeCode.Boolean, NPTypeCode.#1)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.#1)] #else - [Arguments(NPTypeCode.Boolean, NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Byte)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Char)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Double)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Single)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Decimal)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Byte)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Char)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Double)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Single)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Decimal)] #endif - [Test] + [TestMethod] public void AddAllPossabilitiesBoolean(NPTypeCode ltc, NPTypeCode rtc) { var left = np.zeros(new Shape(5, 5), ltc); @@ -74,7 +75,7 @@ public void AddAllPossabilitiesBoolean(NPTypeCode ltc, NPTypeCode rtc) } } - [Test] + [TestMethod] public void AddUpcast() { var left = (np.zeros(new Shape(5, 5)) + 5d).astype(NPTypeCode.Single); @@ -91,7 +92,7 @@ public void AddUpcast() } } - [Test] + [TestMethod] public void AddDowncast() { var left = (np.zeros(new Shape(5, 5)) + 5d).astype(NPTypeCode.Single); @@ -108,14 +109,14 @@ public void AddDowncast() } } - [Test] + [TestMethod] public void Add_Two_Scalars() { var left = NDArray.Scalar(1d) + NDArray.Scalar(5d); left.GetDouble(0).Should().Be(6); } - [Test] + [TestMethod] public void Add_ND_3_1_vs_1_3() { var left = np.arange(3).reshape((3, 1)).astype(np.float64); @@ -133,7 +134,7 @@ public void Add_ND_3_1_vs_1_3() } } - [Test] + [TestMethod] public void Add_ND_2_1_3_3_vs_1_3() { var left = np.arange(2 * 3 * 3).reshape((2, 1, 3, 3)).astype(np.float64); @@ -155,7 +156,7 @@ public void Add_ND_2_1_3_3_vs_1_3() ret.GetDouble(1, 0, 2, 2).Should().Be(19); } - [Test] + [TestMethod] public void Add_ND_2_3_3() { var left = np.arange(6).reshape((2, 3, 1)).astype(np.float64); @@ -176,7 +177,7 @@ public void Add_ND_2_3_3() } } - [Test] + [TestMethod] public void Add_RightScalar() { var left = np.zeros(new Shape(5, 5), np.float64) + 5d; @@ -190,7 +191,7 @@ public void Add_RightScalar() } } - [Test] + [TestMethod] public void Add_LeftScalar() { var left = NDArray.Scalar(1d); @@ -204,7 +205,7 @@ public void Add_LeftScalar() } } - [Test] + [TestMethod] public void Add_Rising() { var left = np.zeros(new Shape(5, 5), np.float64); @@ -228,7 +229,7 @@ public void Add_Rising() } } - [Test] + [TestMethod] public void Add_RightScalar_Rising() { var left = np.zeros(new Shape(5, 5), np.float64); @@ -247,7 +248,7 @@ public void Add_RightScalar_Rising() } } - [Test] + [TestMethod] public void Add_LeftScalar_Rising() { var left = NDArray.Scalar(1d); @@ -271,7 +272,7 @@ public void Add_LeftScalar_Rising() %a = ["Boolean","Byte","Int16","UInt16","Int32","UInt32","Int64","UInt64","Double","Single","Decimal"] %b = [true,"1","1","1","1","1u","1L","1UL","1d","1f","1m"] %foreach forevery(a,a,true), forevery(b,b,true)% - [Test] + [TestMethod] public void Add_#1_To_#2() { var left = np.zeros(new Shape(5, 5), NPTypeCode.#1); @@ -288,7 +289,7 @@ public void Add_LeftScalar_Rising() % #else - [Test] + [TestMethod] public void Add_Boolean_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean); @@ -302,7 +303,7 @@ public void Add_Boolean_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Boolean_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean); @@ -316,7 +317,7 @@ public void Add_Boolean_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Boolean_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean); @@ -330,7 +331,7 @@ public void Add_Boolean_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Boolean_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean); @@ -344,7 +345,7 @@ public void Add_Boolean_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Boolean_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean); @@ -358,7 +359,7 @@ public void Add_Boolean_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Boolean_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean); @@ -372,7 +373,7 @@ public void Add_Boolean_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Boolean_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean); @@ -386,7 +387,7 @@ public void Add_Boolean_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Boolean_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean); @@ -400,7 +401,7 @@ public void Add_Boolean_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Boolean_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean); @@ -414,7 +415,7 @@ public void Add_Boolean_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Boolean_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean); @@ -428,7 +429,7 @@ public void Add_Boolean_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Byte_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte); @@ -442,7 +443,7 @@ public void Add_Byte_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Byte_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte); @@ -456,7 +457,7 @@ public void Add_Byte_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Byte_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte); @@ -470,7 +471,7 @@ public void Add_Byte_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Byte_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte); @@ -484,7 +485,7 @@ public void Add_Byte_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Byte_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte); @@ -498,7 +499,7 @@ public void Add_Byte_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Byte_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte); @@ -512,7 +513,7 @@ public void Add_Byte_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Byte_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte); @@ -526,7 +527,7 @@ public void Add_Byte_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Byte_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte); @@ -540,7 +541,7 @@ public void Add_Byte_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Byte_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte); @@ -554,7 +555,7 @@ public void Add_Byte_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Byte_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte); @@ -568,7 +569,7 @@ public void Add_Byte_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int16_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16); @@ -582,7 +583,7 @@ public void Add_Int16_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int16_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16); @@ -596,7 +597,7 @@ public void Add_Int16_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int16_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16); @@ -610,7 +611,7 @@ public void Add_Int16_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int16_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16); @@ -624,7 +625,7 @@ public void Add_Int16_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int16_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16); @@ -638,7 +639,7 @@ public void Add_Int16_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int16_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16); @@ -652,7 +653,7 @@ public void Add_Int16_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int16_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16); @@ -666,7 +667,7 @@ public void Add_Int16_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int16_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16); @@ -680,7 +681,7 @@ public void Add_Int16_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int16_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16); @@ -694,7 +695,7 @@ public void Add_Int16_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int16_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16); @@ -708,7 +709,7 @@ public void Add_Int16_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt16_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16); @@ -722,7 +723,7 @@ public void Add_UInt16_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt16_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16); @@ -736,7 +737,7 @@ public void Add_UInt16_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt16_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16); @@ -750,7 +751,7 @@ public void Add_UInt16_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt16_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16); @@ -764,7 +765,7 @@ public void Add_UInt16_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt16_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16); @@ -778,7 +779,7 @@ public void Add_UInt16_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt16_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16); @@ -792,7 +793,7 @@ public void Add_UInt16_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt16_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16); @@ -806,7 +807,7 @@ public void Add_UInt16_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt16_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16); @@ -820,7 +821,7 @@ public void Add_UInt16_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt16_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16); @@ -834,7 +835,7 @@ public void Add_UInt16_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt16_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16); @@ -848,7 +849,7 @@ public void Add_UInt16_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int32_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32); @@ -862,7 +863,7 @@ public void Add_Int32_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int32_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32); @@ -876,7 +877,7 @@ public void Add_Int32_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int32_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32); @@ -890,7 +891,7 @@ public void Add_Int32_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int32_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32); @@ -904,7 +905,7 @@ public void Add_Int32_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int32_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32); @@ -918,7 +919,7 @@ public void Add_Int32_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int32_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32); @@ -932,7 +933,7 @@ public void Add_Int32_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int32_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32); @@ -946,7 +947,7 @@ public void Add_Int32_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int32_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32); @@ -960,7 +961,7 @@ public void Add_Int32_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int32_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32); @@ -974,7 +975,7 @@ public void Add_Int32_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int32_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32); @@ -988,7 +989,7 @@ public void Add_Int32_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt32_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32); @@ -1002,7 +1003,7 @@ public void Add_UInt32_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt32_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32); @@ -1016,7 +1017,7 @@ public void Add_UInt32_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt32_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32); @@ -1030,7 +1031,7 @@ public void Add_UInt32_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt32_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32); @@ -1044,7 +1045,7 @@ public void Add_UInt32_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt32_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32); @@ -1058,7 +1059,7 @@ public void Add_UInt32_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt32_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32); @@ -1072,7 +1073,7 @@ public void Add_UInt32_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt32_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32); @@ -1086,7 +1087,7 @@ public void Add_UInt32_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt32_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32); @@ -1100,7 +1101,7 @@ public void Add_UInt32_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt32_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32); @@ -1114,7 +1115,7 @@ public void Add_UInt32_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt32_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32); @@ -1128,7 +1129,7 @@ public void Add_UInt32_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int64_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64); @@ -1142,7 +1143,7 @@ public void Add_Int64_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int64_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64); @@ -1156,7 +1157,7 @@ public void Add_Int64_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int64_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64); @@ -1170,7 +1171,7 @@ public void Add_Int64_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int64_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64); @@ -1184,7 +1185,7 @@ public void Add_Int64_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int64_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64); @@ -1198,7 +1199,7 @@ public void Add_Int64_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int64_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64); @@ -1212,7 +1213,7 @@ public void Add_Int64_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int64_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64); @@ -1226,7 +1227,7 @@ public void Add_Int64_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int64_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64); @@ -1240,7 +1241,7 @@ public void Add_Int64_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int64_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64); @@ -1254,7 +1255,7 @@ public void Add_Int64_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Int64_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64); @@ -1268,7 +1269,7 @@ public void Add_Int64_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt64_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64); @@ -1282,7 +1283,7 @@ public void Add_UInt64_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt64_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64); @@ -1296,7 +1297,7 @@ public void Add_UInt64_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt64_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64); @@ -1310,7 +1311,7 @@ public void Add_UInt64_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt64_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64); @@ -1324,7 +1325,7 @@ public void Add_UInt64_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt64_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64); @@ -1338,7 +1339,7 @@ public void Add_UInt64_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt64_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64); @@ -1352,7 +1353,7 @@ public void Add_UInt64_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt64_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64); @@ -1366,7 +1367,7 @@ public void Add_UInt64_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt64_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64); @@ -1380,7 +1381,7 @@ public void Add_UInt64_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt64_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64); @@ -1394,7 +1395,7 @@ public void Add_UInt64_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_UInt64_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64); @@ -1408,7 +1409,7 @@ public void Add_UInt64_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Double_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double); @@ -1422,7 +1423,7 @@ public void Add_Double_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Double_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double); @@ -1436,7 +1437,7 @@ public void Add_Double_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Double_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double); @@ -1450,7 +1451,7 @@ public void Add_Double_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Double_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double); @@ -1464,7 +1465,7 @@ public void Add_Double_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Double_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double); @@ -1478,7 +1479,7 @@ public void Add_Double_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Double_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double); @@ -1492,7 +1493,7 @@ public void Add_Double_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Double_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double); @@ -1506,7 +1507,7 @@ public void Add_Double_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Double_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double); @@ -1520,7 +1521,7 @@ public void Add_Double_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Double_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double); @@ -1534,7 +1535,7 @@ public void Add_Double_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Double_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double); @@ -1548,7 +1549,7 @@ public void Add_Double_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Single_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single); @@ -1562,7 +1563,7 @@ public void Add_Single_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Single_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single); @@ -1576,7 +1577,7 @@ public void Add_Single_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Single_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single); @@ -1590,7 +1591,7 @@ public void Add_Single_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Single_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single); @@ -1604,7 +1605,7 @@ public void Add_Single_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Single_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single); @@ -1618,7 +1619,7 @@ public void Add_Single_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Single_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single); @@ -1632,7 +1633,7 @@ public void Add_Single_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Single_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single); @@ -1646,7 +1647,7 @@ public void Add_Single_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Add_Single_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single); diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_divide_tests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_divide_tests.cs index 78fbdacbb..e9bad17a6 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_divide_tests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_divide_tests.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged.Math { + [TestClass] public class np_divide_tests { - [Test] + [TestMethod] public void UInt8DivideTest1() { // NumPy: uint8 / int returns float64 (true division) @@ -22,7 +23,7 @@ public void UInt8DivideTest1() nd2.array_equal(new double[] {0.0 / 2, 1.0 / 2, 2.0 / 2}).Should().BeTrue(); } - [Test] + [TestMethod] public void UInt16DivideTest1() { // NumPy: uint16 / int returns float64 (true division) @@ -35,7 +36,7 @@ public void UInt16DivideTest1() nd2.array_equal(new double[] {0.0 / 2, 1.0 / 2, 2.0 / 2}).Should().BeTrue(); } - [Test] + [TestMethod] public void Divide() { var left = np.ones(new Shape(5, 5)) + 5d; @@ -51,22 +52,22 @@ public void Divide() #if _REGEN %a = except(supported_dtypes, "NDArray", "Boolean") %foreach a - [Arguments(NPTypeCode.Boolean, NPTypeCode.#1)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.#1)] #else - [Arguments(NPTypeCode.Boolean, NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Byte)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Char)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Double)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Single)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Decimal)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Byte)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Char)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Double)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Single)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Decimal)] #endif - [Test] + [TestMethod] public void DivideAllPossabilitiesBoolean(NPTypeCode ltc, NPTypeCode rtc) { var left = np.ones(new Shape(5, 5), rtc) + 3; @@ -84,22 +85,22 @@ public void DivideAllPossabilitiesBoolean(NPTypeCode ltc, NPTypeCode rtc) #if _REGEN %a = except(supported_dtypes, "NDArray", "Boolean") %foreach a - [Arguments(NPTypeCode.Boolean, NPTypeCode.#1)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.#1)] #else - [Arguments(NPTypeCode.Boolean, NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Byte)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Char)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Double)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Single)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Decimal)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Byte)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Char)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Double)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Single)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Decimal)] #endif - [Test] + [TestMethod] public void DivideAllPossabilitiesBoolean_Left(NPTypeCode ltc, NPTypeCode rtc) { var left = np.ones(new Shape(5, 5), ltc) + 1; @@ -114,7 +115,7 @@ public void DivideAllPossabilitiesBoolean_Left(NPTypeCode ltc, NPTypeCode rtc) } } - [Test] + [TestMethod] public void DivideUpcast() { var left = (np.ones(new Shape(5, 5)) + 5d).astype(NPTypeCode.Single); @@ -131,7 +132,7 @@ public void DivideUpcast() } } - [Test] + [TestMethod] public void DivideDowncast() { var left = (np.zeros(new Shape(5, 5)) + 5d).astype(NPTypeCode.Single); @@ -148,14 +149,14 @@ public void DivideDowncast() } } - [Test] + [TestMethod] public void Divide_Two_Scalars() { var left = NDArray.Scalar(1d) / NDArray.Scalar(5d); left.GetDouble(0).Should().Be(1 / 5d); } - [Test] + [TestMethod] public void Divide_ND_3_1_vs_1_3() { var left = np.arange(3).reshape((3, 1)).astype(np.float64); @@ -176,7 +177,7 @@ public void Divide_ND_3_1_vs_1_3() } } - [Test] + [TestMethod] public void Divide_ND_3_1_vs_1_3_float() { var left = np.arange(3).reshape((3, 1)).astype(np.float32); @@ -197,7 +198,7 @@ public void Divide_ND_3_1_vs_1_3_float() } } - [Test] + [TestMethod] public void Divide_ND_2_1_3_3_vs_1_3() { var left = np.arange(2 * 3 * 3).reshape((2, 1, 3, 3)).astype(np.float64); @@ -217,7 +218,7 @@ public void Divide_ND_2_1_3_3_vs_1_3() ret.GetDouble(1, 0, 2, 2).Should().Be(8.5); } - [Test] + [TestMethod] public void Divide_ND_2_3_3() { var left = np.arange(6).reshape((2, 3, 1)).astype(np.float64); @@ -244,7 +245,7 @@ public void Divide_ND_2_3_3() } } - [Test] + [TestMethod] public void Divide_RightScalar() { var left = np.zeros(new Shape(5, 5), np.float64) + 5d; @@ -258,7 +259,7 @@ public void Divide_RightScalar() } } - [Test] + [TestMethod] public void Divide_LeftScalar() { var left = NDArray.Scalar(1d); @@ -272,7 +273,7 @@ public void Divide_LeftScalar() } } - [Test] + [TestMethod] public void Divide_Rising() { var left = np.zeros(new Shape(5, 5), np.float64); @@ -297,7 +298,7 @@ public void Divide_Rising() } } - [Test] + [TestMethod] public void Divide_RightScalar_Rising() { var left = np.zeros(new Shape(5, 5), np.float64); @@ -315,7 +316,7 @@ public void Divide_RightScalar_Rising() } } - [Test] + [TestMethod] public void Divide_LeftScalar_Rising() { var left = NDArray.Scalar(1d); @@ -333,7 +334,7 @@ public void Divide_LeftScalar_Rising() %a = ["Boolean","Byte","Int16","UInt16","Int32","UInt32","Int64","UInt64","Double","Single","Decimal"] %b = [true,"1","1","1","1","1u","1L","1UL","1d","1f","1m"] %foreach forevery(a,a,true), forevery(b,b,true)% - [Test] + [TestMethod] public void Divide_#1_To_#2() { var left = np.ones(new Shape(5, 5), NPTypeCode.#1) + 3; @@ -350,7 +351,7 @@ public void Divide_LeftScalar_Rising() % #else - [Test] + [TestMethod] public void Divide_Boolean_To_Byte() { var left = np.ones(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -364,7 +365,7 @@ public void Divide_Boolean_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Boolean_To_Int16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -378,7 +379,7 @@ public void Divide_Boolean_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Boolean_To_UInt16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -392,7 +393,7 @@ public void Divide_Boolean_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Boolean_To_Int32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -406,7 +407,7 @@ public void Divide_Boolean_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Boolean_To_UInt32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -420,7 +421,7 @@ public void Divide_Boolean_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Boolean_To_Int64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -434,7 +435,7 @@ public void Divide_Boolean_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Boolean_To_UInt64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -448,7 +449,7 @@ public void Divide_Boolean_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Boolean_To_Double() { var left = np.ones(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -462,7 +463,7 @@ public void Divide_Boolean_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Boolean_To_Single() { var left = np.ones(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -476,7 +477,7 @@ public void Divide_Boolean_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Boolean_To_Decimal() { var left = np.ones(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -490,7 +491,7 @@ public void Divide_Boolean_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Byte_To_Boolean() { var left = np.ones(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -504,7 +505,7 @@ public void Divide_Byte_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Byte_To_Int16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -518,7 +519,7 @@ public void Divide_Byte_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Byte_To_UInt16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -532,7 +533,7 @@ public void Divide_Byte_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Byte_To_Int32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -546,7 +547,7 @@ public void Divide_Byte_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Byte_To_UInt32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -560,7 +561,7 @@ public void Divide_Byte_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Byte_To_Int64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -574,7 +575,7 @@ public void Divide_Byte_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Byte_To_UInt64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -588,7 +589,7 @@ public void Divide_Byte_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Byte_To_Double() { var left = np.ones(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -602,7 +603,7 @@ public void Divide_Byte_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Byte_To_Single() { var left = np.ones(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -616,7 +617,7 @@ public void Divide_Byte_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Byte_To_Decimal() { var left = np.ones(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -630,7 +631,7 @@ public void Divide_Byte_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int16_To_Boolean() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -644,7 +645,7 @@ public void Divide_Int16_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int16_To_Byte() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -658,7 +659,7 @@ public void Divide_Int16_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int16_To_UInt16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -672,7 +673,7 @@ public void Divide_Int16_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int16_To_Int32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -686,7 +687,7 @@ public void Divide_Int16_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int16_To_UInt32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -700,7 +701,7 @@ public void Divide_Int16_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int16_To_Int64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -714,7 +715,7 @@ public void Divide_Int16_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int16_To_UInt64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -728,7 +729,7 @@ public void Divide_Int16_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int16_To_Double() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -742,7 +743,7 @@ public void Divide_Int16_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int16_To_Single() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -756,7 +757,7 @@ public void Divide_Int16_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int16_To_Decimal() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -770,7 +771,7 @@ public void Divide_Int16_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt16_To_Boolean() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -784,7 +785,7 @@ public void Divide_UInt16_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt16_To_Byte() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -798,7 +799,7 @@ public void Divide_UInt16_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt16_To_Int16() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -812,7 +813,7 @@ public void Divide_UInt16_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt16_To_Int32() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -826,7 +827,7 @@ public void Divide_UInt16_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt16_To_UInt32() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -840,7 +841,7 @@ public void Divide_UInt16_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt16_To_Int64() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -854,7 +855,7 @@ public void Divide_UInt16_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt16_To_UInt64() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -868,7 +869,7 @@ public void Divide_UInt16_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt16_To_Double() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -882,7 +883,7 @@ public void Divide_UInt16_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt16_To_Single() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -896,7 +897,7 @@ public void Divide_UInt16_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt16_To_Decimal() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -910,7 +911,7 @@ public void Divide_UInt16_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int32_To_Boolean() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -924,7 +925,7 @@ public void Divide_Int32_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int32_To_Byte() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -938,7 +939,7 @@ public void Divide_Int32_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int32_To_Int16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -952,7 +953,7 @@ public void Divide_Int32_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int32_To_UInt16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -966,7 +967,7 @@ public void Divide_Int32_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int32_To_UInt32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -980,7 +981,7 @@ public void Divide_Int32_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int32_To_Int64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -994,7 +995,7 @@ public void Divide_Int32_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int32_To_UInt64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -1008,7 +1009,7 @@ public void Divide_Int32_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int32_To_Double() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -1022,7 +1023,7 @@ public void Divide_Int32_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int32_To_Single() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -1036,7 +1037,7 @@ public void Divide_Int32_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int32_To_Decimal() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -1050,7 +1051,7 @@ public void Divide_Int32_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt32_To_Boolean() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1064,7 +1065,7 @@ public void Divide_UInt32_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt32_To_Byte() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1078,7 +1079,7 @@ public void Divide_UInt32_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt32_To_Int16() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1092,7 +1093,7 @@ public void Divide_UInt32_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt32_To_UInt16() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1106,7 +1107,7 @@ public void Divide_UInt32_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt32_To_Int32() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1120,7 +1121,7 @@ public void Divide_UInt32_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt32_To_Int64() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1134,7 +1135,7 @@ public void Divide_UInt32_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt32_To_UInt64() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1148,7 +1149,7 @@ public void Divide_UInt32_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt32_To_Double() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1162,7 +1163,7 @@ public void Divide_UInt32_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt32_To_Single() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1176,7 +1177,7 @@ public void Divide_UInt32_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt32_To_Decimal() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1190,7 +1191,7 @@ public void Divide_UInt32_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int64_To_Boolean() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1204,7 +1205,7 @@ public void Divide_Int64_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int64_To_Byte() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1218,7 +1219,7 @@ public void Divide_Int64_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int64_To_Int16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1232,7 +1233,7 @@ public void Divide_Int64_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int64_To_UInt16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1246,7 +1247,7 @@ public void Divide_Int64_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int64_To_Int32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1260,7 +1261,7 @@ public void Divide_Int64_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int64_To_UInt32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1274,7 +1275,7 @@ public void Divide_Int64_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int64_To_UInt64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1288,7 +1289,7 @@ public void Divide_Int64_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int64_To_Double() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1302,7 +1303,7 @@ public void Divide_Int64_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int64_To_Single() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1316,7 +1317,7 @@ public void Divide_Int64_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Int64_To_Decimal() { var left = np.ones(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1330,7 +1331,7 @@ public void Divide_Int64_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt64_To_Boolean() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1344,7 +1345,7 @@ public void Divide_UInt64_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt64_To_Byte() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1358,7 +1359,7 @@ public void Divide_UInt64_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt64_To_Int16() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1372,7 +1373,7 @@ public void Divide_UInt64_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt64_To_UInt16() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1386,7 +1387,7 @@ public void Divide_UInt64_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt64_To_Int32() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1400,7 +1401,7 @@ public void Divide_UInt64_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt64_To_UInt32() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1414,7 +1415,7 @@ public void Divide_UInt64_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt64_To_Int64() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1428,7 +1429,7 @@ public void Divide_UInt64_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt64_To_Double() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1442,7 +1443,7 @@ public void Divide_UInt64_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt64_To_Single() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1456,7 +1457,7 @@ public void Divide_UInt64_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_UInt64_To_Decimal() { var left = np.ones(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1470,7 +1471,7 @@ public void Divide_UInt64_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Double_To_Boolean() { var left = np.ones(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1484,7 +1485,7 @@ public void Divide_Double_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Double_To_Byte() { var left = np.ones(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1498,7 +1499,7 @@ public void Divide_Double_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Double_To_Int16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1512,7 +1513,7 @@ public void Divide_Double_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Double_To_UInt16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1526,7 +1527,7 @@ public void Divide_Double_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Double_To_Int32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1540,7 +1541,7 @@ public void Divide_Double_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Double_To_UInt32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1554,7 +1555,7 @@ public void Divide_Double_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Double_To_Int64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1568,7 +1569,7 @@ public void Divide_Double_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Double_To_UInt64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1582,7 +1583,7 @@ public void Divide_Double_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Double_To_Single() { var left = np.ones(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1596,7 +1597,7 @@ public void Divide_Double_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Double_To_Decimal() { var left = np.ones(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1610,7 +1611,7 @@ public void Divide_Double_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Single_To_Boolean() { var left = np.ones(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1624,7 +1625,7 @@ public void Divide_Single_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Single_To_Byte() { var left = np.ones(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1638,7 +1639,7 @@ public void Divide_Single_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Single_To_Int16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1652,7 +1653,7 @@ public void Divide_Single_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Single_To_UInt16() { var left = np.ones(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1666,7 +1667,7 @@ public void Divide_Single_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Single_To_Int32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1680,7 +1681,7 @@ public void Divide_Single_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Single_To_UInt32() { var left = np.ones(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1694,7 +1695,7 @@ public void Divide_Single_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Single_To_Int64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1708,7 +1709,7 @@ public void Divide_Single_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Divide_Single_To_UInt64() { var left = np.ones(new Shape(5, 5), NPTypeCode.Single) + 3; diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_exp_tests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_exp_tests.cs index 49acd970f..b9df3d4b4 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_exp_tests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_exp_tests.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged.Math { + [TestClass] public class np_exp_tests { - [Test] + [TestMethod] public void Exp_0() { var arr = np.zeros(new Shape(5, 5)); @@ -22,7 +23,7 @@ public void Exp_0() ret.GetData().All(d => System.Math.Abs(d - 1.0) < 0.0001).Should().BeTrue(); } - [Test] + [TestMethod] public void Exp_1() { var arr = np.ones(new Shape(5, 5)); @@ -52,7 +53,7 @@ public void Exp_1() 1.6948892444103338e+28, 9.253781725587787e+29, 5.052393630276104e+31, 2.7585134545231703e+33 }, new Shape(new int[] { 5, 4 })); - [Test] + [TestMethod] public void Exp_Sliced() { var a = np.arange(1.0, 81.0); @@ -72,7 +73,7 @@ public void Exp_Sliced() } } - [Test] + [TestMethod] public void ExpUpcast() { var right = np.zeros(new Shape(5, 5)).astype(NPTypeCode.Int32) + 5; @@ -86,7 +87,7 @@ public void ExpUpcast() } } - [Test] + [TestMethod] public void ExpDowncast() { var right = np.zeros(new Shape(5, 5)).astype(NPTypeCode.Double) + 5; diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_log_tests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_log_tests.cs index 9ea54f41c..4a4429ea4 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_log_tests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_log_tests.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged.Math { + [TestClass] public class np_log_tests { - [Test] + [TestMethod] public void Log_1() { var arr = np.zeros(new Shape(5, 5)) + 5d; @@ -22,7 +23,7 @@ public void Log_1() ret.GetData().All(d => System.Math.Abs(d - 1.6094379124341) < 0.0001).Should().BeTrue(); } - [Test] + [TestMethod] public void Log_2() { var arr = np.ones(new Shape(5, 5)); @@ -35,7 +36,7 @@ public void Log_2() ret.GetData().All(d => d == 0).Should().BeTrue(); } - [Test] + [TestMethod] public void LogUpcast() { var right = np.zeros(new Shape(5, 5)).astype(NPTypeCode.Int32)+5; @@ -49,7 +50,7 @@ public void LogUpcast() } } - [Test] + [TestMethod] public void LogDowncast() { var right = np.zeros(new Shape(5, 5)).astype(NPTypeCode.Double) + 5; diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_mod_tests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_mod_tests.cs index 0fac77763..5e6e03426 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_mod_tests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_mod_tests.cs @@ -8,6 +8,7 @@ namespace NumSharp.UnitTest.Backends.Unmanaged.Math { + [TestClass] public class np_mod_tests { #region Regular Tests @@ -15,20 +16,20 @@ public class np_mod_tests #if _REGEN %a = except(supported_dtypes, "NDArray", "Boolean") %foreach a - [Arguments(NPTypeCode.Boolean, NPTypeCode.#1)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.#1)] #else - [Arguments(NPTypeCode.Boolean, NPTypeCode.Byte)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Double)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Single)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Decimal)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Byte)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Double)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Single)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Decimal)] #endif - [Test] + [TestMethod] public void ModAllPossabilitiesBoolean(NPTypeCode ltc, NPTypeCode rtc) { var right = np.full(new Shape(5, 5), 2, rtc); @@ -43,14 +44,14 @@ public void ModAllPossabilitiesBoolean(NPTypeCode ltc, NPTypeCode rtc) } } - [Test] + [TestMethod] public void Mod_Two_Scalars() { var left = NDArray.Scalar(1d) % NDArray.Scalar(5d); left.GetDouble(0).Should().Be(1); } - [Test] + [TestMethod] public void Mod_ND_3_1_vs_1_3() { var left = (np.arange(3).reshape((3, 1)) + 1).astype(np.int32); @@ -70,7 +71,7 @@ public void Mod_ND_3_1_vs_1_3() } } - [Test] + [TestMethod] public void Mod_ND_2_1_3_3_vs_1_3() { var left = np.arange(2 * 3 * 3).reshape((2, 1, 3, 3)).astype(np.float64) + 1; @@ -90,7 +91,7 @@ public void Mod_ND_2_1_3_3_vs_1_3() ret.GetDouble(1, 0, 2, 2).Should().Be(0); } - [Test] + [TestMethod] public void Mod_Rising() { var left = np.zeros(new Shape(5, 5), np.float64); @@ -114,7 +115,7 @@ public void Mod_Rising() } } - [Test] + [TestMethod] public void Mod_RightScalar_Rising() { var left = np.zeros(new Shape(5, 5), np.float64); @@ -133,7 +134,7 @@ public void Mod_RightScalar_Rising() } } - [Test] + [TestMethod] public void Mod_LeftScalar_Rising() { var left = NDArray.Scalar(1d); @@ -159,7 +160,7 @@ public void Mod_LeftScalar_Rising() %b = [true,"1","1","1","1","1u","1L","1UL","1d","1f","1m"] %mod = "%" %foreach forevery(a,a,true), forevery(b,b,true)% - [Test] + [TestMethod] public void Mod_#1_To_#2() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.#1); @@ -177,7 +178,7 @@ public void Mod_LeftScalar_Rising() % #else - [Test] + [TestMethod] public void Mod_Boolean_To_Byte() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Boolean); @@ -191,7 +192,7 @@ public void Mod_Boolean_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Boolean_To_Int16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Boolean); @@ -205,7 +206,7 @@ public void Mod_Boolean_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Boolean_To_UInt16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Boolean); @@ -219,7 +220,7 @@ public void Mod_Boolean_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Boolean_To_Int32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Boolean); @@ -233,7 +234,7 @@ public void Mod_Boolean_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Boolean_To_UInt32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Boolean); @@ -247,7 +248,7 @@ public void Mod_Boolean_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Boolean_To_Int64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Boolean); @@ -261,7 +262,7 @@ public void Mod_Boolean_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Boolean_To_UInt64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Boolean); @@ -275,7 +276,7 @@ public void Mod_Boolean_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Boolean_To_Double() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Boolean); @@ -289,7 +290,7 @@ public void Mod_Boolean_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Boolean_To_Single() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Boolean); @@ -303,7 +304,7 @@ public void Mod_Boolean_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Boolean_To_Decimal() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Boolean); @@ -317,7 +318,7 @@ public void Mod_Boolean_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Byte_To_Boolean() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Byte); @@ -331,7 +332,7 @@ public void Mod_Byte_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Byte_To_Int16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Byte); @@ -345,7 +346,7 @@ public void Mod_Byte_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Byte_To_UInt16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Byte); @@ -359,7 +360,7 @@ public void Mod_Byte_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Byte_To_Int32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Byte); @@ -373,7 +374,7 @@ public void Mod_Byte_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Byte_To_UInt32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Byte); @@ -387,7 +388,7 @@ public void Mod_Byte_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Byte_To_Int64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Byte); @@ -401,7 +402,7 @@ public void Mod_Byte_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Byte_To_UInt64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Byte); @@ -415,7 +416,7 @@ public void Mod_Byte_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Byte_To_Double() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Byte); @@ -429,7 +430,7 @@ public void Mod_Byte_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Byte_To_Single() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Byte); @@ -443,7 +444,7 @@ public void Mod_Byte_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Byte_To_Decimal() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Byte); @@ -457,7 +458,7 @@ public void Mod_Byte_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int16_To_Boolean() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int16); @@ -471,7 +472,7 @@ public void Mod_Int16_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int16_To_Byte() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int16); @@ -485,7 +486,7 @@ public void Mod_Int16_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int16_To_UInt16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int16); @@ -499,7 +500,7 @@ public void Mod_Int16_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int16_To_Int32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int16); @@ -513,7 +514,7 @@ public void Mod_Int16_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int16_To_UInt32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int16); @@ -527,7 +528,7 @@ public void Mod_Int16_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int16_To_Int64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int16); @@ -541,7 +542,7 @@ public void Mod_Int16_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int16_To_UInt64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int16); @@ -555,7 +556,7 @@ public void Mod_Int16_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int16_To_Double() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int16); @@ -569,7 +570,7 @@ public void Mod_Int16_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int16_To_Single() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int16); @@ -583,7 +584,7 @@ public void Mod_Int16_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int16_To_Decimal() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int16); @@ -597,7 +598,7 @@ public void Mod_Int16_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt16_To_Boolean() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt16); @@ -611,7 +612,7 @@ public void Mod_UInt16_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt16_To_Byte() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt16); @@ -625,7 +626,7 @@ public void Mod_UInt16_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt16_To_Int16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt16); @@ -639,7 +640,7 @@ public void Mod_UInt16_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt16_To_Int32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt16); @@ -653,7 +654,7 @@ public void Mod_UInt16_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt16_To_UInt32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt16); @@ -667,7 +668,7 @@ public void Mod_UInt16_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt16_To_Int64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt16); @@ -681,7 +682,7 @@ public void Mod_UInt16_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt16_To_UInt64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt16); @@ -695,7 +696,7 @@ public void Mod_UInt16_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt16_To_Double() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt16); @@ -709,7 +710,7 @@ public void Mod_UInt16_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt16_To_Single() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt16); @@ -723,7 +724,7 @@ public void Mod_UInt16_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt16_To_Decimal() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt16); @@ -737,7 +738,7 @@ public void Mod_UInt16_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int32_To_Boolean() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int32); @@ -751,7 +752,7 @@ public void Mod_Int32_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int32_To_Byte() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int32); @@ -765,7 +766,7 @@ public void Mod_Int32_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int32_To_Int16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int32); @@ -779,7 +780,7 @@ public void Mod_Int32_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int32_To_UInt16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int32); @@ -793,7 +794,7 @@ public void Mod_Int32_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int32_To_UInt32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int32); @@ -807,7 +808,7 @@ public void Mod_Int32_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int32_To_Int64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int32); @@ -821,7 +822,7 @@ public void Mod_Int32_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int32_To_UInt64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int32); @@ -835,7 +836,7 @@ public void Mod_Int32_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int32_To_Double() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int32); @@ -849,7 +850,7 @@ public void Mod_Int32_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int32_To_Single() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int32); @@ -863,7 +864,7 @@ public void Mod_Int32_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int32_To_Decimal() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int32); @@ -877,7 +878,7 @@ public void Mod_Int32_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt32_To_Boolean() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt32); @@ -891,7 +892,7 @@ public void Mod_UInt32_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt32_To_Byte() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt32); @@ -905,7 +906,7 @@ public void Mod_UInt32_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt32_To_Int16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt32); @@ -919,7 +920,7 @@ public void Mod_UInt32_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt32_To_UInt16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt32); @@ -933,7 +934,7 @@ public void Mod_UInt32_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt32_To_Int32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt32); @@ -947,7 +948,7 @@ public void Mod_UInt32_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt32_To_Int64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt32); @@ -961,7 +962,7 @@ public void Mod_UInt32_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt32_To_UInt64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt32); @@ -975,7 +976,7 @@ public void Mod_UInt32_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt32_To_Double() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt32); @@ -989,7 +990,7 @@ public void Mod_UInt32_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt32_To_Single() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt32); @@ -1003,7 +1004,7 @@ public void Mod_UInt32_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt32_To_Decimal() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt32); @@ -1017,7 +1018,7 @@ public void Mod_UInt32_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int64_To_Boolean() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int64); @@ -1031,7 +1032,7 @@ public void Mod_Int64_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int64_To_Byte() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int64); @@ -1045,7 +1046,7 @@ public void Mod_Int64_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int64_To_Int16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int64); @@ -1059,7 +1060,7 @@ public void Mod_Int64_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int64_To_UInt16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int64); @@ -1073,7 +1074,7 @@ public void Mod_Int64_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int64_To_Int32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int64); @@ -1087,7 +1088,7 @@ public void Mod_Int64_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int64_To_UInt32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int64); @@ -1101,7 +1102,7 @@ public void Mod_Int64_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int64_To_UInt64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int64); @@ -1115,7 +1116,7 @@ public void Mod_Int64_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int64_To_Double() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int64); @@ -1129,7 +1130,7 @@ public void Mod_Int64_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int64_To_Single() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int64); @@ -1143,7 +1144,7 @@ public void Mod_Int64_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Int64_To_Decimal() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Int64); @@ -1157,7 +1158,7 @@ public void Mod_Int64_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt64_To_Boolean() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt64); @@ -1171,7 +1172,7 @@ public void Mod_UInt64_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt64_To_Byte() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt64); @@ -1185,7 +1186,7 @@ public void Mod_UInt64_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt64_To_Int16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt64); @@ -1199,7 +1200,7 @@ public void Mod_UInt64_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt64_To_UInt16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt64); @@ -1213,7 +1214,7 @@ public void Mod_UInt64_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt64_To_Int32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt64); @@ -1227,7 +1228,7 @@ public void Mod_UInt64_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt64_To_UInt32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt64); @@ -1241,7 +1242,7 @@ public void Mod_UInt64_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt64_To_Int64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt64); @@ -1255,7 +1256,7 @@ public void Mod_UInt64_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt64_To_Double() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt64); @@ -1269,7 +1270,7 @@ public void Mod_UInt64_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt64_To_Single() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt64); @@ -1283,7 +1284,7 @@ public void Mod_UInt64_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_UInt64_To_Decimal() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.UInt64); @@ -1297,7 +1298,7 @@ public void Mod_UInt64_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Double_To_Boolean() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Double); @@ -1311,7 +1312,7 @@ public void Mod_Double_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Double_To_Byte() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Double); @@ -1325,7 +1326,7 @@ public void Mod_Double_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Double_To_Int16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Double); @@ -1339,7 +1340,7 @@ public void Mod_Double_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Double_To_UInt16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Double); @@ -1353,7 +1354,7 @@ public void Mod_Double_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Double_To_Int32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Double); @@ -1367,7 +1368,7 @@ public void Mod_Double_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Double_To_UInt32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Double); @@ -1381,7 +1382,7 @@ public void Mod_Double_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Double_To_Int64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Double); @@ -1395,7 +1396,7 @@ public void Mod_Double_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Double_To_UInt64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Double); @@ -1409,7 +1410,7 @@ public void Mod_Double_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Double_To_Single() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Double); @@ -1423,7 +1424,7 @@ public void Mod_Double_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Double_To_Decimal() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Double); @@ -1437,7 +1438,7 @@ public void Mod_Double_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Single_To_Boolean() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Single); @@ -1451,7 +1452,7 @@ public void Mod_Single_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Single_To_Byte() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Single); @@ -1465,7 +1466,7 @@ public void Mod_Single_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Single_To_Int16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Single); @@ -1479,7 +1480,7 @@ public void Mod_Single_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Single_To_UInt16() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Single); @@ -1493,7 +1494,7 @@ public void Mod_Single_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Single_To_Int32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Single); @@ -1507,7 +1508,7 @@ public void Mod_Single_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Single_To_UInt32() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Single); @@ -1521,7 +1522,7 @@ public void Mod_Single_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Single_To_Int64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Single); @@ -1535,7 +1536,7 @@ public void Mod_Single_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Mod_Single_To_UInt64() { var left = np.full(new Shape(5, 5), 4, NPTypeCode.Single); diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_multiply_tests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_multiply_tests.cs index 4f35891a2..0d5516863 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_multiply_tests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_multiply_tests.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged.Math { + [TestClass] public class np_multiply_tests { - [Test] + [TestMethod] public void Multiply() { var left = np.zeros(new Shape(5, 5)) + 5d; @@ -25,22 +26,22 @@ public void Multiply() #if _REGEN %a = except(supported_dtypes, "NDArray", "Boolean") %foreach a - [Arguments(NPTypeCode.Boolean, NPTypeCode.#1)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.#1)] #else - [Arguments(NPTypeCode.Boolean, NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Byte)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Char)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Double)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Single)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Decimal)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Byte)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Char)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Double)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Single)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Decimal)] #endif - [Test] + [TestMethod] public void MultiplyAllPossabilitiesBoolean(NPTypeCode ltc, NPTypeCode rtc) { var left = np.ones(new Shape(5, 5), rtc); @@ -55,7 +56,7 @@ public void MultiplyAllPossabilitiesBoolean(NPTypeCode ltc, NPTypeCode rtc) } } - [Test] + [TestMethod] public void MultiplyUpcast() { var left = (np.zeros(new Shape(5, 5)) + 5d).astype(NPTypeCode.Single); @@ -72,7 +73,7 @@ public void MultiplyUpcast() } } - [Test] + [TestMethod] public void MultiplyDowncast() { var left = (np.zeros(new Shape(5, 5)) + 5d).astype(NPTypeCode.Single); @@ -89,14 +90,14 @@ public void MultiplyDowncast() } } - [Test] + [TestMethod] public void Multiply_Two_Scalars() { var left = NDArray.Scalar(2d) * NDArray.Scalar(5d); left.GetDouble(0).Should().Be(10); } - [Test] + [TestMethod] public void Multiply_ND_3_1_vs_1_3() { var left = np.arange(3).reshape((3, 1)).astype(np.float64); @@ -117,7 +118,7 @@ public void Multiply_ND_3_1_vs_1_3() } } - [Test] + [TestMethod] public void Multiply_ND_2_1_3_3_vs_1_3() { var left = np.arange(2 * 3 * 3).reshape((2, 1, 3, 3)).astype(np.float64); @@ -139,7 +140,7 @@ public void Multiply_ND_2_1_3_3_vs_1_3() ret.GetDouble(1, 0, 0, 2).Should().Be(22); } - [Test] + [TestMethod] public void Multiply_ND_2_3_3() { var left = np.arange(6).reshape((2, 3, 1)).astype(np.float64); @@ -165,7 +166,7 @@ public void Multiply_ND_2_3_3() } } - [Test] + [TestMethod] public void Multiply_RightScalar() { var left = np.zeros(new Shape(5, 5), np.float64) + 5d; @@ -179,7 +180,7 @@ public void Multiply_RightScalar() } } - [Test] + [TestMethod] public void Multiply_LeftScalar() { var left = NDArray.Scalar(2d); @@ -193,7 +194,7 @@ public void Multiply_LeftScalar() } } - [Test] + [TestMethod] public void Multiply_Rising() { var left = np.zeros(new Shape(5, 5), np.float64); @@ -218,7 +219,7 @@ public void Multiply_Rising() } } - [Test] + [TestMethod] public void Multiply_RightScalar_Rising() { var left = np.zeros(new Shape(5, 5), np.float64); @@ -236,7 +237,7 @@ public void Multiply_RightScalar_Rising() } } - [Test] + [TestMethod] public void Multiply_LeftScalar_Rising() { var left = NDArray.Scalar(2d); @@ -254,7 +255,7 @@ public void Multiply_LeftScalar_Rising() %a = ["Boolean","Byte","Int16","UInt16","Int32","UInt32","Int64","UInt64","Double","Single","Decimal"] %b = [true,"1","1","1","1","1u","1L","1UL","1d","1f","1m"] %foreach forevery(a,a,true), forevery(b,b,true)% - [Test] + [TestMethod] public void Multiply_#1_To_#2() { var left = np.zeros(new Shape(5, 5), NPTypeCode.#1) + 3; @@ -271,7 +272,7 @@ public void Multiply_LeftScalar_Rising() % #else - [Test] + [TestMethod] public void Multiply_Boolean_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -285,7 +286,7 @@ public void Multiply_Boolean_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Boolean_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -299,7 +300,7 @@ public void Multiply_Boolean_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Boolean_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -313,7 +314,7 @@ public void Multiply_Boolean_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Boolean_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -327,7 +328,7 @@ public void Multiply_Boolean_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Boolean_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -341,7 +342,7 @@ public void Multiply_Boolean_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Boolean_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -355,7 +356,7 @@ public void Multiply_Boolean_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Boolean_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -369,7 +370,7 @@ public void Multiply_Boolean_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Boolean_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -383,7 +384,7 @@ public void Multiply_Boolean_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Boolean_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -397,7 +398,7 @@ public void Multiply_Boolean_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Boolean_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -411,7 +412,7 @@ public void Multiply_Boolean_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Byte_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -425,7 +426,7 @@ public void Multiply_Byte_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Byte_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -439,7 +440,7 @@ public void Multiply_Byte_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Byte_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -453,7 +454,7 @@ public void Multiply_Byte_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Byte_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -467,7 +468,7 @@ public void Multiply_Byte_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Byte_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -481,7 +482,7 @@ public void Multiply_Byte_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Byte_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -495,7 +496,7 @@ public void Multiply_Byte_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Byte_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -509,7 +510,7 @@ public void Multiply_Byte_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Byte_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -523,7 +524,7 @@ public void Multiply_Byte_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Byte_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -537,7 +538,7 @@ public void Multiply_Byte_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Byte_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -551,7 +552,7 @@ public void Multiply_Byte_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int16_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -565,7 +566,7 @@ public void Multiply_Int16_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int16_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -579,7 +580,7 @@ public void Multiply_Int16_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int16_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -593,7 +594,7 @@ public void Multiply_Int16_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int16_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -607,7 +608,7 @@ public void Multiply_Int16_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int16_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -621,7 +622,7 @@ public void Multiply_Int16_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int16_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -635,7 +636,7 @@ public void Multiply_Int16_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int16_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -649,7 +650,7 @@ public void Multiply_Int16_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int16_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -663,7 +664,7 @@ public void Multiply_Int16_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int16_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -677,7 +678,7 @@ public void Multiply_Int16_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int16_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -691,7 +692,7 @@ public void Multiply_Int16_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt16_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -705,7 +706,7 @@ public void Multiply_UInt16_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt16_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -719,7 +720,7 @@ public void Multiply_UInt16_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt16_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -733,7 +734,7 @@ public void Multiply_UInt16_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt16_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -747,7 +748,7 @@ public void Multiply_UInt16_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt16_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -761,7 +762,7 @@ public void Multiply_UInt16_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt16_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -775,7 +776,7 @@ public void Multiply_UInt16_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt16_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -789,7 +790,7 @@ public void Multiply_UInt16_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt16_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -803,7 +804,7 @@ public void Multiply_UInt16_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt16_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -817,7 +818,7 @@ public void Multiply_UInt16_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt16_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -831,7 +832,7 @@ public void Multiply_UInt16_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int32_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -845,7 +846,7 @@ public void Multiply_Int32_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int32_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -859,7 +860,7 @@ public void Multiply_Int32_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int32_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -873,7 +874,7 @@ public void Multiply_Int32_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int32_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -887,7 +888,7 @@ public void Multiply_Int32_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int32_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -901,7 +902,7 @@ public void Multiply_Int32_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int32_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -915,7 +916,7 @@ public void Multiply_Int32_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int32_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -929,7 +930,7 @@ public void Multiply_Int32_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int32_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -943,7 +944,7 @@ public void Multiply_Int32_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int32_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -957,7 +958,7 @@ public void Multiply_Int32_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int32_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -971,7 +972,7 @@ public void Multiply_Int32_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt32_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -985,7 +986,7 @@ public void Multiply_UInt32_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt32_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -999,7 +1000,7 @@ public void Multiply_UInt32_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt32_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1013,7 +1014,7 @@ public void Multiply_UInt32_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt32_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1027,7 +1028,7 @@ public void Multiply_UInt32_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt32_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1041,7 +1042,7 @@ public void Multiply_UInt32_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt32_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1055,7 +1056,7 @@ public void Multiply_UInt32_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt32_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1069,7 +1070,7 @@ public void Multiply_UInt32_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt32_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1083,7 +1084,7 @@ public void Multiply_UInt32_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt32_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1097,7 +1098,7 @@ public void Multiply_UInt32_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt32_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1111,7 +1112,7 @@ public void Multiply_UInt32_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int64_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1125,7 +1126,7 @@ public void Multiply_Int64_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int64_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1139,7 +1140,7 @@ public void Multiply_Int64_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int64_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1153,7 +1154,7 @@ public void Multiply_Int64_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int64_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1167,7 +1168,7 @@ public void Multiply_Int64_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int64_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1181,7 +1182,7 @@ public void Multiply_Int64_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int64_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1195,7 +1196,7 @@ public void Multiply_Int64_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int64_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1209,7 +1210,7 @@ public void Multiply_Int64_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int64_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1223,7 +1224,7 @@ public void Multiply_Int64_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int64_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1237,7 +1238,7 @@ public void Multiply_Int64_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Int64_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1251,7 +1252,7 @@ public void Multiply_Int64_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt64_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1265,7 +1266,7 @@ public void Multiply_UInt64_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt64_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1279,7 +1280,7 @@ public void Multiply_UInt64_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt64_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1293,7 +1294,7 @@ public void Multiply_UInt64_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt64_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1307,7 +1308,7 @@ public void Multiply_UInt64_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt64_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1321,7 +1322,7 @@ public void Multiply_UInt64_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt64_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1335,7 +1336,7 @@ public void Multiply_UInt64_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt64_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1349,7 +1350,7 @@ public void Multiply_UInt64_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt64_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1363,7 +1364,7 @@ public void Multiply_UInt64_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt64_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1377,7 +1378,7 @@ public void Multiply_UInt64_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_UInt64_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1391,7 +1392,7 @@ public void Multiply_UInt64_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Double_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1405,7 +1406,7 @@ public void Multiply_Double_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Double_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1419,7 +1420,7 @@ public void Multiply_Double_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Double_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1433,7 +1434,7 @@ public void Multiply_Double_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Double_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1447,7 +1448,7 @@ public void Multiply_Double_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Double_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1461,7 +1462,7 @@ public void Multiply_Double_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Double_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1475,7 +1476,7 @@ public void Multiply_Double_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Double_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1489,7 +1490,7 @@ public void Multiply_Double_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Double_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1503,7 +1504,7 @@ public void Multiply_Double_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Double_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1517,7 +1518,7 @@ public void Multiply_Double_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Double_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1531,7 +1532,7 @@ public void Multiply_Double_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Single_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1545,7 +1546,7 @@ public void Multiply_Single_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Single_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1559,7 +1560,7 @@ public void Multiply_Single_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Single_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1573,7 +1574,7 @@ public void Multiply_Single_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Single_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1587,7 +1588,7 @@ public void Multiply_Single_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Single_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1601,7 +1602,7 @@ public void Multiply_Single_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Single_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1615,7 +1616,7 @@ public void Multiply_Single_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Single_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1629,7 +1630,7 @@ public void Multiply_Single_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Multiply_Single_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_power_tests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_power_tests.cs index b629d38d7..b57972dec 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_power_tests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_power_tests.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged.Math { + [TestClass] public class np_power_tests { - [Test] + [TestMethod] public void Power_1() { var arr = np.zeros(new Shape(5, 5)) + 5d; @@ -22,7 +23,7 @@ public void Power_1() ret.GetData().All(d => d==25).Should().BeTrue(); } - [Test] + [TestMethod] public void Power_2() { var arr = np.ones(new Shape(5, 5)); @@ -35,7 +36,7 @@ public void Power_2() ret.GetData().All(d => d == 1).Should().BeTrue(); } - [Test] + [TestMethod] public void PowerUpcast() { var right = np.zeros(new Shape(5, 5)).astype(NPTypeCode.Int32)+5; @@ -49,7 +50,7 @@ public void PowerUpcast() } } - [Test] + [TestMethod] public void PowerDowncast() { var right = np.zeros(new Shape(5, 5)).astype(NPTypeCode.Double) + 5; diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_subtract_tests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_subtract_tests.cs index 824da2057..412eaff06 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_subtract_tests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/Math/np_subtract_tests.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged.Math { + [TestClass] public class np_subtract_tests { - [Test] + [TestMethod] public void Subtract() { var left = np.zeros(new Shape(5, 5)) + 5d; @@ -25,22 +26,22 @@ public void Subtract() #if _REGEN %a = except(supported_dtypes, "NDArray", "Boolean") %foreach a - [Arguments(NPTypeCode.Boolean, NPTypeCode.#1)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.#1)] #else - [Arguments(NPTypeCode.Boolean, NPTypeCode.Boolean)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Byte)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt16)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt32)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Int64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.UInt64)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Char)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Double)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Single)] - [Arguments(NPTypeCode.Boolean, NPTypeCode.Decimal)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Boolean)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Byte)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt16)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt32)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Int64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.UInt64)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Char)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Double)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Single)] + [DataRow(NPTypeCode.Boolean, NPTypeCode.Decimal)] #endif - [Test] + [TestMethod] public void SubtractAllPossabilitiesBoolean(NPTypeCode ltc, NPTypeCode rtc) { var left = np.ones(new Shape(5, 5), rtc); @@ -55,7 +56,7 @@ public void SubtractAllPossabilitiesBoolean(NPTypeCode ltc, NPTypeCode rtc) } } - [Test] + [TestMethod] public void SubtractUpcast() { var left = (np.zeros(new Shape(5, 5)) + 5d).astype(NPTypeCode.Single); @@ -72,7 +73,7 @@ public void SubtractUpcast() } } - [Test] + [TestMethod] public void SubtractDowncast() { var left = (np.zeros(new Shape(5, 5)) + 5d).astype(NPTypeCode.Single); @@ -89,14 +90,14 @@ public void SubtractDowncast() } } - [Test] + [TestMethod] public void Subtract_Two_Scalars() { var left = NDArray.Scalar(1d) - NDArray.Scalar(5d); left.GetDouble(0).Should().Be(-4); } - [Test] + [TestMethod] public void Subtract_ND_3_1_vs_1_3() { var left = np.arange(3).reshape((3, 1)).astype(np.float64); @@ -117,7 +118,7 @@ public void Subtract_ND_3_1_vs_1_3() } } - [Test] + [TestMethod] public void Subtract_ND_2_1_3_3_vs_1_3() { var left = np.arange(2 * 3 * 3).reshape((2, 1, 3, 3)).astype(np.float64); @@ -139,7 +140,7 @@ public void Subtract_ND_2_1_3_3_vs_1_3() ret.GetDouble(1, 0, 2, 2).Should().Be(15); } - [Test] + [TestMethod] public void Subtract_ND_2_3_3() { var left = np.arange(6).reshape((2, 3, 1)).astype(np.float64); @@ -166,7 +167,7 @@ public void Subtract_ND_2_3_3() } } - [Test] + [TestMethod] public void Subtract_RightScalar() { var left = np.zeros(new Shape(5, 5), np.float64) + 5d; @@ -180,7 +181,7 @@ public void Subtract_RightScalar() } } - [Test] + [TestMethod] public void Subtract_LeftScalar() { var left = NDArray.Scalar(1d); @@ -194,7 +195,7 @@ public void Subtract_LeftScalar() } } - [Test] + [TestMethod] public void Subtract_Rising() { var left = np.zeros(new Shape(5, 5), np.float64); @@ -219,7 +220,7 @@ public void Subtract_Rising() } } - [Test] + [TestMethod] public void Subtract_RightScalar_Rising() { var left = np.zeros(new Shape(5, 5), np.float64); @@ -239,7 +240,7 @@ public void Subtract_RightScalar_Rising() } } - [Test] + [TestMethod] public void Subtract_LeftScalar_Rising() { var left = NDArray.Scalar(1d); @@ -257,7 +258,7 @@ public void Subtract_LeftScalar_Rising() %a = ["Boolean","Byte","Int16","UInt16","Int32","UInt32","Int64","UInt64","Double","Single","Decimal"] %b = [true,"1","1","1","1","1u","1L","1UL","1d","1f","1m"] %foreach forevery(a,a,true), forevery(b,b,true)% - [Test] + [TestMethod] public void Subtract_#1_To_#2() { var left = np.zeros(new Shape(5, 5), NPTypeCode.#1) + 3; @@ -274,7 +275,7 @@ public void Subtract_LeftScalar_Rising() % #else - [Test] + [TestMethod] public void Subtract_Boolean_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -288,7 +289,7 @@ public void Subtract_Boolean_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Boolean_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -302,7 +303,7 @@ public void Subtract_Boolean_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Boolean_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -316,7 +317,7 @@ public void Subtract_Boolean_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Boolean_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -330,7 +331,7 @@ public void Subtract_Boolean_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Boolean_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -344,7 +345,7 @@ public void Subtract_Boolean_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Boolean_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -358,7 +359,7 @@ public void Subtract_Boolean_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Boolean_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -372,7 +373,7 @@ public void Subtract_Boolean_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Boolean_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -386,7 +387,7 @@ public void Subtract_Boolean_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Boolean_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -400,7 +401,7 @@ public void Subtract_Boolean_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Boolean_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Boolean) + 3; @@ -414,7 +415,7 @@ public void Subtract_Boolean_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Byte_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -428,7 +429,7 @@ public void Subtract_Byte_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Byte_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -442,7 +443,7 @@ public void Subtract_Byte_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Byte_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -456,7 +457,7 @@ public void Subtract_Byte_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Byte_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -470,7 +471,7 @@ public void Subtract_Byte_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Byte_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -484,7 +485,7 @@ public void Subtract_Byte_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Byte_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -498,7 +499,7 @@ public void Subtract_Byte_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Byte_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -512,7 +513,7 @@ public void Subtract_Byte_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Byte_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -526,7 +527,7 @@ public void Subtract_Byte_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Byte_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -540,7 +541,7 @@ public void Subtract_Byte_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Byte_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Byte) + 3; @@ -554,7 +555,7 @@ public void Subtract_Byte_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int16_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -568,7 +569,7 @@ public void Subtract_Int16_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int16_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -582,7 +583,7 @@ public void Subtract_Int16_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int16_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -596,7 +597,7 @@ public void Subtract_Int16_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int16_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -610,7 +611,7 @@ public void Subtract_Int16_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int16_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -624,7 +625,7 @@ public void Subtract_Int16_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int16_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -638,7 +639,7 @@ public void Subtract_Int16_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int16_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -652,7 +653,7 @@ public void Subtract_Int16_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int16_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -666,7 +667,7 @@ public void Subtract_Int16_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int16_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -680,7 +681,7 @@ public void Subtract_Int16_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int16_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int16) + 3; @@ -694,7 +695,7 @@ public void Subtract_Int16_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt16_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -708,7 +709,7 @@ public void Subtract_UInt16_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt16_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -722,7 +723,7 @@ public void Subtract_UInt16_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt16_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -736,7 +737,7 @@ public void Subtract_UInt16_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt16_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -750,7 +751,7 @@ public void Subtract_UInt16_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt16_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -764,7 +765,7 @@ public void Subtract_UInt16_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt16_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -778,7 +779,7 @@ public void Subtract_UInt16_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt16_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -792,7 +793,7 @@ public void Subtract_UInt16_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt16_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -806,7 +807,7 @@ public void Subtract_UInt16_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt16_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -820,7 +821,7 @@ public void Subtract_UInt16_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt16_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt16) + 3; @@ -834,7 +835,7 @@ public void Subtract_UInt16_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int32_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -848,7 +849,7 @@ public void Subtract_Int32_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int32_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -862,7 +863,7 @@ public void Subtract_Int32_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int32_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -876,7 +877,7 @@ public void Subtract_Int32_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int32_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -890,7 +891,7 @@ public void Subtract_Int32_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int32_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -904,7 +905,7 @@ public void Subtract_Int32_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int32_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -918,7 +919,7 @@ public void Subtract_Int32_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int32_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -932,7 +933,7 @@ public void Subtract_Int32_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int32_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -946,7 +947,7 @@ public void Subtract_Int32_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int32_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -960,7 +961,7 @@ public void Subtract_Int32_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int32_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int32) + 3; @@ -974,7 +975,7 @@ public void Subtract_Int32_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt32_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -988,7 +989,7 @@ public void Subtract_UInt32_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt32_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1002,7 +1003,7 @@ public void Subtract_UInt32_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt32_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1016,7 +1017,7 @@ public void Subtract_UInt32_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt32_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1030,7 +1031,7 @@ public void Subtract_UInt32_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt32_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1044,7 +1045,7 @@ public void Subtract_UInt32_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt32_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1058,7 +1059,7 @@ public void Subtract_UInt32_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt32_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1072,7 +1073,7 @@ public void Subtract_UInt32_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt32_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1086,7 +1087,7 @@ public void Subtract_UInt32_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt32_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1100,7 +1101,7 @@ public void Subtract_UInt32_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt32_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt32) + 3; @@ -1114,7 +1115,7 @@ public void Subtract_UInt32_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int64_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1128,7 +1129,7 @@ public void Subtract_Int64_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int64_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1142,7 +1143,7 @@ public void Subtract_Int64_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int64_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1156,7 +1157,7 @@ public void Subtract_Int64_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int64_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1170,7 +1171,7 @@ public void Subtract_Int64_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int64_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1184,7 +1185,7 @@ public void Subtract_Int64_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int64_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1198,7 +1199,7 @@ public void Subtract_Int64_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int64_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1212,7 +1213,7 @@ public void Subtract_Int64_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int64_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1226,7 +1227,7 @@ public void Subtract_Int64_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int64_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1240,7 +1241,7 @@ public void Subtract_Int64_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Int64_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Int64) + 3; @@ -1254,7 +1255,7 @@ public void Subtract_Int64_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt64_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1268,7 +1269,7 @@ public void Subtract_UInt64_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt64_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1282,7 +1283,7 @@ public void Subtract_UInt64_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt64_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1296,7 +1297,7 @@ public void Subtract_UInt64_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt64_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1310,7 +1311,7 @@ public void Subtract_UInt64_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt64_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1324,7 +1325,7 @@ public void Subtract_UInt64_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt64_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1338,7 +1339,7 @@ public void Subtract_UInt64_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt64_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1352,7 +1353,7 @@ public void Subtract_UInt64_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt64_To_Double() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1366,7 +1367,7 @@ public void Subtract_UInt64_To_Double() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt64_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1380,7 +1381,7 @@ public void Subtract_UInt64_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_UInt64_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.UInt64) + 3; @@ -1394,7 +1395,7 @@ public void Subtract_UInt64_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Double_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1408,7 +1409,7 @@ public void Subtract_Double_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Double_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1422,7 +1423,7 @@ public void Subtract_Double_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Double_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1436,7 +1437,7 @@ public void Subtract_Double_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Double_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1450,7 +1451,7 @@ public void Subtract_Double_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Double_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1464,7 +1465,7 @@ public void Subtract_Double_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Double_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1478,7 +1479,7 @@ public void Subtract_Double_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Double_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1492,7 +1493,7 @@ public void Subtract_Double_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Double_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1506,7 +1507,7 @@ public void Subtract_Double_To_UInt64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Double_To_Single() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1520,7 +1521,7 @@ public void Subtract_Double_To_Single() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Double_To_Decimal() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Double) + 3; @@ -1534,7 +1535,7 @@ public void Subtract_Double_To_Decimal() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Single_To_Boolean() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1548,7 +1549,7 @@ public void Subtract_Single_To_Boolean() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Single_To_Byte() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1562,7 +1563,7 @@ public void Subtract_Single_To_Byte() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Single_To_Int16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1576,7 +1577,7 @@ public void Subtract_Single_To_Int16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Single_To_UInt16() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1590,7 +1591,7 @@ public void Subtract_Single_To_UInt16() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Single_To_Int32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1604,7 +1605,7 @@ public void Subtract_Single_To_Int32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Single_To_UInt32() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1618,7 +1619,7 @@ public void Subtract_Single_To_UInt32() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Single_To_Int64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; @@ -1632,7 +1633,7 @@ public void Subtract_Single_To_Int64() Console.WriteLine(val); } } - [Test] + [TestMethod] public void Subtract_Single_To_UInt64() { var left = np.zeros(new Shape(5, 5), NPTypeCode.Single) + 3; diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesAxisIncrementorTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesAxisIncrementorTests.cs index 27509044e..4bc704697 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesAxisIncrementorTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesAxisIncrementorTests.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged { + [TestClass] public class NDCoordinatesAxisIncrementorTests : TestClass { - [Test] + [TestMethod] public void Case1_Axis0() { var shape = new Shape(2, 3, 3); @@ -28,7 +29,7 @@ public void Case1_Axis0() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case1_Axis1() { var shape = new Shape(2, 3, 3); @@ -44,7 +45,7 @@ public void Case1_Axis1() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case1_Axis2() { var shape = new Shape(2, 3, 3); @@ -60,7 +61,7 @@ public void Case1_Axis2() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case2_Axis2() { var shape = new Shape(1, 2, 1, 1, 3); @@ -76,7 +77,7 @@ public void Case2_Axis2() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case2_Axis3() { var shape = new Shape(1, 2, 1, 1, 3); @@ -92,7 +93,7 @@ public void Case2_Axis3() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case2_Axis4() { var shape = new Shape(1, 2, 1, 1, 3); @@ -104,28 +105,28 @@ public void Case2_Axis4() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case3_Empty() { var shape = new Shape(0); new Action(() => new NDCoordinatesAxisIncrementor(ref shape, 0)).Should().Throw(); } - [Test] + [TestMethod] public void Case4() { var shape = new Shape(1); new Action(() => new NDCoordinatesAxisIncrementor(ref shape, 0)).Should().Throw(); } - [Test] + [TestMethod] public void Case5() { var shape = new Shape(2); new Action(() => new NDCoordinatesAxisIncrementor(ref shape, 0)).Should().Throw(); } - [Test] + [TestMethod] public void Case6_Scalar() { var shape = Shape.Scalar; diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesIncrementorTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesIncrementorTests.cs index 4dc78edc1..6417dca5c 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesIncrementorTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesIncrementorTests.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged { + [TestClass] public class NDCoordinatesIncrementorTests : TestClass { - [Test] + [TestMethod] public void Case1() { var shape = new Shape(3, 3, 1, 2); @@ -35,7 +36,7 @@ public void Case1() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case2() { var shape = new Shape(1, 1, 1, 3); @@ -47,7 +48,7 @@ public void Case2() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case3() { var shape = new Shape(3, 1, 1, 1); @@ -59,7 +60,7 @@ public void Case3() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case4() { var shape = new Shape(1, 1, 3, 1); @@ -71,7 +72,7 @@ public void Case4() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case5() { var shape = new Shape(2, 1, 3, 1); @@ -86,7 +87,7 @@ public void Case5() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case6() { var shape = new Shape(1); @@ -96,7 +97,7 @@ public void Case6() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case7() { var shape = new Shape(2); @@ -107,7 +108,7 @@ public void Case7() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case8() { var shape = new Shape(100); @@ -117,14 +118,14 @@ public void Case8() sh.Next().Should().ContainInOrder(2); } - [Test] + [TestMethod] public void Case9() { var shape = new Shape(0); new Action(() => new ValueCoordinatesIncrementor(ref shape)).Should().Throw(); } - [Test] + [TestMethod] public void Case1_Extended() { var shape = new Shape(3, 3, 1, 2); @@ -152,7 +153,7 @@ public void Case1_Extended() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case2_Extended() { var shape = new Shape(1, 1, 1, 3); @@ -164,7 +165,7 @@ public void Case2_Extended() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case3_Extended() { var shape = new Shape(3, 1, 1, 1); @@ -176,7 +177,7 @@ public void Case3_Extended() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case4_Extended() { var shape = new Shape(1, 1, 3, 1); @@ -188,7 +189,7 @@ public void Case4_Extended() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case5_Extended() { var shape = new Shape(2, 1, 3, 1); @@ -203,7 +204,7 @@ public void Case5_Extended() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case6_Extended() { var shape = new Shape(1); @@ -213,7 +214,7 @@ public void Case6_Extended() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case7_Extended() { var shape = new Shape(2); @@ -224,7 +225,7 @@ public void Case7_Extended() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case8_Extended() { var shape = new Shape(100); @@ -235,21 +236,21 @@ public void Case8_Extended() sh.Next().Should().ContainInOrder(2, 0, 1); } - [Test] + [TestMethod] public void Case9_Extended() { var shape = new Shape(0); new Action(() => new NDExtendedCoordinatesIncrementor(shape, 2)).Should().Throw(); } - [Test] + [TestMethod] public void Case10_Scalar() { var a = new UnmanagedStorage(17); AssertAreEqual(new int[] {17}, a.ToArray()); } - [Test] + [TestMethod] public void Case10_Scalar_2() { var shape = Shape.Scalar; @@ -258,7 +259,7 @@ public void Case10_Scalar_2() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case11_Scalar() { var sh = new ValueCoordinatesIncrementor(new long[0]); @@ -266,7 +267,7 @@ public void Case11_Scalar() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case10_Scalar_Extended() { var shape = Shape.Scalar; diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesLeftToAxisIncrementorTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesLeftToAxisIncrementorTests.cs index 28db6361c..03e33e97a 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesLeftToAxisIncrementorTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/NDCoordinatesLeftToAxisIncrementorTests.cs @@ -7,16 +7,17 @@ namespace NumSharp.UnitTest.Backends.Unmanaged { + [TestClass] public class NDCoordinatesLeftToAxisIncrementorTests : TestClass { - [Test] + [TestMethod] public void Case1_Axis0() { var shape = new Shape(2, 3, 3); new Action(() => new NDCoordinatesLeftToAxisIncrementor(ref shape, 0)).Should().Throw(); } - [Test] + [TestMethod] public void Case1_Axis1() { var shape = new Shape(2, 3, 3); @@ -32,14 +33,14 @@ public void Case1_Axis1() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case1_Axis2() { var shape = new Shape(2, 3, 3); new Action(() => new NDCoordinatesLeftToAxisIncrementor(ref shape, 2)).Should().Throw(); } - [Test] + [TestMethod] public void Case2_Axis2_OutOf_5() { var shape = new Shape(1, 2, 1, 1, 3); @@ -51,7 +52,7 @@ public void Case2_Axis2_OutOf_5() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case2_Axis3_OutOf_5() { var shape = new Shape(1, 2, 1, 1, 3); @@ -63,7 +64,7 @@ public void Case2_Axis3_OutOf_5() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case5_Axis3_OutOf_5() { var shape = new Shape(3, 2, 1, 1, 3); @@ -79,7 +80,7 @@ public void Case5_Axis3_OutOf_5() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case2_Axis3() { var shape = new Shape(1, 2, 1, 1, 3); @@ -91,35 +92,35 @@ public void Case2_Axis3() sh.Next().Should().BeNull(); } - [Test] + [TestMethod] public void Case2_Axis4() { var shape = new Shape(1, 2, 1, 1, 3); new Action(() => new NDCoordinatesLeftToAxisIncrementor(ref shape, 4)).Should().Throw(); } - [Test] + [TestMethod] public void Case3_Empty() { var shape = new Shape(0); new Action(() => new NDCoordinatesLeftToAxisIncrementor(ref shape, 0)).Should().Throw(); } - [Test] + [TestMethod] public void Case4() { var shape = new Shape(1); new Action(() => new NDCoordinatesLeftToAxisIncrementor(ref shape, 0)).Should().Throw(); } - [Test] + [TestMethod] public void Case5() { var shape = new Shape(2); new Action(() => new NDCoordinatesLeftToAxisIncrementor(ref shape, 0)).Should().Throw(); } - [Test] + [TestMethod] public void Case6_Scalar() { var shape = Shape.Scalar; diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/NDIteratorTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/NDIteratorTests.cs index f0010004e..b333f5bd3 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/NDIteratorTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/NDIteratorTests.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged { + [TestClass] public class NDIteratorTests { - [Test] + [TestMethod] public void Case1() { var sh = new NDIterator(np.arange(10), false); @@ -22,7 +23,7 @@ public void Case1() acc.Should().Be(Enumerable.Range(0, 10).Sum()); } - [Test] + [TestMethod] public void Case2() { Console.WriteLine(); @@ -38,7 +39,7 @@ public void Case2() acc.Should().Be(Enumerable.Range(0, 10).Sum() * 10); } - [Test] + [TestMethod] public void Case3_Sliced() { var sh = new NDIterator(np.arange(15).reshape((3, 5))["0:2,:"], false); @@ -51,7 +52,7 @@ public void Case3_Sliced() acc.Should().Be(Enumerable.Range(0, 10).Sum()); } - [Test] + [TestMethod] public void Case4_Sliced() { Console.WriteLine(); @@ -65,7 +66,7 @@ public void Case4_Sliced() acc.Should().Be(Enumerable.Range(0, 10).Sum() * 10); } - [Test] + [TestMethod] public void Case5_Autoreset() { var sh = new NDIterator(np.arange(10), true); @@ -79,7 +80,7 @@ public void Case5_Autoreset() acc.Should().Be(Enumerable.Range(0, 10).Sum()*2); } - [Test] + [TestMethod] public void Case6_Autoreset() { Console.WriteLine(); @@ -92,7 +93,7 @@ public void Case6_Autoreset() acc.Should().Be(Enumerable.Range(0, 10).Sum() * 10); } - [Test] + [TestMethod] public void Case7_Sliced_Autoreset() { var sh = new NDIterator(np.arange(15).reshape((3, 5))["0:2,:"], false); @@ -105,7 +106,7 @@ public void Case7_Sliced_Autoreset() acc.Should().Be(Enumerable.Range(0, 10).Sum()); } - [Test] + [TestMethod] public void Case8_Sliced_Autoreset() { Console.WriteLine(); @@ -120,7 +121,7 @@ public void Case8_Sliced_Autoreset() } - [Test] + [TestMethod] public void Case17_Reference() { Console.WriteLine(); @@ -133,7 +134,7 @@ public void Case17_Reference() acc.Should().Be(Enumerable.Range(0, 10).Sum()); } - [Test] + [TestMethod] public void Case18_Reference() { Console.WriteLine(); @@ -151,7 +152,7 @@ public void Case18_Reference() acc.Should().Be((int)nd.size); } - [Test] + [TestMethod] public void Case19_Reference_Autoreset() { Console.WriteLine(); @@ -167,7 +168,7 @@ public void Case19_Reference_Autoreset() acc.Should().Be((int)nd.size); } - [Test] + [TestMethod] public void Case20_Sliced_Autoreset_Reference() { var sh = new NDIterator(np.arange(15).reshape((3, 5))["0:2,:"], true); @@ -181,7 +182,7 @@ public void Case20_Sliced_Autoreset_Reference() acc.Should().Be(20); } - [Test] + [TestMethod] public void Case21_Sliced_Autoreset_Reference() { Console.WriteLine(); diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/NDOffsetIncrementorTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/NDOffsetIncrementorTests.cs index 4d2365b05..54a412b51 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/NDOffsetIncrementorTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/NDOffsetIncrementorTests.cs @@ -5,9 +5,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged { + [TestClass] public class ValueOffsetIncrementorTests { - [Test] + [TestMethod] public void Case1() { var shape = new Shape(3, 3, 1, 2); @@ -33,7 +34,7 @@ public void Case1() sh.Next().Should().Be(-1); } - [Test] + [TestMethod] public void Case2() { var shape = new Shape(1, 1, 1, 3); @@ -45,7 +46,7 @@ public void Case2() sh.Next().Should().Be(-1); } - [Test] + [TestMethod] public void Case3() { var shape = new Shape(3, 1, 1, 1); @@ -57,7 +58,7 @@ public void Case3() sh.Next().Should().Be(-1); } - [Test] + [TestMethod] public void Case4() { var shape = new Shape(1, 1, 3, 1); @@ -69,7 +70,7 @@ public void Case4() sh.Next().Should().Be(-1); } - [Test] + [TestMethod] public void Case5() { var shape = new Shape(2, 1, 3, 1); @@ -84,7 +85,7 @@ public void Case5() sh.Next().Should().Be(-1); } - [Test] + [TestMethod] public void Case6() { var shape = new Shape(1); @@ -93,7 +94,7 @@ public void Case6() sh.Next().Should().Be(-1); } - [Test] + [TestMethod] public void Case7() { var shape = new Shape(2); @@ -104,7 +105,7 @@ public void Case7() sh.Next().Should().Be(-1); } - [Test] + [TestMethod] public void Case8() { var shape = new Shape(100); @@ -114,7 +115,7 @@ public void Case8() sh.Next().Should().Be(shape.GetOffset(2)); } - [Test] + [TestMethod] public void Case9() { var shape = new Shape(0); diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/StackedMemoryPoolTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/StackedMemoryPoolTests.cs index 474f7776b..ca7f171cd 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/StackedMemoryPoolTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/StackedMemoryPoolTests.cs @@ -10,9 +10,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged { + [TestClass] public class StackedMemoryPoolTests { - [Test] + [TestMethod] public void Case1() { #if DEBUG diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/StringApiTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/StringApiTests.cs index 657a537fe..869783ac8 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/StringApiTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/StringApiTests.cs @@ -6,25 +6,26 @@ namespace NumSharp.UnitTest.Backends.Unmanaged { + [TestClass] public class StringApiTests { private static string hello = "hello"; - [Test] + [TestMethod] public void np_array_string() { var str = NDArray.FromString(hello); str.Should().BeOfType().And.BeShaped(5).And.BeOfValues('h', 'e', 'l', 'l', 'o'); } - [Test] + [TestMethod] public void FromString() { var str = NDArray.FromString(hello); str.Should().BeOfType().And.BeShaped(5).And.BeOfValues('h', 'e', 'l', 'l', 'o'); } - [Test] + [TestMethod] public void AsString() { var str = np.array('h', 'e', 'l', 'l', 'o'); @@ -32,7 +33,7 @@ public void AsString() NDArray.AsString(str).Should().Be(hello); } - [Test] + [TestMethod] public void GetString() { var str = np.repeat(np.array('h', 'e', 'l', 'l', 'o'), 5); @@ -45,7 +46,7 @@ public void GetString() }).Should().Throw(); } - [Test] + [TestMethod] public void GetString_Sliced() { var str = np.repeat(np.array('h', 'e', 'l', 'l', 'o'), 5).reshape(5, 5)[":, 0"]; @@ -55,7 +56,7 @@ public void GetString_Sliced() str.Shape.IsContiguous.Should().BeFalse("column slice has stride != 1"); str.GetString().Should().Be("hello"); } - [Test] + [TestMethod] public void SetString_Sliced() { var str = np.repeat(np.array('h', 'e', 'l', 'l', 'o'), 5).reshape(5, 5)[":, 0"]; @@ -67,7 +68,7 @@ public void SetString_Sliced() str.Should().BeOfValues("kekek".ToCharArray().Cast().ToArray()); } - [Test] + [TestMethod] public void SetString() { var str = np.repeat(np.array('h', 'e', 'l', 'l', 'o'), 5); diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/StringArrayApiTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/StringArrayApiTests.cs index 9d8e3df95..18c385059 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/StringArrayApiTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/StringArrayApiTests.cs @@ -6,11 +6,12 @@ namespace NumSharp.UnitTest.Backends.Unmanaged { + [TestClass] public class StringArrayApiTests { private static string[] strArray = new string[] { "Hello,", " SciSharp Team!"}; - [Test] + [TestMethod] public void StringArrayConverting() { var nd = np.array(strArray); diff --git a/test/NumSharp.UnitTest/Backends/Unmanaged/UnmanagedStorageTests.cs b/test/NumSharp.UnitTest/Backends/Unmanaged/UnmanagedStorageTests.cs index 1fac5b7f0..029abf8b3 100644 --- a/test/NumSharp.UnitTest/Backends/Unmanaged/UnmanagedStorageTests.cs +++ b/test/NumSharp.UnitTest/Backends/Unmanaged/UnmanagedStorageTests.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.Backends.Unmanaged { + [TestClass] public class UnmanagedStorageTests { - [Test] + [TestMethod] public unsafe void CopyTo() { var src = np.arange(10).astype(NPTypeCode.Int32).Storage; @@ -19,7 +20,7 @@ public unsafe void CopyTo() dst[i].Should().Be(i); } - [Test] + [TestMethod] public unsafe void CopyTo_Sliced() { var src = np.arange(20).astype(NPTypeCode.Int32)["0:10"].Storage; @@ -30,7 +31,7 @@ public unsafe void CopyTo_Sliced() dst[i].Should().Be(i); } - [Test] + [TestMethod] public unsafe void CopyTo_Corruption() { var np1 = np.arange(1,7).reshape(3, 2).astype(NPTypeCode.Double); @@ -44,7 +45,7 @@ public unsafe void CopyTo_Corruption() dst[i].Should().Be(i); } - [Test] + [TestMethod] public unsafe void CopyTo_Block() { var src = np.arange(10).astype(NPTypeCode.Int32).Storage; @@ -55,7 +56,7 @@ public unsafe void CopyTo_Block() dst[i].Should().Be(i); } - [Test] + [TestMethod] public unsafe void CopyTo_Block_Sliced() { var src = np.arange(20).astype(NPTypeCode.Int32)["0:10"].Storage; @@ -66,7 +67,7 @@ public unsafe void CopyTo_Block_Sliced() dst[i].Should().Be(i); } - [Test] + [TestMethod] public unsafe void CopyTo_Array() { var src = np.arange(10).astype(NPTypeCode.Int32).Storage; @@ -77,7 +78,7 @@ public unsafe void CopyTo_Array() dst[i].Should().Be(i); } - [Test] + [TestMethod] public unsafe void CopyTo_Sliced_Array() { var src = np.arange(20).astype(NPTypeCode.Int32)["0:10"].Storage; diff --git a/test/NumSharp.UnitTest/Casting/NDArray.ImplicitCasts.Test.cs b/test/NumSharp.UnitTest/Casting/NDArray.ImplicitCasts.Test.cs index c33a3bc25..bd07d569f 100644 --- a/test/NumSharp.UnitTest/Casting/NDArray.ImplicitCasts.Test.cs +++ b/test/NumSharp.UnitTest/Casting/NDArray.ImplicitCasts.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest { + [TestClass] public class ImplicitCastTester { - [Test] + [TestMethod] public void ConvertFromJagged() { double[][] a = new double[3][]; @@ -29,7 +30,7 @@ public void ConvertFromJagged() Assert.IsTrue(c[idx, jdx] == a[idx][jdx]); } - [Test] + [TestMethod] public void FromDotNetVector() { NDArray nd = new double[] {1, 2, 3, 4}; @@ -40,7 +41,7 @@ public void FromDotNetVector() Assert.IsTrue(((double)nd[3]) == 4); } - [Test] + [TestMethod] public void FromDotNetMatrix() { NDArray nd = new double[,] {{1, 2, 3}, {4, 5, 6}}; @@ -52,7 +53,7 @@ public void FromDotNetMatrix() Assert.IsTrue((double)nd[idx, jdx] == doubleMatr[idx, jdx]); } - [Test] + [TestMethod] public void FromAndToDotNetMatrix() { NDArray nd = new double[,] {{1, 2, 3}, {4, 5, 6}}; @@ -73,7 +74,7 @@ public void FromAndToDotNetMatrix() } } - [Test] + [TestMethod] public void StringCast2() { NDArray nd = "[1,2,3;4,5,6]"; @@ -87,7 +88,7 @@ public void StringCast2() } } - [Test] + [TestMethod] public void StringCast3() { NDArray nd = "[3,1,1,2]"; diff --git a/test/NumSharp.UnitTest/Casting/NDArray.ToArray.Test.cs b/test/NumSharp.UnitTest/Casting/NDArray.ToArray.Test.cs index 1659ac1c9..3ceef86a1 100644 --- a/test/NumSharp.UnitTest/Casting/NDArray.ToArray.Test.cs +++ b/test/NumSharp.UnitTest/Casting/NDArray.ToArray.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest { + [TestClass] public class CastingTester { - [Test] + [TestMethod] public void ToDotNetArray() { //TODO! this test is not a test because it doesn't even have assertions @@ -20,7 +21,7 @@ public void ToDotNetArray() var twoDArrayDotNet = (double[,])twoDArray.ToMuliDimArray(); } - [Test] + [TestMethod] public void ToByteArray() { var nd = np.array(new int[][] {new int[] {3, 1}, new int[] {2, 1}}); diff --git a/test/NumSharp.UnitTest/Casting/ScalarConversionTests.cs b/test/NumSharp.UnitTest/Casting/ScalarConversionTests.cs index 3421987a6..833758d38 100644 --- a/test/NumSharp.UnitTest/Casting/ScalarConversionTests.cs +++ b/test/NumSharp.UnitTest/Casting/ScalarConversionTests.cs @@ -8,6 +8,7 @@ namespace NumSharp.UnitTest /// These verify that implicit/explicit casts perform proper type conversion /// rather than raw byte reinterpretation. /// + [TestClass] public class ScalarConversionTests { /// @@ -17,7 +18,7 @@ public class ScalarConversionTests /// Fixed: (double)(NDArray)sum = 45.0 (numeric conversion) /// Was: returns ~6.95e-310 (int64 bytes read as double) /// - [Test] + [TestMethod] public void DoubleCast_Int64Scalar_ConvertsCorrectly() { // np.sum returns a scalar NDArray (ndim=0) @@ -39,7 +40,7 @@ public void DoubleCast_Int64Scalar_ConvertsCorrectly() /// /// BUG 72 FIX: (double) cast on int32 scalar NDArray should convert correctly. /// - [Test] + [TestMethod] public void DoubleCast_Int32Scalar_ConvertsCorrectly() { var scalar = NDArray.Scalar(42); @@ -59,7 +60,7 @@ public void DoubleCast_Int32Scalar_ConvertsCorrectly() /// The main fix (Bug 72) is that cross-dtype conversion now works correctly /// instead of reinterpreting raw bytes as the wrong type. /// - [Test] + [TestMethod] public void CrossDtypeConversions_WorkCorrectly() { // int64 -> double diff --git a/test/NumSharp.UnitTest/Casting/np.ToString.BattleTests.cs b/test/NumSharp.UnitTest/Casting/np.ToString.BattleTests.cs index 6c6c5fa1e..f142dbec2 100644 --- a/test/NumSharp.UnitTest/Casting/np.ToString.BattleTests.cs +++ b/test/NumSharp.UnitTest/Casting/np.ToString.BattleTests.cs @@ -14,6 +14,7 @@ namespace NumSharp.UnitTest; /// - Edge cases (empty, scalar, single element) /// - All supported dtypes /// +[TestClass] public class np_ToString_BattleTests { private static string Normalize(string s) => @@ -28,28 +29,28 @@ private static bool ValuesMatch(string expected, string actual) #region Basic Arrays - [Test] + [TestMethod] public void ToString_1D_Simple() { var arr = np.arange(5); ValuesMatch("[0, 1, 2, 3, 4]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_2D_Simple() { var arr = np.arange(6).reshape(2, 3); ValuesMatch("[[0, 1, 2], [3, 4, 5]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_3D_Simple() { var arr = np.arange(8).reshape(2, 2, 2); ValuesMatch("[[[0, 1], [2, 3]], [[4, 5], [6, 7]]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_4D_Simple() { var arr = np.arange(16).reshape(2, 2, 2, 2); @@ -61,84 +62,84 @@ public void ToString_4D_Simple() #region Sliced Arrays - [Test] + [TestMethod] public void ToString_1D_Reversed() { var arr = np.arange(5)["::-1"]; ValuesMatch("[4, 3, 2, 1, 0]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_1D_Stepped() { var arr = np.arange(10)["::2"]; ValuesMatch("[0, 2, 4, 6, 8]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_1D_NegativeStep() { var arr = np.arange(10)["8:2:-2"]; ValuesMatch("[8, 6, 4]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_2D_RowSlice() { var arr = np.arange(12).reshape(3, 4)["1:3"]; ValuesMatch("[[4, 5, 6, 7], [8, 9, 10, 11]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_2D_ColSlice() { var arr = np.arange(12).reshape(3, 4)[":, 1:3"]; ValuesMatch("[[1, 2], [5, 6], [9, 10]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_2D_ReversedRows() { var arr = np.arange(12).reshape(3, 4)["::-1"]; ValuesMatch("[[8, 9, 10, 11], [4, 5, 6, 7], [0, 1, 2, 3]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_2D_ReversedCols() { var arr = np.arange(12).reshape(3, 4)[":, ::-1"]; ValuesMatch("[[3, 2, 1, 0], [7, 6, 5, 4], [11, 10, 9, 8]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_2D_BothReversed() { var arr = np.arange(12).reshape(3, 4)["::-1, ::-1"]; ValuesMatch("[[11, 10, 9, 8], [7, 6, 5, 4], [3, 2, 1, 0]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_2D_SteppedRows() { var arr = np.arange(12).reshape(4, 3)["::2"]; ValuesMatch("[[0, 1, 2], [6, 7, 8]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_2D_SkipBoth() { var arr = np.arange(12).reshape(3, 4)["::2, ::2"]; ValuesMatch("[[0, 2], [8, 10]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_2D_ReverseSkip() { var arr = np.arange(12).reshape(3, 4)["::-2, ::-2"]; ValuesMatch("[[11, 9], [3, 1]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_3D_MiddleSlice() { var arr = np.arange(24).reshape(2, 3, 4)["1:2, 1:2"]; @@ -149,28 +150,28 @@ public void ToString_3D_MiddleSlice() #region Broadcast Arrays - [Test] + [TestMethod] public void ToString_Broadcast_1DTo2D() { var arr = np.broadcast_to(np.arange(3), new Shape(2, 3)); ValuesMatch("[[0, 1, 2], [0, 1, 2]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Broadcast_ColTo2D() { var arr = np.broadcast_to(np.arange(3).reshape(3, 1), new Shape(3, 4)); ValuesMatch("[[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Broadcast_ScalarTo2D() { var arr = np.broadcast_to(np.array(5), new Shape(2, 3)); ValuesMatch("[[5, 5, 5], [5, 5, 5]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Broadcast_ScalarTo3D() { var arr = np.broadcast_to(np.array(7), new Shape(2, 2, 2)); @@ -181,7 +182,7 @@ public void ToString_Broadcast_ScalarTo3D() #region Broadcast + Slice Combinations (Originally OpenBugs) - [Test] + [TestMethod] public void ToString_BroadcastSlice_Reversed() { // This was Bug_ToString_ReversedSliceBroadcast @@ -189,7 +190,7 @@ public void ToString_BroadcastSlice_Reversed() ValuesMatch("[[2, 1, 0], [2, 1, 0]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_BroadcastSlice_Stepped() { // This was Bug_ToString_StepSliceBroadcast @@ -197,7 +198,7 @@ public void ToString_BroadcastSlice_Stepped() ValuesMatch("[[0, 2, 4], [0, 2, 4]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_BroadcastSlice_ColSlice() { // This was Bug_ToString_SlicedColumnBroadcast @@ -205,7 +206,7 @@ public void ToString_BroadcastSlice_ColSlice() ValuesMatch("[[1, 1, 1], [5, 5, 5], [9, 9, 9]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_BroadcastSlice_DoubleSlice() { // This was Bug_ToString_DoubleSlicedBroadcast @@ -216,7 +217,7 @@ public void ToString_BroadcastSlice_DoubleSlice() ValuesMatch("[[0, 0, 0, 0], [8, 8, 8, 8]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_BroadcastSlice_SliceOfBroadcast() { var b = np.broadcast_to(np.arange(3), new Shape(4, 3)); @@ -224,7 +225,7 @@ public void ToString_BroadcastSlice_SliceOfBroadcast() ValuesMatch("[[0, 1, 2], [0, 1, 2]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_BroadcastSlice_ReverseSliceOfBroadcast() { var b = np.broadcast_to(np.arange(3), new Shape(4, 3)); @@ -236,14 +237,14 @@ public void ToString_BroadcastSlice_ReverseSliceOfBroadcast() #region Transpose - [Test] + [TestMethod] public void ToString_Transpose_2D() { var arr = np.arange(6).reshape(2, 3).T; ValuesMatch("[[0, 3], [1, 4], [2, 5]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Transpose_3D() { var arr = np.arange(24).reshape(2, 3, 4).transpose(new int[] { 2, 0, 1 }); @@ -255,42 +256,42 @@ public void ToString_Transpose_3D() #region Edge Cases - [Test] + [TestMethod] public void ToString_Empty_1D() { var arr = np.array(new long[0]); ValuesMatch("[]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Empty_2D() { var arr = np.zeros(new Shape(0, 3)); ValuesMatch("[]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Scalar() { var arr = np.array(42); ValuesMatch("42", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Single_1D() { var arr = np.array(new long[] { 7 }); ValuesMatch("[7]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Single_2D() { var arr = np.array(new long[] { 7 }).reshape(1, 1); ValuesMatch("[[7]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_3D_AllReversed() { var arr = np.arange(8).reshape(2, 2, 2)["::-1, ::-1, ::-1"]; @@ -301,7 +302,7 @@ public void ToString_3D_AllReversed() #region Chained Slices - [Test] + [TestMethod] public void ToString_ChainedSlices() { var e = np.arange(100).reshape(10, 10); @@ -315,7 +316,7 @@ public void ToString_ChainedSlices() #region Negative Indices - [Test] + [TestMethod] public void ToString_NegativeIndices() { var arr = np.arange(30).reshape(3, 10)["-3:-1, -4:"]; @@ -326,49 +327,49 @@ public void ToString_NegativeIndices() #region Dtypes - [Test] + [TestMethod] public void ToString_Dtype_Int16() { var arr = np.array(new short[] { 1, 2, 3 }); ValuesMatch("[1, 2, 3]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Dtype_Int32() { var arr = np.array(new int[] { 1, 2, 3 }); ValuesMatch("[1, 2, 3]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Dtype_Int64() { var arr = np.array(new long[] { 1, 2, 3 }); ValuesMatch("[1, 2, 3]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Dtype_Float32() { var arr = np.array(new float[] { 1f, 2f, 3f }); ValuesMatch("[1, 2, 3]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Dtype_Float64() { var arr = np.array(new double[] { 1.0, 2.0, 3.0 }); ValuesMatch("[1, 2, 3]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Dtype_Bool() { var arr = np.array(new bool[] { true, false, true }); ValuesMatch("[True, False, True]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Dtype_Byte() { var arr = np.array(new byte[] { 1, 2, 3 }); @@ -379,7 +380,7 @@ public void ToString_Dtype_Byte() #region Extreme Edge Cases - [Test] + [TestMethod] public void ToString_5D_Array() { var arr = np.arange(16).reshape(1, 2, 2, 2, 2); @@ -387,7 +388,7 @@ public void ToString_5D_Array() arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Long_1D() { var arr = np.arange(20); @@ -395,7 +396,7 @@ public void ToString_Long_1D() arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_BroadcastThenSlice() { var a = np.arange(2).reshape(2, 1); @@ -404,21 +405,21 @@ public void ToString_BroadcastThenSlice() ValuesMatch("[[0, 0, 0]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_ReduceToSingleElement3D() { var arr = np.arange(24).reshape(2, 3, 4)["0:1, 1:2, 1:2"]; ValuesMatch("[[[5]]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_AlternatingReverse() { var arr = np.arange(10)["::-2"]; ValuesMatch("[9, 7, 5, 3, 1]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_BroadcastSlicedTransposed() { var b = np.arange(6).reshape(2, 3).T; // Shape (3, 2) @@ -427,7 +428,7 @@ public void ToString_BroadcastSlicedTransposed() ValuesMatch("[[1, 4], [1, 4], [1, 4]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_ScalarBroadcast3D() { var s = np.array(42); @@ -435,21 +436,21 @@ public void ToString_ScalarBroadcast3D() ValuesMatch("[[[42, 42], [42, 42]], [[42, 42], [42, 42]]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_SingleRowSlice() { var arr = np.arange(12).reshape(3, 4)["1:2"]; ValuesMatch("[[4, 5, 6, 7]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_SingleColSlice() { var arr = np.arange(12).reshape(3, 4)[":, 1:2"]; ValuesMatch("[[1], [5], [9]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_TransposeSliceBroadcast() { var c = np.arange(12).reshape(3, 4).T; // (4, 3) @@ -458,14 +459,14 @@ public void ToString_TransposeSliceBroadcast() ValuesMatch("[[[1, 9], [2, 10]], [[1, 9], [2, 10]], [[1, 9], [2, 10]]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_TallNarrow() { var arr = np.arange(10).reshape(10, 1); ValuesMatch("[[0], [1], [2], [3], [4], [5], [6], [7], [8], [9]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_ShortWide() { var arr = np.arange(10).reshape(1, 10); @@ -476,70 +477,70 @@ public void ToString_ShortWide() #region Special Values - [Test] + [TestMethod] public void ToString_NaN() { var arr = np.array(new double[] { double.NaN }); ValuesMatch("[NaN]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_NegativeInts() { var arr = np.arange(-5, 1); ValuesMatch("[-5, -4, -3, -2, -1, 0]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Negative2D() { var arr = np.arange(-3, 3).reshape(2, 3); ValuesMatch("[[-3, -2, -1], [0, 1, 2]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_LargeInts() { var arr = np.array(new long[] { 1000000, 2000000, 3000000 }); ValuesMatch("[1000000, 2000000, 3000000]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Decimals() { var arr = np.array(new double[] { 0.5, 1.5, 2.5 }); Normalize(arr.ToString(false)).Should().Contain("0.5").And.Contain("1.5").And.Contain("2.5"); } - [Test] + [TestMethod] public void ToString_AllTrue() { var arr = np.array(new bool[] { true, true, true }); ValuesMatch("[True, True, True]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_AllFalse() { var arr = np.array(new bool[] { false, false, false }); ValuesMatch("[False, False, False]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Bool2D() { var arr = np.array(new bool[] { true, false, false, true }).reshape(2, 2); ValuesMatch("[[True, False], [False, True]]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Int32Extremes() { var arr = np.array(new int[] { int.MinValue, int.MaxValue }); ValuesMatch("[-2147483648, 2147483647]", arr.ToString(false)).Should().BeTrue(); } - [Test] + [TestMethod] public void ToString_Int64Extremes() { var arr = np.array(new long[] { long.MinValue, long.MaxValue }); diff --git a/test/NumSharp.UnitTest/Creation/NdArray.Array.Test.cs b/test/NumSharp.UnitTest/Creation/NdArray.Array.Test.cs index eeb3dbaba..b64e81253 100644 --- a/test/NumSharp.UnitTest/Creation/NdArray.Array.Test.cs +++ b/test/NumSharp.UnitTest/Creation/NdArray.Array.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class NdArrayArrayTest { - [Test] + [TestMethod] public void Array1Dim() { var list = new int[] {1, 2, 3}; @@ -19,7 +20,7 @@ public void Array1Dim() Assert.IsTrue(Enumerable.SequenceEqual(n.Data(), new int[] {1, 2, 3})); } - [Test] + [TestMethod] public void Array2Dim() { var list = new int[][] {new int[] {1, 2}, new int[] {3, 4}}; @@ -36,7 +37,7 @@ public void Array2Dim() } - [Test] + [TestMethod] public void Array2Dim_Accessing() { var list = new int[][] {new int[] {1, 2}, new int[] {3, 4}}; @@ -52,7 +53,7 @@ public void Array2Dim_Accessing() } } - [Test] + [TestMethod] public void Array3Dim() { var list = new int[,,] {{{1, 2}, {3, 4}}, {{2, 2}, {3, 3}}, {{3, 2}, {3, 1}},}; @@ -79,7 +80,7 @@ public void Array3Dim() return imageArray; }*/ - [Test] + [TestMethod] public void ArrayImage() { /*var relativePath = string.Empty; @@ -104,7 +105,7 @@ public void ArrayImage() }*/ } - [Test] + [TestMethod] public void flatten2d() { var a = np.array(new int[,] {{1, 2}, {3, 4}}); @@ -116,7 +117,7 @@ public void flatten2d() Assert.IsTrue(Enumerable.SequenceEqual(a.Data(), new int[] {1, 2, 3, 4})); } - [Test] + [TestMethod] public void StringCheck() { var nd = np.arange(9d).reshape(3, 3).MakeGeneric(); @@ -134,7 +135,7 @@ public void StringCheck() Assert.IsTrue(stringOfNp.Contains("[[")); } - [Test, Skip("No assertions inside")] + [TestMethod, Ignore("No assertions inside")] public void CheckVectorString() { var np = NumSharp.np.arange(9).MakeGeneric(); @@ -149,7 +150,7 @@ public void CheckVectorString() var stringOfNp = np.ToString(); } - [Test] + [TestMethod] public void ToDotNetArray1D() { var np1 = np.arange(9d).MakeGeneric(); @@ -159,7 +160,7 @@ public void ToDotNetArray1D() Assert.IsTrue(Enumerable.SequenceEqual(np1_, np1.Data())); } - [Test] + [TestMethod] public void ToDotNetArray2D() { var np1 = np.arange(9d).reshape(3, 3).MakeGeneric(); @@ -174,7 +175,7 @@ public void ToDotNetArray2D() } } - [Test] + [TestMethod] public void ToDotNetArray3D() { var np1 = np.arange(27d).astype(np.float64).reshape(3, 3, 3); diff --git a/test/NumSharp.UnitTest/Creation/NdArray.Eye.Test.cs b/test/NumSharp.UnitTest/Creation/NdArray.Eye.Test.cs index d87a80dbb..7e820e665 100644 --- a/test/NumSharp.UnitTest/Creation/NdArray.Eye.Test.cs +++ b/test/NumSharp.UnitTest/Creation/NdArray.Eye.Test.cs @@ -10,9 +10,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class NdArrayEyeTest { - [Test] + [TestMethod] public void Case1() { np.eye(3, k: 1).flat.Cast().Count(i => i == 1d).Should().Be(2); @@ -21,7 +22,7 @@ public void Case1() .Be(new NDArray(new double[][] {new double[] {0.0d, 1.0d, 0.0d}, new double[] {0.0d, 0d, 1.0d}, new double[] {0d, 0d, 0d}}, Shape.Matrix(3, 3))); } - [Test] + [TestMethod] public void Case2() { np.eye(3).flat.Cast().Count(i => i == 1).Should().Be(3); @@ -29,12 +30,12 @@ public void Case2() .Be(new NDArray(new double[][] { new double[] { 1.0d, 0.0d, 0.0d }, new double[] { 0.0d, 1d, 0d }, new double[] { 0d, 0d, 1d } }, Shape.Matrix(3, 3))); } - [Test] + [TestMethod] public void Case3() { np.eye(10, k: -6).flat.Cast().Count(i=>i==1).Should().Be(4); } - [Test] + [TestMethod] public void Case4() { np.eye(10, k: -6).flat.Cast().Count(i=>i==1).Should().Be(4); diff --git a/test/NumSharp.UnitTest/Creation/NdArray.LinSpace.Test.cs b/test/NumSharp.UnitTest/Creation/NdArray.LinSpace.Test.cs index a52eba66a..29e58572c 100644 --- a/test/NumSharp.UnitTest/Creation/NdArray.LinSpace.Test.cs +++ b/test/NumSharp.UnitTest/Creation/NdArray.LinSpace.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class np_linspace_tests { - [Test] + [TestMethod] public void FromNumpyDocs() { NDArray nd; diff --git a/test/NumSharp.UnitTest/Creation/NdArray.MakeGeneric.Test.cs b/test/NumSharp.UnitTest/Creation/NdArray.MakeGeneric.Test.cs index 6309b2aee..eb3151914 100644 --- a/test/NumSharp.UnitTest/Creation/NdArray.MakeGeneric.Test.cs +++ b/test/NumSharp.UnitTest/Creation/NdArray.MakeGeneric.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class NdArrayMakeGenericTester { - [Test] + [TestMethod] public void Array1DimGeneric() { var list = new double[] {1.1, 2.2, 3.3}; diff --git a/test/NumSharp.UnitTest/Creation/NdArray.Mgrid.Test.cs b/test/NumSharp.UnitTest/Creation/NdArray.Mgrid.Test.cs index 0c7c206e1..d9c34c634 100644 --- a/test/NumSharp.UnitTest/Creation/NdArray.Mgrid.Test.cs +++ b/test/NumSharp.UnitTest/Creation/NdArray.Mgrid.Test.cs @@ -9,6 +9,7 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class NdArrayMGridTest { // These C# NDArray declarations were generated using ndarray-generatory.py, @@ -70,7 +71,7 @@ public class NdArrayMGridTest 0, 1, 2, 3, 4 }, new Shape(new int[] { 5, 5 })); - [Test] + [TestMethod] public void BaseTest() { var V53 = np.arange(0, 5, 1).mgrid(np.arange(0, 3, 1)); diff --git a/test/NumSharp.UnitTest/Creation/NdArray.Roll.Test.cs b/test/NumSharp.UnitTest/Creation/NdArray.Roll.Test.cs index d8b2c96e8..e6b92f1d8 100644 --- a/test/NumSharp.UnitTest/Creation/NdArray.Roll.Test.cs +++ b/test/NumSharp.UnitTest/Creation/NdArray.Roll.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class NdArrayRollTest { - [Test] + [TestMethod] public void Base1DTest() { NDArray nd1 = new double[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; @@ -41,7 +42,7 @@ public void Base1DTest() Assert.IsTrue(Enumerable.SequenceEqual(nd2_, expNd2)); } - [Test] + [TestMethod] public void Base2DTest() { var nd1 = np.arange(10).reshape(2, 5); @@ -55,7 +56,7 @@ public void Base2DTest() Assert.IsTrue(Enumerable.SequenceEqual(nd1.shape, nd3.shape)); } - [Test] + [TestMethod] public void RollWithAxis() { var x = np.arange(10); diff --git a/test/NumSharp.UnitTest/Creation/NdArray.Scalar.Test.cs b/test/NumSharp.UnitTest/Creation/NdArray.Scalar.Test.cs index d38513938..8f1bdff12 100644 --- a/test/NumSharp.UnitTest/Creation/NdArray.Scalar.Test.cs +++ b/test/NumSharp.UnitTest/Creation/NdArray.Scalar.Test.cs @@ -5,23 +5,24 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class NdArrayScalarTests { - [Test] - //TODO! [Arguments(typeof(Complex), 3)] - [Arguments(typeof(Boolean), (Boolean)false)] - [Arguments(typeof(Byte), (Byte)1)] - [Arguments(typeof(Int16), (Int16)1)] - [Arguments(typeof(UInt16), (UInt16)1)] - [Arguments(typeof(Int32), (Int32)1)] - [Arguments(typeof(UInt32), (UInt32)1)] - [Arguments(typeof(Int64), (Int64)1)] - [Arguments(typeof(UInt64), (UInt64)1)] - [Arguments(typeof(Char), (Char)'c')] - [Arguments(typeof(Double), (Double)1d)] - [Arguments(typeof(Single), (Single)2f)] - [Arguments(typeof(Decimal), 3)] - //TODO! [Arguments(typeof(String), "3")] + [TestMethod] + //TODO! [DataRow(typeof(Complex), 3)] + [DataRow(typeof(Boolean), (Boolean)false)] + [DataRow(typeof(Byte), (Byte)1)] + [DataRow(typeof(Int16), (Int16)1)] + [DataRow(typeof(UInt16), (UInt16)1)] + [DataRow(typeof(Int32), (Int32)1)] + [DataRow(typeof(UInt32), (UInt32)1)] + [DataRow(typeof(Int64), (Int64)1)] + [DataRow(typeof(UInt64), (UInt64)1)] + [DataRow(typeof(Char), (Char)'c')] + [DataRow(typeof(Double), (Double)1d)] + [DataRow(typeof(Single), (Single)2f)] + [DataRow(typeof(Decimal), 3)] + //TODO! [DataRow(typeof(String), "3")] public void CreateScalar(Type type, object val) { if (type == typeof(Complex)) diff --git a/test/NumSharp.UnitTest/Creation/NpBroadcastFromNumPyTests.cs b/test/NumSharp.UnitTest/Creation/NpBroadcastFromNumPyTests.cs index 4650f2825..3dab7c8fd 100644 --- a/test/NumSharp.UnitTest/Creation/NpBroadcastFromNumPyTests.cs +++ b/test/NumSharp.UnitTest/Creation/NpBroadcastFromNumPyTests.cs @@ -14,6 +14,7 @@ namespace NumSharp.UnitTest.Creation /// - numpy/_core/tests/test_numeric.py (np.broadcast class) /// Verifies NumSharp's broadcasting against NumPy 2.x behavior. /// + [TestClass] public class NpBroadcastFromNumPyTests : TestClass { #region Helpers @@ -60,7 +61,7 @@ private static void AssertShapeEqual(NDArray actual, params int[] expected) /// >>> np.array_equal(a, x) and np.array_equal(b, x) /// True /// - [Test] + [TestMethod] public void BroadcastArrays_Same() { var x = np.array(new long[,] { { 1, 2, 3 } }); // shape (1,3) @@ -86,7 +87,7 @@ public void BroadcastArrays_Same() /// [2, 2, 2], /// [3, 3, 3]]) /// - [Test] + [TestMethod] public void BroadcastArrays_OneOff() { var x = np.array(new long[,] { { 1, 2, 3 } }); // shape (1,3) @@ -113,7 +114,7 @@ public void BroadcastArrays_OneOff() /// Shapes tested: (1,), (3,), (1,3), (3,1), (3,3) /// (Omitting zero-size shapes since they require special handling) /// - [Test] + [TestMethod] public void BroadcastArrays_SameInputShapes() { var shapes = new[] @@ -148,7 +149,7 @@ public void BroadcastArrays_SameInputShapes() /// /// Tests both (a,b) and (b,a) orderings for symmetry. /// - [Test] + [TestMethod] public void BroadcastArrays_CompatibleByOnes() { // (input1_shape, input2_shape, expected_output_shape) @@ -192,7 +193,7 @@ public void BroadcastArrays_CompatibleByOnes() /// /// Tests both (a,b) and (b,a) orderings for symmetry. /// - [Test] + [TestMethod] public void BroadcastArrays_CompatibleByPrependingOnes() { // (input1_shape, input2_shape, expected_output_shape) @@ -238,7 +239,7 @@ public void BroadcastArrays_CompatibleByPrependingOnes() /// >>> np.broadcast_arrays(np.ones(3), np.ones(4)) /// ValueError: shape mismatch /// - [Test] + [TestMethod] public void BroadcastArrays_IncompatibleShapesThrow() { var incompatible_pairs = new[] @@ -269,7 +270,7 @@ public void BroadcastArrays_IncompatibleShapesThrow() /// >>> np.broadcast_arrays(np.ones(3), np.ones(3), np.ones(4)) /// ValueError: shape mismatch /// - [Test] + [TestMethod] public void BroadcastArrays_ThreeWayIncompatibleThrows() { var x1 = np.ones(new Shape(3)); @@ -306,7 +307,7 @@ public void BroadcastArrays_ThreeWayIncompatibleThrows() /// np.broadcast_to(np.arange(3), (1,3)) -> shape (1,3) /// np.broadcast_to(np.arange(3), (2,3)) -> shape (2,3) /// - [Test] + [TestMethod] public void BroadcastTo_Succeeds() { // Scalar to various shapes @@ -342,7 +343,7 @@ public void BroadcastTo_Succeeds() /// >>> np.broadcast_to(np.ones((2,1)), (2,0)).shape /// (2, 0) /// - [Test] + [TestMethod] public void BroadcastTo_ZeroSizeShapes() { AssertShapeEqual(np.broadcast_to(np.ones(new Shape(1)), new Shape(0)), 0); @@ -360,7 +361,7 @@ public void BroadcastTo_ZeroSizeShapes() /// >>> np.broadcast_to(np.ones(3), (4,)) /// ValueError: ... /// - [Test] + [TestMethod] public void BroadcastTo_Raises() { // (3,) -> (2,) incompatible: dimension 3 vs 2, neither is 1 @@ -382,7 +383,7 @@ public void BroadcastTo_Raises() /// >>> np.broadcast_to(np.ones((1,2)), (2,1)) # NumPy: ValueError /// >>> np.broadcast_to(np.ones((1,1)), (1,)) # NumPy: ValueError (ndim mismatch) /// - [Test] + [TestMethod] public void BroadcastTo_UnilateralSemantics_RejectsInvalidCases() { // (3,) -> (1,): source dim 3 != target dim 1 and != 1 → must throw @@ -407,7 +408,7 @@ public void BroadcastTo_UnilateralSemantics_RejectsInvalidCases() /// >>> y.base is x # (shares memory) /// True /// - [Test] + [TestMethod] public void BroadcastTo_IsView() { var x = np.array(new long[] { 1, 2, 3 }); @@ -433,7 +434,7 @@ public void BroadcastTo_IsView() /// array([[0, 1, 2], /// [0, 1, 2]]) /// - [Test] + [TestMethod] public void BroadcastTo_ValuesCorrect() { var x = np.arange(3); // [0, 1, 2] @@ -451,7 +452,7 @@ public void BroadcastTo_ValuesCorrect() /// array([[5, 5, 5], /// [5, 5, 5]]) /// - [Test] + [TestMethod] public void BroadcastTo_ScalarValues() { var scalar = NDArray.Scalar(5); @@ -471,7 +472,7 @@ public void BroadcastTo_ScalarValues() /// [2, 2, 2], /// [3, 3, 3]]) /// - [Test] + [TestMethod] public void BroadcastTo_ColumnToMatrix() { var x = np.array(new long[,] { { 1 }, { 2 }, { 3 } }); // shape (3,1) @@ -500,7 +501,7 @@ public void BroadcastTo_ColumnToMatrix() /// /// From test_stride_tricks.py test_same_as_ufunc. /// - [Test] + [TestMethod] public void BroadcastArrays_SameAsUfunc() { var cases = new[] @@ -555,7 +556,7 @@ public void BroadcastArrays_SameAsUfunc() /// >>> b.size /// 6 /// - [Test] + [TestMethod] public void Broadcast_Properties() { var arr1 = np.arange(6).reshape(2, 3); @@ -578,7 +579,7 @@ public void Broadcast_Properties() /// >>> b.size /// 6 /// - [Test] + [TestMethod] public void Broadcast_BroadcastedShape() { var arr1 = np.ones(new Shape(2, 1)); @@ -597,7 +598,7 @@ public void Broadcast_BroadcastedShape() /// >>> b.shape /// (2, 3) /// - [Test] + [TestMethod] public void Broadcast_WithScalar() { var arr = np.arange(6).reshape(2, 3); @@ -616,7 +617,7 @@ public void Broadcast_WithScalar() /// >>> b.size /// 1680 /// - [Test] + [TestMethod] public void Broadcast_4D() { var arr1 = np.ones(new Shape(8, 1, 6, 1)); @@ -634,7 +635,7 @@ public void Broadcast_4D() /// >>> len(b.iters) /// 2 /// - [Test] + [TestMethod] public void Broadcast_HasIters() { var arr1 = np.arange(3); @@ -660,7 +661,7 @@ public void Broadcast_HasIters() /// >>> np.array([1, 2, 3]) + np.int32(10) /// array([11, 12, 13]) /// - [Test] + [TestMethod] public void Add_ScalarAndArray() { var arr = np.array(new long[] { 1, 2, 3 }); @@ -682,7 +683,7 @@ public void Add_ScalarAndArray() /// array([[0, 2, 4], /// [3, 5, 7]]) /// - [Test] + [TestMethod] public void Add_1DTo2D() { var a = np.arange(6).reshape(2, 3); // [[0,1,2],[3,4,5]] @@ -701,7 +702,7 @@ public void Add_1DTo2D() /// [1, 2, 3], /// [2, 3, 4]]) /// - [Test] + [TestMethod] public void Add_ColumnPlusRow() { var col = np.array(new long[,] { { 0 }, { 1 }, { 2 } }); // shape (3,1) @@ -719,7 +720,7 @@ public void Add_ColumnPlusRow() /// >>> (np.ones((8,1,6,1)) + np.ones((7,1,5))).shape /// (8, 7, 6, 5) /// - [Test] + [TestMethod] public void Add_4DBroadcast() { var a = np.ones(new Shape(8, 1, 6, 1)); @@ -739,7 +740,7 @@ public void Add_4DBroadcast() /// array([[0, 0, 0], /// [3, 3, 3]]) /// - [Test] + [TestMethod] public void Subtract_Broadcast() { var a = np.arange(6).reshape(2, 3); // [[0,1,2],[3,4,5]] @@ -757,7 +758,7 @@ public void Subtract_Broadcast() /// array([[ 0, 2, 6], /// [ 3, 8, 15]]) /// - [Test] + [TestMethod] public void Multiply_Broadcast() { var a = np.arange(6).reshape(2, 3); // [[0,1,2],[3,4,5]] @@ -778,7 +779,7 @@ public void Multiply_Broadcast() /// array([[False, False, True], /// [ True, True, True]]) /// - [Test] + [TestMethod] public void Comparison_Broadcast() { var a = np.arange(6).reshape(2, 3); // [[0,1,2],[3,4,5]] @@ -808,7 +809,7 @@ public void Comparison_Broadcast() /// [1., 1., 1., 1.], /// [1., 1., 1., 1.]]) /// - [Test] + [TestMethod] public void BroadcastTo_ScalarToShape() { var scalar = NDArray.Scalar(1.0); @@ -841,7 +842,7 @@ public void BroadcastTo_ScalarToShape() /// /// Verify that a/b reflect the original data. /// - [Test] + [TestMethod] public void BroadcastArrays_ReturnsViews() { var x = np.array(new long[] { 1, 2, 3 }); // shape (3,) @@ -878,7 +879,7 @@ public void BroadcastArrays_ReturnsViews() /// [4, 4, 4, 4], /// [8, 8, 8, 8]]) /// - [Test] + [TestMethod] public void Broadcast_SlicedInput() { var x = np.arange(12).reshape(3, 4); @@ -907,7 +908,7 @@ public void Broadcast_SlicedInput() /// [ 8, 9, 10, 11], /// [16, 17, 18, 19]]) /// - [Test] + [TestMethod] public void Broadcast_SlicedInputArithmetic() { var x = np.arange(12).reshape(3, 4); @@ -931,7 +932,7 @@ public void Broadcast_SlicedInputArithmetic() /// >>> (a + b).shape /// (2, 4, 3, 6, 5) /// - [Test] + [TestMethod] public void Broadcast_HighDimensional() { var a = np.ones(new Shape(2, 1, 3, 1, 5)); @@ -952,7 +953,7 @@ public void Broadcast_HighDimensional() /// >>> (a + b).shape /// (5, 2, 6, 3, 7, 4) /// - [Test] + [TestMethod] public void Broadcast_6D() { var a = np.ones(new Shape(1, 2, 1, 3, 1, 4)); @@ -972,7 +973,7 @@ public void Broadcast_6D() /// >>> [x.shape for x in r] /// [(2, 3), (2, 3), (2, 3)] /// - [Test] + [TestMethod] public void BroadcastArrays_ThreeInputs() { var a = np.ones(new Shape(2, 1)); @@ -995,7 +996,7 @@ public void BroadcastArrays_ThreeInputs() /// >>> [x.shape for x in r] /// [(5, 6, 7), (5, 6, 7), (5, 6, 7), (5, 6, 7)] /// - [Test] + [TestMethod] public void BroadcastArrays_FourInputs() { var a = np.ones(new Shape(6, 7)); @@ -1013,7 +1014,7 @@ public void BroadcastArrays_FourInputs() /// ResolveReturnShape: classic broadcasting examples from NumPy docs. /// Validates the low-level shape resolution. /// - [Test] + [TestMethod] public void ResolveReturnShape_ClassicExamples() { // (256,256,3) + (3,) -> (256,256,3) @@ -1040,7 +1041,7 @@ public void ResolveReturnShape_ClassicExamples() /// /// are_broadcastable returns true for compatible and false for incompatible shapes. /// - [Test] + [TestMethod] public void AreBroadcastable_CompatibleAndIncompatible() { // Compatible pairs @@ -1060,7 +1061,7 @@ public void AreBroadcastable_CompatibleAndIncompatible() /// >>> np.float64(2.5) + np.array([1.0, 2.0, 3.0]) /// array([3.5, 4.5, 5.5]) /// - [Test] + [TestMethod] public void Add_BroadcastFloat() { var scalar = NDArray.Scalar(2.5); @@ -1080,7 +1081,7 @@ public void Add_BroadcastFloat() /// >>> y[0] /// 42 /// - [Test] + [TestMethod] public void BroadcastTo_IdentityShape() { var x = np.array(new long[] { 42 }); @@ -1097,7 +1098,7 @@ public void BroadcastTo_IdentityShape() /// [ 4., 5., 6.], /// [ 7., 8., 9.]]) /// - [Test] + [TestMethod] public void Add_1x1_Plus_3x3() { var a = np.ones(new Shape(1, 1)); // [[1.0]] @@ -1119,7 +1120,7 @@ public void Add_1x1_Plus_3x3() /// >>> y.strides /// (0, 4) # (0 bytes for first dim since it's broadcasted, 4 bytes for int32) /// - [Test] + [TestMethod] public void BroadcastTo_StridesCorrect() { var x = np.array(new long[] { 1, 2, 3 }); // shape (3,) @@ -1148,7 +1149,7 @@ public void BroadcastTo_StridesCorrect() /// >>> by.strides /// (0, 8) # 0 for broadcast rows, 8 bytes stride for cols /// - [Test] + [TestMethod] public void BroadcastArrays_StridesCorrect() { var x = np.ones(new Shape(3, 1)); @@ -1178,7 +1179,7 @@ public void BroadcastArrays_StridesCorrect() /// array([[2, 1, 0], /// [2, 1, 0]]) /// - [Test] + [TestMethod] public void BroadcastTo_ReversedSlice() { // np.arange returns int64 by default (NumPy 2.x) @@ -1213,7 +1214,7 @@ public void BroadcastTo_ReversedSlice() /// array([[0, 2, 4], /// [0, 2, 4]]) /// - [Test] + [TestMethod] public void BroadcastTo_StepSlice() { var stepped = np.arange(6)["::2"]; // [0, 2, 4] @@ -1247,7 +1248,7 @@ public void BroadcastTo_StepSlice() /// [5, 5, 5], /// [9, 9, 9]]) /// - [Test] + [TestMethod] public void BroadcastTo_SlicedColumn() { var x = np.arange(12).reshape(3, 4); @@ -1276,7 +1277,7 @@ public void BroadcastTo_SlicedColumn() /// array([[0, 0, 0, 0], /// [8, 8, 8, 8]]) /// - [Test] + [TestMethod] public void BroadcastTo_DoubleSliced() { var x = np.arange(12).reshape(3, 4); @@ -1301,7 +1302,7 @@ public void BroadcastTo_DoubleSliced() /// array([[3, 2, 1], /// [3, 2, 1]]) /// - [Test] + [TestMethod] public void Add_ReversedSliceBroadcast() { var rev = np.arange(3)["::-1"]; @@ -1326,7 +1327,7 @@ public void Add_ReversedSliceBroadcast() /// >>> np.sum(bc, axis=1) /// array([10, 30, 50]) /// - [Test] + [TestMethod] public void Sum_SlicedBroadcast() { var x = np.arange(12).reshape(3, 4); @@ -1361,7 +1362,7 @@ public void Sum_SlicedBroadcast() /// array([[2, 1, 0], /// [2, 1, 0]]) /// - [Test] + [TestMethod] public void FlattenAndCopy_SlicedBroadcast() { var rev = np.arange(3)["::-1"]; @@ -1400,7 +1401,7 @@ public void FlattenAndCopy_SlicedBroadcast() /// >>> y = np.broadcast_to(x, (2, 4)) /// >>> y[0, 0] = 999 # NumPy: ValueError /// - [Test] + [TestMethod] public void BroadcastTo_WriteThrough_ThrowsReadOnly() { var x = np.array(new long[] { 1, 2, 3, 4 }); @@ -1422,7 +1423,7 @@ public void BroadcastTo_WriteThrough_ThrowsReadOnly() /// /// This is inconsistent behavior. /// - [Test] + [TestMethod] public void BroadcastArrays_AlreadyBroadcasted_Succeeds() { var x = np.ones(new Shape(1, 3)); @@ -1440,7 +1441,7 @@ public void BroadcastArrays_AlreadyBroadcasted_Succeeds() /// NumPy: broadcast_to(broadcast_to(ones((1,3)), (4,3)), (2,4,3)) → shape (2,4,3). /// The IsBroadcasted guard was removed in Bug 4 fix (Phase 3). /// - [Test] + [TestMethod] public void BroadcastTo_AlreadyBroadcasted_Works() { var x = np.ones(new Shape(1, 3)); @@ -1457,7 +1458,7 @@ public void BroadcastTo_AlreadyBroadcasted_Works() /// >>> np.broadcast_arrays(np.ones((0, 3)), np.ones((1, 3))) /// Both shapes become (0, 3). /// - [Test] + [TestMethod] public void BroadcastArrays_ZeroSizeDimension() { var z = np.ones(new Shape(0, 3)); @@ -1473,7 +1474,7 @@ public void BroadcastArrays_ZeroSizeDimension() /// >>> np.broadcast_arrays(np.ones((0, 3)), np.ones((2, 3))) /// ValueError: shape mismatch /// - [Test] + [TestMethod] public void BroadcastArrays_ZeroVsNonZeroDim_Throws() { var z = np.ones(new Shape(0, 3)); @@ -1487,7 +1488,7 @@ public void BroadcastArrays_ZeroVsNonZeroDim_Throws() /// All 12 dtypes can broadcast via arithmetic (shape correctness). /// (1,3) + (3,1) -> (3,3) for every supported type. /// - [Test] + [TestMethod] public void Add_BroadcastAllDtypes() { var dtypes = new NPTypeCode[] @@ -1511,7 +1512,7 @@ public void Add_BroadcastAllDtypes() /// >>> np.array([1, 2, 3]) + np.array([0.5]) /// array([1.5, 2.5, 3.5]) /// - [Test] + [TestMethod] public void Add_MixedDtypeBroadcast() { var i32 = np.array(new long[] { 1, 2, 3 }); @@ -1531,7 +1532,7 @@ public void Add_MixedDtypeBroadcast() /// array([[ 7, 8, 9, 10, 11, 12, 13], /// [-13, -12, -11, -10, -9, -8, -7]]) /// - [Test] + [TestMethod] public void Add_NegativeValuesBroadcast() { var a = np.array(new long[] { -3, -2, -1, 0, 1, 2, 3 }); @@ -1551,7 +1552,7 @@ public void Add_NegativeValuesBroadcast() /// array([[2, 5, 3], /// [4, 5, 4]]) /// - [Test] + [TestMethod] public void Maximum_Broadcast() { var a = np.array(new long[] { 1, 5, 3 }); @@ -1576,7 +1577,7 @@ public void Maximum_Broadcast() /// [23, 24, 25, 26, 27], /// [28, 29, 30, 31, 32]]) /// - [Test] + [TestMethod] public void Add_SlicedColPlusSlicedRow() { var x = np.arange(20).reshape(4, 5); @@ -1599,7 +1600,7 @@ public void Add_SlicedColPlusSlicedRow() /// array([[10, 20, 30], /// [10, 20, 30]]) /// - [Test] + [TestMethod] public void BroadcastTo_ThenSlice() { var x = np.array(new long[] { 10, 20, 30 }); @@ -1621,7 +1622,7 @@ public void BroadcastTo_ThenSlice() /// >>> y[-1] /// array([10, 20, 30]) /// - [Test] + [TestMethod] public void BroadcastTo_ThenIntegerIndex() { var bx = np.broadcast_to(np.array(new long[] { 10, 20, 30 }), new Shape(4, 3)); @@ -1645,7 +1646,7 @@ public void BroadcastTo_ThenIntegerIndex() /// [1, 2, 3], /// [2, 3, 4]]) /// - [Test] + [TestMethod] public void BroadcastResult_Transpose() { var c = np.arange(3).reshape(1, 3) + np.arange(3).reshape(3, 1); @@ -1666,7 +1667,7 @@ public void BroadcastResult_Transpose() /// [5, 4], /// [6, 8]]) /// - [Test] + [TestMethod] public void BroadcastResult_Reshape() { var c = np.arange(6).reshape(2, 3) + np.array(new long[] { 1, 2, 3 }); @@ -1688,7 +1689,7 @@ public void BroadcastResult_Reshape() /// >>> np.sum(c, axis=0, keepdims=True) /// array([[8., 8., 8.]]) /// - [Test] + [TestMethod] public void Sum_Keepdims_BroadcastResult() { var c = np.ones(new Shape(1, 3)) + np.ones(new Shape(4, 1)); @@ -1706,7 +1707,7 @@ public void Sum_Keepdims_BroadcastResult() /// >>> np.mean(c) /// 11.0 /// - [Test] + [TestMethod] public void Mean_BroadcastResult() { var c = np.arange(3).reshape(1, 3) + np.ones(new Shape(4, 1), NPTypeCode.Int32) * 10; @@ -1721,7 +1722,7 @@ public void Mean_BroadcastResult() /// >>> np.int32(5) + np.int32(3) /// 8 /// - [Test] + [TestMethod] public void Add_ScalarPlusScalar() { // NDArray.Scalar(int) creates int32 scalar @@ -1734,7 +1735,7 @@ public void Add_ScalarPlusScalar() /// >>> (np.ones((1,2,1,3,1,4,1)) + np.ones((5,1,6,1,7,1,8))).shape /// (5, 2, 6, 3, 7, 4, 8) /// - [Test] + [TestMethod] public void Broadcast_7D() { var a = np.ones(new Shape(1, 2, 1, 3, 1, 4, 1)); @@ -1751,7 +1752,7 @@ public void Broadcast_7D() /// array([[ 0, -1, -2], /// [-1, -2, -3]]) /// - [Test] + [TestMethod] public void UnaryMinus_BroadcastResult() { var c = np.arange(3).reshape(1, 3) + np.arange(2).reshape(2, 1); @@ -1770,7 +1771,7 @@ public void UnaryMinus_BroadcastResult() /// array([[1., 2., 3.], /// [1., 2., 3.]]) /// - [Test] + [TestMethod] public void Sqrt_BroadcastResult() { var c = np.array(new double[] { 1.0, 4.0, 9.0 }) + np.zeros(new Shape(2, 1)); @@ -1787,7 +1788,7 @@ public void Sqrt_BroadcastResult() /// >>> (np.ones((100, 1)) + np.ones((1, 200))).shape /// (100, 200) /// - [Test] + [TestMethod] public void Broadcast_LargeAsymmetric() { var a = np.ones(new Shape(100, 1)); @@ -1805,7 +1806,7 @@ public void Broadcast_LargeAsymmetric() /// >>> np.broadcast_to(np.float64(1.0), (10000,)) /// All elements should be 1.0. /// - [Test] + [TestMethod] public void BroadcastTo_ScalarToLargeShape() { var scalar = np.array(new double[] { 1.0 }); @@ -1825,7 +1826,7 @@ public void BroadcastTo_ScalarToLargeShape() /// >>> np.sum(d) /// 48 /// - [Test] + [TestMethod] public void ChainedBroadcast_AddSquareSum() { var a = np.arange(3).reshape(1, 3); @@ -1843,7 +1844,7 @@ public void ChainedBroadcast_AddSquareSum() /// >>> np.broadcast_arrays(np.array([True, False, True]), np.array([[True], [False]])) /// Results should preserve boolean values across broadcast dimensions. /// - [Test] + [TestMethod] public void BroadcastArrays_BoolDtype() { var a = np.array(new bool[] { true, false, true }); @@ -1884,7 +1885,7 @@ public void BroadcastArrays_BoolDtype() /// >>> b /// array([[1, 2, 3], [1, 2, 3], [1, 2, 3]]) /// - [Test] + [TestMethod] public void ReBroadcast_2Arg_SameShape() { var a = np.broadcast_to(np.array(new long[] { 1, 2, 3 }), new Shape(3, 3)); @@ -1909,7 +1910,7 @@ public void ReBroadcast_2Arg_SameShape() /// >>> b[1] /// array([[1, 1, 1], [2, 2, 2], [3, 3, 3]]) /// - [Test] + [TestMethod] public void ReBroadcast_2Arg_HigherDim() { var col = np.array(new long[,] { { 1 }, { 2 }, { 3 } }); @@ -1931,7 +1932,7 @@ public void ReBroadcast_2Arg_HigherDim() /// >>> np.clip(np.broadcast_to(np.array([1.,5.,9.]), (2,3)), 2., 7.) /// array([[2., 5., 7.], [2., 5., 7.]]) /// - [Test] + [TestMethod] public void ReBroadcast_2Arg_ClipOnBroadcast() { var a = np.broadcast_to(np.array(new double[] { 1.0, 5.0, 9.0 }), new Shape(2, 3)); @@ -1961,7 +1962,7 @@ public void ReBroadcast_2Arg_ClipOnBroadcast() /// >>> r[0] /// array([[1, 1, 1], [5, 5, 5], [9, 9, 9]]) /// - [Test] + [TestMethod] public void BroadcastArrays_NArg_SlicedInput_CorrectValues() { var x = np.arange(12).reshape(3, 4); @@ -1995,7 +1996,7 @@ public void BroadcastArrays_NArg_SlicedInput_CorrectValues() /// >>> np.broadcast_arrays(row, np.ones((3,3), dtype=int))[0] /// array([[0, 1, 2], [0, 1, 2], [0, 1, 2]]) /// - [Test] + [TestMethod] public void BroadcastPaths_2Arg_vs_NArg_SlicedInput_Identical() { var x = np.arange(6).reshape(2, 3); diff --git a/test/NumSharp.UnitTest/Creation/np.arange.BattleTests.cs b/test/NumSharp.UnitTest/Creation/np.arange.BattleTests.cs index ca9a74688..ef1a23014 100644 --- a/test/NumSharp.UnitTest/Creation/np.arange.BattleTests.cs +++ b/test/NumSharp.UnitTest/Creation/np.arange.BattleTests.cs @@ -1,10 +1,7 @@ using System; -using System.Threading.Tasks; using AwesomeAssertions; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; namespace NumSharp.UnitTest.Creation; @@ -12,48 +9,49 @@ namespace NumSharp.UnitTest.Creation; /// Battle tests for np.arange - verifies NumSharp matches NumPy behavior exactly. /// All expected values captured from NumPy 2.x. /// +[TestClass] public class ArangeBattleTests { #region Basic Integer Ranges - [Test] - public async Task Arange_StopOnly_Zero_ReturnsEmptyInt64() + [TestMethod] + public void Arange_StopOnly_Zero_ReturnsEmptyInt64() { // np.arange(0): array([], dtype=int64) var result = np.arange(0); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 0 }); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(long)); + result.shape.Should().BeEquivalentTo(new long[] { 0 }); } - [Test] - public async Task Arange_StopOnly_One_ReturnsSingleElementInt64() + [TestMethod] + public void Arange_StopOnly_One_ReturnsSingleElementInt64() { // np.arange(1): array([0]) dtype=int64 var result = np.arange(1); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(0L); } - [Test] - public async Task Arange_StopOnly_Five_ReturnsZeroToFourInt64() + [TestMethod] + public void Arange_StopOnly_Five_ReturnsZeroToFourInt64() { // np.arange(5): array([0, 1, 2, 3, 4]) dtype=int64 var result = np.arange(5); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(0L, 1L, 2L, 3L, 4L); } - [Test] - public async Task Arange_StopOnly_Ten_ReturnsZeroToNineInt64() + [TestMethod] + public void Arange_StopOnly_Ten_ReturnsZeroToNineInt64() { // np.arange(10): array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) dtype=int64 var result = np.arange(10); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L); } @@ -61,53 +59,53 @@ public async Task Arange_StopOnly_Ten_ReturnsZeroToNineInt64() #region Start and Stop - [Test] - public async Task Arange_StartStop_ZeroToFive() + [TestMethod] + public void Arange_StartStop_ZeroToFive() { // np.arange(0, 5): array([0, 1, 2, 3, 4]) dtype=int64 var result = np.arange(0, 5); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(0L, 1L, 2L, 3L, 4L); } - [Test] - public async Task Arange_StartStop_OneToFive() + [TestMethod] + public void Arange_StartStop_OneToFive() { // np.arange(1, 5): array([1, 2, 3, 4]) dtype=int64 var result = np.arange(1, 5); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(1L, 2L, 3L, 4L); } - [Test] - public async Task Arange_StartStop_FiveToTen() + [TestMethod] + public void Arange_StartStop_FiveToTen() { // np.arange(5, 10): array([5, 6, 7, 8, 9]) dtype=int64 var result = np.arange(5, 10); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(5L, 6L, 7L, 8L, 9L); } - [Test] - public async Task Arange_StartStop_NegativeFiveToFive() + [TestMethod] + public void Arange_StartStop_NegativeFiveToFive() { // np.arange(-5, 5): array([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]) dtype=int64 var result = np.arange(-5, 5); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(-5L, -4L, -3L, -2L, -1L, 0L, 1L, 2L, 3L, 4L); } - [Test] - public async Task Arange_StartStop_NegativeTenToNegativeFive() + [TestMethod] + public void Arange_StartStop_NegativeTenToNegativeFive() { // np.arange(-10, -5): array([-10, -9, -8, -7, -6]) dtype=int64 var result = np.arange(-10, -5); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(-10L, -9L, -8L, -7L, -6L); } @@ -115,33 +113,33 @@ public async Task Arange_StartStop_NegativeTenToNegativeFive() #region With Step - [Test] - public async Task Arange_WithStep_ZeroToTenByTwo() + [TestMethod] + public void Arange_WithStep_ZeroToTenByTwo() { // np.arange(0, 10, 2): array([0, 2, 4, 6, 8]) dtype=int64 var result = np.arange(0, 10, 2); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(0L, 2L, 4L, 6L, 8L); } - [Test] - public async Task Arange_WithStep_ZeroToTenByThree() + [TestMethod] + public void Arange_WithStep_ZeroToTenByThree() { // np.arange(0, 10, 3): array([0, 3, 6, 9]) dtype=int64 var result = np.arange(0, 10, 3); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(0L, 3L, 6L, 9L); } - [Test] - public async Task Arange_WithStep_OneToTenByTwo() + [TestMethod] + public void Arange_WithStep_OneToTenByTwo() { // np.arange(1, 10, 2): array([1, 3, 5, 7, 9]) dtype=int64 var result = np.arange(1, 10, 2); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(1L, 3L, 5L, 7L, 9L); } @@ -149,53 +147,53 @@ public async Task Arange_WithStep_OneToTenByTwo() #region Negative Step - [Test] - public async Task Arange_NegativeStep_TenToZeroByMinusOne() + [TestMethod] + public void Arange_NegativeStep_TenToZeroByMinusOne() { // np.arange(10, 0, -1): array([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) dtype=int64 var result = np.arange(10, 0, -1); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L); } - [Test] - public async Task Arange_NegativeStep_TenToZeroByMinusTwo() + [TestMethod] + public void Arange_NegativeStep_TenToZeroByMinusTwo() { // np.arange(10, 0, -2): array([10, 8, 6, 4, 2]) dtype=int64 var result = np.arange(10, 0, -2); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(10L, 8L, 6L, 4L, 2L); } - [Test] - public async Task Arange_NegativeStep_FiveToNegativeFiveByMinusOne() + [TestMethod] + public void Arange_NegativeStep_FiveToNegativeFiveByMinusOne() { // np.arange(5, -5, -1): array([5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) dtype=int64 var result = np.arange(5, -5, -1); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(5L, 4L, 3L, 2L, 1L, 0L, -1L, -2L, -3L, -4L); } - [Test] - public async Task Arange_NegativeStep_FiveToNegativeFiveByMinusTwo() + [TestMethod] + public void Arange_NegativeStep_FiveToNegativeFiveByMinusTwo() { // np.arange(5, -5, -2): array([5, 3, 1, -1, -3]) dtype=int64 var result = np.arange(5, -5, -2); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(5L, 3L, 1L, -1L, -3L); } - [Test] - public async Task Arange_NegativeStep_NegativeOneToNegativeTenByMinusOne() + [TestMethod] + public void Arange_NegativeStep_NegativeOneToNegativeTenByMinusOne() { // np.arange(-1, -10, -1): array([-1, -2, -3, -4, -5, -6, -7, -8, -9]) dtype=int64 var result = np.arange(-1, -10, -1); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(-1L, -2L, -3L, -4L, -5L, -6L, -7L, -8L, -9L); } @@ -203,110 +201,110 @@ public async Task Arange_NegativeStep_NegativeOneToNegativeTenByMinusOne() #region Empty Arrays - [Test] - public async Task Arange_Empty_StartGreaterThanStop() + [TestMethod] + public void Arange_Empty_StartGreaterThanStop() { // np.arange(5, 0): array([], dtype=int64) var result = np.arange(5, 0); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(long)); } - [Test] - public async Task Arange_Empty_StartEqualsStop() + [TestMethod] + public void Arange_Empty_StartEqualsStop() { // np.arange(5, 5): array([], dtype=int64) var result = np.arange(5, 5); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(long)); } - [Test] - public async Task Arange_Empty_ZeroToNegative() + [TestMethod] + public void Arange_Empty_ZeroToNegative() { // np.arange(0, -5): array([], dtype=int64) var result = np.arange(0, -5); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(long)); } - [Test] - public async Task Arange_Empty_WrongStepDirection() + [TestMethod] + public void Arange_Empty_WrongStepDirection() { // np.arange(0, 5, -1): array([], dtype=int64) var result = np.arange(0, 5, -1); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(long)); } #endregion #region Float Ranges - [Test] - public async Task Arange_Float_ZeroToFive() + [TestMethod] + public void Arange_Float_ZeroToFive() { // np.arange(0.0, 5.0): array([0., 1., 2., 3., 4.]) dtype=float64 var result = np.arange(0.0, 5.0); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); + result.dtype.Should().Be(typeof(double)); result.Should().BeOfValues(0.0, 1.0, 2.0, 3.0, 4.0); } - [Test] - public async Task Arange_Float_ZeroToOneByPointOne() + [TestMethod] + public void Arange_Float_ZeroToOneByPointOne() { // np.arange(0.0, 1.0, 0.1): array([0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]) dtype=float64 var result = np.arange(0.0, 1.0, 0.1); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); - await Assert.That(result.size).IsEqualTo(10); + result.dtype.Should().Be(typeof(double)); + result.size.Should().Be(10); // Check first and last due to floating point precision - await Assert.That((double)result[0]).IsEqualTo(0.0); - await Assert.That((double)result[9]).IsEqualTo(0.9).Within(1e-10); + ((double)result[0]).Should().Be(0.0); + ((double)result[9]).Should().BeApproximately(0.9, 1e-10); } - [Test] - public async Task Arange_Float_ZeroToOneByPointTwo() + [TestMethod] + public void Arange_Float_ZeroToOneByPointTwo() { // np.arange(0.0, 1.0, 0.2): array([0., 0.2, 0.4, 0.6, 0.8]) dtype=float64 var result = np.arange(0.0, 1.0, 0.2); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); - await Assert.That(result.size).IsEqualTo(5); + result.dtype.Should().Be(typeof(double)); + result.size.Should().Be(5); } - [Test] - public async Task Arange_Float_ZeroToOneByPointThree() + [TestMethod] + public void Arange_Float_ZeroToOneByPointThree() { // np.arange(0.0, 1.0, 0.3): array([0., 0.3, 0.6, 0.9]) dtype=float64 var result = np.arange(0.0, 1.0, 0.3); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); - await Assert.That(result.size).IsEqualTo(4); + result.dtype.Should().Be(typeof(double)); + result.size.Should().Be(4); } - [Test] - public async Task Arange_Float_HalfToFivePointFive() + [TestMethod] + public void Arange_Float_HalfToFivePointFive() { // np.arange(0.5, 5.5): array([0.5, 1.5, 2.5, 3.5, 4.5]) dtype=float64 var result = np.arange(0.5, 5.5); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); + result.dtype.Should().Be(typeof(double)); result.Should().BeOfValues(0.5, 1.5, 2.5, 3.5, 4.5); } - [Test] - public async Task Arange_Float_OnePointFiveToFivePointFiveByHalf() + [TestMethod] + public void Arange_Float_OnePointFiveToFivePointFiveByHalf() { // np.arange(1.5, 5.5, 0.5): array([1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5.]) dtype=float64 var result = np.arange(1.5, 5.5, 0.5); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); + result.dtype.Should().Be(typeof(double)); result.Should().BeOfValues(1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0); } @@ -314,99 +312,99 @@ public async Task Arange_Float_OnePointFiveToFivePointFiveByHalf() #region Float Negative Step - [Test] - public async Task Arange_FloatNegativeStep_FiveToZeroByMinusOne() + [TestMethod] + public void Arange_FloatNegativeStep_FiveToZeroByMinusOne() { // np.arange(5.0, 0.0, -1.0): array([5., 4., 3., 2., 1.]) dtype=float64 var result = np.arange(5.0, 0.0, -1.0); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); + result.dtype.Should().Be(typeof(double)); result.Should().BeOfValues(5.0, 4.0, 3.0, 2.0, 1.0); } - [Test] - public async Task Arange_FloatNegativeStep_OneToZeroByMinusPointTwo() + [TestMethod] + public void Arange_FloatNegativeStep_OneToZeroByMinusPointTwo() { // np.arange(1.0, 0.0, -0.2): array([1., 0.8, 0.6, 0.4, 0.2]) dtype=float64 var result = np.arange(1.0, 0.0, -0.2); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); - await Assert.That(result.size).IsEqualTo(5); - await Assert.That((double)result[0]).IsEqualTo(1.0); - await Assert.That((double)result[4]).IsEqualTo(0.2).Within(1e-10); + result.dtype.Should().Be(typeof(double)); + result.size.Should().Be(5); + ((double)result[0]).Should().Be(1.0); + ((double)result[4]).Should().BeApproximately(0.2, 1e-10); } #endregion #region With dtype Parameter - [Test] - public async Task Arange_Dtype_Int32() + [TestMethod] + public void Arange_Dtype_Int32() { // np.arange(5, dtype=np.int32): array([0, 1, 2, 3, 4], dtype=int32) var result = np.arange(5, typeof(int)); - await Assert.That(result.dtype).IsEqualTo(typeof(int)); + result.dtype.Should().Be(typeof(int)); result.Should().BeOfValues(0, 1, 2, 3, 4); } - [Test] - public async Task Arange_Dtype_Int64() + [TestMethod] + public void Arange_Dtype_Int64() { // np.arange(5, dtype=np.int64): array([0, 1, 2, 3, 4]) dtype=int64 var result = np.arange(5, typeof(long)); - await Assert.That(result.dtype).IsEqualTo(typeof(long)); + result.dtype.Should().Be(typeof(long)); result.Should().BeOfValues(0L, 1L, 2L, 3L, 4L); } - [Test] - public async Task Arange_Dtype_Float32() + [TestMethod] + public void Arange_Dtype_Float32() { // np.arange(5, dtype=np.float32): array([0., 1., 2., 3., 4.], dtype=float32) var result = np.arange(5, typeof(float)); - await Assert.That(result.dtype).IsEqualTo(typeof(float)); + result.dtype.Should().Be(typeof(float)); result.Should().BeOfValues(0f, 1f, 2f, 3f, 4f); } - [Test] - public async Task Arange_Dtype_Float64() + [TestMethod] + public void Arange_Dtype_Float64() { // np.arange(5, dtype=np.float64): array([0., 1., 2., 3., 4.]) dtype=float64 var result = np.arange(5, typeof(double)); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); + result.dtype.Should().Be(typeof(double)); result.Should().BeOfValues(0.0, 1.0, 2.0, 3.0, 4.0); } - [Test] - public async Task Arange_Dtype_FloatInputToInt32() + [TestMethod] + public void Arange_Dtype_FloatInputToInt32() { // np.arange(5.0, dtype=np.int32): array([0, 1, 2, 3, 4], dtype=int32) var result = np.arange(5.0, typeof(int)); - await Assert.That(result.dtype).IsEqualTo(typeof(int)); + result.dtype.Should().Be(typeof(int)); result.Should().BeOfValues(0, 1, 2, 3, 4); } - [Test] - public async Task Arange_Dtype_WithStepToFloat32() + [TestMethod] + public void Arange_Dtype_WithStepToFloat32() { // np.arange(0, 10, 2, dtype=np.float32): array([0., 2., 4., 6., 8.], dtype=float32) var result = np.arange(0, 10, 2, typeof(float)); - await Assert.That(result.dtype).IsEqualTo(typeof(float)); + result.dtype.Should().Be(typeof(float)); result.Should().BeOfValues(0f, 2f, 4f, 6f, 8f); } - [Test] - public async Task Arange_Dtype_FloatRangeToInt32() + [TestMethod] + public void Arange_Dtype_FloatRangeToInt32() { // np.arange(0.0, 5.0, dtype=np.int32): array([0, 1, 2, 3, 4], dtype=int32) var result = np.arange(0.0, 5.0, 1.0, typeof(int)); - await Assert.That(result.dtype).IsEqualTo(typeof(int)); + result.dtype.Should().Be(typeof(int)); result.Should().BeOfValues(0, 1, 2, 3, 4); } @@ -414,53 +412,53 @@ public async Task Arange_Dtype_FloatRangeToInt32() #region Various Integer dtypes - [Test] - public async Task Arange_Dtype_UInt8() + [TestMethod] + public void Arange_Dtype_UInt8() { // np.arange(10, dtype=np.uint8): array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint8) var result = np.arange(10, typeof(byte)); - await Assert.That(result.dtype).IsEqualTo(typeof(byte)); + result.dtype.Should().Be(typeof(byte)); result.Should().BeOfValues((byte)0, (byte)1, (byte)2, (byte)3, (byte)4, (byte)5, (byte)6, (byte)7, (byte)8, (byte)9); } - [Test] - public async Task Arange_Dtype_Int16() + [TestMethod] + public void Arange_Dtype_Int16() { // np.arange(10, dtype=np.int16): array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=int16) var result = np.arange(10, typeof(short)); - await Assert.That(result.dtype).IsEqualTo(typeof(short)); + result.dtype.Should().Be(typeof(short)); result.Should().BeOfValues((short)0, (short)1, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9); } - [Test] - public async Task Arange_Dtype_UInt16() + [TestMethod] + public void Arange_Dtype_UInt16() { // np.arange(10, dtype=np.uint16): array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint16) var result = np.arange(10, typeof(ushort)); - await Assert.That(result.dtype).IsEqualTo(typeof(ushort)); + result.dtype.Should().Be(typeof(ushort)); result.Should().BeOfValues((ushort)0, (ushort)1, (ushort)2, (ushort)3, (ushort)4, (ushort)5, (ushort)6, (ushort)7, (ushort)8, (ushort)9); } - [Test] - public async Task Arange_Dtype_UInt32() + [TestMethod] + public void Arange_Dtype_UInt32() { // np.arange(10, dtype=np.uint32): array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint32) var result = np.arange(10, typeof(uint)); - await Assert.That(result.dtype).IsEqualTo(typeof(uint)); + result.dtype.Should().Be(typeof(uint)); result.Should().BeOfValues(0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u); } - [Test] - public async Task Arange_Dtype_UInt64() + [TestMethod] + public void Arange_Dtype_UInt64() { // np.arange(10, dtype=np.uint64): array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint64) var result = np.arange(10, typeof(ulong)); - await Assert.That(result.dtype).IsEqualTo(typeof(ulong)); + result.dtype.Should().Be(typeof(ulong)); result.Should().BeOfValues(0ul, 1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul, 8ul, 9ul); } @@ -468,97 +466,97 @@ public async Task Arange_Dtype_UInt64() #region Large Ranges - [Test] - public async Task Arange_Large_Thousand() + [TestMethod] + public void Arange_Large_Thousand() { // np.arange(1000).shape: (1000,) var result = np.arange(1000); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 1000 }); - await Assert.That(result.size).IsEqualTo(1000); - await Assert.That((long)result[0]).IsEqualTo(0L); - await Assert.That((long)result[999]).IsEqualTo(999L); + result.shape.Should().BeEquivalentTo(new long[] { 1000 }); + result.size.Should().Be(1000); + ((long)result[0]).Should().Be(0L); + ((long)result[999]).Should().Be(999L); } - [Test] - public async Task Arange_Large_WithStep() + [TestMethod] + public void Arange_Large_WithStep() { // np.arange(0, 1000000, 1000).shape: (1000,) // np.arange(0, 1000000, 1000)[-5:]: array([995000, 996000, 997000, 998000, 999000]) var result = np.arange(0, 1000000, 1000); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 1000 }); - await Assert.That((long)result[995]).IsEqualTo(995000L); - await Assert.That((long)result[996]).IsEqualTo(996000L); - await Assert.That((long)result[997]).IsEqualTo(997000L); - await Assert.That((long)result[998]).IsEqualTo(998000L); - await Assert.That((long)result[999]).IsEqualTo(999000L); + result.shape.Should().BeEquivalentTo(new long[] { 1000 }); + ((long)result[995]).Should().Be(995000L); + ((long)result[996]).Should().Be(996000L); + ((long)result[997]).Should().Be(997000L); + ((long)result[998]).Should().Be(998000L); + ((long)result[999]).Should().Be(999000L); } #endregion #region Floating Point Edge Cases - [Test] - public async Task Arange_FloatEdge_PointOneToPointFour() + [TestMethod] + public void Arange_FloatEdge_PointOneToPointFour() { // np.arange(0.1, 0.4, 0.1): array([0.1, 0.2, 0.3, 0.4]) len=4 // Note: NumPy includes 0.4 due to floating point rounding var result = np.arange(0.1, 0.4, 0.1); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); + result.dtype.Should().Be(typeof(double)); // NumPy returns 4 elements due to floating point math - await Assert.That(result.size).IsEqualTo(4); + result.size.Should().Be(4); } - [Test] - public async Task Arange_FloatEdge_ZeroToPointSix() + [TestMethod] + public void Arange_FloatEdge_ZeroToPointSix() { // np.arange(0.0, 0.6, 0.1): array([0., 0.1, 0.2, 0.3, 0.4, 0.5]) len=6 var result = np.arange(0.0, 0.6, 0.1); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); - await Assert.That(result.size).IsEqualTo(6); + result.dtype.Should().Be(typeof(double)); + result.size.Should().Be(6); } - [Test] - public async Task Arange_FloatEdge_ZeroToPointSeven() + [TestMethod] + public void Arange_FloatEdge_ZeroToPointSeven() { // np.arange(0.0, 0.7, 0.1): array([0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6]) len=7 var result = np.arange(0.0, 0.7, 0.1); - await Assert.That(result.dtype).IsEqualTo(typeof(double)); - await Assert.That(result.size).IsEqualTo(7); + result.dtype.Should().Be(typeof(double)); + result.size.Should().Be(7); } #endregion #region NPTypeCode Overloads - [Test] - public async Task Arange_NPTypeCode_Int32() + [TestMethod] + public void Arange_NPTypeCode_Int32() { var result = np.arange(5, NPTypeCode.Int32); - await Assert.That(result.dtype).IsEqualTo(typeof(int)); + result.dtype.Should().Be(typeof(int)); result.Should().BeOfValues(0, 1, 2, 3, 4); } - [Test] - public async Task Arange_NPTypeCode_WithStartStop() + [TestMethod] + public void Arange_NPTypeCode_WithStartStop() { var result = np.arange(2, 8, NPTypeCode.Int16); - await Assert.That(result.dtype).IsEqualTo(typeof(short)); + result.dtype.Should().Be(typeof(short)); result.Should().BeOfValues((short)2, (short)3, (short)4, (short)5, (short)6, (short)7); } - [Test] - public async Task Arange_NPTypeCode_WithStep() + [TestMethod] + public void Arange_NPTypeCode_WithStep() { var result = np.arange(0, 10, 2, NPTypeCode.Single); - await Assert.That(result.dtype).IsEqualTo(typeof(float)); + result.dtype.Should().Be(typeof(float)); result.Should().BeOfValues(0f, 2f, 4f, 6f, 8f); } @@ -566,31 +564,31 @@ public async Task Arange_NPTypeCode_WithStep() #region Single-Precision Float (float32) - [Test] - public async Task Arange_Float32_Basic() + [TestMethod] + public void Arange_Float32_Basic() { // Explicit float overload var result = np.arange(0f, 5f); - await Assert.That(result.dtype).IsEqualTo(typeof(float)); + result.dtype.Should().Be(typeof(float)); result.Should().BeOfValues(0f, 1f, 2f, 3f, 4f); } - [Test] - public async Task Arange_Float32_WithStep() + [TestMethod] + public void Arange_Float32_WithStep() { var result = np.arange(0f, 2f, 0.5f); - await Assert.That(result.dtype).IsEqualTo(typeof(float)); + result.dtype.Should().Be(typeof(float)); result.Should().BeOfValues(0f, 0.5f, 1f, 1.5f); } - [Test] - public async Task Arange_Float32_NegativeStep() + [TestMethod] + public void Arange_Float32_NegativeStep() { var result = np.arange(5f, 0f, -1f); - await Assert.That(result.dtype).IsEqualTo(typeof(float)); + result.dtype.Should().Be(typeof(float)); result.Should().BeOfValues(5f, 4f, 3f, 2f, 1f); } @@ -598,16 +596,16 @@ public async Task Arange_Float32_NegativeStep() #region Error Cases - [Test] - public async Task Arange_ZeroStep_ThrowsArgumentException() + [TestMethod] + public void Arange_ZeroStep_ThrowsArgumentException() { - await Assert.ThrowsAsync(async () => np.arange(0, 10, 0)); + new Action(() => np.arange(0, 10, 0)).Should().Throw(); } - [Test] - public async Task Arange_ZeroStepFloat_ThrowsArgumentException() + [TestMethod] + public void Arange_ZeroStepFloat_ThrowsArgumentException() { - await Assert.ThrowsAsync(async () => np.arange(0.0, 10.0, 0.0)); + new Action(() => np.arange(0.0, 10.0, 0.0)).Should().Throw(); } #endregion @@ -618,15 +616,15 @@ public async Task Arange_ZeroStepFloat_ThrowsArgumentException() /// NumPy calculates delta in target dtype: delta = int(start+step) - int(start). /// For arange(0, 5, 0.5, int32): delta = int(0.5) - int(0) = 0, so all values are 0. /// - [Test] - public async Task Arange_FractionalStep_IntDtype_ZeroDelta() + [TestMethod] + public void Arange_FractionalStep_IntDtype_ZeroDelta() { // np.arange(0, 5, 0.5, dtype=np.int32) → [0,0,0,0,0,0,0,0,0,0] // NumPy: int(0)=0, int(0+0.5)=0, delta=0, all values=0 var result = np.arange(0, 5, 0.5, typeof(int)); - await Assert.That(result.dtype).IsEqualTo(typeof(int)); - await Assert.That(result.size).IsEqualTo(10); + result.dtype.Should().Be(typeof(int)); + result.size.Should().Be(10); // NumPy returns all zeros because delta=0 result.Should().BeOfValues(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } @@ -635,15 +633,15 @@ public async Task Arange_FractionalStep_IntDtype_ZeroDelta() /// For arange(5, 0, -0.5, int32): delta = int(4.5) - int(5) = 4 - 5 = -1. /// Values decrement by 1, not by 0.5. /// - [Test] - public async Task Arange_FractionalNegativeStep_IntDtype_IntegerDelta() + [TestMethod] + public void Arange_FractionalNegativeStep_IntDtype_IntegerDelta() { // np.arange(5, 0, -0.5, dtype=np.int32) → [5,4,3,2,1,0,-1,-2,-3,-4] // NumPy: int(5)=5, int(5-0.5)=4, delta=-1 var result = np.arange(5, 0, -0.5, typeof(int)); - await Assert.That(result.dtype).IsEqualTo(typeof(int)); - await Assert.That(result.size).IsEqualTo(10); + result.dtype.Should().Be(typeof(int)); + result.size.Should().Be(10); // NumPy decrements by 1 (the integer delta), not by 0.5 result.Should().BeOfValues(5, 4, 3, 2, 1, 0, -1, -2, -3, -4); } @@ -651,55 +649,55 @@ public async Task Arange_FractionalNegativeStep_IntDtype_IntegerDelta() /// /// For arange(0, 5, 0.7, int32): delta = int(0.7) - int(0) = 0. /// - [Test] - public async Task Arange_FractionalStep_0_7_IntDtype() + [TestMethod] + public void Arange_FractionalStep_0_7_IntDtype() { // np.arange(0, 5, 0.7, dtype=np.int32) → [0,0,0,0,0,0,0,0] var result = np.arange(0, 5, 0.7, typeof(int)); - await Assert.That(result.dtype).IsEqualTo(typeof(int)); - await Assert.That(result.size).IsEqualTo(8); + result.dtype.Should().Be(typeof(int)); + result.size.Should().Be(8); result.Should().BeOfValues(0, 0, 0, 0, 0, 0, 0, 0); } /// /// For arange(5, 0, -0.7, int32): delta = int(4.3) - int(5) = 4 - 5 = -1. /// - [Test] - public async Task Arange_FractionalNegativeStep_0_7_IntDtype() + [TestMethod] + public void Arange_FractionalNegativeStep_0_7_IntDtype() { // np.arange(5, 0, -0.7, dtype=np.int32) → [5,4,3,2,1,0,-1,-2] var result = np.arange(5, 0, -0.7, typeof(int)); - await Assert.That(result.dtype).IsEqualTo(typeof(int)); - await Assert.That(result.size).IsEqualTo(8); + result.dtype.Should().Be(typeof(int)); + result.size.Should().Be(8); result.Should().BeOfValues(5, 4, 3, 2, 1, 0, -1, -2); } /// /// Float start with integer step and int dtype works correctly. /// - [Test] - public async Task Arange_FloatStart_IntStep_IntDtype() + [TestMethod] + public void Arange_FloatStart_IntStep_IntDtype() { // np.arange(0.5, 5.5, 1, dtype=np.int32) → [0,1,2,3,4] // NumPy: int(0.5)=0, int(1.5)=1, delta=1 var result = np.arange(0.5, 5.5, 1, typeof(int)); - await Assert.That(result.dtype).IsEqualTo(typeof(int)); + result.dtype.Should().Be(typeof(int)); result.Should().BeOfValues(0, 1, 2, 3, 4); } /// /// Another float start case. /// - [Test] - public async Task Arange_FloatStart_0_9_IntDtype() + [TestMethod] + public void Arange_FloatStart_0_9_IntDtype() { // np.arange(0.9, 5.9, 1, dtype=np.int32) → [0,1,2,3,4] var result = np.arange(0.9, 5.9, 1, typeof(int)); - await Assert.That(result.dtype).IsEqualTo(typeof(int)); + result.dtype.Should().Be(typeof(int)); result.Should().BeOfValues(0, 1, 2, 3, 4); } diff --git a/test/NumSharp.UnitTest/Creation/np.arange.Test.cs b/test/NumSharp.UnitTest/Creation/np.arange.Test.cs index 8b1897fb3..ce73fa037 100644 --- a/test/NumSharp.UnitTest/Creation/np.arange.Test.cs +++ b/test/NumSharp.UnitTest/Creation/np.arange.Test.cs @@ -10,9 +10,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class NumPyArangeTest { - [Test] + [TestMethod] public void arange() { var n = np.arange(3); @@ -38,7 +39,7 @@ public void arange() Assert.IsTrue(Enumerable.SequenceEqual(r, t)); } - [Test] + [TestMethod] public void arange_negative() { np.arange(3, 0, -1).Should().BeOfValues(3, 2, 1); @@ -49,7 +50,7 @@ public void arange_negative() np.arange(3f, 0f, -2f).Should().BeOfValues(3f, 1f); } - [Test] + [TestMethod] public void arange_case2() { np.arange(10, 1, -1).Should().BeOfValues(10, 9, 8, 7, 6, 5, 4, 3, 2); diff --git a/test/NumSharp.UnitTest/Creation/np.array.BattleTests.cs b/test/NumSharp.UnitTest/Creation/np.array.BattleTests.cs index 15ab9f160..1e0509a7e 100644 --- a/test/NumSharp.UnitTest/Creation/np.array.BattleTests.cs +++ b/test/NumSharp.UnitTest/Creation/np.array.BattleTests.cs @@ -13,11 +13,12 @@ namespace NumSharp.UnitTest; /// - With ndmin parameter /// - With copy parameter /// +[TestClass] public class np_array_BattleTests { #region Scalars (0-dimensional) - [Test] + [TestMethod] public void Array_ScalarInt32_Creates0DimArray() { // NumPy: np.array(42) creates shape=(), ndim=0 @@ -28,7 +29,7 @@ public void Array_ScalarInt32_Creates0DimArray() ((int)arr).Should().Be(42); } - [Test] + [TestMethod] public void Array_ScalarInt64_Creates0DimArray() { var arr = np.array(42L); @@ -37,7 +38,7 @@ public void Array_ScalarInt64_Creates0DimArray() arr.dtype.Should().Be(typeof(long)); } - [Test] + [TestMethod] public void Array_ScalarDouble_Creates0DimArray() { var arr = np.array(3.14); @@ -47,7 +48,7 @@ public void Array_ScalarDouble_Creates0DimArray() ((double)arr).Should().BeApproximately(3.14, 0.001); } - [Test] + [TestMethod] public void Array_ScalarBoolTrue_Creates0DimArray() { var arr = np.array(true); @@ -56,7 +57,7 @@ public void Array_ScalarBoolTrue_Creates0DimArray() ((bool)arr).Should().BeTrue(); } - [Test] + [TestMethod] public void Array_ScalarBoolFalse_Creates0DimArray() { var arr = np.array(false); @@ -64,7 +65,7 @@ public void Array_ScalarBoolFalse_Creates0DimArray() ((bool)arr).Should().BeFalse(); } - [Test] + [TestMethod] public void Array_ScalarNegative_Creates0DimArray() { var arr = np.array(-99); @@ -72,7 +73,7 @@ public void Array_ScalarNegative_Creates0DimArray() ((int)arr).Should().Be(-99); } - [Test] + [TestMethod] public void Array_ScalarZero_Creates0DimArray() { var arr = np.array(0); @@ -80,7 +81,7 @@ public void Array_ScalarZero_Creates0DimArray() ((int)arr).Should().Be(0); } - [Test] + [TestMethod] public void Array_ScalarLargeValue_Creates0DimArray() { var arr = np.array(long.MaxValue); @@ -92,7 +93,7 @@ public void Array_ScalarLargeValue_Creates0DimArray() #region 1D Arrays - [Test] + [TestMethod] public void Array_1DInt32_CreatesVector() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -101,7 +102,7 @@ public void Array_1DInt32_CreatesVector() arr.dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void Array_1DInt64_CreatesVector() { var arr = np.array(new long[] { 1, 2, 3 }); @@ -110,7 +111,7 @@ public void Array_1DInt64_CreatesVector() arr.dtype.Should().Be(typeof(long)); } - [Test] + [TestMethod] public void Array_1DFloat32_CreatesVector() { var arr = np.array(new float[] { 1f, 2f, 3f }); @@ -118,7 +119,7 @@ public void Array_1DFloat32_CreatesVector() arr.dtype.Should().Be(typeof(float)); } - [Test] + [TestMethod] public void Array_1DFloat64_CreatesVector() { var arr = np.array(new double[] { 1.0, 2.0, 3.0 }); @@ -126,7 +127,7 @@ public void Array_1DFloat64_CreatesVector() arr.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Array_1DBool_CreatesVector() { var arr = np.array(new bool[] { true, false, true }); @@ -135,7 +136,7 @@ public void Array_1DBool_CreatesVector() arr.dtype.Should().Be(typeof(bool)); } - [Test] + [TestMethod] public void Array_1DSingleElement_CreatesVector() { // NumPy: np.array([42]) creates shape=(1,), ndim=1 @@ -144,7 +145,7 @@ public void Array_1DSingleElement_CreatesVector() arr.shape.Should().BeEquivalentTo(new[] { 1 }); } - [Test] + [TestMethod] public void Array_1DEmpty_CreatesEmptyVector() { var arr = np.array(new int[0]); @@ -153,7 +154,7 @@ public void Array_1DEmpty_CreatesEmptyVector() arr.size.Should().Be(0); } - [Test] + [TestMethod] public void Array_1DNegative_CreatesVector() { var arr = np.array(new int[] { -1, -2, -3 }); @@ -165,7 +166,7 @@ public void Array_1DNegative_CreatesVector() #region 2D Arrays - [Test] + [TestMethod] public void Array_2DInt32_CreatesMatrix() { var arr = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); @@ -174,7 +175,7 @@ public void Array_2DInt32_CreatesMatrix() arr.dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void Array_2DDouble_CreatesMatrix() { var arr = np.array(new double[,] { { 1.0, 2.0 }, { 3.0, 4.0 } }); @@ -183,7 +184,7 @@ public void Array_2DDouble_CreatesMatrix() arr.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Array_2DSingleRow_CreatesMatrix() { var arr = np.array(new int[,] { { 1, 2, 3 } }); @@ -191,7 +192,7 @@ public void Array_2DSingleRow_CreatesMatrix() arr.shape.Should().BeEquivalentTo(new[] { 1, 3 }); } - [Test] + [TestMethod] public void Array_2DSingleCol_CreatesMatrix() { var arr = np.array(new int[,] { { 1 }, { 2 }, { 3 } }); @@ -199,7 +200,7 @@ public void Array_2DSingleCol_CreatesMatrix() arr.shape.Should().BeEquivalentTo(new[] { 3, 1 }); } - [Test] + [TestMethod] public void Array_2D1x1_CreatesMatrix() { var arr = np.array(new int[,] { { 42 } }); @@ -211,7 +212,7 @@ public void Array_2D1x1_CreatesMatrix() #region 3D+ Arrays - [Test] + [TestMethod] public void Array_3D_CreatesTensor() { var arr = np.array(new int[,,] { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } }); @@ -219,7 +220,7 @@ public void Array_3D_CreatesTensor() arr.shape.Should().BeEquivalentTo(new[] { 2, 2, 2 }); } - [Test] + [TestMethod] public void Array_4D_CreatesTensor() { var arr = np.array(new int[,,,] { { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } } }); @@ -231,7 +232,7 @@ public void Array_4D_CreatesTensor() #region Jagged Arrays - [Test] + [TestMethod] public void Array_2DJagged_CreatesMatrix() { var arr = np.array(new int[][] { new[] { 1, 2 }, new[] { 3, 4 } }); @@ -239,7 +240,7 @@ public void Array_2DJagged_CreatesMatrix() arr.shape.Should().BeEquivalentTo(new[] { 2, 2 }); } - [Test] + [TestMethod] public void Array_3DJagged_CreatesTensor() { var arr = np.array(new int[][][] { @@ -254,7 +255,7 @@ public void Array_3DJagged_CreatesTensor() #region ndmin Parameter - [Test] + [TestMethod] public void Array_Ndmin1_On1DArray_NoChange() { var arr = np.array(new int[] { 1, 2, 3 }, ndmin: 1); @@ -262,7 +263,7 @@ public void Array_Ndmin1_On1DArray_NoChange() arr.shape.Should().BeEquivalentTo(new[] { 3 }); } - [Test] + [TestMethod] public void Array_Ndmin2_On1DArray_AddsLeadingDim() { // NumPy: np.array([1,2,3], ndmin=2) -> shape (1, 3) @@ -271,7 +272,7 @@ public void Array_Ndmin2_On1DArray_AddsLeadingDim() arr.shape.Should().BeEquivalentTo(new[] { 1, 3 }); } - [Test] + [TestMethod] public void Array_Ndmin3_On1DArray_AddsTwoLeadingDims() { // NumPy: np.array([1,2,3], ndmin=3) -> shape (1, 1, 3) @@ -280,7 +281,7 @@ public void Array_Ndmin3_On1DArray_AddsTwoLeadingDims() arr.shape.Should().BeEquivalentTo(new[] { 1, 1, 3 }); } - [Test] + [TestMethod] public void Array_Ndmin3_On2DArray_AddsOneLeadingDim() { // NumPy: np.array([[1,2],[3,4]], ndmin=3) -> shape (1, 2, 2) @@ -289,7 +290,7 @@ public void Array_Ndmin3_On2DArray_AddsOneLeadingDim() arr.shape.Should().BeEquivalentTo(new[] { 1, 2, 2 }); } - [Test] + [TestMethod] public void Array_Ndmin1_On2DArray_NoChange() { var arr = np.array(new int[,] { { 1, 2 }, { 3, 4 } }, ndmin: 1); @@ -301,7 +302,7 @@ public void Array_Ndmin1_On2DArray_NoChange() #region From Existing NDArray - [Test] + [TestMethod] public void Array_FromNDArray_DefaultCopyFalse_SharesMemory() { var original = np.array(new int[] { 1, 2, 3 }); @@ -311,7 +312,7 @@ public void Array_FromNDArray_DefaultCopyFalse_SharesMemory() original.GetInt32(0).Should().Be(999, "copy=false should share memory"); } - [Test] + [TestMethod] public void Array_FromNDArray_CopyTrue_Independent() { var original = np.array(new int[] { 1, 2, 3 }); @@ -321,7 +322,7 @@ public void Array_FromNDArray_CopyTrue_Independent() original.GetInt32(0).Should().Be(1, "copy=true should not affect original"); } - [Test] + [TestMethod] public void Array_FromNDArray_PreservesShape() { var original = np.arange(6).reshape(2, 3); @@ -333,7 +334,7 @@ public void Array_FromNDArray_PreservesShape() #region Params Syntax - [Test] + [TestMethod] public void Array_ParamsMultipleValues_Creates1DArray() { var arr = np.array(1, 2, 3); @@ -345,7 +346,7 @@ public void Array_ParamsMultipleValues_Creates1DArray() #region Special Values - [Test] + [TestMethod] public void Array_WithInfinity_Preserved() { var arr = np.array(new double[] { 1, double.PositiveInfinity, double.NegativeInfinity }); @@ -353,7 +354,7 @@ public void Array_WithInfinity_Preserved() arr.GetDouble(2).Should().Be(double.NegativeInfinity); } - [Test] + [TestMethod] public void Array_WithNaN_Preserved() { var arr = np.array(new double[] { 1, double.NaN, 2 }); @@ -364,7 +365,7 @@ public void Array_WithNaN_Preserved() #region Edge Cases - [Test] + [TestMethod] public void Array_EmptyInt_CreatesEmptyWithCorrectDtype() { var arr = np.array(new int[0]); @@ -372,7 +373,7 @@ public void Array_EmptyInt_CreatesEmptyWithCorrectDtype() arr.dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void Array_EmptyDouble_CreatesEmptyWithCorrectDtype() { var arr = np.array(new double[0]); @@ -380,7 +381,7 @@ public void Array_EmptyDouble_CreatesEmptyWithCorrectDtype() arr.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Array_EmptyBool_CreatesEmptyWithCorrectDtype() { var arr = np.array(new bool[0]); @@ -388,7 +389,7 @@ public void Array_EmptyBool_CreatesEmptyWithCorrectDtype() arr.dtype.Should().Be(typeof(bool)); } - [Test] + [TestMethod] public void Array_String_CreatesCharArray() { // NumSharp-specific: string creates char array @@ -402,35 +403,35 @@ public void Array_String_CreatesCharArray() #region All Supported Dtypes - [Test] + [TestMethod] public void Array_Byte_Supported() { var arr = np.array(new byte[] { 1, 2, 3 }); arr.dtype.Should().Be(typeof(byte)); } - [Test] + [TestMethod] public void Array_Int16_Supported() { var arr = np.array(new short[] { 1, 2, 3 }); arr.dtype.Should().Be(typeof(short)); } - [Test] + [TestMethod] public void Array_UInt16_Supported() { var arr = np.array(new ushort[] { 1, 2, 3 }); arr.dtype.Should().Be(typeof(ushort)); } - [Test] + [TestMethod] public void Array_UInt32_Supported() { var arr = np.array(new uint[] { 1, 2, 3 }); arr.dtype.Should().Be(typeof(uint)); } - [Test] + [TestMethod] public void Array_UInt64_Supported() { var arr = np.array(new ulong[] { 1, 2, 3 }); diff --git a/test/NumSharp.UnitTest/Creation/np.array.Tests.cs b/test/NumSharp.UnitTest/Creation/np.array.Tests.cs index e4d6cdd28..b9aee76d6 100644 --- a/test/NumSharp.UnitTest/Creation/np.array.Tests.cs +++ b/test/NumSharp.UnitTest/Creation/np.array.Tests.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class np_array_tests { - [Test] + [TestMethod] public void nparray_1d() { var v = np.array(new int[] {1, 2, 3, 4, 5, 6, 7, 8}); @@ -16,7 +17,7 @@ public void nparray_1d() v.size.Should().Be(8); } - [Test] + [TestMethod] public void nparray_params() { var v = np.array(1, 2, 3, 4, 5, 6, 7, 8); @@ -25,7 +26,7 @@ public void nparray_params() v.size.Should().Be(8); } - [Test] + [TestMethod] public void nparray_1d_typeless() { var v = np.array((Array)new int[] {1, 2, 3, 4, 5, 6, 7, 8}); @@ -34,7 +35,7 @@ public void nparray_1d_typeless() v.size.Should().Be(8); } - [Test] + [TestMethod] public void nparray_3d_jagged() { var v = np.array((Array)new int[,] {{1, 2, 3, 4}, {5, 6, 7, 8}}); @@ -43,7 +44,7 @@ public void nparray_3d_jagged() v.size.Should().Be(8); } - [Test] + [TestMethod] public void nparray_1d_typeless_knowntype() { var v = np.array(new int[] {1, 2, 3, 4, 5, 6, 7, 8}); @@ -52,7 +53,7 @@ public void nparray_1d_typeless_knowntype() v.size.Should().Be(8); } - [Test] + [TestMethod] public void nparray_3d_jagged_knowntype() { var v = np.array(new int[,] {{1, 2, 3, 4}, {5, 6, 7, 8}}); @@ -61,7 +62,7 @@ public void nparray_3d_jagged_knowntype() v.size.Should().Be(8); } - [Test] + [TestMethod] public void nparray_3d_typeless() { // @formatter:off — disable formatter after this line @@ -81,7 +82,7 @@ public void nparray_3d_typeless() v.size.Should().Be(8); } - [Test] + [TestMethod] public void nparray_2d() { var v = np.array(new int[][] {new int[] {1, 2, 3, 4}, new int[] {5, 6, 7, 8}}); @@ -90,7 +91,7 @@ public void nparray_2d() v.size.Should().Be(8); } - [Test] + [TestMethod] public void nparray_3d() { // @formatter:off — disable formatter after this line @@ -110,7 +111,7 @@ public void nparray_3d() v.size.Should().Be(8); } - [Test] + [TestMethod] public void nparray_4d() { // @formatter:off — disable formatter after this line @@ -135,7 +136,7 @@ public void nparray_4d() v.size.Should().Be(8); } - [Test] + [TestMethod] public void Arrays_Concat() { var a = new int[] {1, 2, 3}; @@ -144,7 +145,7 @@ public void Arrays_Concat() r.Should().ContainInOrder(1, 2, 3, 4, 5, 6); } - [Test] + [TestMethod] public void Array_Copy() { var arr = new int[,] {{1, 2, 3}, {4, 5, 6}}; @@ -152,7 +153,7 @@ public void Array_Copy() np.array(arr, copy: false).Should().BeShaped(2, 3).And.BeOfValues(1, 2, 3, 4, 5, 6); } - [Test] + [TestMethod] public void Array_NonCopy() { var arr = new int[,] {{1, 2, 3}, {4, 5, 6}}; @@ -162,7 +163,7 @@ public void Array_NonCopy() nd[0, 2].Should().BeOfValues(0); } - [Test] + [TestMethod] public void Array_Jagged() { var arr = new int[][] {new int[] {1, 2, 3}, new int[] {4, 5, 6}}; diff --git a/test/NumSharp.UnitTest/Creation/np.broadcast.Tests.cs b/test/NumSharp.UnitTest/Creation/np.broadcast.Tests.cs index 9c993a11d..b6fc3450d 100644 --- a/test/NumSharp.UnitTest/Creation/np.broadcast.Tests.cs +++ b/test/NumSharp.UnitTest/Creation/np.broadcast.Tests.cs @@ -11,9 +11,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class BroadcastTests { - [Test] + [TestMethod] public void BroadcastArrayTest() { var arr1 = new int[][] {new int[] {1, 2, 3}}; @@ -36,7 +37,7 @@ public void BroadcastArrayTest() /// /// Taken from https://numpy.org/doc/stable/user/basics.broadcasting.html /// - [Test] + [TestMethod] public void basics_ResolveReturnShape() { Shape arrOne; @@ -75,7 +76,7 @@ public void basics_ResolveReturnShape() /// /// Taken from https://numpy.org/doc/stable/user/basics.broadcasting.html /// - [Test] + [TestMethod] public void basics_broadcasting() { (Shape LeftShape, Shape RightShape) ret; @@ -142,7 +143,7 @@ public void basics_broadcasting() /// /// Taken from https://numpy.org/doc/stable/user/basics.broadcasting.html /// - [Test] + [TestMethod] public void basics_broadcasting_narrays() { Shape[] ret; @@ -204,7 +205,7 @@ public void basics_broadcasting_narrays() new Action(() => DefaultEngine.ResolveReturnShape(new Shape(2, 1), new Shape(8, 4, 3))).Should().Throw(); } - [Test] + [TestMethod] public void broadcast_accessing() { // np.arange returns int64 by default (NumPy 2.x) diff --git a/test/NumSharp.UnitTest/Creation/np.concatenate.Test.cs b/test/NumSharp.UnitTest/Creation/np.concatenate.Test.cs index c047a6fbc..5599b2ed2 100644 --- a/test/NumSharp.UnitTest/Creation/np.concatenate.Test.cs +++ b/test/NumSharp.UnitTest/Creation/np.concatenate.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class np_concatenate_test : TestClass { - [Test] + [TestMethod] public void Case1_Axis1() { var a = np.full(new Shape(3, 1, 3), 1, NPTypeCode.Int32); @@ -25,7 +26,7 @@ public void Case1_Axis1() c[":, 2, :"].flat.Cast().Should().AllBeEquivalentTo(2); } - [Test] + [TestMethod] public void Case1_Axis1_Cast() { var a = np.full(new Shape(3, 1, 3), 1, NPTypeCode.Int32); @@ -40,7 +41,7 @@ public void Case1_Axis1_Cast() c[":, 2, :"].flat.Cast().Should().AllBeEquivalentTo(2); } - [Test] + [TestMethod] public void Case1_Axis0() { var a = np.full(new Shape(1, 3, 3), 1, NPTypeCode.Int32); @@ -54,7 +55,7 @@ public void Case1_Axis0() c["2, :, :"].flat.Cast().Should().AllBeEquivalentTo(2); } - [Test] + [TestMethod] public void Case1_Axis2() { var a = np.full(new Shape(3, 3, 1), 1, NPTypeCode.Int32); @@ -68,7 +69,7 @@ public void Case1_Axis2() c[":, :, 2"].flat.Cast().Should().AllBeEquivalentTo(2); } - [Test] + [TestMethod] public void Case1_Axis_minus1() { var a = np.full(new Shape(3, 3, 1), 1, NPTypeCode.Int32); @@ -82,7 +83,7 @@ public void Case1_Axis_minus1() c[":, :, 2"].flat.Cast().Should().AllBeEquivalentTo(2); } - [Test] + [TestMethod] public void Case2_Axis1_3Arrays_Cast() { var a = np.full(new Shape(3, 1, 3), 1, NPTypeCode.Int32); @@ -103,7 +104,7 @@ public void Case2_Axis1_3Arrays_Cast() /// NumPy: np.hstack([np.broadcast_to([[1],[2]],(2,2)), np.broadcast_to([[3],[4]],(2,3))]) /// → [[1,1,3,3,3], [2,2,4,4,4]] /// - [Test] + [TestMethod] public void Hstack_BroadcastColumnVectors() { var a = np.broadcast_to(np.array(new int[,] { { 1 }, { 2 } }), new Shape(2, 2)); @@ -124,7 +125,7 @@ public void Hstack_BroadcastColumnVectors() /// np.vstack([np.broadcast_to(x[:,0:1],(3,3)), [[10,20,30]]]) /// → [[0,0,0], [2,2,2], [4,4,4], [10,20,30]] /// - [Test] + [TestMethod] public void Vstack_SlicedBroadcast() { var x = np.arange(6).reshape(3, 2); @@ -148,7 +149,7 @@ public void Vstack_SlicedBroadcast() /// np.concatenate([np.broadcast_to(x[:,1:2],(3,3)), np.ones((1,3),dtype=int)]) /// → [[1,1,1], [5,5,5], [9,9,9], [1,1,1]] /// - [Test] + [TestMethod] public void Concatenate_SlicedBroadcast_Axis0() { var x = np.arange(12).reshape(3, 4); diff --git a/test/NumSharp.UnitTest/Creation/np.creation.Test.cs b/test/NumSharp.UnitTest/Creation/np.creation.Test.cs index 139c7db86..0ff7a635a 100644 --- a/test/NumSharp.UnitTest/Creation/np.creation.Test.cs +++ b/test/NumSharp.UnitTest/Creation/np.creation.Test.cs @@ -8,16 +8,17 @@ namespace NumSharp.UnitTest.APIs { + [TestClass] public class ApiCreationTest : TestClass { - [Test] + [TestMethod] public void arange() { var nd = np.arange(3); AssertAreEqual(nd.Data(), new int[] {0, 1, 2}); } - [Test] + [TestMethod] public void ndarray() { var x = np.ndarray((2, 3), dtype: np.int32, order: 'C'); @@ -25,7 +26,7 @@ public void ndarray() x.flat.Cast().Should().AllBeEquivalentTo(0); } - [Test] + [TestMethod] public void ReshapeDoesNotSelfModify() { var x = np.arange(9); diff --git a/test/NumSharp.UnitTest/Creation/np.dtype.Test.cs b/test/NumSharp.UnitTest/Creation/np.dtype.Test.cs index a1bc09771..5387bd10e 100644 --- a/test/NumSharp.UnitTest/Creation/np.dtype.Test.cs +++ b/test/NumSharp.UnitTest/Creation/np.dtype.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class np_dtype_tests { - [Test] + [TestMethod] public void Case1() { np.dtype("?").type.Should().Be(); diff --git a/test/NumSharp.UnitTest/Creation/np.empty.Test.cs b/test/NumSharp.UnitTest/Creation/np.empty.Test.cs index 28be5cd23..2b133c07d 100644 --- a/test/NumSharp.UnitTest/Creation/np.empty.Test.cs +++ b/test/NumSharp.UnitTest/Creation/np.empty.Test.cs @@ -7,10 +7,11 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class np_empty_Test { - [Test] + [TestMethod] public void Empty_Like() { var a = np.zeros((10, 10)); @@ -20,7 +21,7 @@ public void Empty_Like() alike.Array.GetIndex(0).GetType().Should().Be(); } - [Test] + [TestMethod] public void SimpleInt1D() { var np1 = np.empty(new Shape(5)); @@ -31,7 +32,7 @@ public void SimpleInt1D() } - [Test] + [TestMethod] public void SimpleDouble3D() { var np1 = np.empty(new Shape(5, 5, 5)); @@ -39,20 +40,20 @@ public void SimpleDouble3D() np1.dtype.Should().Be(); } - [Test] - [Arguments(typeof(double))] - [Arguments(typeof(float))] - [Arguments(typeof(byte))] - [Arguments(typeof(int))] - [Arguments(typeof(long))] - [Arguments(typeof(char))] - [Arguments(typeof(short))] - [Arguments(typeof(uint))] - [Arguments(typeof(ulong))] - [Arguments(typeof(ushort))] - [Arguments(typeof(decimal))] - //TODO! [Arguments(typeof(Complex))] - [Arguments(typeof(bool))] + [TestMethod] + [DataRow(typeof(double))] + [DataRow(typeof(float))] + [DataRow(typeof(byte))] + [DataRow(typeof(int))] + [DataRow(typeof(long))] + [DataRow(typeof(char))] + [DataRow(typeof(short))] + [DataRow(typeof(uint))] + [DataRow(typeof(ulong))] + [DataRow(typeof(ushort))] + [DataRow(typeof(decimal))] + //TODO! [DataRow(typeof(Complex))] + [DataRow(typeof(bool))] public void Empty_AllTypes(Type dtype) { var np1 = np.empty(new Shape(3, 3, 3), dtype); diff --git a/test/NumSharp.UnitTest/Creation/np.empty_like.Test.cs b/test/NumSharp.UnitTest/Creation/np.empty_like.Test.cs index f7084b698..a8cb006e4 100644 --- a/test/NumSharp.UnitTest/Creation/np.empty_like.Test.cs +++ b/test/NumSharp.UnitTest/Creation/np.empty_like.Test.cs @@ -20,13 +20,14 @@ namespace NumSharp.UnitTest.Creation /// - Content is uninitialized (no zeroing guarantee) /// - Since NumSharp is C-order only, result is always C-contiguous /// + [TestClass] public class np_empty_like_Test { // ========================================================== // 1. BASIC: shape and dtype preservation // ========================================================== - [Test] + [TestMethod] public void Basic_1D_Int32_PreservesShapeAndDtype() { // NumPy: np.empty_like(np.arange(5, dtype='int32')) → shape=(5,), dtype=int32 @@ -37,7 +38,7 @@ public void Basic_1D_Int32_PreservesShapeAndDtype() r.ndim.Should().Be(1); } - [Test] + [TestMethod] public void Basic_2D_Float64_PreservesShapeAndDtype() { // NumPy: np.empty_like(np.arange(6, dtype='float64').reshape(2,3)) → shape=(2,3), dtype=float64 @@ -48,7 +49,7 @@ public void Basic_2D_Float64_PreservesShapeAndDtype() r.ndim.Should().Be(2); } - [Test] + [TestMethod] public void Basic_3D_PreservesShapeAndDtype() { // NumPy: np.empty_like(np.arange(24).reshape(2,3,4)) → shape=(2,3,4) @@ -58,7 +59,7 @@ public void Basic_3D_PreservesShapeAndDtype() r.ndim.Should().Be(3); } - [Test] + [TestMethod] public void Basic_4D_PreservesShapeAndDtype() { // NumPy: np.empty_like(np.arange(120).reshape(2,3,4,5)) → shape=(2,3,4,5) @@ -68,7 +69,7 @@ public void Basic_4D_PreservesShapeAndDtype() r.ndim.Should().Be(4); } - [Test] + [TestMethod] public void Basic_Scalar_PreservesScalarShape() { // NumPy: np.empty_like(np.array(3.14)) → shape=(), dtype=float64, ndim=0 @@ -80,7 +81,7 @@ public void Basic_Scalar_PreservesScalarShape() r.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Basic_SingleElement_PreservesShape() { // NumPy: np.empty_like(np.array([42], dtype='int32')) → shape=(1,), dtype=int32 @@ -94,7 +95,7 @@ public void Basic_SingleElement_PreservesShape() // 2. DTYPE OVERRIDE (Type overload) // ========================================================== - [Test] + [TestMethod] public void DtypeOverride_Int32ToFloat32() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -103,7 +104,7 @@ public void DtypeOverride_Int32ToFloat32() r.dtype.Should().Be(typeof(float), "dtype overridden"); } - [Test] + [TestMethod] public void DtypeOverride_Int32ToFloat64() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -112,7 +113,7 @@ public void DtypeOverride_Int32ToFloat64() r.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void DtypeOverride_Int32ToInt64() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -121,7 +122,7 @@ public void DtypeOverride_Int32ToInt64() r.dtype.Should().Be(typeof(long)); } - [Test] + [TestMethod] public void DtypeOverride_Int32ToInt16() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -130,7 +131,7 @@ public void DtypeOverride_Int32ToInt16() r.dtype.Should().Be(typeof(short)); } - [Test] + [TestMethod] public void DtypeOverride_Int32ToByte() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -139,7 +140,7 @@ public void DtypeOverride_Int32ToByte() r.dtype.Should().Be(typeof(byte)); } - [Test] + [TestMethod] public void DtypeOverride_Int32ToBool() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -148,7 +149,7 @@ public void DtypeOverride_Int32ToBool() r.dtype.Should().Be(typeof(bool)); } - [Test] + [TestMethod] public void DtypeOverride_Float64ToDecimal() { var a = np.arange(4).astype(np.float64).reshape(2, 2); @@ -157,7 +158,7 @@ public void DtypeOverride_Float64ToDecimal() r.dtype.Should().Be(typeof(decimal)); } - [Test] + [TestMethod] public void DtypeOverride_NullDtype_PreservesOriginal() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -169,7 +170,7 @@ public void DtypeOverride_NullDtype_PreservesOriginal() // 3. NPTypeCode OVERLOAD // ========================================================== - [Test] + [TestMethod] public void NPTypeCode_Overload_Float32() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -178,7 +179,7 @@ public void NPTypeCode_Overload_Float32() r.dtype.Should().Be(typeof(float)); } - [Test] + [TestMethod] public void NPTypeCode_Overload_Float64() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -187,7 +188,7 @@ public void NPTypeCode_Overload_Float64() r.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void NPTypeCode_Overload_Boolean() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -196,7 +197,7 @@ public void NPTypeCode_Overload_Boolean() r.dtype.Should().Be(typeof(bool)); } - [Test] + [TestMethod] public void NPTypeCode_Overload_Int64() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -205,7 +206,7 @@ public void NPTypeCode_Overload_Int64() r.dtype.Should().Be(typeof(long)); } - [Test] + [TestMethod] public void NPTypeCode_Overload_Byte() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -214,19 +215,19 @@ public void NPTypeCode_Overload_Byte() r.dtype.Should().Be(typeof(byte)); } - [Test] - [Arguments(NPTypeCode.Boolean, typeof(bool), DisplayName = "NPTypeCode_Boolean")] - [Arguments(NPTypeCode.Byte, typeof(byte), DisplayName = "NPTypeCode_Byte")] - [Arguments(NPTypeCode.Int16, typeof(short), DisplayName = "NPTypeCode_Int16")] - [Arguments(NPTypeCode.UInt16, typeof(ushort), DisplayName = "NPTypeCode_UInt16")] - [Arguments(NPTypeCode.Int32, typeof(int), DisplayName = "NPTypeCode_Int32")] - [Arguments(NPTypeCode.UInt32, typeof(uint), DisplayName = "NPTypeCode_UInt32")] - [Arguments(NPTypeCode.Int64, typeof(long), DisplayName = "NPTypeCode_Int64")] - [Arguments(NPTypeCode.UInt64, typeof(ulong), DisplayName = "NPTypeCode_UInt64")] - [Arguments(NPTypeCode.Char, typeof(char), DisplayName = "NPTypeCode_Char")] - [Arguments(NPTypeCode.Single, typeof(float), DisplayName = "NPTypeCode_Single")] - [Arguments(NPTypeCode.Double, typeof(double), DisplayName = "NPTypeCode_Double")] - [Arguments(NPTypeCode.Decimal, typeof(decimal), DisplayName = "NPTypeCode_Decimal")] + [TestMethod] + [DataRow(NPTypeCode.Boolean, typeof(bool), DisplayName = "NPTypeCode_Boolean")] + [DataRow(NPTypeCode.Byte, typeof(byte), DisplayName = "NPTypeCode_Byte")] + [DataRow(NPTypeCode.Int16, typeof(short), DisplayName = "NPTypeCode_Int16")] + [DataRow(NPTypeCode.UInt16, typeof(ushort), DisplayName = "NPTypeCode_UInt16")] + [DataRow(NPTypeCode.Int32, typeof(int), DisplayName = "NPTypeCode_Int32")] + [DataRow(NPTypeCode.UInt32, typeof(uint), DisplayName = "NPTypeCode_UInt32")] + [DataRow(NPTypeCode.Int64, typeof(long), DisplayName = "NPTypeCode_Int64")] + [DataRow(NPTypeCode.UInt64, typeof(ulong), DisplayName = "NPTypeCode_UInt64")] + [DataRow(NPTypeCode.Char, typeof(char), DisplayName = "NPTypeCode_Char")] + [DataRow(NPTypeCode.Single, typeof(float), DisplayName = "NPTypeCode_Single")] + [DataRow(NPTypeCode.Double, typeof(double), DisplayName = "NPTypeCode_Double")] + [DataRow(NPTypeCode.Decimal, typeof(decimal), DisplayName = "NPTypeCode_Decimal")] public void NPTypeCode_Overload_All12Types(NPTypeCode typeCode, Type expectedType) { var a = np.arange(4).reshape(2, 2); @@ -235,7 +236,7 @@ public void NPTypeCode_Overload_All12Types(NPTypeCode typeCode, Type expectedTyp r.shape.Should().BeEquivalentTo(new long[] { 2, 2 }); } - [Test] + [TestMethod] public void NPTypeCode_Overload_WithShapeOverride() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -248,19 +249,19 @@ public void NPTypeCode_Overload_WithShapeOverride() // 4. ALL 12 DTYPES preserved (Type overload, no dtype override) // ========================================================== - [Test] - [Arguments(typeof(bool), DisplayName = "Boolean")] - [Arguments(typeof(byte), DisplayName = "Byte")] - [Arguments(typeof(short), DisplayName = "Int16")] - [Arguments(typeof(ushort), DisplayName = "UInt16")] - [Arguments(typeof(int), DisplayName = "Int32")] - [Arguments(typeof(uint), DisplayName = "UInt32")] - [Arguments(typeof(long), DisplayName = "Int64")] - [Arguments(typeof(ulong), DisplayName = "UInt64")] - [Arguments(typeof(char), DisplayName = "Char")] - [Arguments(typeof(float), DisplayName = "Single")] - [Arguments(typeof(double), DisplayName = "Double")] - [Arguments(typeof(decimal), DisplayName = "Decimal")] + [TestMethod] + [DataRow(typeof(bool), DisplayName = "Boolean")] + [DataRow(typeof(byte), DisplayName = "Byte")] + [DataRow(typeof(short), DisplayName = "Int16")] + [DataRow(typeof(ushort), DisplayName = "UInt16")] + [DataRow(typeof(int), DisplayName = "Int32")] + [DataRow(typeof(uint), DisplayName = "UInt32")] + [DataRow(typeof(long), DisplayName = "Int64")] + [DataRow(typeof(ulong), DisplayName = "UInt64")] + [DataRow(typeof(char), DisplayName = "Char")] + [DataRow(typeof(float), DisplayName = "Single")] + [DataRow(typeof(double), DisplayName = "Double")] + [DataRow(typeof(decimal), DisplayName = "Decimal")] public void AllDtypes_Preserved(Type dtype) { var a = np.ones(new Shape(3), dtype); @@ -269,19 +270,19 @@ public void AllDtypes_Preserved(Type dtype) r.shape.Should().BeEquivalentTo(new long[] { 3 }); } - [Test] - [Arguments(typeof(bool), DisplayName = "Boolean_2D")] - [Arguments(typeof(byte), DisplayName = "Byte_2D")] - [Arguments(typeof(short), DisplayName = "Int16_2D")] - [Arguments(typeof(ushort), DisplayName = "UInt16_2D")] - [Arguments(typeof(int), DisplayName = "Int32_2D")] - [Arguments(typeof(uint), DisplayName = "UInt32_2D")] - [Arguments(typeof(long), DisplayName = "Int64_2D")] - [Arguments(typeof(ulong), DisplayName = "UInt64_2D")] - [Arguments(typeof(char), DisplayName = "Char_2D")] - [Arguments(typeof(float), DisplayName = "Single_2D")] - [Arguments(typeof(double), DisplayName = "Double_2D")] - [Arguments(typeof(decimal), DisplayName = "Decimal_2D")] + [TestMethod] + [DataRow(typeof(bool), DisplayName = "Boolean_2D")] + [DataRow(typeof(byte), DisplayName = "Byte_2D")] + [DataRow(typeof(short), DisplayName = "Int16_2D")] + [DataRow(typeof(ushort), DisplayName = "UInt16_2D")] + [DataRow(typeof(int), DisplayName = "Int32_2D")] + [DataRow(typeof(uint), DisplayName = "UInt32_2D")] + [DataRow(typeof(long), DisplayName = "Int64_2D")] + [DataRow(typeof(ulong), DisplayName = "UInt64_2D")] + [DataRow(typeof(char), DisplayName = "Char_2D")] + [DataRow(typeof(float), DisplayName = "Single_2D")] + [DataRow(typeof(double), DisplayName = "Double_2D")] + [DataRow(typeof(decimal), DisplayName = "Decimal_2D")] public void AllDtypes_2D_Preserved(Type dtype) { var a = np.ones(new Shape(2, 3), dtype); @@ -294,7 +295,7 @@ public void AllDtypes_2D_Preserved(Type dtype) // 5. EMPTY ARRAYS (zero-size dimensions) // ========================================================== - [Test] + [TestMethod] public void Empty_1D_ZeroElements() { // NumPy: np.empty_like(np.array([], dtype='float64')) → shape=(0,), size=0 @@ -305,7 +306,7 @@ public void Empty_1D_ZeroElements() r.size.Should().Be(0); } - [Test] + [TestMethod] public void Empty_2D_ZeroRows() { // NumPy: np.empty_like(np.empty((0,3), dtype='int32')) → shape=(0,3), size=0 @@ -316,7 +317,7 @@ public void Empty_2D_ZeroRows() r.size.Should().Be(0); } - [Test] + [TestMethod] public void Empty_2D_ZeroCols() { // NumPy: np.empty_like(np.empty((3,0), dtype='int32')) → shape=(3,0), size=0 @@ -327,7 +328,7 @@ public void Empty_2D_ZeroCols() r.size.Should().Be(0); } - [Test] + [TestMethod] public void Empty_3D_ZeroMiddleDim() { // NumPy: np.empty_like(np.empty((2,0,4), dtype='float32')) → shape=(2,0,4), size=0 @@ -342,7 +343,7 @@ public void Empty_3D_ZeroMiddleDim() // 6. SLICED PROTOTYPES // ========================================================== - [Test] + [TestMethod] public void Sliced_1D_Contiguous() { // NumPy: np.empty_like(np.arange(10)[2:7]) → shape=(5,), C-contiguous @@ -356,7 +357,7 @@ public void Sliced_1D_Contiguous() r.ndim.Should().Be(1); } - [Test] + [TestMethod] public void Sliced_1D_Stepped() { // NumPy: np.empty_like(np.arange(10)[::2]) → shape=(5,), C-contiguous @@ -369,7 +370,7 @@ public void Sliced_1D_Stepped() r.dtype.Should().Be(a.dtype); } - [Test] + [TestMethod] public void Sliced_2D_RowSlice() { // NumPy: np.empty_like(np.arange(12).reshape(3,4)[1:3]) → shape=(2,4) @@ -382,7 +383,7 @@ public void Sliced_2D_RowSlice() r.dtype.Should().Be(a.dtype); } - [Test] + [TestMethod] public void Sliced_2D_ColumnSlice() { // NumPy: np.empty_like(np.arange(12).reshape(3,4)[:,1:3]) → shape=(3,2), C-contiguous @@ -395,7 +396,7 @@ public void Sliced_2D_ColumnSlice() r.dtype.Should().Be(a.dtype); } - [Test] + [TestMethod] public void Sliced_ReversedSlice() { // NumPy: np.empty_like(np.arange(5)[::-1]) → shape=(5,) @@ -411,7 +412,7 @@ public void Sliced_ReversedSlice() // 7. BROADCAST PROTOTYPES // ========================================================== - [Test] + [TestMethod] public void Broadcast_RowVector() { // NumPy: np.empty_like(np.broadcast_to([1,2,3], (4,3))) → shape=(4,3), writeable @@ -425,7 +426,7 @@ public void Broadcast_RowVector() r.size.Should().Be(12); } - [Test] + [TestMethod] public void Broadcast_ScalarToMatrix() { // NumPy: np.empty_like(np.broadcast_to(5, (3,4))) → shape=(3,4) @@ -438,7 +439,7 @@ public void Broadcast_ScalarToMatrix() r.dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void Broadcast_ColumnVector() { // np.broadcast_to(np.array([[10],[20],[30]]), (3,3)) @@ -451,7 +452,7 @@ public void Broadcast_ColumnVector() r.dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void Broadcast_WithDtypeOverride() { var a = np.array(new int[] { 1, 2, 3 }); @@ -466,7 +467,7 @@ public void Broadcast_WithDtypeOverride() // 8. TRANSPOSED PROTOTYPES // ========================================================== - [Test] + [TestMethod] public void Transposed_2D() { // NumPy: np.empty_like(np.arange(6).reshape(2,3).T) → shape=(3,2) @@ -483,7 +484,7 @@ public void Transposed_2D() // 9. MEMORY INDEPENDENCE — result never shares memory // ========================================================== - [Test] + [TestMethod] public void MemoryIndependence_PlainArray() { // NumPy: np.shares_memory(a, np.empty_like(a)) → False @@ -493,7 +494,7 @@ public void MemoryIndependence_PlainArray() a.GetAtIndex(0).Should().Be(1, "writing to result must not affect prototype"); } - [Test] + [TestMethod] [OpenBugs] // BUG: SetAtIndex fails on Int64 array (NEP50 type change) public void MemoryIndependence_SlicedPrototype() { @@ -505,7 +506,7 @@ public void MemoryIndependence_SlicedPrototype() a.GetInt64(1, 0).Should().Be(4L, "writing to result must not affect original array"); } - [Test] + [TestMethod] public void MemoryIndependence_BroadcastPrototype() { var a = np.array(new int[] { 1, 2, 3 }); @@ -520,7 +521,7 @@ public void MemoryIndependence_BroadcastPrototype() // 10. WRITEABILITY — result is always writeable // ========================================================== - [Test] + [TestMethod] public void Writeable_FromBroadcastPrototype() { // Broadcast arrays in NumPy are read-only, but empty_like result is writeable @@ -534,7 +535,7 @@ public void Writeable_FromBroadcastPrototype() r.GetAtIndex(0).Should().Be(42); } - [Test] + [TestMethod] [OpenBugs] // BUG: SetAtIndex fails on Int64 array (NEP50 type change) public void Writeable_FromSlicedPrototype() { @@ -549,7 +550,7 @@ public void Writeable_FromSlicedPrototype() // 11. SIZE CORRECTNESS // ========================================================== - [Test] + [TestMethod] public void Size_Matches_Prototype() { var a = np.arange(24).reshape(2, 3, 4); @@ -557,7 +558,7 @@ public void Size_Matches_Prototype() r.size.Should().Be(24); } - [Test] + [TestMethod] public void Size_WithDtypeOverride_MatchesPrototypeShape() { // dtype override changes element size but not count @@ -571,7 +572,7 @@ public void Size_WithDtypeOverride_MatchesPrototypeShape() // (same shape/dtype contract, different initialization) // ========================================================== - [Test] + [TestMethod] public void SameContract_AsZerosLike() { var a = np.arange(6).astype(np.float64).reshape(2, 3); @@ -583,7 +584,7 @@ public void SameContract_AsZerosLike() e.dtype.Should().Be(z.dtype, "empty_like and zeros_like should have same dtype"); } - [Test] + [TestMethod] public void SameContract_AsOnesLike() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -599,7 +600,7 @@ public void SameContract_AsOnesLike() // 13. LARGE ARRAYS // ========================================================== - [Test] + [TestMethod] public void LargeArray_1000x1000() { var a = np.empty(new Shape(1000, 1000), typeof(double)); @@ -613,13 +614,13 @@ public void LargeArray_1000x1000() // 14. SCALAR DTYPES (ndim=0) — all supported types // ========================================================== - [Test] - [Arguments(typeof(int), DisplayName = "Scalar_Int32")] - [Arguments(typeof(double), DisplayName = "Scalar_Double")] - [Arguments(typeof(bool), DisplayName = "Scalar_Boolean")] - [Arguments(typeof(float), DisplayName = "Scalar_Single")] - [Arguments(typeof(long), DisplayName = "Scalar_Int64")] - [Arguments(typeof(byte), DisplayName = "Scalar_Byte")] + [TestMethod] + [DataRow(typeof(int), DisplayName = "Scalar_Int32")] + [DataRow(typeof(double), DisplayName = "Scalar_Double")] + [DataRow(typeof(bool), DisplayName = "Scalar_Boolean")] + [DataRow(typeof(float), DisplayName = "Scalar_Single")] + [DataRow(typeof(long), DisplayName = "Scalar_Int64")] + [DataRow(typeof(byte), DisplayName = "Scalar_Byte")] public void Scalar_AllDtypes(Type dtype) { // NumPy: np.empty_like(np.array(42, dtype=...)) → shape=(), ndim=0 @@ -634,7 +635,7 @@ public void Scalar_AllDtypes(Type dtype) // 15. RESULT IS NOT A VIEW — always a fresh allocation // ========================================================== - [Test] + [TestMethod] public void NotAView_PlainArray() { var a = np.arange(5).astype(np.int32); @@ -648,7 +649,7 @@ public void NotAView_PlainArray() a.GetAtIndex(i).Should().Be(i, $"prototype[{i}] should be unchanged"); } - [Test] + [TestMethod] public void NotAView_SlicedArray() { var a = np.arange(10).astype(np.int32); @@ -668,7 +669,7 @@ public void NotAView_SlicedArray() // 16. CHAINED OPERATIONS — empty_like on empty_like result // ========================================================== - [Test] + [TestMethod] public void Chained_EmptyLikeOfEmptyLike() { var a = np.arange(6).astype(np.float64).reshape(2, 3); @@ -683,7 +684,7 @@ public void Chained_EmptyLikeOfEmptyLike() // 17. INTEGRATION — empty_like used in np.roll pattern // ========================================================== - [Test] + [TestMethod] public void Integration_RollPattern() { // np.roll uses empty_like internally for its result buffer @@ -695,7 +696,7 @@ public void Integration_RollPattern() result.size.Should().Be(a.size); } - [Test] + [TestMethod] public void Integration_RollPattern_2D() { var a = np.arange(6).astype(np.int32).reshape(2, 3); @@ -710,7 +711,7 @@ public void Integration_RollPattern_2D() // 18. SHAPE OVERRIDE PARAMETER // ========================================================== - [Test] + [TestMethod] public void ShapeOverride_2DTo2D() { // NumPy: np.empty_like(a, shape=(4,5)) → shape=(4,5), dtype preserved from a @@ -720,7 +721,7 @@ public void ShapeOverride_2DTo2D() r.dtype.Should().Be(typeof(int), "dtype preserved from prototype"); } - [Test] + [TestMethod] public void ShapeOverride_2DTo1D() { // NumPy: np.empty_like(a, shape=(10,)) → shape=(10,), dtype preserved @@ -730,7 +731,7 @@ public void ShapeOverride_2DTo1D() r.dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void ShapeOverride_2DTo3D() { var a = np.arange(6).astype(np.float64).reshape(2, 3); @@ -739,7 +740,7 @@ public void ShapeOverride_2DTo3D() r.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void ShapeOverride_WithDtypeOverride() { // NumPy: np.empty_like(a, dtype='float64', shape=(3,3,3)) → shape=(3,3,3), dtype=float64 @@ -749,7 +750,7 @@ public void ShapeOverride_WithDtypeOverride() r.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void ShapeOverride_SameSize() { // Override with same total element count but different shape @@ -760,7 +761,7 @@ public void ShapeOverride_SameSize() r.size.Should().Be(12); } - [Test] + [TestMethod] public void ShapeOverride_DifferentSize() { // Override with different total element count @@ -771,7 +772,7 @@ public void ShapeOverride_DifferentSize() r.size.Should().Be(100); } - [Test] + [TestMethod] public void ShapeOverride_ToScalar() { // NumPy: np.empty_like(a, shape=()) → shape=(), ndim=0 @@ -782,7 +783,7 @@ public void ShapeOverride_ToScalar() r.dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void ShapeOverride_DefaultShape_UsesPrototype() { // When shape is default (empty), prototype shape is used @@ -791,7 +792,7 @@ public void ShapeOverride_DefaultShape_UsesPrototype() r.shape.Should().BeEquivalentTo(new long[] { 2, 3 }); } - [Test] + [TestMethod] public void ShapeOverride_FromBroadcast() { // Override shape on broadcast prototype @@ -802,7 +803,7 @@ public void ShapeOverride_FromBroadcast() r.dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void ShapeOverride_FromSlice() { // Override shape on sliced prototype @@ -817,7 +818,7 @@ public void ShapeOverride_FromSlice() // 19. SHAPE DIMENSIONS INDEPENDENCE (aliasing fix) // ========================================================== - [Test] + [TestMethod] public void ShapeDimensionsArray_NotAliased() { // Fixed: np.empty_like now clones the dimensions int[] from prototype. @@ -829,7 +830,7 @@ public void ShapeDimensionsArray_NotAliased() "dimensions array should not be the same reference (defensive copy)"); } - [Test] + [TestMethod] public void ShapeDimensionsArray_MutationIsolation() { // Verify that having separate int[] means mutations to one don't affect the other. diff --git a/test/NumSharp.UnitTest/Creation/np.frombuffer.Test.cs b/test/NumSharp.UnitTest/Creation/np.frombuffer.Test.cs index 785392fa0..26a195477 100644 --- a/test/NumSharp.UnitTest/Creation/np.frombuffer.Test.cs +++ b/test/NumSharp.UnitTest/Creation/np.frombuffer.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class NpFromBufferTest { - [Test] + [TestMethod] public void ToInt16() { short[] ints = { -100, 200, 300, 400, 500 }; @@ -22,7 +23,7 @@ public void ToInt16() Assert.AreEqual(nd.GetInt16(4), 500); } - [Test] + [TestMethod] public void ToInt32() { int[] ints = {-100, 200, 300, 400, 500}; @@ -34,7 +35,7 @@ public void ToInt32() Assert.AreEqual(nd.GetInt32(4), 500); } - [Test] + [TestMethod] public void ToInt64() { long[] ints = { -100, 200, 300, 400, 500 }; @@ -46,7 +47,7 @@ public void ToInt64() Assert.AreEqual(nd.GetInt64(4), 500); } - [Test] + [TestMethod] public void ToUInt16() { ushort[] ints = { 100, 200, 300, 400, 500 }; @@ -58,7 +59,7 @@ public void ToUInt16() Assert.AreEqual(nd.GetUInt16(4), (ushort)500); } - [Test] + [TestMethod] public void ToUInt32() { uint[] ints = { 100, 200, 300, 400, 500 }; @@ -70,7 +71,7 @@ public void ToUInt32() Assert.AreEqual(nd.GetUInt32(4), (uint)500); } - [Test] + [TestMethod] public void ToUInt64() { ulong[] ints = { 100, 200, 300, 400, 500 }; @@ -82,7 +83,7 @@ public void ToUInt64() Assert.AreEqual(nd.GetUInt64(4), (ulong)500); } - [Test] + [TestMethod] public void ToSingle() { float[] floats = { 100.5F, 200.0F, 300.0F, 400.0F, 500.0F }; @@ -94,7 +95,7 @@ public void ToSingle() Assert.AreEqual(nd.GetSingle(4), 500.0F); } - [Test] + [TestMethod] public void ToDouble() { double[] floats = { 100.5, 200.0, 300.0, 400.0, 500.0 }; diff --git a/test/NumSharp.UnitTest/Creation/np.full.Test.cs b/test/NumSharp.UnitTest/Creation/np.full.Test.cs index 62f935558..147b17f5b 100644 --- a/test/NumSharp.UnitTest/Creation/np.full.Test.cs +++ b/test/NumSharp.UnitTest/Creation/np.full.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class np_full_Test { - [Test] + [TestMethod] public void Full_Like() { var a = np.zeros((10, 10)); @@ -19,7 +20,7 @@ public void Full_Like() alike.Array.GetIndex(0).Should().Be(5).And.BeOfType(); } - [Test] + [TestMethod] public void SimpleInt1D() { var np1 = np.full(new Shape(5), 1d); @@ -27,7 +28,7 @@ public void SimpleInt1D() Assert.IsTrue(np1.Data().Where(x => x == 1).ToArray().Length == 5); } - [Test] + [TestMethod] public void SimpleInt2D() { var np1 = np.full(new Shape(5, 5), 1d); @@ -35,7 +36,7 @@ public void SimpleInt2D() Assert.IsTrue(np1.Data().Where(x => x == 1).ToArray().Length == 25); } - [Test] + [TestMethod] public void SimpleDouble3D() { var np1 = np.full(new Shape(5, 5, 5), 1d); @@ -43,20 +44,20 @@ public void SimpleDouble3D() Assert.IsTrue(np1.Data().Where(x => x == 1).ToArray().Length == 125); } - [Test] - [Arguments(typeof(double))] - [Arguments(typeof(float))] - [Arguments(typeof(byte))] - [Arguments(typeof(int))] - [Arguments(typeof(long))] - [Arguments(typeof(char))] - [Arguments(typeof(short))] - [Arguments(typeof(uint))] - [Arguments(typeof(ulong))] - [Arguments(typeof(ushort))] - [Arguments(typeof(decimal))] - //TODO! [Arguments(typeof(Complex))] - [Arguments(typeof(bool))] + [TestMethod] + [DataRow(typeof(double))] + [DataRow(typeof(float))] + [DataRow(typeof(byte))] + [DataRow(typeof(int))] + [DataRow(typeof(long))] + [DataRow(typeof(char))] + [DataRow(typeof(short))] + [DataRow(typeof(uint))] + [DataRow(typeof(ulong))] + [DataRow(typeof(ushort))] + [DataRow(typeof(decimal))] + //TODO! [DataRow(typeof(Complex))] + [DataRow(typeof(bool))] public void Full_AllTypes(Type dtype) { var np1 = np.full(new Shape(3, 3, 3), Activator.CreateInstance(dtype), dtype); diff --git a/test/NumSharp.UnitTest/Creation/np.meshgrid.test.cs b/test/NumSharp.UnitTest/Creation/np.meshgrid.test.cs index 1cd728684..3827b09f8 100644 --- a/test/NumSharp.UnitTest/Creation/np.meshgrid.test.cs +++ b/test/NumSharp.UnitTest/Creation/np.meshgrid.test.cs @@ -5,9 +5,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class NumpyMeshgridTest { - [Test] + [TestMethod] public void MeshgridTest() { NDArray X = np.array(0, 1, 2); diff --git a/test/NumSharp.UnitTest/Creation/np.ones.Test.cs b/test/NumSharp.UnitTest/Creation/np.ones.Test.cs index 2ced4f140..da0c9f7f5 100644 --- a/test/NumSharp.UnitTest/Creation/np.ones.Test.cs +++ b/test/NumSharp.UnitTest/Creation/np.ones.Test.cs @@ -5,9 +5,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class np_ones_Test { - [Test] + [TestMethod] public void SimpleInt1D() { var np1 = np.ones(new Shape(5)); @@ -15,7 +16,7 @@ public void SimpleInt1D() Assert.IsTrue(np1.Data().Where(x => x == 1).ToArray().Length == 5); } - [Test] + [TestMethod] public void SimpleInt2D() { var np1 = np.ones(new Shape(5, 5)); @@ -23,7 +24,7 @@ public void SimpleInt2D() Assert.IsTrue(np1.Data().Where(x => x == 1).ToArray().Length == 25); } - [Test] + [TestMethod] public void SimpleDouble3D() { var np1 = np.ones(new Shape(5, 5, 5)); @@ -31,20 +32,20 @@ public void SimpleDouble3D() Assert.IsTrue(np1.Data().Where(x => x == 1).ToArray().Length == 125); } - [Test] - [Arguments(typeof(double))] - [Arguments(typeof(float))] - [Arguments(typeof(byte))] - [Arguments(typeof(int))] - [Arguments(typeof(long))] - [Arguments(typeof(char))] - [Arguments(typeof(short))] - [Arguments(typeof(uint))] - [Arguments(typeof(ulong))] - [Arguments(typeof(ushort))] - [Arguments(typeof(decimal))] - //TODO! [Arguments(typeof(Complex))] - [Arguments(typeof(bool))] + [TestMethod] + [DataRow(typeof(double))] + [DataRow(typeof(float))] + [DataRow(typeof(byte))] + [DataRow(typeof(int))] + [DataRow(typeof(long))] + [DataRow(typeof(char))] + [DataRow(typeof(short))] + [DataRow(typeof(uint))] + [DataRow(typeof(ulong))] + [DataRow(typeof(ushort))] + [DataRow(typeof(decimal))] + //TODO! [DataRow(typeof(Complex))] + [DataRow(typeof(bool))] public void One_AllTypes(Type dtype) { var np1 = np.ones(new Shape(3, 3, 3), dtype); diff --git a/test/NumSharp.UnitTest/Creation/np.zeros.Test.cs b/test/NumSharp.UnitTest/Creation/np.zeros.Test.cs index f51d97988..40c7e3973 100644 --- a/test/NumSharp.UnitTest/Creation/np.zeros.Test.cs +++ b/test/NumSharp.UnitTest/Creation/np.zeros.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.Creation { + [TestClass] public class NumPyZerosTest { - [Test] + [TestMethod] public void zero() { var n = np.zeros(3); @@ -19,21 +20,21 @@ public void zero() Assert.IsTrue(Enumerable.SequenceEqual(n.Data(), new double[] {0, 0, 0})); } - [Test] + [TestMethod] public void Zeros2Dim() { var n = np.zeros(new Shape(3, 2)); Assert.IsTrue(Enumerable.SequenceEqual(n.Data(), new double[] {0, 0, 0, 0, 0, 0})); } - [Test] + [TestMethod] public void Zeros1DimWithDtype() { var n = np.zeros(new Shape(3), np.int32); Assert.IsTrue(Enumerable.SequenceEqual(n.Data(), new int[] {0, 0, 0})); } - [Test] + [TestMethod] public void SimpleInt1D() { var np1 = np.zeros(new Shape(5)); @@ -41,7 +42,7 @@ public void SimpleInt1D() Assert.IsTrue(np1.Data().Where(x => x == 0).ToArray().Length == 5); } - [Test] + [TestMethod] public void SimpleInt2D() { var np1 = np.zeros(new Shape(5, 5)); @@ -49,7 +50,7 @@ public void SimpleInt2D() Assert.IsTrue(np1.Data().Where(x => x == 0).ToArray().Length == 25); } - [Test] + [TestMethod] public void SimpleDouble3D() { var np1 = np.zeros(new Shape(5, 5, 5)); diff --git a/test/NumSharp.UnitTest/Creation/np.zeros_like.Test.cs b/test/NumSharp.UnitTest/Creation/np.zeros_like.Test.cs index 96c72aa81..914e9dee5 100644 --- a/test/NumSharp.UnitTest/Creation/np.zeros_like.Test.cs +++ b/test/NumSharp.UnitTest/Creation/np.zeros_like.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.Extensions { + [TestClass] public class np_zeros_like_Test { - [Test] + [TestMethod] public void SimpleInt1D() { // create same-shaped zeros from ones @@ -20,7 +21,7 @@ public void SimpleInt1D() Assert.IsTrue(np1.Data().Where(x => x == 0).ToArray().Length == 5); } - [Test] + [TestMethod] public void SimpleInt2D() { // create same-shaped zeros from ones @@ -29,7 +30,7 @@ public void SimpleInt2D() Assert.IsTrue(np1.Data().Where(x => x == 0).ToArray().Length == 25); } - [Test] + [TestMethod] public void SimpleDouble3D() { // create same-shaped zeros from ones diff --git a/test/NumSharp.UnitTest/Extensions/ndarray.argsort.Test.cs b/test/NumSharp.UnitTest/Extensions/ndarray.argsort.Test.cs index d58c31aea..e714cfcfd 100644 --- a/test/NumSharp.UnitTest/Extensions/ndarray.argsort.Test.cs +++ b/test/NumSharp.UnitTest/Extensions/ndarray.argsort.Test.cs @@ -10,9 +10,10 @@ namespace NumSharp.UnitTest.Extensions /// /// Tests following https://numpy.org/doc/stable/reference/generated/numpy.hstack.html /// + [TestClass] public class NdArrayArgSortTest { - [Test] + [TestMethod] public void OneDimension() { // NumPy argsort always returns int64 indices @@ -21,7 +22,7 @@ public void OneDimension() Assert.IsTrue(Enumerable.SequenceEqual(new long[] {1, 2, 0}, x.Data())); } - [Test] + [TestMethod] public void TwoDimension() { var x = np.array(new int[] {3, 1, 2}); diff --git a/test/NumSharp.UnitTest/Generic/NDArray.Generic.Test.cs b/test/NumSharp.UnitTest/Generic/NDArray.Generic.Test.cs index 3d6087a83..0d1664505 100644 --- a/test/NumSharp.UnitTest/Generic/NDArray.Generic.Test.cs +++ b/test/NumSharp.UnitTest/Generic/NDArray.Generic.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.Generic { + [TestClass] public class NDArrayGenericTest { - [Test] + [TestMethod] public void Generic1DBool_NDArray() { var np1 = new NDArray(new[] {true, true, false, false}, new Shape(4)); @@ -25,7 +26,7 @@ public void Generic1DBool_NDArray() Assert.AreEqual(1, np2.ndim); } - [Test] + [TestMethod] public void Generic2DBool_NDArrayOR() { var np1 = new NDArray(new Shape(2, 3)); diff --git a/test/NumSharp.UnitTest/GlobalUsings.cs b/test/NumSharp.UnitTest/GlobalUsings.cs index fbd3627c8..d3aaaa465 100644 --- a/test/NumSharp.UnitTest/GlobalUsings.cs +++ b/test/NumSharp.UnitTest/GlobalUsings.cs @@ -3,5 +3,5 @@ global using System.Threading.Tasks; global using NumSharp; global using AwesomeAssertions; -global using TUnit.Assertions.Extensions; +global using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/test/NumSharp.UnitTest/Indexing/NonzeroInt64Tests.cs b/test/NumSharp.UnitTest/Indexing/NonzeroInt64Tests.cs index be68a70a7..a924940c2 100644 --- a/test/NumSharp.UnitTest/Indexing/NonzeroInt64Tests.cs +++ b/test/NumSharp.UnitTest/Indexing/NonzeroInt64Tests.cs @@ -1,10 +1,6 @@ using System; -using System.Threading.Tasks; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.Indexing; @@ -12,33 +8,34 @@ namespace NumSharp.UnitTest.Indexing; /// Tests for np.nonzero with int64 indexing support. /// Verifies nonzero returns int64 indices and handles various dtypes. /// +[TestClass] public class NonzeroInt64Tests { #region Return Type Tests - [Test] - public async Task Nonzero_ReturnsInt64Indices() + [TestMethod] + public void Nonzero_ReturnsInt64Indices() { // NumPy: np.nonzero([0, 1, 0, 2])[0].dtype = int64 var a = np.array(new int[] { 0, 1, 0, 2 }); var result = np.nonzero(a); - await Assert.That(result[0].typecode).IsEqualTo(NPTypeCode.Int64); + result[0].typecode.Should().Be(NPTypeCode.Int64); } - [Test] - public async Task Nonzero_2D_AllArraysAreInt64() + [TestMethod] + public void Nonzero_2D_AllArraysAreInt64() { var a = np.array(new int[,] { { 0, 1 }, { 2, 0 } }); var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(2); - await Assert.That(result[0].typecode).IsEqualTo(NPTypeCode.Int64); - await Assert.That(result[1].typecode).IsEqualTo(NPTypeCode.Int64); + result.Length.Should().Be(2); + result[0].typecode.Should().Be(NPTypeCode.Int64); + result[1].typecode.Should().Be(NPTypeCode.Int64); } - [Test] - public async Task Nonzero_3D_AllArraysAreInt64() + [TestMethod] + public void Nonzero_3D_AllArraysAreInt64() { var a = np.zeros(new Shape(2, 2, 2), NPTypeCode.Int32); a.SetInt32(1, 0, 0, 0); @@ -46,228 +43,228 @@ public async Task Nonzero_3D_AllArraysAreInt64() var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(3); - await Assert.That(result[0].typecode).IsEqualTo(NPTypeCode.Int64); - await Assert.That(result[1].typecode).IsEqualTo(NPTypeCode.Int64); - await Assert.That(result[2].typecode).IsEqualTo(NPTypeCode.Int64); + result.Length.Should().Be(3); + result[0].typecode.Should().Be(NPTypeCode.Int64); + result[1].typecode.Should().Be(NPTypeCode.Int64); + result[2].typecode.Should().Be(NPTypeCode.Int64); } #endregion #region Various DType Tests - [Test] - public async Task Nonzero_Byte_ReturnsCorrectIndices() + [TestMethod] + public void Nonzero_Byte_ReturnsCorrectIndices() { var a = np.array(new byte[] { 0, 1, 0, 2, 0 }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3L); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1L); + result[0].GetInt64(1).Should().Be(3L); } - [Test] - public async Task Nonzero_Int16_ReturnsCorrectIndices() + [TestMethod] + public void Nonzero_Int16_ReturnsCorrectIndices() { var a = np.array(new short[] { 0, -1, 0, 2, 0 }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3L); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1L); + result[0].GetInt64(1).Should().Be(3L); } - [Test] - public async Task Nonzero_UInt16_ReturnsCorrectIndices() + [TestMethod] + public void Nonzero_UInt16_ReturnsCorrectIndices() { var a = np.array(new ushort[] { 0, 1, 0, 2, 0 }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3L); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1L); + result[0].GetInt64(1).Should().Be(3L); } - [Test] - public async Task Nonzero_Int64_ReturnsCorrectIndices() + [TestMethod] + public void Nonzero_Int64_ReturnsCorrectIndices() { var a = np.array(new long[] { 0, 1, 0, 2, 0 }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3L); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1L); + result[0].GetInt64(1).Should().Be(3L); } - [Test] - public async Task Nonzero_UInt64_ReturnsCorrectIndices() + [TestMethod] + public void Nonzero_UInt64_ReturnsCorrectIndices() { var a = np.array(new ulong[] { 0, 1, 0, 2, 0 }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3L); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1L); + result[0].GetInt64(1).Should().Be(3L); } - [Test] - public async Task Nonzero_Float32_ReturnsCorrectIndices() + [TestMethod] + public void Nonzero_Float32_ReturnsCorrectIndices() { var a = np.array(new float[] { 0f, 1.5f, 0f, -2.5f, 0f }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3L); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1L); + result[0].GetInt64(1).Should().Be(3L); } - [Test] - public async Task Nonzero_Float64_ReturnsCorrectIndices() + [TestMethod] + public void Nonzero_Float64_ReturnsCorrectIndices() { var a = np.array(new double[] { 0.0, 1.5, 0.0, -2.5, 0.0 }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3L); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1L); + result[0].GetInt64(1).Should().Be(3L); } - [Test] - public async Task Nonzero_Decimal_ReturnsCorrectIndices() + [TestMethod] + public void Nonzero_Decimal_ReturnsCorrectIndices() { var a = np.array(new decimal[] { 0m, 1.5m, 0m, -2.5m, 0m }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3L); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1L); + result[0].GetInt64(1).Should().Be(3L); } #endregion #region Boolean Array Tests - [Test] - public async Task Nonzero_Boolean_TrueIsNonzero() + [TestMethod] + public void Nonzero_Boolean_TrueIsNonzero() { var a = np.array(new bool[] { false, true, false, true, false }); var result = np.nonzero(a); - await Assert.That(result[0].typecode).IsEqualTo(NPTypeCode.Int64); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3L); + result[0].typecode.Should().Be(NPTypeCode.Int64); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1L); + result[0].GetInt64(1).Should().Be(3L); } - [Test] - public async Task Nonzero_Boolean_2D_ReturnsCorrectIndices() + [TestMethod] + public void Nonzero_Boolean_2D_ReturnsCorrectIndices() { var a = np.array(new bool[,] { { false, true }, { true, false } }); var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(2); - await Assert.That(result[0].size).IsEqualTo(2); + result.Length.Should().Be(2); + result[0].size.Should().Be(2); // (0,1) and (1,0) are true - await Assert.That(result[0].GetInt64(0)).IsEqualTo(0L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(1L); - await Assert.That(result[1].GetInt64(0)).IsEqualTo(1L); - await Assert.That(result[1].GetInt64(1)).IsEqualTo(0L); + result[0].GetInt64(0).Should().Be(0L); + result[0].GetInt64(1).Should().Be(1L); + result[1].GetInt64(0).Should().Be(1L); + result[1].GetInt64(1).Should().Be(0L); } #endregion #region Special Float Values - [Test] - public async Task Nonzero_NaN_IsNonzero() + [TestMethod] + public void Nonzero_NaN_IsNonzero() { // NumPy: NaN is considered nonzero var a = np.array(new double[] { 0.0, double.NaN, 0.0 }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(1); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); + result[0].size.Should().Be(1); + result[0].GetInt64(0).Should().Be(1L); } - [Test] - public async Task Nonzero_PositiveInfinity_IsNonzero() + [TestMethod] + public void Nonzero_PositiveInfinity_IsNonzero() { var a = np.array(new double[] { 0.0, double.PositiveInfinity, 0.0 }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(1); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); + result[0].size.Should().Be(1); + result[0].GetInt64(0).Should().Be(1L); } - [Test] - public async Task Nonzero_NegativeInfinity_IsNonzero() + [TestMethod] + public void Nonzero_NegativeInfinity_IsNonzero() { var a = np.array(new double[] { 0.0, double.NegativeInfinity, 0.0 }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(1); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); + result[0].size.Should().Be(1); + result[0].GetInt64(0).Should().Be(1L); } - [Test] - public async Task Nonzero_NegativeZero_IsZero() + [TestMethod] + public void Nonzero_NegativeZero_IsZero() { // NumPy: -0.0 is still zero var a = np.array(new double[] { 1.0, -0.0, 2.0 }); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(0L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(2L); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(0L); + result[0].GetInt64(1).Should().Be(2L); } #endregion #region Edge Cases - [Test] - public async Task Nonzero_AllZeros_ReturnsEmptyArray() + [TestMethod] + public void Nonzero_AllZeros_ReturnsEmptyArray() { var a = np.zeros(new Shape(10), NPTypeCode.Int32); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(0); - await Assert.That(result[0].typecode).IsEqualTo(NPTypeCode.Int64); + result[0].size.Should().Be(0); + result[0].typecode.Should().Be(NPTypeCode.Int64); } - [Test] - public async Task Nonzero_AllNonzero_ReturnsAllIndices() + [TestMethod] + public void Nonzero_AllNonzero_ReturnsAllIndices() { var a = np.ones(new Shape(5), NPTypeCode.Int32); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(5); + result[0].size.Should().Be(5); for (int i = 0; i < 5; i++) { - await Assert.That(result[0].GetInt64(i)).IsEqualTo((long)i); + result[0].GetInt64(i).Should().Be((long)i); } } - [Test] - public async Task Nonzero_SingleNonzero_ReturnsOneIndex() + [TestMethod] + public void Nonzero_SingleNonzero_ReturnsOneIndex() { var a = np.zeros(new Shape(10), NPTypeCode.Int32); a.SetInt32(1, 5); var result = np.nonzero(a); - await Assert.That(result[0].size).IsEqualTo(1); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(5L); + result[0].size.Should().Be(1); + result[0].GetInt64(0).Should().Be(5L); } #endregion #region Using Result for Indexing - [Test] - public async Task Nonzero_CanBeUsedForIndexing() + [TestMethod] + public void Nonzero_CanBeUsedForIndexing() { // NumPy pattern: a[np.nonzero(a)] extracts nonzero values var a = np.array(new int[] { 0, 3, 0, 1, 0, 2 }); @@ -275,10 +272,10 @@ public async Task Nonzero_CanBeUsedForIndexing() var nonzeroValues = a[indices]; - await Assert.That(nonzeroValues.size).IsEqualTo(3); - await Assert.That(nonzeroValues.GetInt32(0)).IsEqualTo(3); - await Assert.That(nonzeroValues.GetInt32(1)).IsEqualTo(1); - await Assert.That(nonzeroValues.GetInt32(2)).IsEqualTo(2); + nonzeroValues.size.Should().Be(3); + nonzeroValues.GetInt32(0).Should().Be(3); + nonzeroValues.GetInt32(1).Should().Be(1); + nonzeroValues.GetInt32(2).Should().Be(2); } #endregion diff --git a/test/NumSharp.UnitTest/Indexing/NonzeroTests.cs b/test/NumSharp.UnitTest/Indexing/NonzeroTests.cs index 2de268267..27f188346 100644 --- a/test/NumSharp.UnitTest/Indexing/NonzeroTests.cs +++ b/test/NumSharp.UnitTest/Indexing/NonzeroTests.cs @@ -1,10 +1,6 @@ using System; -using System.Threading.Tasks; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.Indexing; @@ -12,113 +8,114 @@ namespace NumSharp.UnitTest.Indexing; /// Tests for np.nonzero behavior. /// NumPy: Returns a tuple of arrays, one for each dimension. /// +[TestClass] public class NonzeroTests { #region 1D Arrays - [Test] - public async Task Nonzero_1D_ReturnsIndices() + [TestMethod] + public void Nonzero_1D_ReturnsIndices() { // NumPy: np.nonzero([0, 1, 0, 2]) = (array([1, 3]),) var a = np.array(new int[] { 0, 1, 0, 2 }); var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(1); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3); + result.Length.Should().Be(1); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1); + result[0].GetInt64(1).Should().Be(3); } - [Test] - public async Task Nonzero_1D_Empty_ReturnsEmptyArray() + [TestMethod] + public void Nonzero_1D_Empty_ReturnsEmptyArray() { // NumPy: np.nonzero([0, 0, 0]) = (array([], dtype=int64),) var a = np.array(new int[] { 0, 0, 0 }); var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(1); - await Assert.That(result[0].size).IsEqualTo(0); + result.Length.Should().Be(1); + result[0].size.Should().Be(0); } - [Test] - public async Task Nonzero_1D_AllNonzero_ReturnsAllIndices() + [TestMethod] + public void Nonzero_1D_AllNonzero_ReturnsAllIndices() { // NumPy: np.nonzero([1, 2, 3]) = (array([0, 1, 2]),) var a = np.array(new int[] { 1, 2, 3 }); var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(1); - await Assert.That(result[0].size).IsEqualTo(3); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(0); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(1); - await Assert.That(result[0].GetInt64(2)).IsEqualTo(2); + result.Length.Should().Be(1); + result[0].size.Should().Be(3); + result[0].GetInt64(0).Should().Be(0); + result[0].GetInt64(1).Should().Be(1); + result[0].GetInt64(2).Should().Be(2); } #endregion #region 2D Arrays - [Test] - public async Task Nonzero_2D_ReturnsTupleOfIndices() + [TestMethod] + public void Nonzero_2D_ReturnsTupleOfIndices() { // NumPy: np.nonzero([[0, 1], [2, 0]]) = (array([0, 1]), array([1, 0])) // First array is row indices, second is column indices var a = np.array(new int[,] { { 0, 1 }, { 2, 0 } }); var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(2); + result.Length.Should().Be(2); // Row indices - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(0); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(1); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(0); + result[0].GetInt64(1).Should().Be(1); // Column indices - await Assert.That(result[1].size).IsEqualTo(2); - await Assert.That(result[1].GetInt64(0)).IsEqualTo(1); - await Assert.That(result[1].GetInt64(1)).IsEqualTo(0); + result[1].size.Should().Be(2); + result[1].GetInt64(0).Should().Be(1); + result[1].GetInt64(1).Should().Be(0); } - [Test] - public async Task Nonzero_2D_ThreeElements() + [TestMethod] + public void Nonzero_2D_ThreeElements() { // NumPy: np.nonzero([[1, 0], [0, 2], [3, 0]]) = (array([0, 1, 2]), array([0, 1, 0])) var a = np.array(new int[,] { { 1, 0 }, { 0, 2 }, { 3, 0 } }); var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(2); + result.Length.Should().Be(2); // Row indices - await Assert.That(result[0].size).IsEqualTo(3); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(0); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(1); - await Assert.That(result[0].GetInt64(2)).IsEqualTo(2); + result[0].size.Should().Be(3); + result[0].GetInt64(0).Should().Be(0); + result[0].GetInt64(1).Should().Be(1); + result[0].GetInt64(2).Should().Be(2); // Column indices - await Assert.That(result[1].size).IsEqualTo(3); - await Assert.That(result[1].GetInt64(0)).IsEqualTo(0); - await Assert.That(result[1].GetInt64(1)).IsEqualTo(1); - await Assert.That(result[1].GetInt64(2)).IsEqualTo(0); + result[1].size.Should().Be(3); + result[1].GetInt64(0).Should().Be(0); + result[1].GetInt64(1).Should().Be(1); + result[1].GetInt64(2).Should().Be(0); } - [Test] - public async Task Nonzero_2D_AllZero_ReturnsEmptyArrays() + [TestMethod] + public void Nonzero_2D_AllZero_ReturnsEmptyArrays() { // NumPy: np.nonzero([[0, 0], [0, 0]]) = (array([], dtype=int64), array([], dtype=int64)) var a = np.array(new int[,] { { 0, 0 }, { 0, 0 } }); var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(2); - await Assert.That(result[0].size).IsEqualTo(0); - await Assert.That(result[1].size).IsEqualTo(0); + result.Length.Should().Be(2); + result[0].size.Should().Be(0); + result[1].size.Should().Be(0); } #endregion #region 3D Arrays - [Test] - public async Task Nonzero_3D_ReturnsTupleOfThreeIndices() + [TestMethod] + public void Nonzero_3D_ReturnsTupleOfThreeIndices() { // 3D array: each nonzero element has (depth, row, col) index var a = np.zeros(new Shape(2, 2, 2), NPTypeCode.Int32); @@ -127,68 +124,68 @@ public async Task Nonzero_3D_ReturnsTupleOfThreeIndices() var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(3); + result.Length.Should().Be(3); // All index arrays should have 2 elements - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[1].size).IsEqualTo(2); - await Assert.That(result[2].size).IsEqualTo(2); + result[0].size.Should().Be(2); + result[1].size.Should().Be(2); + result[2].size.Should().Be(2); // First nonzero at [0,0,0] - await Assert.That(result[0].GetInt64(0)).IsEqualTo(0); - await Assert.That(result[1].GetInt64(0)).IsEqualTo(0); - await Assert.That(result[2].GetInt64(0)).IsEqualTo(0); + result[0].GetInt64(0).Should().Be(0); + result[1].GetInt64(0).Should().Be(0); + result[2].GetInt64(0).Should().Be(0); // Second nonzero at [1,1,1] - await Assert.That(result[0].GetInt64(1)).IsEqualTo(1); - await Assert.That(result[1].GetInt64(1)).IsEqualTo(1); - await Assert.That(result[2].GetInt64(1)).IsEqualTo(1); + result[0].GetInt64(1).Should().Be(1); + result[1].GetInt64(1).Should().Be(1); + result[2].GetInt64(1).Should().Be(1); } #endregion #region Boolean Arrays - [Test] - public async Task Nonzero_Boolean_TrueIsTreatedAsNonzero() + [TestMethod] + public void Nonzero_Boolean_TrueIsTreatedAsNonzero() { // NumPy: np.nonzero([False, True, False, True]) = (array([1, 3]),) var a = np.array(new bool[] { false, true, false, true }); var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(1); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3); + result.Length.Should().Be(1); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1); + result[0].GetInt64(1).Should().Be(3); } #endregion #region Float Arrays - [Test] - public async Task Nonzero_Float_ZeroIsExact() + [TestMethod] + public void Nonzero_Float_ZeroIsExact() { // NumPy: np.nonzero([0.0, 1.0, 0.0, 2.0]) = (array([1, 3]),) var a = np.array(new double[] { 0.0, 1.0, 0.0, 2.0 }); var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(1); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3); + result.Length.Should().Be(1); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1); + result[0].GetInt64(1).Should().Be(3); } - [Test] - public async Task Nonzero_Float_NaN_IsNonzero() + [TestMethod] + public void Nonzero_Float_NaN_IsNonzero() { // NumPy: np.nonzero([0.0, nan]) = (array([1]),) - NaN is treated as nonzero var a = np.array(new double[] { 0.0, double.NaN }); var result = np.nonzero(a); - await Assert.That(result.Length).IsEqualTo(1); - await Assert.That(result[0].size).IsEqualTo(1); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1); + result.Length.Should().Be(1); + result[0].size.Should().Be(1); + result[0].GetInt64(0).Should().Be(1); } #endregion diff --git a/test/NumSharp.UnitTest/Indexing/np_nonzero_edge_cases.cs b/test/NumSharp.UnitTest/Indexing/np_nonzero_edge_cases.cs index a82070607..15f9f4c8c 100644 --- a/test/NumSharp.UnitTest/Indexing/np_nonzero_edge_cases.cs +++ b/test/NumSharp.UnitTest/Indexing/np_nonzero_edge_cases.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.Indexing /// /// Edge case tests for np.nonzero based on actual NumPy 2.4.2 behavior. /// + [TestClass] public class np_nonzero_edge_cases : TestClass { - [Test] + [TestMethod] public void EmptyArray_ReturnsEmptyIndices() { // NumPy: np.nonzero(np.array([], dtype=np.int32)) returns (array([], dtype=int64),) @@ -22,7 +23,7 @@ public void EmptyArray_ReturnsEmptyIndices() Assert.AreEqual(0, r[0].size); } - [Test] + [TestMethod] public void NaN_IsNonZero() { // NumPy: nonzero([0, nan, 1]) = [1, 2] - NaN is considered nonzero @@ -32,7 +33,7 @@ public void NaN_IsNonZero() r[0].Should().BeOfValues(1, 2); } - [Test] + [TestMethod] public void PositiveInfinity_IsNonZero() { // NumPy: nonzero([0, inf, 1]) = [1, 2] @@ -42,7 +43,7 @@ public void PositiveInfinity_IsNonZero() r[0].Should().BeOfValues(1, 2); } - [Test] + [TestMethod] public void NegativeInfinity_IsNonZero() { // NumPy: nonzero([0, -inf, 1]) = [1, 2] @@ -52,7 +53,7 @@ public void NegativeInfinity_IsNonZero() r[0].Should().BeOfValues(1, 2); } - [Test] + [TestMethod] public void NegativeZero_IsZero() { // NumPy: nonzero([0, -0.0, 1]) = [2] - negative zero is still zero @@ -62,7 +63,7 @@ public void NegativeZero_IsZero() r[0].Should().BeOfValues(2); } - [Test] + [TestMethod] public void AllZeros_ReturnsEmptyIndices() { // NumPy: nonzero(zeros(5)) = [] @@ -72,7 +73,7 @@ public void AllZeros_ReturnsEmptyIndices() Assert.AreEqual(0, r[0].size); } - [Test] + [TestMethod] public void AllNonZero_ReturnsAllIndices() { // NumPy: nonzero(ones(5)) = [0, 1, 2, 3, 4] @@ -82,7 +83,7 @@ public void AllNonZero_ReturnsAllIndices() r[0].Should().BeOfValues(0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void NonContiguous_Slice_Works() { // NumPy: nonzero(arange(10)[::2]) = [1, 2, 3, 4] (values [0, 2, 4, 6, 8]) @@ -97,7 +98,7 @@ public void NonContiguous_Slice_Works() r[0].Should().BeOfValues(1, 2, 3, 4); // indices of nonzero values } - [Test] + [TestMethod] public void TwoDimensional_Basic() { // NumPy: nonzero([[0,1,0],[2,0,3]]) = ([0,1,1], [1,0,2]) diff --git a/test/NumSharp.UnitTest/Indexing/np_nonzero_strided_tests.cs b/test/NumSharp.UnitTest/Indexing/np_nonzero_strided_tests.cs index 2234deb74..7689cd50d 100644 --- a/test/NumSharp.UnitTest/Indexing/np_nonzero_strided_tests.cs +++ b/test/NumSharp.UnitTest/Indexing/np_nonzero_strided_tests.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.Indexing /// Tests for np.nonzero with strided (non-contiguous) arrays. /// Based on NumPy 2.4.2 behavior. /// + [TestClass] public class np_nonzero_strided_tests : TestClass { - [Test] + [TestMethod] public void Transposed_2D() { // NumPy: @@ -29,7 +30,7 @@ public void Transposed_2D() result[1].Should().BeOfValues(0, 1, 2); // col indices } - [Test] + [TestMethod] public void Strided_1D_EveryOther() { // NumPy: @@ -48,7 +49,7 @@ public void Strided_1D_EveryOther() result[0].Should().BeOfValues(0, 1, 2, 3, 4); // all elements are non-zero } - [Test] + [TestMethod] public void Strided_1D_WithZeros() { // NumPy: @@ -66,7 +67,7 @@ public void Strided_1D_WithZeros() Assert.AreEqual(0, result[0].size); // all zeros } - [Test] + [TestMethod] public void Strided_1D_Reversed() { // NumPy: @@ -85,7 +86,7 @@ public void Strided_1D_Reversed() result[0].Should().BeOfValues(0, 2, 4); // indices 0, 2, 4 have values 3, 2, 1 } - [Test] + [TestMethod] public void Sliced_2D_NonContiguous() { // NumPy: @@ -104,7 +105,7 @@ public void Sliced_2D_NonContiguous() result[1].Should().BeOfValues(0, 1, 0, 1); // cols } - [Test] + [TestMethod] public void Transposed_3D() { // Test transpose of 3D array @@ -128,7 +129,7 @@ public void Transposed_3D() result[2].Should().BeOfValues(0, 1); // dim 2 (was dim 0) } - [Test] + [TestMethod] public void Boolean_Strided() { // NumPy: @@ -146,7 +147,7 @@ public void Boolean_Strided() Assert.AreEqual(0, result[0].size); // all false at even indices } - [Test] + [TestMethod] public void Boolean_Strided_Odd() { // NumPy: @@ -165,7 +166,7 @@ public void Boolean_Strided_Odd() result[0].Should().BeOfValues(0, 1, 2); // all true } - [Test] + [TestMethod] public void Float_Strided_WithNaN() { // NaN should be treated as non-zero even in strided arrays @@ -180,7 +181,7 @@ public void Float_Strided_WithNaN() result[0].Should().BeOfValues(0, 1, 2); // all non-zero (NaN is non-zero) } - [Test] + [TestMethod] public void Column_Slice() { // Test extracting a column (non-contiguous in row-major) @@ -200,7 +201,7 @@ public void Column_Slice() result[0].Should().BeOfValues(0, 2); // indices 0 and 2 are non-zero } - [Test] + [TestMethod] public void Row_Slice_Contiguous() { // Test extracting a row (should be contiguous in row-major) diff --git a/test/NumSharp.UnitTest/Indexing/np_nonzero_tests.cs b/test/NumSharp.UnitTest/Indexing/np_nonzero_tests.cs index 80eb99cbb..edb47d3bf 100644 --- a/test/NumSharp.UnitTest/Indexing/np_nonzero_tests.cs +++ b/test/NumSharp.UnitTest/Indexing/np_nonzero_tests.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest.Indexing { + [TestClass] public class np_nonzero_tests : TestClass { - [Test] + [TestMethod] public void Case1() { var x = np.array(3, 0, 0, 0, 4, 0, 5, 6, 0).reshape(3, 3); @@ -20,7 +21,7 @@ public void Case1() x[np.nonzero(x)].Should().BeOfValues(3, 4, 5, 6).And.BeShaped(4); } - [Test] + [TestMethod] public void Case2() { var x = np.arange(9).reshape(3, 3); diff --git a/test/NumSharp.UnitTest/Issues/443.cs b/test/NumSharp.UnitTest/Issues/443.cs index fbe61efe9..a0e2f90cb 100644 --- a/test/NumSharp.UnitTest/Issues/443.cs +++ b/test/NumSharp.UnitTest/Issues/443.cs @@ -2,12 +2,13 @@ namespace NumSharp.UnitTest.Issues { + [TestClass] public class Issue443 { /// /// https://github.com/SciSharp/NumSharp/issues/443#issue-825238582 /// - [Test] + [TestMethod] public void ReproducingTest() { var ones = np.ones((10, 1)); diff --git a/test/NumSharp.UnitTest/Issues/447.cs b/test/NumSharp.UnitTest/Issues/447.cs index 2f8199e07..fc898b357 100644 --- a/test/NumSharp.UnitTest/Issues/447.cs +++ b/test/NumSharp.UnitTest/Issues/447.cs @@ -2,12 +2,13 @@ namespace NumSharp.UnitTest.Issues { + [TestClass] public class Issue447 { /// /// https://github.com/SciSharp/NumSharp/issues/447#issuecomment-825556230 /// - [Test] + [TestMethod] public void ReproducingTest() { NDArray array3d = new NDArray(typeof(double), new Shape(new int[] {10, 50, 50}), true); diff --git a/test/NumSharp.UnitTest/Issues/448.cs b/test/NumSharp.UnitTest/Issues/448.cs index 19e44a95d..d8147c845 100644 --- a/test/NumSharp.UnitTest/Issues/448.cs +++ b/test/NumSharp.UnitTest/Issues/448.cs @@ -7,7 +7,7 @@ namespace NumSharp.UnitTest.Issues { public class Issue448 { - [Test, OpenBugs] + [TestMethod, OpenBugs] public void ReproducingTest1() { NDArray nd = new double[,] {{1, 2, 3}, {4, 5, 6}}; @@ -17,7 +17,7 @@ public void ReproducingTest1() nd.Should().BeOfValues(-2, -2, 3, 4, 5, 6); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void ReproducingTest2() { NDArray nd = new double[,] {{1, 2, 3}, {4, 5, 6}}; diff --git a/test/NumSharp.UnitTest/LinearAlgebra/MatMulInt64Tests.cs b/test/NumSharp.UnitTest/LinearAlgebra/MatMulInt64Tests.cs index 8e20e6ba9..1d226cb44 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/MatMulInt64Tests.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/MatMulInt64Tests.cs @@ -1,11 +1,7 @@ using System; using System.Linq; -using System.Threading.Tasks; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.LinearAlgebra; @@ -13,12 +9,13 @@ namespace NumSharp.UnitTest.LinearAlgebra; /// Tests for np.matmul and np.dot with int64 indexing support. /// Verifies SIMD path works correctly for contiguous arrays. /// +[TestClass] public class MatMulInt64Tests { #region Basic Correctness Tests - [Test] - public async Task MatMul_Float64_2x2_Correct() + [TestMethod] + public void MatMul_Float64_2x2_Correct() { // NumPy: // a = np.array([[1., 2.], [3., 4.]]) @@ -29,69 +26,69 @@ public async Task MatMul_Float64_2x2_Correct() var result = np.matmul(a, b); - await Assert.That(result.GetDouble(0, 0)).IsEqualTo(19.0); - await Assert.That(result.GetDouble(0, 1)).IsEqualTo(22.0); - await Assert.That(result.GetDouble(1, 0)).IsEqualTo(43.0); - await Assert.That(result.GetDouble(1, 1)).IsEqualTo(50.0); + result.GetDouble(0, 0).Should().Be(19.0); + result.GetDouble(0, 1).Should().Be(22.0); + result.GetDouble(1, 0).Should().Be(43.0); + result.GetDouble(1, 1).Should().Be(50.0); } - [Test] - public async Task MatMul_Float32_2x2_Correct() + [TestMethod] + public void MatMul_Float32_2x2_Correct() { var a = np.array(new float[,] { { 1, 2 }, { 3, 4 } }); var b = np.array(new float[,] { { 5, 6 }, { 7, 8 } }); var result = np.matmul(a, b); - await Assert.That(result.GetSingle(0, 0)).IsEqualTo(19.0f); - await Assert.That(result.GetSingle(0, 1)).IsEqualTo(22.0f); - await Assert.That(result.GetSingle(1, 0)).IsEqualTo(43.0f); - await Assert.That(result.GetSingle(1, 1)).IsEqualTo(50.0f); + result.GetSingle(0, 0).Should().Be(19.0f); + result.GetSingle(0, 1).Should().Be(22.0f); + result.GetSingle(1, 0).Should().Be(43.0f); + result.GetSingle(1, 1).Should().Be(50.0f); } - [Test] - public async Task MatMul_Int32_2x2_Correct() + [TestMethod] + public void MatMul_Int32_2x2_Correct() { var a = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); var b = np.array(new int[,] { { 5, 6 }, { 7, 8 } }); var result = np.matmul(a, b); - await Assert.That(result.GetInt32(0, 0)).IsEqualTo(19); - await Assert.That(result.GetInt32(0, 1)).IsEqualTo(22); - await Assert.That(result.GetInt32(1, 0)).IsEqualTo(43); - await Assert.That(result.GetInt32(1, 1)).IsEqualTo(50); + result.GetInt32(0, 0).Should().Be(19); + result.GetInt32(0, 1).Should().Be(22); + result.GetInt32(1, 0).Should().Be(43); + result.GetInt32(1, 1).Should().Be(50); } #endregion #region SIMD Path Tests (Contiguous Arrays) - [Test] - public async Task MatMul_ContiguousArrays_UsesSimdPath() + [TestMethod] + public void MatMul_ContiguousArrays_UsesSimdPath() { // Create contiguous arrays that should trigger SIMD path var a = np.arange(100).reshape(10, 10).astype(NPTypeCode.Double); var b = np.arange(100).reshape(10, 10).astype(NPTypeCode.Double); // Verify arrays are contiguous - await Assert.That(a.Shape.IsContiguous).IsTrue(); - await Assert.That(b.Shape.IsContiguous).IsTrue(); + a.Shape.IsContiguous.Should().BeTrue(); + b.Shape.IsContiguous.Should().BeTrue(); var result = np.matmul(a, b); // Verify shape - await Assert.That(result.shape[0]).IsEqualTo(10); - await Assert.That(result.shape[1]).IsEqualTo(10); + result.shape[0].Should().Be(10); + result.shape[1].Should().Be(10); // Verify a specific element: result[0,0] = sum(a[0,:] * b[:,0]) // a[0,:] = [0,1,2,...,9], b[:,0] = [0,10,20,...,90] // sum = 0*0 + 1*10 + 2*20 + ... + 9*90 = 10+40+90+160+250+360+490+640+810 = 2850 - await Assert.That(result.GetDouble(0, 0)).IsEqualTo(2850.0); + result.GetDouble(0, 0).Should().Be(2850.0); } - [Test] - public async Task MatMul_LargerMatrices_Correct() + [TestMethod] + public void MatMul_LargerMatrices_Correct() { // Test with larger matrices to exercise blocking in SIMD path var a = np.ones(new Shape(64, 64), NPTypeCode.Double); @@ -100,37 +97,37 @@ public async Task MatMul_LargerMatrices_Correct() var result = np.matmul(a, b); // All elements should be 64 (sum of 64 ones) - await Assert.That(result.GetDouble(0, 0)).IsEqualTo(64.0); - await Assert.That(result.GetDouble(32, 32)).IsEqualTo(64.0); - await Assert.That(result.GetDouble(63, 63)).IsEqualTo(64.0); + result.GetDouble(0, 0).Should().Be(64.0); + result.GetDouble(32, 32).Should().Be(64.0); + result.GetDouble(63, 63).Should().Be(64.0); } - [Test] - public async Task MatMul_NonSquare_MxN_NxP() + [TestMethod] + public void MatMul_NonSquare_MxN_NxP() { // Test non-square matrix multiplication // (3x4) @ (4x5) = (3x5) var a = np.arange(12).reshape(3, 4).astype(NPTypeCode.Double); var b = np.arange(20).reshape(4, 5).astype(NPTypeCode.Double); - await Assert.That(a.Shape.IsContiguous).IsTrue(); - await Assert.That(b.Shape.IsContiguous).IsTrue(); + a.Shape.IsContiguous.Should().BeTrue(); + b.Shape.IsContiguous.Should().BeTrue(); var result = np.matmul(a, b); - await Assert.That(result.shape[0]).IsEqualTo(3); - await Assert.That(result.shape[1]).IsEqualTo(5); + result.shape[0].Should().Be(3); + result.shape[1].Should().Be(5); // NumPy: result[0,0] = 0*0 + 1*5 + 2*10 + 3*15 = 70 - await Assert.That(result.GetDouble(0, 0)).IsEqualTo(70.0); + result.GetDouble(0, 0).Should().Be(70.0); } #endregion #region np.dot Tests - [Test] - public async Task Dot_Float64_VectorVector() + [TestMethod] + public void Dot_Float64_VectorVector() { // NumPy: np.dot([1,2,3], [4,5,6]) = 32 var a = np.array(new double[] { 1, 2, 3 }); @@ -138,22 +135,22 @@ public async Task Dot_Float64_VectorVector() var result = np.dot(a, b); - await Assert.That((double)result).IsEqualTo(32.0); + ((double)result).Should().Be(32.0); } - [Test] - public async Task Dot_Float32_VectorVector() + [TestMethod] + public void Dot_Float32_VectorVector() { var a = np.array(new float[] { 1, 2, 3 }); var b = np.array(new float[] { 4, 5, 6 }); var result = np.dot(a, b); - await Assert.That((float)result).IsEqualTo(32.0f); + ((float)result).Should().Be(32.0f); } - [Test] - public async Task Dot_MatrixVector() + [TestMethod] + public void Dot_MatrixVector() { // NumPy: np.dot([[1,2],[3,4]], [5,6]) = [17, 39] var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -161,13 +158,13 @@ public async Task Dot_MatrixVector() var result = np.dot(a, b); - await Assert.That(result.shape[0]).IsEqualTo(2); - await Assert.That(result.GetDouble(0)).IsEqualTo(17.0); - await Assert.That(result.GetDouble(1)).IsEqualTo(39.0); + result.shape[0].Should().Be(2); + result.GetDouble(0).Should().Be(17.0); + result.GetDouble(1).Should().Be(39.0); } - [Test] - public async Task Dot_MatrixMatrix_SameAsMatMul() + [TestMethod] + public void Dot_MatrixMatrix_SameAsMatMul() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); var b = np.array(new double[,] { { 5, 6 }, { 7, 8 } }); @@ -176,75 +173,75 @@ public async Task Dot_MatrixMatrix_SameAsMatMul() var matmulResult = np.matmul(a, b); // For 2D arrays, dot and matmul should give same result - await Assert.That(dotResult.GetDouble(0, 0)).IsEqualTo(matmulResult.GetDouble(0, 0)); - await Assert.That(dotResult.GetDouble(0, 1)).IsEqualTo(matmulResult.GetDouble(0, 1)); - await Assert.That(dotResult.GetDouble(1, 0)).IsEqualTo(matmulResult.GetDouble(1, 0)); - await Assert.That(dotResult.GetDouble(1, 1)).IsEqualTo(matmulResult.GetDouble(1, 1)); + dotResult.GetDouble(0, 0).Should().Be(matmulResult.GetDouble(0, 0)); + dotResult.GetDouble(0, 1).Should().Be(matmulResult.GetDouble(0, 1)); + dotResult.GetDouble(1, 0).Should().Be(matmulResult.GetDouble(1, 0)); + dotResult.GetDouble(1, 1).Should().Be(matmulResult.GetDouble(1, 1)); } #endregion #region Edge Cases - [Test] - public async Task MatMul_1x1_Matrices() + [TestMethod] + public void MatMul_1x1_Matrices() { var a = np.array(new double[,] { { 3 } }); var b = np.array(new double[,] { { 4 } }); var result = np.matmul(a, b); - await Assert.That(result.shape[0]).IsEqualTo(1); - await Assert.That(result.shape[1]).IsEqualTo(1); - await Assert.That(result.GetDouble(0, 0)).IsEqualTo(12.0); + result.shape[0].Should().Be(1); + result.shape[1].Should().Be(1); + result.GetDouble(0, 0).Should().Be(12.0); } - [Test] - public async Task MatMul_Identity_PreservesMatrix() + [TestMethod] + public void MatMul_Identity_PreservesMatrix() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); var identity = np.eye(2); var result = np.matmul(a, identity); - await Assert.That(result.GetDouble(0, 0)).IsEqualTo(1.0); - await Assert.That(result.GetDouble(0, 1)).IsEqualTo(2.0); - await Assert.That(result.GetDouble(1, 0)).IsEqualTo(3.0); - await Assert.That(result.GetDouble(1, 1)).IsEqualTo(4.0); + result.GetDouble(0, 0).Should().Be(1.0); + result.GetDouble(0, 1).Should().Be(2.0); + result.GetDouble(1, 0).Should().Be(3.0); + result.GetDouble(1, 1).Should().Be(4.0); } - [Test] - public async Task MatMul_ZeroMatrix_ReturnsZeros() + [TestMethod] + public void MatMul_ZeroMatrix_ReturnsZeros() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); var zeros = np.zeros(new Shape(2, 2), NPTypeCode.Double); var result = np.matmul(a, zeros); - await Assert.That(result.GetDouble(0, 0)).IsEqualTo(0.0); - await Assert.That(result.GetDouble(0, 1)).IsEqualTo(0.0); - await Assert.That(result.GetDouble(1, 0)).IsEqualTo(0.0); - await Assert.That(result.GetDouble(1, 1)).IsEqualTo(0.0); + result.GetDouble(0, 0).Should().Be(0.0); + result.GetDouble(0, 1).Should().Be(0.0); + result.GetDouble(1, 0).Should().Be(0.0); + result.GetDouble(1, 1).Should().Be(0.0); } #endregion #region Various DTypes - [Test] - public async Task MatMul_Int64_Correct() + [TestMethod] + public void MatMul_Int64_Correct() { var a = np.array(new long[,] { { 1, 2 }, { 3, 4 } }); var b = np.array(new long[,] { { 5, 6 }, { 7, 8 } }); var result = np.matmul(a, b); - await Assert.That(result.GetInt64(0, 0)).IsEqualTo(19L); - await Assert.That(result.GetInt64(1, 1)).IsEqualTo(50L); + result.GetInt64(0, 0).Should().Be(19L); + result.GetInt64(1, 1).Should().Be(50L); } - [Test] - public async Task Dot_LargeContiguousArrays() + [TestMethod] + public void Dot_LargeContiguousArrays() { // Test with larger arrays to ensure SIMD path handles size correctly var rng = np.random.RandomState(42); @@ -254,8 +251,8 @@ public async Task Dot_LargeContiguousArrays() // Should not throw var result = np.dot(a, b); - await Assert.That(result.shape[0]).IsEqualTo(100); - await Assert.That(result.shape[1]).IsEqualTo(100); + result.shape[0].Should().Be(100); + result.shape[1].Should().Be(100); } #endregion diff --git a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.Inv.Test.cs b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.Inv.Test.cs index 2d1d62718..43a95f14a 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.Inv.Test.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.Inv.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest.LinearAlgebra { + [TestClass] public class NdArrayInvTest { - //[Test] + //[TestMethod] public void Simple2x2() { var np1 = np.arange(4.0).reshape(2, 2); @@ -22,7 +23,7 @@ public void Simple2x2() Assert.IsTrue(Enumerable.SequenceEqual(new double[] {1, 0, 0, 1}, OncesMatrix.Data())); } - //[Test] + //[TestMethod] public void Simple3x3() { var np1 = new NDArray(typeof(double), new Shape(3, 3)); diff --git a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.LstSq.Test.cs b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.LstSq.Test.cs index 163f8ea99..410145f1f 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.LstSq.Test.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.LstSq.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.LinearAlgebra { + [TestClass] public class NDArrayLinSqTester { - //[Test] + //[TestMethod] public void DefaultTest() { NDArray A = new double[,] {{0.0, 1.0}, {1.0, 1.0}, {2.0, 1.0}, {3.0, 1.0}}; diff --git a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.QR.Test.cs b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.QR.Test.cs index d7a0703bc..6615b30ee 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.QR.Test.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.QR.Test.cs @@ -13,9 +13,10 @@ namespace NumSharp.UnitTest.LinearAlgebra /// Test concolve with standard example from /// https://www.numpy.org/devdocs/reference/generated/numpy.convolve.html /// + [TestClass] public class NdArrayQRTest { - //[Test] + //[TestMethod] public void FullMatrix() { var nd1 = np.array(new double[] {1, 1, 0, 1, 0, 1, 0, 1, 1}).reshape(3, 3); diff --git a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.SVD.Test.cs b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.SVD.Test.cs index 73d22a089..93ad65d7e 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.SVD.Test.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.SVD.Test.cs @@ -10,9 +10,10 @@ namespace NumSharp.UnitTest.LinearAlgebra { + [TestClass] public class NDArraySVDTester { - //[Test] + //[TestMethod] public void DefaultTest() { NDArray A = new NDArray(np.float64, new Shape(6, 5)); diff --git a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.Transpose.Test.cs b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.Transpose.Test.cs index 4f316cc9f..9863dcf4f 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.Transpose.Test.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.Transpose.Test.cs @@ -11,9 +11,10 @@ namespace NumSharp.UnitTest.LinearAlgebra { + [TestClass] public class TransposeTest { - [Test] + [TestMethod] public void TransposeVector() { // NumPy: transpose of 1D array returns the array itself (view semantics) @@ -25,7 +26,7 @@ public void TransposeVector() Assert.IsTrue(Enumerable.SequenceEqual(x.Data(), y.Data()), "Transpose should share memory with original (view semantics)"); } - [Test] + [TestMethod] public void Transpose3x2() { // np.arange returns int64 by default (NumPy 2.x) diff --git a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.matrix_power.Test.cs b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.matrix_power.Test.cs index 3594ef2cd..c921dc813 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/NdArray.matrix_power.Test.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/NdArray.matrix_power.Test.cs @@ -13,9 +13,10 @@ namespace NumSharp.UnitTest.LinearAlgebra /// Test concolve with standard example from /// https://www.numpy.org/devdocs/reference/generated/numpy.convolve.html /// + [TestClass] public class NdArrayMatrixPowerTest { - [Test] + [TestMethod] public void ZeroPowerTest() { var nd1 = new NDArray(typeof(double), new Shape(3, 3)); @@ -29,7 +30,7 @@ public void ZeroPowerTest() Assert.IsTrue(expected[idx, jdx] == onces[idx, jdx]); } - //[Test] + //[TestMethod] public void PowerOf3Test() { var nd1 = np.arange(9).reshape(3, 3).MakeGeneric(); diff --git a/test/NumSharp.UnitTest/LinearAlgebra/np.dot.BattleTest.cs b/test/NumSharp.UnitTest/LinearAlgebra/np.dot.BattleTest.cs index 56822ad28..0e82aa277 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/np.dot.BattleTest.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/np.dot.BattleTest.cs @@ -11,9 +11,10 @@ namespace NumSharp.UnitTest.LinearAlgebra; /// Battle tests for np.dot to ensure NumPy alignment. /// Based on running actual NumPy code and verifying NumSharp matches. /// +[TestClass] public class DotBattleTests : TestClass { - [Test] + [TestMethod] public void Dot_1D_1D_InnerProduct() { // NumPy: np.dot([1,2,3], [4,5,6]) = 32, dtype=int64 @@ -25,7 +26,7 @@ public void Dot_1D_1D_InnerProduct() Assert.AreEqual(0, result.ndim); // Scalar result } - [Test] + [TestMethod] public void Dot_2D_1D() { // NumPy: [[1,2],[3,4]] dot [5,6] = [17, 39], shape=(2,) @@ -37,7 +38,7 @@ public void Dot_2D_1D() result.Should().BeOfValues(17, 39); } - [Test] + [TestMethod] public void Dot_1D_2D() { // NumPy: [1,2] dot [[3,4],[5,6]] = [13, 16], shape=(2,) @@ -49,7 +50,7 @@ public void Dot_1D_2D() result.Should().BeOfValues(13, 16); } - [Test] + [TestMethod] public void Dot_2D_2D_MatrixMultiply() { // NumPy: [[1,2],[3,4]] dot [[5,6],[7,8]] = [[19,22],[43,50]] @@ -64,7 +65,7 @@ public void Dot_2D_2D_MatrixMultiply() Assert.AreEqual(50, (int)result[1, 1]); } - [Test] + [TestMethod] public void Dot_Scalars() { // NumPy: np.dot(3, 4) = 12 @@ -72,7 +73,7 @@ public void Dot_Scalars() Assert.AreEqual(12, (int)result); } - [Test] + [TestMethod] public void Dot_MixedDtypes_Int32_Float64() { // NumPy: int32 dot float64 = float64 @@ -83,7 +84,7 @@ public void Dot_MixedDtypes_Int32_Float64() Assert.AreEqual(17.0, (double)result, 1e-10); } - [Test] + [TestMethod] public void Dot_EmptyArrays() { // NumPy: dot of empty 1D = 0.0 @@ -94,7 +95,7 @@ public void Dot_EmptyArrays() Assert.AreEqual(0.0, (double)result); } - [Test] + [TestMethod] public void Dot_3D_2D_HigherDimensions() { // NumPy: shape(2,3,4) dot shape(4,5) = shape(2,3,5) @@ -105,7 +106,7 @@ public void Dot_3D_2D_HigherDimensions() result.Should().BeShaped(2, 3, 5); } - [Test] + [TestMethod] [OpenBugs] // NumSharp returns (2,4) instead of (2,3) public void Dot_ND_1D() { @@ -121,7 +122,7 @@ public void Dot_ND_1D() Assert.AreEqual(220, (int)result[1, 2]); } - [Test] + [TestMethod] public void Dot_StridedArrays_NonContiguous() { // NumPy: strided (non-contiguous) arrays @@ -135,7 +136,7 @@ public void Dot_StridedArrays_NonContiguous() Assert.AreEqual(140, (int)result); } - [Test] + [TestMethod] public void Dot_TransposedArrays() { // NumPy: (2,3) dot (3,2) = (2,2) @@ -151,7 +152,7 @@ public void Dot_TransposedArrays() Assert.AreEqual(50, (int)result[1, 1]); } - [Test] + [TestMethod] public void Dot_LargeMatrices() { // Verify large matrix multiply works @@ -167,7 +168,7 @@ public void Dot_LargeMatrices() Assert.AreEqual(expected, (double)result[0, 0], 1e-10); } - [Test] + [TestMethod] public void Dot_ColumnVector_RowVector() { // (3,1) dot (1,3) = (3,3) outer product @@ -181,7 +182,7 @@ public void Dot_ColumnVector_RowVector() Assert.AreEqual(18, (int)result[2, 2]); // 3 * 6 = 18 } - [Test] + [TestMethod] public void Dot_RowVector_ColumnVector() { // (1,3) dot (3,1) = (1,1) scalar in matrix form diff --git a/test/NumSharp.UnitTest/LinearAlgebra/np.dot.Test.cs b/test/NumSharp.UnitTest/LinearAlgebra/np.dot.Test.cs index 038a68789..b46d92cdc 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/np.dot.Test.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/np.dot.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.LinearAlgebra { + [TestClass] public class np_dot_test : TestClass { - [Test] + [TestMethod] public void Vector_Vector() { var a = arange(5); @@ -17,7 +18,7 @@ public void Vector_Vector() np.dot(a, b).Should().BeScalar(30); } - [Test] + [TestMethod] public void Dot0X0() { int x = 2; @@ -27,7 +28,7 @@ public void Dot0X0() Assert.AreEqual(z, 6); } - [Test] + [TestMethod] public void Dot1x1() { var x = np.arange(3); @@ -37,7 +38,7 @@ public void Dot1x1() Assert.IsTrue(nd3 == 14); } - [Test] + [TestMethod] public void Dot2x1() { var x = np.array(1, 1, 1, 2, 2, 2, 2, 3).reshape((4, 2)); @@ -46,7 +47,7 @@ public void Dot2x1() np.dot(x, y).Should().BeShaped(4).And.BeOfValues(5, 8, 10, 13); } - [Test] + [TestMethod] public void Dot2x2() { var x = array((2, 2), 3, 1, 1, 2); @@ -54,7 +55,7 @@ public void Dot2x2() np.dot(x, y).Should().BeShaped(2, 2).And.BeOfValues(7, 11, 4, 7); } - [Test] + [TestMethod] public void Dot2222x2222() { var x = arange((2, 2, 2, 2)); @@ -67,7 +68,7 @@ public void Dot2222x2222() 30, 59, 146, 175, 262, 291, 378, 407); } - [Test] + [TestMethod] public void Dot3412x5621() { var x = arange((3, 4, 1, 2)); @@ -76,7 +77,7 @@ public void Dot3412x5621() .And.BeOfValues(1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 3, 13, 23, 33, 43, 53, 63, 73, 83, 93, 103, 113, 123, 133, 143, 153, 163, 173, 183, 193, 203, 213, 223, 233, 243, 253, 263, 273, 283, 293, 5, 23, 41, 59, 77, 95, 113, 131, 149, 167, 185, 203, 221, 239, 257, 275, 293, 311, 329, 347, 365, 383, 401, 419, 437, 455, 473, 491, 509, 527, 7, 33, 59, 85, 111, 137, 163, 189, 215, 241, 267, 293, 319, 345, 371, 397, 423, 449, 475, 501, 527, 553, 579, 605, 631, 657, 683, 709, 735, 761, 9, 43, 77, 111, 145, 179, 213, 247, 281, 315, 349, 383, 417, 451, 485, 519, 553, 587, 621, 655, 689, 723, 757, 791, 825, 859, 893, 927, 961, 995, 11, 53, 95, 137, 179, 221, 263, 305, 347, 389, 431, 473, 515, 557, 599, 641, 683, 725, 767, 809, 851, 893, 935, 977, 1019, 1061, 1103, 1145, 1187, 1229, 13, 63, 113, 163, 213, 263, 313, 363, 413, 463, 513, 563, 613, 663, 713, 763, 813, 863, 913, 963, 1013, 1063, 1113, 1163, 1213, 1263, 1313, 1363, 1413, 1463, 15, 73, 131, 189, 247, 305, 363, 421, 479, 537, 595, 653, 711, 769, 827, 885, 943, 1001, 1059, 1117, 1175, 1233, 1291, 1349, 1407, 1465, 1523, 1581, 1639, 1697, 17, 83, 149, 215, 281, 347, 413, 479, 545, 611, 677, 743, 809, 875, 941, 1007, 1073, 1139, 1205, 1271, 1337, 1403, 1469, 1535, 1601, 1667, 1733, 1799, 1865, 1931, 19, 93, 167, 241, 315, 389, 463, 537, 611, 685, 759, 833, 907, 981, 1055, 1129, 1203, 1277, 1351, 1425, 1499, 1573, 1647, 1721, 1795, 1869, 1943, 2017, 2091, 2165, 21, 103, 185, 267, 349, 431, 513, 595, 677, 759, 841, 923, 1005, 1087, 1169, 1251, 1333, 1415, 1497, 1579, 1661, 1743, 1825, 1907, 1989, 2071, 2153, 2235, 2317, 2399, 23, 113, 203, 293, 383, 473, 563, 653, 743, 833, 923, 1013, 1103, 1193, 1283, 1373, 1463, 1553, 1643, 1733, 1823, 1913, 2003, 2093, 2183, 2273, 2363, 2453, 2543, 2633); } - [Test] + [TestMethod] public void Dot311x511() { var x = arange((3, 1, 1)); @@ -85,7 +86,7 @@ public void Dot311x511() .And.BeOfValues(0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 2, 4, 6, 8); } - [Test] + [TestMethod] public void Dot2x3And3x2() { var x = np.array(new float[,] {{0, 1, 2}, {3, 4, 5}}); @@ -97,7 +98,7 @@ public void Dot2x3And3x2() Assert.IsTrue(Enumerable.SequenceEqual(z.Data(), new float[] {5, 14, 14, 50})); } - [Test] + [TestMethod] [OpenBugs] // RNG IndexOutOfRangeException in MT19937 public void Dot30_300x30_300() { diff --git a/test/NumSharp.UnitTest/LinearAlgebra/np.matmul.BattleTest.cs b/test/NumSharp.UnitTest/LinearAlgebra/np.matmul.BattleTest.cs index 9a0ed093c..4a914c5e5 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/np.matmul.BattleTest.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/np.matmul.BattleTest.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.LinearAlgebra; /// /// Battle tests for np.matmul (@ operator) to ensure NumPy alignment. /// +[TestClass] public class MatmulBattleTests : TestClass { - [Test] + [TestMethod] public void Matmul_2D_2D() { // NumPy: [[1,2],[3,4]] @ [[5,6],[7,8]] = [[19,22],[43,50]] @@ -26,7 +27,7 @@ public void Matmul_2D_2D() Assert.AreEqual(50, (int)result[1, 1]); } - [Test] + [TestMethod] [OpenBugs] // NumSharp requires 2D inputs, doesn't support 1D @ 1D public void Matmul_1D_1D_DotProduct() { @@ -38,7 +39,7 @@ public void Matmul_1D_1D_DotProduct() Assert.AreEqual(32, (int)result); } - [Test] + [TestMethod] [OpenBugs] // NumSharp returns shape (2,1) instead of (2,) public void Matmul_2D_1D() { @@ -51,7 +52,7 @@ public void Matmul_2D_1D() result.Should().BeOfValues(17, 39); } - [Test] + [TestMethod] [OpenBugs] // NumSharp throws dimension mismatch for 1D @ 2D public void Matmul_1D_2D() { @@ -64,7 +65,7 @@ public void Matmul_1D_2D() result.Should().BeOfValues(13, 16); } - [Test] + [TestMethod] [OpenBugs] // NumSharp crashes on >2D broadcasting public void Matmul_Broadcasting_3D_2D() { @@ -81,7 +82,7 @@ public void Matmul_Broadcasting_3D_2D() Assert.AreEqual(3, (int)result[0, 1, 1]); } - [Test] + [TestMethod] public void Matmul_LargeMatrices() { var a = np.arange(1000).reshape(100, 10).astype(np.float64); @@ -91,7 +92,7 @@ public void Matmul_LargeMatrices() result.Should().BeShaped(100, 50); } - [Test] + [TestMethod] public void Matmul_Transposed() { // (2,3) @ (3,2) = (2,2) diff --git a/test/NumSharp.UnitTest/LinearAlgebra/np.matmul.Test.cs b/test/NumSharp.UnitTest/LinearAlgebra/np.matmul.Test.cs index d0370e2e3..42daf0ce3 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/np.matmul.Test.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/np.matmul.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.LinearAlgebra { + [TestClass] public class np_matmul_test { - [Test] + [TestMethod] public void Case1_2_2() { var a = np.arange(9).reshape(3, 3); @@ -22,7 +23,7 @@ public void Case1_2_2() ret.flat.AsIterator().ToArray().Should().BeEquivalentTo(new long[] { 15, 18, 21, 42, 54, 66, 69, 90, 111 }); } - [Test] + [TestMethod] public void Case2_2_2() { var a = np.full(new Shape(3, 3), 2); @@ -32,7 +33,7 @@ public void Case2_2_2() ret.flat.AsIterator().Cast().Distinct().ToArray().Should().Contain(12).And.HaveCount(1); } - [Test] + [TestMethod] public void Case1_2_1() { var a = np.arange(9).reshape(3, 3); @@ -43,7 +44,7 @@ public void Case1_2_1() ret.flat.AsIterator().ToArray().Should().BeEquivalentTo(new long[] { 5, 14, 23 }); } - [Test] + [TestMethod] public void Case2_2_1() { var a = np.full(new Shape(3, 3), 2); @@ -53,7 +54,7 @@ public void Case2_2_1() ret.flat.AsIterator().Cast().Distinct().ToArray().Should().Contain(18).And.HaveCount(1); } - [Test] + [TestMethod] public void Case_3_2_2__3_2_2() { var a = np.full(new Shape(3, 2, 2), 2); @@ -62,7 +63,7 @@ public void Case_3_2_2__3_2_2() ret.Should().AllValuesBe(12).And.BeShaped(3, 2, 2); } - [Test] + [TestMethod] public void Case_3_1_2_2__3_2_2() { var a = np.full(new Shape(3, 1, 2, 2), 2); @@ -71,7 +72,7 @@ public void Case_3_1_2_2__3_2_2() ret.Should().AllValuesBe(12).And.BeShaped(3, 3, 2, 2); } - [Test] + [TestMethod] public void Case_3_1_2_2__3_2_2_Arange() { var a = np.arange(2 * 1 * 2 * 2).reshape((2, 1, 2, 2)); @@ -80,7 +81,7 @@ public void Case_3_1_2_2__3_2_2_Arange() ret.Should().BeOfValues(2, 3, 6, 11, 6, 7, 26, 31, 10, 19, 14, 27, 46, 55, 66, 79).And.BeShaped(2, 2, 2, 2); } - [Test] + [TestMethod] public void Case1_3_1_vs_1_3() { var a = np.arange(3).reshape(3, 1); @@ -91,7 +92,7 @@ public void Case1_3_1_vs_1_3() ret.flat.AsIterator().ToArray().Should().BeEquivalentTo(new long[] { 0, 0, 0, 0, 1, 2, 0, 2, 4 }); } - [Test] + [TestMethod] public void Case2_3_1_vs_1_3() { var a = np.full(new Shape(3, 1), 2); @@ -101,7 +102,7 @@ public void Case2_3_1_vs_1_3() ret.flat.AsIterator().Cast().Distinct().ToArray().Should().Contain(4).And.HaveCount(1); } - [Test] + [TestMethod] public void TwoAndTwoInt() { var a = np.array(new int[][] {new int[] {1, 0}, new int[] {0, 1}}); diff --git a/test/NumSharp.UnitTest/LinearAlgebra/np.outer.BattleTest.cs b/test/NumSharp.UnitTest/LinearAlgebra/np.outer.BattleTest.cs index a1d19dbac..2b7aa14a5 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/np.outer.BattleTest.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/np.outer.BattleTest.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.LinearAlgebra; /// /// Battle tests for np.outer to ensure NumPy alignment. /// +[TestClass] public class OuterBattleTests : TestClass { - [Test] + [TestMethod] public void Outer_1D_1D() { // NumPy: outer([1,2,3], [4,5]) = [[4,5],[8,10],[12,15]] @@ -28,7 +29,7 @@ public void Outer_1D_1D() Assert.AreEqual(15, (int)result[2, 1]); } - [Test] + [TestMethod] public void Outer_DifferentSizes() { // NumPy: outer(arange(5), arange(3)) has shape (5,3) @@ -47,7 +48,7 @@ public void Outer_DifferentSizes() Assert.AreEqual(8, (int)result[4, 2]); } - [Test] + [TestMethod] public void Outer_2D_Flattened() { // NumPy flattens 2D inputs: outer([[1,2],[3,4]], [[5,6],[7,8]]) has shape (4,4) @@ -62,7 +63,7 @@ public void Outer_2D_Flattened() Assert.AreEqual(32, (int)result[3, 3]); } - [Test] + [TestMethod] public void Outer_WithFloats() { var a = np.array(new[] { 1.0, 2.0, 3.0 }); @@ -75,7 +76,7 @@ public void Outer_WithFloats() Assert.AreEqual(4.5, (double)result[2, 1], 1e-10); // 3.0 * 1.5 } - [Test] + [TestMethod] public void Outer_SingleElement() { var a = np.array(new[] { 5 }); diff --git a/test/NumSharp.UnitTest/LinearAlgebra/np.outer.Test.cs b/test/NumSharp.UnitTest/LinearAlgebra/np.outer.Test.cs index e04cf5bdf..c180b0561 100644 --- a/test/NumSharp.UnitTest/LinearAlgebra/np.outer.Test.cs +++ b/test/NumSharp.UnitTest/LinearAlgebra/np.outer.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.LinearAlgebra { + [TestClass] public class np_outer_test { - [Test] + [TestMethod] public void Case1() { np.outer(np.ones(5), np.linspace(-2, 2, 5)) diff --git a/test/NumSharp.UnitTest/Logic/NEP50.cs b/test/NumSharp.UnitTest/Logic/NEP50.cs index 07677f528..fc92568c2 100644 --- a/test/NumSharp.UnitTest/Logic/NEP50.cs +++ b/test/NumSharp.UnitTest/Logic/NEP50.cs @@ -24,6 +24,7 @@ namespace NumSharp.UnitTest.Logic; /// /// Each test is verified against NumPy 2.4.2 output. /// +[TestClass] public class NEP50_TypePromotion { #region 1. Unsigned Array + Python Int (array dtype wins) @@ -32,7 +33,7 @@ public class NEP50_TypePromotion /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.uint8) + 5).dtype)" /// Output: uint8 /// - [Test] + [TestMethod] public void UInt8Array_Plus_PythonInt_Returns_UInt8() { var arr = np.array(new byte[] { 1, 2, 3 }); @@ -48,7 +49,7 @@ public void UInt8Array_Plus_PythonInt_Returns_UInt8() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.uint16) + 5).dtype)" /// Output: uint16 /// - [Test] + [TestMethod] public void UInt16Array_Plus_PythonInt_Returns_UInt16() { var arr = np.array(new ushort[] { 1, 2, 3 }); @@ -62,7 +63,7 @@ public void UInt16Array_Plus_PythonInt_Returns_UInt16() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.uint32) + 5).dtype)" /// Output: uint32 /// - [Test] + [TestMethod] public void UInt32Array_Plus_PythonInt_Returns_UInt32() { var arr = np.array(new uint[] { 1, 2, 3 }); @@ -76,7 +77,7 @@ public void UInt32Array_Plus_PythonInt_Returns_UInt32() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.uint64) + 5).dtype)" /// Output: uint64 /// - [Test] + [TestMethod] public void UInt64Array_Plus_PythonInt_Returns_UInt64() { var arr = np.array(new ulong[] { 1, 2, 3 }); @@ -94,7 +95,7 @@ public void UInt64Array_Plus_PythonInt_Returns_UInt64() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.int16) + 5).dtype)" /// Output: int16 /// - [Test] + [TestMethod] public void Int16Array_Plus_PythonInt_Returns_Int16() { var arr = np.array(new short[] { 1, 2, 3 }); @@ -108,7 +109,7 @@ public void Int16Array_Plus_PythonInt_Returns_Int16() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.int32) + 5).dtype)" /// Output: int32 /// - [Test] + [TestMethod] public void Int32Array_Plus_PythonInt_Returns_Int32() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -122,7 +123,7 @@ public void Int32Array_Plus_PythonInt_Returns_Int32() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.int64) + 5).dtype)" /// Output: int64 /// - [Test] + [TestMethod] public void Int64Array_Plus_PythonInt_Returns_Int64() { var arr = np.array(new long[] { 1, 2, 3 }); @@ -140,7 +141,7 @@ public void Int64Array_Plus_PythonInt_Returns_Int64() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.float32) + 5).dtype)" /// Output: float32 /// - [Test] + [TestMethod] public void Float32Array_Plus_PythonInt_Returns_Float32() { var arr = np.array(new float[] { 1f, 2f, 3f }); @@ -154,7 +155,7 @@ public void Float32Array_Plus_PythonInt_Returns_Float32() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.float64) + 5).dtype)" /// Output: float64 /// - [Test] + [TestMethod] public void Float64Array_Plus_PythonInt_Returns_Float64() { var arr = np.array(new double[] { 1.0, 2.0, 3.0 }); @@ -172,7 +173,7 @@ public void Float64Array_Plus_PythonInt_Returns_Float64() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.float32) + 5.0).dtype)" /// Output: float32 /// - [Test] + [TestMethod] public void Float32Array_Plus_PythonFloat_Returns_Float32() { var arr = np.array(new float[] { 1f, 2f, 3f }); @@ -186,7 +187,7 @@ public void Float32Array_Plus_PythonFloat_Returns_Float32() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.float64) + 5.0).dtype)" /// Output: float64 /// - [Test] + [TestMethod] public void Float64Array_Plus_PythonFloat_Returns_Float64() { var arr = np.array(new double[] { 1.0, 2.0, 3.0 }); @@ -204,7 +205,7 @@ public void Float64Array_Plus_PythonFloat_Returns_Float64() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.int32) + 5.0).dtype)" /// Output: float64 /// - [Test] + [TestMethod] public void Int32Array_Plus_PythonFloat_Returns_Float64() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -218,7 +219,7 @@ public void Int32Array_Plus_PythonFloat_Returns_Float64() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.uint8) + 5.0).dtype)" /// Output: float64 /// - [Test] + [TestMethod] public void UInt8Array_Plus_PythonFloat_Returns_Float64() { var arr = np.array(new byte[] { 1, 2, 3 }); @@ -236,7 +237,7 @@ public void UInt8Array_Plus_PythonFloat_Returns_Float64() /// Verified: python3 -c "import numpy as np; print((np.array([10,20,30], np.uint8) - 5).dtype)" /// Output: uint8 /// - [Test] + [TestMethod] public void UInt8Array_Minus_PythonInt_Returns_UInt8() { var arr = np.array(new byte[] { 10, 20, 30 }); @@ -252,7 +253,7 @@ public void UInt8Array_Minus_PythonInt_Returns_UInt8() /// Verified: python3 -c "import numpy as np; print((np.array([10,20,30], np.uint16) - 5).dtype)" /// Output: uint16 /// - [Test] + [TestMethod] public void UInt16Array_Minus_PythonInt_Returns_UInt16() { var arr = np.array(new ushort[] { 10, 20, 30 }); @@ -270,7 +271,7 @@ public void UInt16Array_Minus_PythonInt_Returns_UInt16() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.uint8) * 5).dtype)" /// Output: uint8 /// - [Test] + [TestMethod] public void UInt8Array_Times_PythonInt_Returns_UInt8() { var arr = np.array(new byte[] { 1, 2, 3 }); @@ -286,7 +287,7 @@ public void UInt8Array_Times_PythonInt_Returns_UInt8() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.uint32) * 5).dtype)" /// Output: uint32 /// - [Test] + [TestMethod] public void UInt32Array_Times_PythonInt_Returns_UInt32() { var arr = np.array(new uint[] { 1, 2, 3 }); @@ -306,7 +307,7 @@ public void UInt32Array_Times_PythonInt_Returns_UInt32() /// /// NumSharp now matches NumPy: true division returns float64. /// - [Test] + [TestMethod] public void UInt8Array_Divide_PythonInt_Returns_Float64() { var arr = np.array(new byte[] { 10, 20, 30 }); @@ -323,7 +324,7 @@ public void UInt8Array_Divide_PythonInt_Returns_Float64() /// /// NumSharp now matches NumPy: true division returns float64. /// - [Test] + [TestMethod] public void Int32Array_Divide_PythonInt_Returns_Float64() { var arr = np.array(new int[] { 10, 20, 30 }); @@ -339,7 +340,7 @@ public void Int32Array_Divide_PythonInt_Returns_Float64() /// Verified: python3 -c "import numpy as np; print((np.array([10,20,30], np.float64) / 5).dtype)" /// Output: float64 /// - [Test] + [TestMethod] public void Float64Array_Divide_PythonInt_Returns_Float64() { var arr = np.array(new double[] { 10.0, 20.0, 30.0 }); @@ -357,7 +358,7 @@ public void Float64Array_Divide_PythonInt_Returns_Float64() /// Verified: python3 -c "import numpy as np; print((np.array([10,20,30], np.uint8) % 7).dtype)" /// Output: uint8 /// - [Test] + [TestMethod] public void UInt8Array_Mod_PythonInt_Returns_UInt8() { var arr = np.array(new byte[] { 10, 20, 30 }); @@ -373,7 +374,7 @@ public void UInt8Array_Mod_PythonInt_Returns_UInt8() /// Verified: python3 -c "import numpy as np; print((np.array([10,20,30], np.int32) % 7).dtype)" /// Output: int32 /// - [Test] + [TestMethod] public void Int32Array_Mod_PythonInt_Returns_Int32() { var arr = np.array(new int[] { 10, 20, 30 }); @@ -391,7 +392,7 @@ public void Int32Array_Mod_PythonInt_Returns_Int32() /// Verified: python3 -c "import numpy as np; print((5 + np.array([1,2,3], np.uint8)).dtype)" /// Output: uint8 /// - [Test] + [TestMethod] public void PythonInt_Plus_UInt8Array_Returns_UInt8() { var arr = np.array(new byte[] { 1, 2, 3 }); @@ -405,7 +406,7 @@ public void PythonInt_Plus_UInt8Array_Returns_UInt8() /// Verified: python3 -c "import numpy as np; print((5 - np.array([1,2,3], np.uint8)).dtype)" /// Output: uint8 /// - [Test] + [TestMethod] public void PythonInt_Minus_UInt8Array_Returns_UInt8() { var arr = np.array(new byte[] { 1, 2, 3 }); @@ -421,7 +422,7 @@ public void PythonInt_Minus_UInt8Array_Returns_UInt8() /// Verified: python3 -c "import numpy as np; print((5 * np.array([1,2,3], np.uint8)).dtype)" /// Output: uint8 /// - [Test] + [TestMethod] public void PythonInt_Times_UInt8Array_Returns_UInt8() { var arr = np.array(new byte[] { 1, 2, 3 }); @@ -439,7 +440,7 @@ public void PythonInt_Times_UInt8Array_Returns_UInt8() /// Direct verification of the type promotion table for NEP 50 changes. /// These are the 12 entries that changed from NumPy 1.x to 2.x behavior. /// - [Test] + [TestMethod] public void ArrayScalarType_UInt8_SignedScalars() { // NEP 50: uint8 array + signed scalar → uint8 (array wins) @@ -448,7 +449,7 @@ public void ArrayScalarType_UInt8_SignedScalars() np._FindCommonArrayScalarType(NPTypeCode.Byte, NPTypeCode.Int64).Should().Be(NPTypeCode.Byte); } - [Test] + [TestMethod] public void ArrayScalarType_UInt16_SignedScalars() { // NEP 50: uint16 array + signed scalar → uint16 (array wins) @@ -457,7 +458,7 @@ public void ArrayScalarType_UInt16_SignedScalars() np._FindCommonArrayScalarType(NPTypeCode.UInt16, NPTypeCode.Int64).Should().Be(NPTypeCode.UInt16); } - [Test] + [TestMethod] public void ArrayScalarType_UInt32_SignedScalars() { // NEP 50: uint32 array + signed scalar → uint32 (array wins) @@ -466,7 +467,7 @@ public void ArrayScalarType_UInt32_SignedScalars() np._FindCommonArrayScalarType(NPTypeCode.UInt32, NPTypeCode.Int64).Should().Be(NPTypeCode.UInt32); } - [Test] + [TestMethod] public void ArrayScalarType_UInt64_SignedScalars() { // NEP 50: uint64 array + signed scalar → uint64 (array wins) @@ -486,7 +487,7 @@ public void ArrayScalarType_UInt64_SignedScalars() /// Verified: python3 -c "import numpy as np; print((np.array([1], np.uint8) + np.array([5], np.int32)).dtype)" /// Output: int32 /// - [Test] + [TestMethod] public void ArrayArray_UInt8_Plus_Int32_Returns_Int32() { var arr1 = np.array(new byte[] { 1, 2, 3 }); @@ -501,7 +502,7 @@ public void ArrayArray_UInt8_Plus_Int32_Returns_Int32() /// Verified: python3 -c "import numpy as np; print((np.array([1], np.uint16) + np.array([5], np.int32)).dtype)" /// Output: int32 /// - [Test] + [TestMethod] public void ArrayArray_UInt16_Plus_Int32_Returns_Int32() { var arr1 = np.array(new ushort[] { 1, 2, 3 }); @@ -518,7 +519,7 @@ public void ArrayArray_UInt16_Plus_Int32_Returns_Int32() /// /// Same-type operations remain unchanged. /// - [Test] + [TestMethod] public void SameType_UInt8_Plus_UInt8_Returns_UInt8() { var arr1 = np.array(new byte[] { 1, 2, 3 }); @@ -532,7 +533,7 @@ public void SameType_UInt8_Plus_UInt8_Returns_UInt8() /// /// Unsigned array + larger unsigned scalar → array dtype (unchanged). /// - [Test] + [TestMethod] public void UInt8Array_Plus_UInt32Scalar_Returns_UInt8() { // This was already "array wins" in NumPy 1.x for same-kind @@ -542,7 +543,7 @@ public void UInt8Array_Plus_UInt32Scalar_Returns_UInt8() /// /// Float operations with int scalars → float (array kind wins). /// - [Test] + [TestMethod] public void Float32Array_Operations_PreserveFloat() { var arr = np.array(new float[] { 1f, 2f, 3f }); @@ -560,7 +561,7 @@ public void Float32Array_Operations_PreserveFloat() /// /// Empty array operations should preserve dtype. /// - [Test] + [TestMethod] public void EmptyArray_Operations_PreserveDtype() { var arr = np.array(Array.Empty()); @@ -573,7 +574,7 @@ public void EmptyArray_Operations_PreserveDtype() /// /// 1D array operations. /// - [Test] + [TestMethod] public void OneDimensional_UInt8_Operations() { var arr = np.arange(10).astype(np.uint8); @@ -586,7 +587,7 @@ public void OneDimensional_UInt8_Operations() /// /// Multi-dimensional array operations. /// - [Test] + [TestMethod] public void MultiDimensional_UInt8_Operations() { var arr = np.arange(12).astype(np.uint8).reshape(3, 4); @@ -607,7 +608,7 @@ public void MultiDimensional_UInt8_Operations() /// /// NumSharp uses scalar-scalar table which may differ. /// - [Test] + [TestMethod] [Misaligned] public void ScalarArray_Operations_UsesScalarScalarPromotion() { @@ -628,7 +629,7 @@ public void ScalarArray_Operations_UsesScalarScalarPromotion() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.uint8) ** 2).dtype)" /// Output: uint8 /// - [Test] + [TestMethod] public void UInt8Array_Power_PythonInt_Returns_UInt8() { var arr = np.array(new byte[] { 1, 2, 3 }); @@ -644,7 +645,7 @@ public void UInt8Array_Power_PythonInt_Returns_UInt8() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.int32) ** 2).dtype)" /// Output: int32 /// - [Test] + [TestMethod] public void Int32Array_Power_PythonInt_Returns_Int32() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -668,7 +669,7 @@ public void Int32Array_Power_PythonInt_Returns_Int32() /// /// NumSharp now follows NumPy 2.x behavior. /// - [Test] + [TestMethod] public void Documentation_NEP50_BreakingChange() { // This is the key behavioral change from NumPy 1.x to 2.x @@ -692,7 +693,7 @@ public void Documentation_NEP50_BreakingChange() /// /// Note: NumSharp doesn't support int8 (sbyte), so we use int16. /// - [Test] + [TestMethod] public void CrossKind_IntArray_Plus_Float_Returns_Float64() { var intArr = np.array(new short[] { 1, 2, 3 }); // int16 @@ -705,7 +706,7 @@ public void CrossKind_IntArray_Plus_Float_Returns_Float64() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.uint8) + 5.0).dtype)" /// Output: float64 /// - [Test] + [TestMethod] public void CrossKind_UInt8Array_Plus_Float_Returns_Float64() { var arr = np.array(new byte[] { 1, 2, 3 }); @@ -718,7 +719,7 @@ public void CrossKind_UInt8Array_Plus_Float_Returns_Float64() /// Verified: python3 -c "import numpy as np; print((np.array([1,2,3], np.int32) + 5.0).dtype)" /// Output: float64 /// - [Test] + [TestMethod] public void CrossKind_Int32Array_Plus_Float_Returns_Float64() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -740,7 +741,7 @@ public void CrossKind_Int32Array_Plus_Float_Returns_Float64() /// NumPy 2.x with numpy scalar: int16 (strongly typed) /// NumSharp with C# short: treats as weakly typed → uint8 /// - [Test] + [TestMethod] public void NEP50_UInt8_Plus_Short_AllOps() { var arr = np.array(new byte[] { 10, 20, 30 }); @@ -752,7 +753,7 @@ public void NEP50_UInt8_Plus_Short_AllOps() (arr % scalar).dtype.Should().Be(np.uint8, "uint8 % int16 → uint8"); } - [Test] + [TestMethod] public void NEP50_UInt8_Plus_Int_AllOps() { var arr = np.array(new byte[] { 10, 20, 30 }); @@ -764,7 +765,7 @@ public void NEP50_UInt8_Plus_Int_AllOps() (arr % scalar).dtype.Should().Be(np.uint8, "uint8 % int32 → uint8"); } - [Test] + [TestMethod] public void NEP50_UInt8_Plus_Long_AllOps() { var arr = np.array(new byte[] { 10, 20, 30 }); @@ -780,7 +781,7 @@ public void NEP50_UInt8_Plus_Long_AllOps() // UINT16 + SIGNED SCALARS (3 combinations) // ============================================================================ - [Test] + [TestMethod] public void NEP50_UInt16_Plus_Short_AllOps() { var arr = np.array(new ushort[] { 100, 200, 300 }); @@ -792,7 +793,7 @@ public void NEP50_UInt16_Plus_Short_AllOps() (arr % scalar).dtype.Should().Be(np.uint16, "uint16 % int16 → uint16"); } - [Test] + [TestMethod] public void NEP50_UInt16_Plus_Int_AllOps() { var arr = np.array(new ushort[] { 100, 200, 300 }); @@ -804,7 +805,7 @@ public void NEP50_UInt16_Plus_Int_AllOps() (arr % scalar).dtype.Should().Be(np.uint16, "uint16 % int32 → uint16"); } - [Test] + [TestMethod] public void NEP50_UInt16_Plus_Long_AllOps() { var arr = np.array(new ushort[] { 100, 200, 300 }); @@ -820,7 +821,7 @@ public void NEP50_UInt16_Plus_Long_AllOps() // UINT32 + SIGNED SCALARS (3 combinations) // ============================================================================ - [Test] + [TestMethod] public void NEP50_UInt32_Plus_Short_AllOps() { var arr = np.array(new uint[] { 1000, 2000, 3000 }); @@ -832,7 +833,7 @@ public void NEP50_UInt32_Plus_Short_AllOps() (arr % scalar).dtype.Should().Be(np.uint32, "uint32 % int16 → uint32"); } - [Test] + [TestMethod] public void NEP50_UInt32_Plus_Int_AllOps() { var arr = np.array(new uint[] { 1000, 2000, 3000 }); @@ -844,7 +845,7 @@ public void NEP50_UInt32_Plus_Int_AllOps() (arr % scalar).dtype.Should().Be(np.uint32, "uint32 % int32 → uint32"); } - [Test] + [TestMethod] public void NEP50_UInt32_Plus_Long_AllOps() { var arr = np.array(new uint[] { 1000, 2000, 3000 }); @@ -860,7 +861,7 @@ public void NEP50_UInt32_Plus_Long_AllOps() // UINT64 + SIGNED SCALARS (3 combinations) // ============================================================================ - [Test] + [TestMethod] public void NEP50_UInt64_Plus_Short_AllOps() { var arr = np.array(new ulong[] { 10000, 20000, 30000 }); @@ -872,7 +873,7 @@ public void NEP50_UInt64_Plus_Short_AllOps() (arr % scalar).dtype.Should().Be(np.uint64, "uint64 % int16 → uint64"); } - [Test] + [TestMethod] public void NEP50_UInt64_Plus_Int_AllOps() { var arr = np.array(new ulong[] { 10000, 20000, 30000 }); @@ -884,7 +885,7 @@ public void NEP50_UInt64_Plus_Int_AllOps() (arr % scalar).dtype.Should().Be(np.uint64, "uint64 % int32 → uint64"); } - [Test] + [TestMethod] public void NEP50_UInt64_Plus_Long_AllOps() { var arr = np.array(new ulong[] { 10000, 20000, 30000 }); @@ -903,7 +904,7 @@ public void NEP50_UInt64_Plus_Long_AllOps() /// /// Verify actual computed values are correct, not just dtypes. /// - [Test] + [TestMethod] public void NEP50_Values_UInt8_Operations() { var arr = np.array(new byte[] { 10, 20, 30 }); @@ -929,7 +930,7 @@ public void NEP50_Values_UInt8_Operations() mod.GetAtIndex(2).Should().Be(2); // 30 % 7 } - [Test] + [TestMethod] public void NEP50_Values_UInt32_Operations() { var arr = np.array(new uint[] { 1000, 2000, 3000 }); @@ -945,7 +946,7 @@ public void NEP50_Values_UInt32_Operations() sub.GetAtIndex(2).Should().Be(2500); } - [Test] + [TestMethod] public void NEP50_Values_UInt64_Operations() { var arr = np.array(new ulong[] { 10000, 20000, 30000 }); diff --git a/test/NumSharp.UnitTest/Logic/NPTypeHierarchy.BattleTest.cs b/test/NumSharp.UnitTest/Logic/NPTypeHierarchy.BattleTest.cs index 64e1b03f3..951570fd5 100644 --- a/test/NumSharp.UnitTest/Logic/NPTypeHierarchy.BattleTest.cs +++ b/test/NumSharp.UnitTest/Logic/NPTypeHierarchy.BattleTest.cs @@ -1,7 +1,3 @@ -using System.Threading.Tasks; -using TUnit.Core; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; using NumSharp; namespace NumSharp.UnitTest.Logic; @@ -25,6 +21,7 @@ namespace NumSharp.UnitTest.Logic; /// ├── Floating (float16, float32, float64) /// └── ComplexFloating (complex64, complex128) /// +[TestClass] public class NPTypeHierarchyBattleTest { #region issubdtype - Type Hierarchy Tests (NumPy verified) @@ -33,171 +30,169 @@ public class NPTypeHierarchyBattleTest // SIGNED INTEGERS: belong to generic, number, integer, signedinteger // ========================================================================== - [Test] - public async Task Int16_BelongsTo_Generic() => - await Assert.That(np.issubdtype(NPTypeCode.Int16, "generic")).IsTrue(); + [TestMethod] + public void Int16_BelongsTo_Generic() => + np.issubdtype(NPTypeCode.Int16, "generic").Should().BeTrue(); - [Test] - public async Task Int16_BelongsTo_Number() => - await Assert.That(np.issubdtype(NPTypeCode.Int16, "number")).IsTrue(); + [TestMethod] + public void Int16_BelongsTo_Number() => + np.issubdtype(NPTypeCode.Int16, "number").Should().BeTrue(); - [Test] - public async Task Int16_BelongsTo_Integer() => - await Assert.That(np.issubdtype(NPTypeCode.Int16, "integer")).IsTrue(); + [TestMethod] + public void Int16_BelongsTo_Integer() => + np.issubdtype(NPTypeCode.Int16, "integer").Should().BeTrue(); - [Test] - public async Task Int16_BelongsTo_SignedInteger() => - await Assert.That(np.issubdtype(NPTypeCode.Int16, "signedinteger")).IsTrue(); + [TestMethod] + public void Int16_BelongsTo_SignedInteger() => + np.issubdtype(NPTypeCode.Int16, "signedinteger").Should().BeTrue(); - [Test] - public async Task Int16_NotBelongsTo_UnsignedInteger() => - await Assert.That(np.issubdtype(NPTypeCode.Int16, "unsignedinteger")).IsFalse(); + [TestMethod] + public void Int16_NotBelongsTo_UnsignedInteger() => + np.issubdtype(NPTypeCode.Int16, "unsignedinteger").Should().BeFalse(); - [Test] - public async Task Int16_NotBelongsTo_Inexact() => - await Assert.That(np.issubdtype(NPTypeCode.Int16, "inexact")).IsFalse(); + [TestMethod] + public void Int16_NotBelongsTo_Inexact() => + np.issubdtype(NPTypeCode.Int16, "inexact").Should().BeFalse(); - [Test] - public async Task Int16_NotBelongsTo_Floating() => - await Assert.That(np.issubdtype(NPTypeCode.Int16, "floating")).IsFalse(); + [TestMethod] + public void Int16_NotBelongsTo_Floating() => + np.issubdtype(NPTypeCode.Int16, "floating").Should().BeFalse(); - [Test] - public async Task Int32_BelongsTo_SignedInteger() => - await Assert.That(np.issubdtype(NPTypeCode.Int32, "signedinteger")).IsTrue(); + [TestMethod] + public void Int32_BelongsTo_SignedInteger() => + np.issubdtype(NPTypeCode.Int32, "signedinteger").Should().BeTrue(); - [Test] - public async Task Int64_BelongsTo_SignedInteger() => - await Assert.That(np.issubdtype(NPTypeCode.Int64, "signedinteger")).IsTrue(); + [TestMethod] + public void Int64_BelongsTo_SignedInteger() => + np.issubdtype(NPTypeCode.Int64, "signedinteger").Should().BeTrue(); // ========================================================================== // UNSIGNED INTEGERS: belong to generic, number, integer, unsignedinteger // ========================================================================== - [Test] - public async Task Byte_BelongsTo_Generic() => - await Assert.That(np.issubdtype(NPTypeCode.Byte, "generic")).IsTrue(); + [TestMethod] + public void Byte_BelongsTo_Generic() => + np.issubdtype(NPTypeCode.Byte, "generic").Should().BeTrue(); - [Test] - public async Task Byte_BelongsTo_Number() => - await Assert.That(np.issubdtype(NPTypeCode.Byte, "number")).IsTrue(); + [TestMethod] + public void Byte_BelongsTo_Number() => + np.issubdtype(NPTypeCode.Byte, "number").Should().BeTrue(); - [Test] - public async Task Byte_BelongsTo_Integer() => - await Assert.That(np.issubdtype(NPTypeCode.Byte, "integer")).IsTrue(); + [TestMethod] + public void Byte_BelongsTo_Integer() => + np.issubdtype(NPTypeCode.Byte, "integer").Should().BeTrue(); - [Test] - public async Task Byte_BelongsTo_UnsignedInteger() => - await Assert.That(np.issubdtype(NPTypeCode.Byte, "unsignedinteger")).IsTrue(); + [TestMethod] + public void Byte_BelongsTo_UnsignedInteger() => + np.issubdtype(NPTypeCode.Byte, "unsignedinteger").Should().BeTrue(); - [Test] - public async Task Byte_NotBelongsTo_SignedInteger() => - await Assert.That(np.issubdtype(NPTypeCode.Byte, "signedinteger")).IsFalse(); + [TestMethod] + public void Byte_NotBelongsTo_SignedInteger() => + np.issubdtype(NPTypeCode.Byte, "signedinteger").Should().BeFalse(); - [Test] - public async Task UInt16_BelongsTo_UnsignedInteger() => - await Assert.That(np.issubdtype(NPTypeCode.UInt16, "unsignedinteger")).IsTrue(); + [TestMethod] + public void UInt16_BelongsTo_UnsignedInteger() => + np.issubdtype(NPTypeCode.UInt16, "unsignedinteger").Should().BeTrue(); - [Test] - public async Task UInt32_BelongsTo_UnsignedInteger() => - await Assert.That(np.issubdtype(NPTypeCode.UInt32, "unsignedinteger")).IsTrue(); + [TestMethod] + public void UInt32_BelongsTo_UnsignedInteger() => + np.issubdtype(NPTypeCode.UInt32, "unsignedinteger").Should().BeTrue(); - [Test] - public async Task UInt64_BelongsTo_UnsignedInteger() => - await Assert.That(np.issubdtype(NPTypeCode.UInt64, "unsignedinteger")).IsTrue(); + [TestMethod] + public void UInt64_BelongsTo_UnsignedInteger() => + np.issubdtype(NPTypeCode.UInt64, "unsignedinteger").Should().BeTrue(); // ========================================================================== // FLOATING: belong to generic, number, inexact, floating // ========================================================================== - [Test] - public async Task Single_BelongsTo_Generic() => - await Assert.That(np.issubdtype(NPTypeCode.Single, "generic")).IsTrue(); + [TestMethod] + public void Single_BelongsTo_Generic() => + np.issubdtype(NPTypeCode.Single, "generic").Should().BeTrue(); - [Test] - public async Task Single_BelongsTo_Number() => - await Assert.That(np.issubdtype(NPTypeCode.Single, "number")).IsTrue(); + [TestMethod] + public void Single_BelongsTo_Number() => + np.issubdtype(NPTypeCode.Single, "number").Should().BeTrue(); - [Test] - public async Task Single_BelongsTo_Inexact() => - await Assert.That(np.issubdtype(NPTypeCode.Single, "inexact")).IsTrue(); + [TestMethod] + public void Single_BelongsTo_Inexact() => + np.issubdtype(NPTypeCode.Single, "inexact").Should().BeTrue(); - [Test] - public async Task Single_BelongsTo_Floating() => - await Assert.That(np.issubdtype(NPTypeCode.Single, "floating")).IsTrue(); + [TestMethod] + public void Single_BelongsTo_Floating() => + np.issubdtype(NPTypeCode.Single, "floating").Should().BeTrue(); - [Test] - public async Task Single_NotBelongsTo_Integer() => - await Assert.That(np.issubdtype(NPTypeCode.Single, "integer")).IsFalse(); + [TestMethod] + public void Single_NotBelongsTo_Integer() => + np.issubdtype(NPTypeCode.Single, "integer").Should().BeFalse(); - [Test] - public async Task Single_NotBelongsTo_ComplexFloating() => - await Assert.That(np.issubdtype(NPTypeCode.Single, "complexfloating")).IsFalse(); + [TestMethod] + public void Single_NotBelongsTo_ComplexFloating() => + np.issubdtype(NPTypeCode.Single, "complexfloating").Should().BeFalse(); - [Test] - public async Task Double_BelongsTo_Floating() => - await Assert.That(np.issubdtype(NPTypeCode.Double, "floating")).IsTrue(); + [TestMethod] + public void Double_BelongsTo_Floating() => + np.issubdtype(NPTypeCode.Double, "floating").Should().BeTrue(); - [Test] - public async Task Decimal_BelongsTo_Floating() => - await Assert.That(np.issubdtype(NPTypeCode.Decimal, "floating")).IsTrue(); + [TestMethod] + public void Decimal_BelongsTo_Floating() => + np.issubdtype(NPTypeCode.Decimal, "floating").Should().BeTrue(); // ========================================================================== // COMPLEX: belong to generic, number, inexact, complexfloating // ========================================================================== - [Test] - public async Task Complex_BelongsTo_Generic() => - await Assert.That(np.issubdtype(NPTypeCode.Complex, "generic")).IsTrue(); + [TestMethod] + public void Complex_BelongsTo_Generic() => + np.issubdtype(NPTypeCode.Complex, "generic").Should().BeTrue(); - [Test] - public async Task Complex_BelongsTo_Number() => - await Assert.That(np.issubdtype(NPTypeCode.Complex, "number")).IsTrue(); + [TestMethod] + public void Complex_BelongsTo_Number() => + np.issubdtype(NPTypeCode.Complex, "number").Should().BeTrue(); - [Test] - public async Task Complex_BelongsTo_Inexact() => - await Assert.That(np.issubdtype(NPTypeCode.Complex, "inexact")).IsTrue(); + [TestMethod] + public void Complex_BelongsTo_Inexact() => + np.issubdtype(NPTypeCode.Complex, "inexact").Should().BeTrue(); - [Test] - public async Task Complex_BelongsTo_ComplexFloating() => - await Assert.That(np.issubdtype(NPTypeCode.Complex, "complexfloating")).IsTrue(); + [TestMethod] + public void Complex_BelongsTo_ComplexFloating() => + np.issubdtype(NPTypeCode.Complex, "complexfloating").Should().BeTrue(); - [Test] - public async Task Complex_NotBelongsTo_Floating() => - await Assert.That(np.issubdtype(NPTypeCode.Complex, "floating")).IsFalse(); + [TestMethod] + public void Complex_NotBelongsTo_Floating() => + np.issubdtype(NPTypeCode.Complex, "floating").Should().BeFalse(); - [Test] - public async Task Complex_NotBelongsTo_Integer() => - await Assert.That(np.issubdtype(NPTypeCode.Complex, "integer")).IsFalse(); + [TestMethod] + public void Complex_NotBelongsTo_Integer() => + np.issubdtype(NPTypeCode.Complex, "integer").Should().BeFalse(); // ========================================================================== // BOOLEAN: belongs to generic ONLY (NumPy 2.x critical behavior!) // ========================================================================== - [Test] - public async Task Bool_BelongsTo_Generic() => - await Assert.That(np.issubdtype(NPTypeCode.Boolean, "generic")).IsTrue(); + [TestMethod] + public void Bool_BelongsTo_Generic() => + np.issubdtype(NPTypeCode.Boolean, "generic").Should().BeTrue(); - [Test] - public async Task Bool_BelongsTo_Boolean() => - await Assert.That(np.issubdtype(NPTypeCode.Boolean, "boolean")).IsTrue(); + [TestMethod] + public void Bool_BelongsTo_Boolean() => + np.issubdtype(NPTypeCode.Boolean, "boolean").Should().BeTrue(); - [Test] - [DisplayName("CRITICAL: Bool is NOT under Number in NumPy 2.x")] - public async Task Bool_NotBelongsTo_Number() => - await Assert.That(np.issubdtype(NPTypeCode.Boolean, "number")).IsFalse(); + [TestMethod] + public void Bool_NotBelongsTo_Number() => + np.issubdtype(NPTypeCode.Boolean, "number").Should().BeFalse(); - [Test] - [DisplayName("CRITICAL: Bool is NOT under Integer in NumPy 2.x")] - public async Task Bool_NotBelongsTo_Integer() => - await Assert.That(np.issubdtype(NPTypeCode.Boolean, "integer")).IsFalse(); + [TestMethod] + public void Bool_NotBelongsTo_Integer() => + np.issubdtype(NPTypeCode.Boolean, "integer").Should().BeFalse(); - [Test] - public async Task Bool_NotBelongsTo_SignedInteger() => - await Assert.That(np.issubdtype(NPTypeCode.Boolean, "signedinteger")).IsFalse(); + [TestMethod] + public void Bool_NotBelongsTo_SignedInteger() => + np.issubdtype(NPTypeCode.Boolean, "signedinteger").Should().BeFalse(); - [Test] - public async Task Bool_NotBelongsTo_UnsignedInteger() => - await Assert.That(np.issubdtype(NPTypeCode.Boolean, "unsignedinteger")).IsFalse(); + [TestMethod] + public void Bool_NotBelongsTo_UnsignedInteger() => + np.issubdtype(NPTypeCode.Boolean, "unsignedinteger").Should().BeFalse(); #endregion @@ -206,291 +201,271 @@ public async Task Bool_NotBelongsTo_UnsignedInteger() => // NumPy: issubdtype(int32, int64) = False (different concrete types) // NumPy: issubdtype(int32, int32) = True (same type) - [Test] - public async Task ConcreteType_SameType_ReturnsTrue_Int32() + [TestMethod] + public void ConcreteType_SameType_ReturnsTrue_Int32() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, NPTypeCode.Int32)).IsTrue(); + np.issubdtype(NPTypeCode.Int32, NPTypeCode.Int32).Should().BeTrue(); } - [Test] - public async Task ConcreteType_SameType_ReturnsTrue_Double() + [TestMethod] + public void ConcreteType_SameType_ReturnsTrue_Double() { - await Assert.That(np.issubdtype(NPTypeCode.Double, NPTypeCode.Double)).IsTrue(); + np.issubdtype(NPTypeCode.Double, NPTypeCode.Double).Should().BeTrue(); } - [Test] - [DisplayName("NumPy: issubdtype(int32, int64) = False")] - public async Task ConcreteType_DifferentType_SameKind_ReturnsFalse() + [TestMethod] + public void ConcreteType_DifferentType_SameKind_ReturnsFalse() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, NPTypeCode.Int64)).IsFalse(); + np.issubdtype(NPTypeCode.Int32, NPTypeCode.Int64).Should().BeFalse(); } - [Test] - [DisplayName("NumPy: issubdtype(int64, int32) = False")] - public async Task ConcreteType_DifferentType_SameKind_ReturnsFalse_Reverse() + [TestMethod] + public void ConcreteType_DifferentType_SameKind_ReturnsFalse_Reverse() { - await Assert.That(np.issubdtype(NPTypeCode.Int64, NPTypeCode.Int32)).IsFalse(); + np.issubdtype(NPTypeCode.Int64, NPTypeCode.Int32).Should().BeFalse(); } - [Test] - [DisplayName("NumPy: issubdtype(float32, float64) = False")] - public async Task ConcreteType_Float32_Float64_ReturnsFalse() + [TestMethod] + public void ConcreteType_Float32_Float64_ReturnsFalse() { - await Assert.That(np.issubdtype(NPTypeCode.Single, NPTypeCode.Double)).IsFalse(); + np.issubdtype(NPTypeCode.Single, NPTypeCode.Double).Should().BeFalse(); } - [Test] - [DisplayName("NumPy: issubdtype(uint8, uint64) = False")] - public async Task ConcreteType_Uint8_Uint64_ReturnsFalse() + [TestMethod] + public void ConcreteType_Uint8_Uint64_ReturnsFalse() { - await Assert.That(np.issubdtype(NPTypeCode.Byte, NPTypeCode.UInt64)).IsFalse(); + np.issubdtype(NPTypeCode.Byte, NPTypeCode.UInt64).Should().BeFalse(); } - [Test] - [DisplayName("NumPy: issubdtype(int32, float64) = False")] - public async Task ConcreteType_DifferentKind_ReturnsFalse() + [TestMethod] + public void ConcreteType_DifferentKind_ReturnsFalse() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, NPTypeCode.Double)).IsFalse(); + np.issubdtype(NPTypeCode.Int32, NPTypeCode.Double).Should().BeFalse(); } - [Test] - [DisplayName("NumPy: issubdtype(bool, int32) = False")] - public async Task ConcreteType_Bool_Int32_ReturnsFalse() + [TestMethod] + public void ConcreteType_Bool_Int32_ReturnsFalse() { - await Assert.That(np.issubdtype(NPTypeCode.Boolean, NPTypeCode.Int32)).IsFalse(); + np.issubdtype(NPTypeCode.Boolean, NPTypeCode.Int32).Should().BeFalse(); } #endregion #region isdtype - Category Checks (NumPy 2.0+ verified) - [Test] - [DisplayName("NumPy: isdtype(int32, 'integral') = True")] - public async Task Isdtype_Int32_Integral() + [TestMethod] + public void Isdtype_Int32_Integral() { - await Assert.That(np.isdtype(NPTypeCode.Int32, "integral")).IsTrue(); + np.isdtype(NPTypeCode.Int32, "integral").Should().BeTrue(); } - [Test] - [DisplayName("NumPy: isdtype(float64, 'real floating') = True")] - public async Task Isdtype_Float64_RealFloating() + [TestMethod] + public void Isdtype_Float64_RealFloating() { - await Assert.That(np.isdtype(NPTypeCode.Double, "real floating")).IsTrue(); + np.isdtype(NPTypeCode.Double, "real floating").Should().BeTrue(); } - [Test] - [DisplayName("NumPy: isdtype(complex128, 'complex floating') = True")] - public async Task Isdtype_Complex_ComplexFloating() + [TestMethod] + public void Isdtype_Complex_ComplexFloating() { - await Assert.That(np.isdtype(NPTypeCode.Complex, "complex floating")).IsTrue(); + np.isdtype(NPTypeCode.Complex, "complex floating").Should().BeTrue(); } - [Test] - [DisplayName("NumPy: isdtype(bool, 'bool') = True")] - public async Task Isdtype_Bool_Bool() + [TestMethod] + public void Isdtype_Bool_Bool() { - await Assert.That(np.isdtype(NPTypeCode.Boolean, "bool")).IsTrue(); + np.isdtype(NPTypeCode.Boolean, "bool").Should().BeTrue(); } - [Test] - [DisplayName("NumPy: isdtype(int32, 'numeric') = True")] - public async Task Isdtype_Int32_Numeric() + [TestMethod] + public void Isdtype_Int32_Numeric() { - await Assert.That(np.isdtype(NPTypeCode.Int32, "numeric")).IsTrue(); + np.isdtype(NPTypeCode.Int32, "numeric").Should().BeTrue(); } - [Test] - [DisplayName("CRITICAL: NumPy: isdtype(bool, 'numeric') = False")] - public async Task Isdtype_Bool_Numeric_IsFalse() + [TestMethod] + public void Isdtype_Bool_Numeric_IsFalse() { // Bool is excluded from 'numeric' in NumPy's isdtype - await Assert.That(np.isdtype(NPTypeCode.Boolean, "numeric")).IsFalse(); + np.isdtype(NPTypeCode.Boolean, "numeric").Should().BeFalse(); } - [Test] - public async Task Isdtype_AllIntegerTypes_AreIntegral() + [TestMethod] + public void Isdtype_AllIntegerTypes_AreIntegral() { - await Assert.That(np.isdtype(NPTypeCode.Byte, "integral")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Int16, "integral")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.UInt16, "integral")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Int32, "integral")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.UInt32, "integral")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Int64, "integral")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.UInt64, "integral")).IsTrue(); + np.isdtype(NPTypeCode.Byte, "integral").Should().BeTrue(); + np.isdtype(NPTypeCode.Int16, "integral").Should().BeTrue(); + np.isdtype(NPTypeCode.UInt16, "integral").Should().BeTrue(); + np.isdtype(NPTypeCode.Int32, "integral").Should().BeTrue(); + np.isdtype(NPTypeCode.UInt32, "integral").Should().BeTrue(); + np.isdtype(NPTypeCode.Int64, "integral").Should().BeTrue(); + np.isdtype(NPTypeCode.UInt64, "integral").Should().BeTrue(); } - [Test] - public async Task Isdtype_AllFloatTypes_AreRealFloating() + [TestMethod] + public void Isdtype_AllFloatTypes_AreRealFloating() { - await Assert.That(np.isdtype(NPTypeCode.Single, "real floating")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Double, "real floating")).IsTrue(); - await Assert.That(np.isdtype(NPTypeCode.Decimal, "real floating")).IsTrue(); + np.isdtype(NPTypeCode.Single, "real floating").Should().BeTrue(); + np.isdtype(NPTypeCode.Double, "real floating").Should().BeTrue(); + np.isdtype(NPTypeCode.Decimal, "real floating").Should().BeTrue(); } #endregion #region maximum_sctype (NumPy verified) - [Test] - [DisplayName("NumPy: maximum_sctype(int16) = int64")] - public async Task MaximumSctype_Int16_ReturnsInt64() + [TestMethod] + public void MaximumSctype_Int16_ReturnsInt64() { - await Assert.That(np.maximum_sctype(NPTypeCode.Int16)).IsEqualTo(NPTypeCode.Int64); + np.maximum_sctype(NPTypeCode.Int16).Should().Be(NPTypeCode.Int64); } - [Test] - [DisplayName("NumPy: maximum_sctype(int32) = int64")] - public async Task MaximumSctype_Int32_ReturnsInt64() + [TestMethod] + public void MaximumSctype_Int32_ReturnsInt64() { - await Assert.That(np.maximum_sctype(NPTypeCode.Int32)).IsEqualTo(NPTypeCode.Int64); + np.maximum_sctype(NPTypeCode.Int32).Should().Be(NPTypeCode.Int64); } - [Test] - [DisplayName("NumPy: maximum_sctype(int64) = int64")] - public async Task MaximumSctype_Int64_ReturnsInt64() + [TestMethod] + public void MaximumSctype_Int64_ReturnsInt64() { - await Assert.That(np.maximum_sctype(NPTypeCode.Int64)).IsEqualTo(NPTypeCode.Int64); + np.maximum_sctype(NPTypeCode.Int64).Should().Be(NPTypeCode.Int64); } - [Test] - [DisplayName("NumPy: maximum_sctype(uint8) = uint64")] - public async Task MaximumSctype_Byte_ReturnsUInt64() + [TestMethod] + public void MaximumSctype_Byte_ReturnsUInt64() { - await Assert.That(np.maximum_sctype(NPTypeCode.Byte)).IsEqualTo(NPTypeCode.UInt64); + np.maximum_sctype(NPTypeCode.Byte).Should().Be(NPTypeCode.UInt64); } - [Test] - [DisplayName("NumPy: maximum_sctype(uint32) = uint64")] - public async Task MaximumSctype_UInt32_ReturnsUInt64() + [TestMethod] + public void MaximumSctype_UInt32_ReturnsUInt64() { - await Assert.That(np.maximum_sctype(NPTypeCode.UInt32)).IsEqualTo(NPTypeCode.UInt64); + np.maximum_sctype(NPTypeCode.UInt32).Should().Be(NPTypeCode.UInt64); } - [Test] - [DisplayName("NumPy: maximum_sctype(float32) = longdouble (NumSharp: Double)")] - public async Task MaximumSctype_Single_ReturnsDouble() + [TestMethod] + public void MaximumSctype_Single_ReturnsDouble() { // NumPy returns longdouble, NumSharp doesn't have longdouble so we return Double - await Assert.That(np.maximum_sctype(NPTypeCode.Single)).IsEqualTo(NPTypeCode.Double); + np.maximum_sctype(NPTypeCode.Single).Should().Be(NPTypeCode.Double); } - [Test] - [DisplayName("NumPy: maximum_sctype(float64) = longdouble (NumSharp: Double)")] - public async Task MaximumSctype_Double_ReturnsDouble() + [TestMethod] + public void MaximumSctype_Double_ReturnsDouble() { - await Assert.That(np.maximum_sctype(NPTypeCode.Double)).IsEqualTo(NPTypeCode.Double); + np.maximum_sctype(NPTypeCode.Double).Should().Be(NPTypeCode.Double); } - [Test] - [DisplayName("NumPy: maximum_sctype(bool) = bool")] - public async Task MaximumSctype_Bool_ReturnsBool() + [TestMethod] + public void MaximumSctype_Bool_ReturnsBool() { - await Assert.That(np.maximum_sctype(NPTypeCode.Boolean)).IsEqualTo(NPTypeCode.Boolean); + np.maximum_sctype(NPTypeCode.Boolean).Should().Be(NPTypeCode.Boolean); } - [Test] - public async Task MaximumSctype_Decimal_ReturnsDecimal() + [TestMethod] + public void MaximumSctype_Decimal_ReturnsDecimal() { // NumSharp-specific: Decimal stays Decimal - await Assert.That(np.maximum_sctype(NPTypeCode.Decimal)).IsEqualTo(NPTypeCode.Decimal); + np.maximum_sctype(NPTypeCode.Decimal).Should().Be(NPTypeCode.Decimal); } - [Test] - public async Task MaximumSctype_Complex_ReturnsComplex() + [TestMethod] + public void MaximumSctype_Complex_ReturnsComplex() { - await Assert.That(np.maximum_sctype(NPTypeCode.Complex)).IsEqualTo(NPTypeCode.Complex); + np.maximum_sctype(NPTypeCode.Complex).Should().Be(NPTypeCode.Complex); } #endregion #region NPTypeHierarchy.IsSameKind - Used by can_cast same_kind - [Test] - public async Task IsSameKind_SignedIntegers() + [TestMethod] + public void IsSameKind_SignedIntegers() { - await Assert.That(NPTypeHierarchy.IsSameKind(NPTypeCode.Int16, NPTypeCode.Int32)).IsTrue(); - await Assert.That(NPTypeHierarchy.IsSameKind(NPTypeCode.Int32, NPTypeCode.Int64)).IsTrue(); + NPTypeHierarchy.IsSameKind(NPTypeCode.Int16, NPTypeCode.Int32).Should().BeTrue(); + NPTypeHierarchy.IsSameKind(NPTypeCode.Int32, NPTypeCode.Int64).Should().BeTrue(); } - [Test] - public async Task IsSameKind_UnsignedIntegers() + [TestMethod] + public void IsSameKind_UnsignedIntegers() { - await Assert.That(NPTypeHierarchy.IsSameKind(NPTypeCode.Byte, NPTypeCode.UInt16)).IsTrue(); - await Assert.That(NPTypeHierarchy.IsSameKind(NPTypeCode.UInt32, NPTypeCode.UInt64)).IsTrue(); + NPTypeHierarchy.IsSameKind(NPTypeCode.Byte, NPTypeCode.UInt16).Should().BeTrue(); + NPTypeHierarchy.IsSameKind(NPTypeCode.UInt32, NPTypeCode.UInt64).Should().BeTrue(); } - [Test] - public async Task IsSameKind_SignedAndUnsigned_AreInSameKind() + [TestMethod] + public void IsSameKind_SignedAndUnsigned_AreInSameKind() { // In NumPy, same_kind casting allows int <-> uint (they're both integers) - await Assert.That(NPTypeHierarchy.IsSameKind(NPTypeCode.Int32, NPTypeCode.UInt32)).IsTrue(); - await Assert.That(NPTypeHierarchy.IsSameKind(NPTypeCode.Int64, NPTypeCode.Byte)).IsTrue(); + NPTypeHierarchy.IsSameKind(NPTypeCode.Int32, NPTypeCode.UInt32).Should().BeTrue(); + NPTypeHierarchy.IsSameKind(NPTypeCode.Int64, NPTypeCode.Byte).Should().BeTrue(); } - [Test] - public async Task IsSameKind_Floats() + [TestMethod] + public void IsSameKind_Floats() { - await Assert.That(NPTypeHierarchy.IsSameKind(NPTypeCode.Single, NPTypeCode.Double)).IsTrue(); - await Assert.That(NPTypeHierarchy.IsSameKind(NPTypeCode.Double, NPTypeCode.Decimal)).IsTrue(); + NPTypeHierarchy.IsSameKind(NPTypeCode.Single, NPTypeCode.Double).Should().BeTrue(); + NPTypeHierarchy.IsSameKind(NPTypeCode.Double, NPTypeCode.Decimal).Should().BeTrue(); } - [Test] - public async Task IsSameKind_DifferentKinds_ReturnsFalse() + [TestMethod] + public void IsSameKind_DifferentKinds_ReturnsFalse() { - await Assert.That(NPTypeHierarchy.IsSameKind(NPTypeCode.Int32, NPTypeCode.Double)).IsFalse(); - await Assert.That(NPTypeHierarchy.IsSameKind(NPTypeCode.Single, NPTypeCode.Complex)).IsFalse(); - await Assert.That(NPTypeHierarchy.IsSameKind(NPTypeCode.Boolean, NPTypeCode.Int32)).IsFalse(); + NPTypeHierarchy.IsSameKind(NPTypeCode.Int32, NPTypeCode.Double).Should().BeFalse(); + NPTypeHierarchy.IsSameKind(NPTypeCode.Single, NPTypeCode.Complex).Should().BeFalse(); + NPTypeHierarchy.IsSameKind(NPTypeCode.Boolean, NPTypeCode.Int32).Should().BeFalse(); } #endregion #region Category Alias Tests - [Test] - public async Task CategoryAlias_Signed_EqualsSignedInteger() + [TestMethod] + public void CategoryAlias_Signed_EqualsSignedInteger() { - await Assert.That(np.issubdtype(NPTypeCode.Int32, "signed")).IsTrue(); - await Assert.That(np.issubdtype(NPTypeCode.Byte, "signed")).IsFalse(); + np.issubdtype(NPTypeCode.Int32, "signed").Should().BeTrue(); + np.issubdtype(NPTypeCode.Byte, "signed").Should().BeFalse(); } - [Test] - public async Task CategoryAlias_Unsigned_EqualsUnsignedInteger() + [TestMethod] + public void CategoryAlias_Unsigned_EqualsUnsignedInteger() { - await Assert.That(np.issubdtype(NPTypeCode.Byte, "unsigned")).IsTrue(); - await Assert.That(np.issubdtype(NPTypeCode.Int32, "unsigned")).IsFalse(); + np.issubdtype(NPTypeCode.Byte, "unsigned").Should().BeTrue(); + np.issubdtype(NPTypeCode.Int32, "unsigned").Should().BeFalse(); } - [Test] - public async Task CategoryAlias_Float_EqualsFloating() + [TestMethod] + public void CategoryAlias_Float_EqualsFloating() { - await Assert.That(np.issubdtype(NPTypeCode.Double, "float")).IsTrue(); - await Assert.That(np.issubdtype(NPTypeCode.Int32, "float")).IsFalse(); + np.issubdtype(NPTypeCode.Double, "float").Should().BeTrue(); + np.issubdtype(NPTypeCode.Int32, "float").Should().BeFalse(); } - [Test] - public async Task CategoryAlias_Complex_EqualsComplexFloating() + [TestMethod] + public void CategoryAlias_Complex_EqualsComplexFloating() { - await Assert.That(np.issubdtype(NPTypeCode.Complex, "complex")).IsTrue(); - await Assert.That(np.issubdtype(NPTypeCode.Double, "complex")).IsFalse(); + np.issubdtype(NPTypeCode.Complex, "complex").Should().BeTrue(); + np.issubdtype(NPTypeCode.Double, "complex").Should().BeFalse(); } #endregion #region NumSharp-specific: Char type handling - [Test] - public async Task Char_TreatedAsUnsignedInteger() + [TestMethod] + public void Char_TreatedAsUnsignedInteger() { // Char is treated like uint16 in NumSharp - await Assert.That(np.issubdtype(NPTypeCode.Char, "unsignedinteger")).IsTrue(); - await Assert.That(np.issubdtype(NPTypeCode.Char, "integer")).IsTrue(); - await Assert.That(np.issubdtype(NPTypeCode.Char, "number")).IsTrue(); + np.issubdtype(NPTypeCode.Char, "unsignedinteger").Should().BeTrue(); + np.issubdtype(NPTypeCode.Char, "integer").Should().BeTrue(); + np.issubdtype(NPTypeCode.Char, "number").Should().BeTrue(); } - [Test] - public async Task Char_MaximumSctype_ReturnsUInt64() + [TestMethod] + public void Char_MaximumSctype_ReturnsUInt64() { - await Assert.That(np.maximum_sctype(NPTypeCode.Char)).IsEqualTo(NPTypeCode.UInt64); + np.maximum_sctype(NPTypeCode.Char).Should().Be(NPTypeCode.UInt64); } #endregion diff --git a/test/NumSharp.UnitTest/Logic/TypePromotionTests.cs b/test/NumSharp.UnitTest/Logic/TypePromotionTests.cs index ab1ae0a6b..73447f7e7 100644 --- a/test/NumSharp.UnitTest/Logic/TypePromotionTests.cs +++ b/test/NumSharp.UnitTest/Logic/TypePromotionTests.cs @@ -8,11 +8,12 @@ namespace NumSharp.UnitTest.Logic /// Tests for NumPy 2.x type promotion rules (NEP50). /// Verifies that mixed-type operations produce correct result dtypes. /// + [TestClass] public class TypePromotionTests { #region Integer Promotions - [Test] + [TestMethod] public void IntegerPromotion_Uint8_Int16() { // uint8 + int16 → int16 (int16 can hold both ranges) @@ -22,7 +23,7 @@ public void IntegerPromotion_Uint8_Int16() Assert.AreEqual(NPTypeCode.Int16, result.typecode); } - [Test] + [TestMethod] public void IntegerPromotion_Uint8_Int32() { var a = np.array(new byte[] { 1, 2, 3 }); @@ -31,7 +32,7 @@ public void IntegerPromotion_Uint8_Int32() Assert.AreEqual(NPTypeCode.Int32, result.typecode); } - [Test] + [TestMethod] public void IntegerPromotion_Uint16_Int16() { // uint16 + int16 → int32 (need larger to hold both ranges) @@ -41,7 +42,7 @@ public void IntegerPromotion_Uint16_Int16() Assert.AreEqual(NPTypeCode.Int32, result.typecode); } - [Test] + [TestMethod] public void IntegerPromotion_Uint32_Int32() { // uint32 + int32 → int64 (need larger to hold both ranges) @@ -51,7 +52,7 @@ public void IntegerPromotion_Uint32_Int32() Assert.AreEqual(NPTypeCode.Int64, result.typecode); } - [Test] + [TestMethod] public void IntegerPromotion_Uint32_Int64() { var a = np.array(new uint[] { 1, 2, 3 }); @@ -60,7 +61,7 @@ public void IntegerPromotion_Uint32_Int64() Assert.AreEqual(NPTypeCode.Int64, result.typecode); } - [Test] + [TestMethod] public void IntegerPromotion_Uint64_Int64() { // uint64 + int64 → float64 (no larger integer type available) @@ -74,7 +75,7 @@ public void IntegerPromotion_Uint64_Int64() #region Float Promotions (NEP50) - [Test] + [TestMethod] public void FloatPromotion_Int32_Float32_ReturnsFloat64() { // NEP50: int32 + float32 → float64 (NOT float32!) @@ -85,7 +86,7 @@ public void FloatPromotion_Int32_Float32_ReturnsFloat64() Assert.AreEqual(NPTypeCode.Double, result.typecode); } - [Test] + [TestMethod] public void FloatPromotion_Int32_Float64() { var a = np.array(new int[] { 1, 2, 3 }); @@ -94,7 +95,7 @@ public void FloatPromotion_Int32_Float64() Assert.AreEqual(NPTypeCode.Double, result.typecode); } - [Test] + [TestMethod] public void FloatPromotion_Float32_Float64() { var a = np.array(new float[] { 1.0f, 2.0f, 3.0f }); @@ -107,7 +108,7 @@ public void FloatPromotion_Float32_Float64() #region Boolean Promotions - [Test] + [TestMethod] public void BoolPromotion_Bool_Int32() { var a = np.array(new bool[] { true, false, true }); @@ -116,7 +117,7 @@ public void BoolPromotion_Bool_Int32() Assert.AreEqual(NPTypeCode.Int32, result.typecode); } - [Test] + [TestMethod] public void BoolPromotion_Bool_Float32() { var a = np.array(new bool[] { true, false, true }); @@ -125,7 +126,7 @@ public void BoolPromotion_Bool_Float32() Assert.AreEqual(NPTypeCode.Single, result.typecode); } - [Test] + [TestMethod] public void BoolPromotion_Bool_Float64() { var a = np.array(new bool[] { true, false, true }); @@ -138,7 +139,7 @@ public void BoolPromotion_Bool_Float64() #region Scalar + Array (NEP50 - scalar doesn't promote) - [Test] + [TestMethod] public void ScalarPromotion_Int32Array_IntScalar() { // NEP50: Scalar doesn't promote array dtype @@ -147,7 +148,7 @@ public void ScalarPromotion_Int32Array_IntScalar() Assert.AreEqual(NPTypeCode.Int32, result.typecode); } - [Test] + [TestMethod] public void ScalarPromotion_Float32Array_IntScalar() { // NEP50: Int scalar doesn't promote float32 to float64 @@ -156,7 +157,7 @@ public void ScalarPromotion_Float32Array_IntScalar() Assert.AreEqual(NPTypeCode.Single, result.typecode); } - [Test] + [TestMethod] public void ScalarPromotion_Float32Array_DoubleScalar() { // NEP50: Double scalar doesn't promote float32 array @@ -165,7 +166,7 @@ public void ScalarPromotion_Float32Array_DoubleScalar() Assert.AreEqual(NPTypeCode.Single, result.typecode); } - [Test] + [TestMethod] public void ScalarPromotion_Int32Array_DoubleScalar() { // Float scalar DOES promote int array to float @@ -178,7 +179,7 @@ public void ScalarPromotion_Int32Array_DoubleScalar() #region All Operations Preserve Type Rules - [Test] + [TestMethod] public void Subtraction_SameRulesAsAddition() { var a = np.array(new int[] { 1, 2, 3 }); @@ -187,7 +188,7 @@ public void Subtraction_SameRulesAsAddition() Assert.AreEqual(NPTypeCode.Double, result.typecode); } - [Test] + [TestMethod] public void Multiplication_SameRulesAsAddition() { var a = np.array(new int[] { 1, 2, 3 }); @@ -196,7 +197,7 @@ public void Multiplication_SameRulesAsAddition() Assert.AreEqual(NPTypeCode.Double, result.typecode); } - [Test] + [TestMethod] public void Division_SameRulesAsAddition() { var a = np.array(new int[] { 1, 2, 3 }); diff --git a/test/NumSharp.UnitTest/Logic/np.all.Test.cs b/test/NumSharp.UnitTest/Logic/np.all.Test.cs index c29e5b2eb..b8988654f 100644 --- a/test/NumSharp.UnitTest/Logic/np.all.Test.cs +++ b/test/NumSharp.UnitTest/Logic/np.all.Test.cs @@ -2,16 +2,14 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using TUnit.Core; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; namespace NumSharp.UnitTest.Logic { + [TestClass] public class np_all_Test { - [Test] + [TestMethod] public void np_all_1D() { var np1 = new NDArray(new[] {true, true, false, false}, new Shape(4)); @@ -22,7 +20,7 @@ public void np_all_1D() Assert.IsTrue(np.all(np3)); } - [Test] + [TestMethod] public void np_all_2D() { var np1 = new NDArray(new bool[] {true, true, false, false, true, false}, new Shape(2, 3)); @@ -33,7 +31,7 @@ public void np_all_2D() Assert.IsTrue(np.all(np3)); } - [Test] + [TestMethod] public void np_all_0D_WithAxis0_ReturnsScalar() { // NumPy 2.x: np.all(0D_array, axis=0) returns 0D boolean scalar @@ -50,7 +48,7 @@ public void np_all_0D_WithAxis0_ReturnsScalar() Assert.AreEqual(false, (bool)resultFalsy); } - [Test] + [TestMethod] public void np_all_0D_WithAxisNeg1_ReturnsScalar() { // NumPy 2.x: np.all(0D_array, axis=-1) is equivalent to axis=0 @@ -60,7 +58,7 @@ public void np_all_0D_WithAxisNeg1_ReturnsScalar() Assert.AreEqual(true, (bool)result); } - [Test] + [TestMethod] public void np_all_0D_WithInvalidAxis_Throws() { // NumPy 2.x: np.all(0D_array, axis=1) raises AxisError diff --git a/test/NumSharp.UnitTest/Logic/np.allclose.Test.cs b/test/NumSharp.UnitTest/Logic/np.allclose.Test.cs index a62ee634b..535c74908 100644 --- a/test/NumSharp.UnitTest/Logic/np.allclose.Test.cs +++ b/test/NumSharp.UnitTest/Logic/np.allclose.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Logic { + [TestClass] public class np_allclose_Test { - [Test] + [TestMethod] public void np_allclose_1D() { //>>> np.allclose([1e10, 1e-7], [1.00001e10,1e-8]) diff --git a/test/NumSharp.UnitTest/Logic/np.any.Test.cs b/test/NumSharp.UnitTest/Logic/np.any.Test.cs index 61d8e42fb..be6d5f891 100644 --- a/test/NumSharp.UnitTest/Logic/np.any.Test.cs +++ b/test/NumSharp.UnitTest/Logic/np.any.Test.cs @@ -1,15 +1,13 @@ using System; using System.Linq; -using TUnit.Core; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; namespace NumSharp.UnitTest.Logic { + [TestClass] public class NpAnyTest { - [Test] + [TestMethod] public void Any1DArrayTest() { // 测试1维数组 @@ -18,7 +16,7 @@ public void Any1DArrayTest() Assert.AreEqual(true, result.GetBoolean(0)); } - [Test] + [TestMethod] public void Any2DArrayTest() { // 测试2维数组 @@ -28,7 +26,7 @@ public void Any2DArrayTest() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), expected.Data())); } - [Test] + [TestMethod] public void Any2DArrayWithAxis1Test() { // 测试2维数组,axis=1 @@ -38,7 +36,7 @@ public void Any2DArrayWithAxis1Test() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), expected.Data())); } - [Test] + [TestMethod] public void AnyWithKeepdimsTest() { // 测试keepdims参数 @@ -50,7 +48,7 @@ public void AnyWithKeepdimsTest() Assert.AreEqual(2, result.shape[1]); } - [Test] + [TestMethod] public void AnyWithNegativeAxisTest() { // 测试负轴 @@ -60,7 +58,7 @@ public void AnyWithNegativeAxisTest() Assert.IsTrue(Enumerable.SequenceEqual(result1.Data(), result2.Data())); } - [Test] + [TestMethod] public void AnyAllZerosTest() { // 测试全零数组 @@ -70,7 +68,7 @@ public void AnyAllZerosTest() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), expected.Data())); } - [Test] + [TestMethod] public void AnyAllNonZerosTest() { // 测试全非零数组 @@ -80,7 +78,7 @@ public void AnyAllNonZerosTest() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), expected.Data())); } - [Test] + [TestMethod] public void AnyInvalidAxisTest() { // Test invalid axis - should throw ArgumentOutOfRangeException @@ -88,7 +86,7 @@ public void AnyInvalidAxisTest() Assert.ThrowsException(() => np.any(arr, axis: 5, keepdims: false)); } - [Test] + [TestMethod] public void AnyScalarArrayTest() { // NumPy: np.array(5) creates 0D array, np.any(a) returns True @@ -101,7 +99,7 @@ public void AnyScalarArrayTest() Assert.AreEqual(true, result); } - [Test] + [TestMethod] public void Any0DArray_WithAxis0_ReturnsScalar() { // NumPy 2.x: np.any(0D_array, axis=0) returns 0D boolean scalar @@ -113,7 +111,7 @@ public void Any0DArray_WithAxis0_ReturnsScalar() Assert.AreEqual(true, (bool)result); } - [Test] + [TestMethod] public void Any0DArray_WithAxisNeg1_ReturnsScalar() { // NumPy 2.x: np.any(0D_array, axis=-1) is equivalent to axis=0 @@ -123,7 +121,7 @@ public void Any0DArray_WithAxisNeg1_ReturnsScalar() Assert.AreEqual(false, (bool)result); } - [Test] + [TestMethod] public void Any0DArray_WithInvalidAxis_Throws() { // NumPy 2.x: np.any(0D_array, axis=1) raises AxisError @@ -133,7 +131,7 @@ public void Any0DArray_WithInvalidAxis_Throws() Assert.ThrowsException(() => np.any(arr, axis: -2)); } - [Test] + [TestMethod] public void Any0DArray_WithKeepdims_Returns0D() { // NumPy 2.x: keepdims=True on 0D still returns 0D (no axes to keep) @@ -143,7 +141,7 @@ public void Any0DArray_WithKeepdims_Returns0D() Assert.AreEqual(true, (bool)result); } - [Test] + [TestMethod] public void AnyNullArrayTest() { // Test null array - should throw ArgumentNullException diff --git a/test/NumSharp.UnitTest/Logic/np.comparison.Test.cs b/test/NumSharp.UnitTest/Logic/np.comparison.Test.cs index 294e9d3d3..acbb5abf5 100644 --- a/test/NumSharp.UnitTest/Logic/np.comparison.Test.cs +++ b/test/NumSharp.UnitTest/Logic/np.comparison.Test.cs @@ -8,11 +8,12 @@ namespace NumSharp.UnitTest.Logic /// Tests for np.equal, np.not_equal, np.less, np.greater, np.less_equal, np.greater_equal /// These are thin wrappers around operators that exist for NumPy API compatibility. /// + [TestClass] public class np_comparison_Test { #region np.equal - [Test] + [TestMethod] public void equal_ArrayArray() { // NumPy: np.equal([1, 2, 3], [1, 0, 3]) -> [True, False, True] @@ -26,7 +27,7 @@ public void equal_ArrayArray() Assert.IsTrue(result.GetBoolean(2)); } - [Test] + [TestMethod] public void equal_ArrayScalar() { // NumPy: np.equal([1, 2, 3], 2) -> [False, True, False] @@ -39,7 +40,7 @@ public void equal_ArrayScalar() Assert.IsFalse(result.GetBoolean(2)); } - [Test] + [TestMethod] public void equal_ScalarArray() { // NumPy: np.equal(2, [1, 2, 3]) -> [False, True, False] @@ -52,7 +53,7 @@ public void equal_ScalarArray() Assert.IsFalse(result.GetBoolean(2)); } - [Test] + [TestMethod] public void equal_Float64() { // NumPy: np.equal([1.0, 2.0, 3.0], [1.0, 2.1, 3.0]) -> [True, False, True] @@ -69,7 +70,7 @@ public void equal_Float64() #region np.not_equal - [Test] + [TestMethod] public void not_equal_ArrayArray() { // NumPy: np.not_equal([1, 2, 3], [1, 0, 3]) -> [False, True, False] @@ -82,7 +83,7 @@ public void not_equal_ArrayArray() Assert.IsFalse(result.GetBoolean(2)); } - [Test] + [TestMethod] public void not_equal_ArrayScalar() { // NumPy: np.not_equal([1, 2, 3], 2) -> [True, False, True] @@ -98,7 +99,7 @@ public void not_equal_ArrayScalar() #region np.less - [Test] + [TestMethod] public void less_ArrayArray() { // NumPy: np.less([1, 2, 3], [2, 2, 2]) -> [True, False, False] @@ -111,7 +112,7 @@ public void less_ArrayArray() Assert.IsFalse(result.GetBoolean(2)); } - [Test] + [TestMethod] public void less_ArrayScalar() { // NumPy: np.less([1, 2, 3], 2) -> [True, False, False] @@ -123,7 +124,7 @@ public void less_ArrayScalar() Assert.IsFalse(result.GetBoolean(2)); } - [Test] + [TestMethod] public void less_ScalarArray() { // NumPy: np.less(2, [1, 2, 3]) -> [False, False, True] @@ -139,7 +140,7 @@ public void less_ScalarArray() #region np.greater - [Test] + [TestMethod] public void greater_ArrayArray() { // NumPy: np.greater([1, 2, 3], [2, 2, 2]) -> [False, False, True] @@ -152,7 +153,7 @@ public void greater_ArrayArray() Assert.IsTrue(result.GetBoolean(2)); } - [Test] + [TestMethod] public void greater_ArrayScalar() { // NumPy: np.greater([1, 2, 3], 2) -> [False, False, True] @@ -168,7 +169,7 @@ public void greater_ArrayScalar() #region np.less_equal - [Test] + [TestMethod] public void less_equal_ArrayArray() { // NumPy: np.less_equal([1, 2, 3], [2, 2, 2]) -> [True, True, False] @@ -181,7 +182,7 @@ public void less_equal_ArrayArray() Assert.IsFalse(result.GetBoolean(2)); } - [Test] + [TestMethod] public void less_equal_ArrayScalar() { // NumPy: np.less_equal([1, 2, 3], 2) -> [True, True, False] @@ -197,7 +198,7 @@ public void less_equal_ArrayScalar() #region np.greater_equal - [Test] + [TestMethod] public void greater_equal_ArrayArray() { // NumPy: np.greater_equal([1, 2, 3], [2, 2, 2]) -> [False, True, True] @@ -210,7 +211,7 @@ public void greater_equal_ArrayArray() Assert.IsTrue(result.GetBoolean(2)); } - [Test] + [TestMethod] public void greater_equal_ArrayScalar() { // NumPy: np.greater_equal([1, 2, 3], 2) -> [False, True, True] @@ -226,7 +227,7 @@ public void greater_equal_ArrayScalar() #region Broadcasting - [Test] + [TestMethod] public void comparison_Broadcasting2D() { // NumPy: np.equal([[1, 2], [3, 4]], [1, 4]) -> [[True, False], [False, True]] @@ -241,7 +242,7 @@ public void comparison_Broadcasting2D() Assert.IsTrue(result.GetBoolean(1, 1)); } - [Test] + [TestMethod] public void less_Broadcasting() { // NumPy: np.less([[1], [2], [3]], [1, 2, 3]) broadcasts to (3, 3) @@ -272,7 +273,7 @@ public void less_Broadcasting() #region Different dtypes - [Test] + [TestMethod] public void equal_MixedTypes() { // NumPy: np.equal(int32_array, float64_array) works with type promotion @@ -285,7 +286,7 @@ public void equal_MixedTypes() Assert.IsTrue(result.GetBoolean(2)); } - [Test] + [TestMethod] public void less_MixedTypes() { // NumPy: np.less(int32_array, float64_array) diff --git a/test/NumSharp.UnitTest/Logic/np.find_common_type.Test.cs b/test/NumSharp.UnitTest/Logic/np.find_common_type.Test.cs index 693304b3d..86097541c 100644 --- a/test/NumSharp.UnitTest/Logic/np.find_common_type.Test.cs +++ b/test/NumSharp.UnitTest/Logic/np.find_common_type.Test.cs @@ -6,156 +6,157 @@ namespace NumSharp.UnitTest.Logic { + [TestClass] public class np_find_common_type_test { - [Test] + [TestMethod] public void Case1() { var r = np.find_common_type(new[] {np.float32}, new[] {np.int64, np.float64}); r.Should().Be(NPTypeCode.Single); } - [Test] + [TestMethod] public void Case2() { var r = np.find_common_type(new[] {np.float32}, new[] {np.complex64}); r.Should().Be(NPTypeCode.Complex); } - [Test] + [TestMethod] public void Case3() { var r = np.find_common_type(new[] {np.float32}, new[] {np.complex64}); r.Should().Be(NPTypeCode.Complex); } - [Test] + [TestMethod] public void Case4() { var r = np.find_common_type(new[] {"f4", "f4", "i4",}, new[] {"c8"}); r.Should().Be(NPTypeCode.Complex); } - [Test] + [TestMethod] public void Case5() { var r = np.find_common_type(new[] {"f4", "f4", "i4",}, new[] {"c8"}); r.Should().Be(NPTypeCode.Complex); } - [Test] + [TestMethod] public void Case6() { var r = np.find_common_type(new[] {np.int32, np.float32}); r.Should().Be(NPTypeCode.Double); } - [Test] + [TestMethod] public void Case7() { var r = np.find_common_type(new[] {np.int32, np.float64}); r.Should().Be(NPTypeCode.Double); } - [Test] + [TestMethod] public void Case8() { var r = np.find_common_type(new[] {np.int32, np.float64}, new[] {np.int32, np.float64}); r.Should().Be(NPTypeCode.Double); } - [Test] + [TestMethod] public void Case9() { var r = np.find_common_type(new[] {np.int32, np.float64}, new[] {np.int32, np.float32}); r.Should().Be(NPTypeCode.Double); } - [Test] + [TestMethod] public void Case10() { var r = np.find_common_type(new[] {np.int32, np.float64}, new[] {np.complex64}); r.Should().Be(NPTypeCode.Complex); } - [Test] + [TestMethod] public void Case11() { var r = np.find_common_type(new[] {np.uint8, np.float32}, new Type[0]); r.Should().Be(NPTypeCode.Single); } - [Test] + [TestMethod] public void Case12() { var r = np.find_common_type(new[] {np.@byte, np.float32}, new Type[0]); r.Should().Be(NPTypeCode.Single); } - [Test] + [TestMethod] public void Case13() { var r = np.find_common_type(new[] {np.float32, np.float32}, new Type[0]); r.Should().Be(NPTypeCode.Single); } - [Test] + [TestMethod] public void Case14() { var r = np.find_common_type(new[] {np.float32, np.@byte}, new Type[0]); r.Should().Be(NPTypeCode.Single); } - [Test] + [TestMethod] public void Case15() { var r = np.find_common_type(new[] {np.float64, np.float64}, new Type[0]); r.Should().Be(NPTypeCode.Double); } - [Test] + [TestMethod] public void Case17() { var r = np.find_common_type(new[] {np.@byte, np.@byte}, new Type[0]); r.Should().Be(NPTypeCode.Byte); } - [Test] + [TestMethod] public void Case18() { var r = np.find_common_type(new[] {np.complex128, np.@double}, new Type[0]); r.Should().Be(NPTypeCode.Complex); } - [Test] + [TestMethod] public void Case19() { var r = np.find_common_type(new[] {np.complex128, np.complex128}, new Type[0]); r.Should().Be(NPTypeCode.Complex); } - [Test] + [TestMethod] public void Case20() { var r = np.find_common_type(new[] {np.complex128, np.complex128}, new[] {np.@double}); r.Should().Be(NPTypeCode.Complex); } - [Test] + [TestMethod] public void Case21() { var r = np.find_common_type(new[] {np.@decimal, np.@double}, new NPTypeCode[0]); r.Should().Be(NPTypeCode.Decimal); } - [Test] + [TestMethod] public void Case22() { var r = np.find_common_type(new[] {np.int16, np.int64}, new NPTypeCode[0]); r.Should().Be(NPTypeCode.Int64); } - [Test] + [TestMethod] public void Case23() { var r = np.find_common_type(new[] {np.@char, np.int16}, new NPTypeCode[0]); @@ -167,7 +168,7 @@ public void Case23() /// the array dtype wins (no type widening). This matches NumPy 2.x behavior. /// See: https://numpy.org/neps/nep-0050-scalar-promotion.html /// - [Test] + [TestMethod] public void NEP50_UnsignedArray_SignedScalar_ArrayWins() { // uint8 array + signed scalar → uint8 @@ -191,7 +192,7 @@ public void NEP50_UnsignedArray_SignedScalar_ArrayWins() np._FindCommonArrayScalarType(NPTypeCode.UInt64, NPTypeCode.Int64).Should().Be(NPTypeCode.UInt64); } - [Test, Skip("Ignored")] + [TestMethod, Ignore("Ignored")] public void gen_typecode_map() { var r = np.find_common_type(new[] {np.float32, np.float64}, new NPTypeCode[0]); @@ -340,8 +341,8 @@ public void gen_typecode_map() #endif } - [Test] - [Skip("Ignored")] + [TestMethod] + [Ignore("Ignored")] public void gen_all_possible_combinations() { #if _REGEN diff --git a/test/NumSharp.UnitTest/Logic/np.isclose.Test.cs b/test/NumSharp.UnitTest/Logic/np.isclose.Test.cs index 6329fdff3..d0090f8d6 100644 --- a/test/NumSharp.UnitTest/Logic/np.isclose.Test.cs +++ b/test/NumSharp.UnitTest/Logic/np.isclose.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Logic { + [TestClass] public class np_isclose_Test { - [Test] + [TestMethod] public void np_isclose_1D() { //>>> np.isclose([1e10, 1e-7], [1.00001e10,1e-8]) diff --git a/test/NumSharp.UnitTest/Logic/np.isfinite.Test.cs b/test/NumSharp.UnitTest/Logic/np.isfinite.Test.cs index ef895994b..f6b0b2f05 100644 --- a/test/NumSharp.UnitTest/Logic/np.isfinite.Test.cs +++ b/test/NumSharp.UnitTest/Logic/np.isfinite.Test.cs @@ -12,9 +12,10 @@ namespace NumSharp.UnitTest.Logic /// Tests for np.isfinite - test element-wise for finiteness (not infinity and not NaN). /// NumPy reference: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html /// + [TestClass] public class np_isfinite_Test { - [Test] + [TestMethod] public void np_isfinite_1D() { var np1 = new NDArray(new[] {1.0, Math.PI, Math.E, 42, double.MaxValue, double.MinValue, double.NaN}); @@ -32,7 +33,7 @@ public void np_isfinite_1D() Assert.AreEqual(1, np.isfinite(np3).ndim); } - [Test] + [TestMethod] public void np_isfinite_2D() { var np1 = new NDArray(new[] {Math.PI, Math.E, 42, double.MaxValue, double.MinValue, double.NaN}, new Shape(2, 3)); @@ -49,7 +50,7 @@ public void np_isfinite_2D() Assert.AreEqual(2, np.isfinite(np3).ndim); } - [Test] + [TestMethod] public void np_isfinite_Float32() { // Test with float32 array @@ -60,7 +61,7 @@ public void np_isfinite_Float32() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), new[] {true, false, false, false, true, true})); } - [Test] + [TestMethod] public void np_isfinite_IntegerTypes_AlwaysTrue() { // All integer types are always finite @@ -70,7 +71,7 @@ public void np_isfinite_IntegerTypes_AlwaysTrue() Assert.IsTrue(np.all(np.isfinite(np.array(new short[] {0, short.MaxValue, short.MinValue})))); } - [Test] + [TestMethod] public void np_isfinite_Scalar() { Assert.IsTrue(np.isfinite(np.array(1.0)).GetBoolean()); @@ -79,7 +80,7 @@ public void np_isfinite_Scalar() Assert.IsFalse(np.isfinite(np.array(double.NegativeInfinity)).GetBoolean()); } - [Test] + [TestMethod] public void np_isfinite_EmptyArray() { var empty = np.array(new double[0]); @@ -88,7 +89,7 @@ public void np_isfinite_EmptyArray() Assert.AreEqual(typeof(bool), result.dtype); } - [Test] + [TestMethod] public void np_isfinite_SlicedArray() { // Test with non-contiguous (sliced) array diff --git a/test/NumSharp.UnitTest/Logic/np.isinf.Test.cs b/test/NumSharp.UnitTest/Logic/np.isinf.Test.cs index 70ea53cdc..4de1f47fe 100644 --- a/test/NumSharp.UnitTest/Logic/np.isinf.Test.cs +++ b/test/NumSharp.UnitTest/Logic/np.isinf.Test.cs @@ -15,7 +15,7 @@ namespace NumSharp.UnitTest.Logic /// public class np_isinf_Test { - [Test, OpenBugs] + [TestMethod, OpenBugs] public void np_isinf_1D() { var arr = new NDArray(new[] { 1.0, Math.PI, double.PositiveInfinity, double.NegativeInfinity, double.NaN, 0.0 }); @@ -27,7 +27,7 @@ public void np_isinf_1D() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), new[] { false, false, true, true, false, false })); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void np_isinf_2D() { var arr = new NDArray(new[] { @@ -41,7 +41,7 @@ public void np_isinf_2D() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), new[] { true, false, false, true, false, false })); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void np_isinf_Float32() { // Test with float32 array @@ -53,7 +53,7 @@ public void np_isinf_Float32() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), new[] { false, true, true, false, false, false })); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void np_isinf_IntegerTypes_AlwaysFalse() { // Integer types cannot be infinity @@ -63,7 +63,7 @@ public void np_isinf_IntegerTypes_AlwaysFalse() Assert.IsFalse(np.any(np.isinf(np.array(new short[] { 0, short.MaxValue, short.MinValue })))); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void np_isinf_Scalar() { Assert.IsFalse(np.isinf(np.array(1.0)).GetBoolean()); @@ -72,7 +72,7 @@ public void np_isinf_Scalar() Assert.IsTrue(np.isinf(np.array(double.NegativeInfinity)).GetBoolean()); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void np_isinf_EmptyArray() { var empty = np.array(new double[0]); @@ -81,7 +81,7 @@ public void np_isinf_EmptyArray() Assert.AreEqual(typeof(bool), result.dtype); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void np_isinf_SlicedArray() { // Test with non-contiguous (sliced) array @@ -93,7 +93,7 @@ public void np_isinf_SlicedArray() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), new[] { false, false, false })); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void np_isinf_NaNIsNotInfinity() { // Important: NaN is NOT infinity @@ -102,7 +102,7 @@ public void np_isinf_NaNIsNotInfinity() Assert.IsFalse(result.GetBoolean(0)); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void np_isinf_MaxValueIsNotInfinity() { // Important: MaxValue/MinValue are NOT infinity diff --git a/test/NumSharp.UnitTest/Logic/np.isnan.Test.cs b/test/NumSharp.UnitTest/Logic/np.isnan.Test.cs index 4cb7d2781..cb5d04548 100644 --- a/test/NumSharp.UnitTest/Logic/np.isnan.Test.cs +++ b/test/NumSharp.UnitTest/Logic/np.isnan.Test.cs @@ -11,9 +11,10 @@ namespace NumSharp.UnitTest.Logic /// Tests for np.isnan - test element-wise for NaN. /// NumPy reference: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html /// + [TestClass] public class np_isnan_Test { - [Test] + [TestMethod] public void np_isnan_1D() { var np1 = new NDArray(new[] {1.0, Math.PI, Math.E, 42, double.MaxValue, double.MinValue, double.NaN}); @@ -31,7 +32,7 @@ public void np_isnan_1D() Assert.AreEqual(1, np.isnan(np3).ndim); } - [Test] + [TestMethod] public void np_isnan_2D() { var np1 = new NDArray(new[] {Math.PI, Math.E, 42, double.MaxValue, double.MinValue, double.NaN}, new Shape(2, 3)); @@ -48,7 +49,7 @@ public void np_isnan_2D() Assert.AreEqual(2, np.isnan(np3).ndim); } - [Test] + [TestMethod] public void np_isnan_Float32() { // Test with float32 array @@ -60,7 +61,7 @@ public void np_isnan_Float32() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), new[] {false, false, false, true, false, false})); } - [Test] + [TestMethod] public void np_isnan_IntegerTypes_AlwaysFalse() { // Integer types cannot be NaN @@ -70,7 +71,7 @@ public void np_isnan_IntegerTypes_AlwaysFalse() Assert.IsFalse(np.any(np.isnan(np.array(new short[] {0, short.MaxValue, short.MinValue})))); } - [Test] + [TestMethod] public void np_isnan_Scalar() { Assert.IsFalse(np.isnan(np.array(1.0)).GetBoolean()); @@ -80,7 +81,7 @@ public void np_isnan_Scalar() Assert.IsFalse(np.isnan(np.array(double.NegativeInfinity)).GetBoolean()); } - [Test] + [TestMethod] public void np_isnan_EmptyArray() { var empty = np.array(new double[0]); @@ -89,7 +90,7 @@ public void np_isnan_EmptyArray() Assert.AreEqual(typeof(bool), result.dtype); } - [Test] + [TestMethod] public void np_isnan_SlicedArray() { // Test with non-contiguous (sliced) array @@ -101,7 +102,7 @@ public void np_isnan_SlicedArray() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), new[] {false, false, false})); } - [Test] + [TestMethod] public void np_isnan_InfinityIsNotNaN() { // Important: Infinity is NOT NaN diff --git a/test/NumSharp.UnitTest/Logic/np.isscalar.Test.cs b/test/NumSharp.UnitTest/Logic/np.isscalar.Test.cs index c50d6cdbc..5786c156a 100644 --- a/test/NumSharp.UnitTest/Logic/np.isscalar.Test.cs +++ b/test/NumSharp.UnitTest/Logic/np.isscalar.Test.cs @@ -7,38 +7,39 @@ namespace NumSharp.UnitTest.Logic { + [TestClass] public class np_isscalar_tests { - [Test] - [Arguments(typeof(double))] - [Arguments(typeof(float))] - [Arguments(typeof(byte))] - [Arguments(typeof(int))] - [Arguments(typeof(long))] - [Arguments(typeof(char))] - [Arguments(typeof(short))] - [Arguments(typeof(uint))] - [Arguments(typeof(ulong))] - [Arguments(typeof(ushort))] - [Arguments(typeof(decimal))] + [TestMethod] + [DataRow(typeof(double))] + [DataRow(typeof(float))] + [DataRow(typeof(byte))] + [DataRow(typeof(int))] + [DataRow(typeof(long))] + [DataRow(typeof(char))] + [DataRow(typeof(short))] + [DataRow(typeof(uint))] + [DataRow(typeof(ulong))] + [DataRow(typeof(ushort))] + [DataRow(typeof(decimal))] public void AllPrimitiveTypes(Type type) { var value = Convert.ChangeType((byte)0, type); Assert.IsTrue(np.isscalar(value)); } - [Test] - [Arguments(typeof(double))] - [Arguments(typeof(float))] - [Arguments(typeof(byte))] - [Arguments(typeof(int))] - [Arguments(typeof(long))] - [Arguments(typeof(char))] - [Arguments(typeof(short))] - [Arguments(typeof(uint))] - [Arguments(typeof(ulong))] - [Arguments(typeof(ushort))] - [Arguments(typeof(decimal))] + [TestMethod] + [DataRow(typeof(double))] + [DataRow(typeof(float))] + [DataRow(typeof(byte))] + [DataRow(typeof(int))] + [DataRow(typeof(long))] + [DataRow(typeof(char))] + [DataRow(typeof(short))] + [DataRow(typeof(uint))] + [DataRow(typeof(ulong))] + [DataRow(typeof(ushort))] + [DataRow(typeof(decimal))] public void AllPrimitiveArrayTypes(Type type) { var value = Convert.ChangeType((byte)0, type); @@ -47,28 +48,28 @@ public void AllPrimitiveArrayTypes(Type type) Assert.IsFalse(np.isscalar(arr)); } - [Test] + [TestMethod] public void Complex() { var value = new Complex(15, 15); Assert.IsTrue(np.isscalar(value)); } - [Test] + [TestMethod] public void Null() { Assert.IsFalse(np.isscalar(null)); } - [Test] - [Arguments("")] - [Arguments("Hi")] + [TestMethod] + [DataRow("")] + [DataRow("Hi")] public void String(string value) { Assert.IsTrue(np.isscalar(value)); } - [Test] + [TestMethod] public void NDArray() { var value = np.zeros(new Shape(3, 3)); diff --git a/test/NumSharp.UnitTest/Logic/np_all_axis_Test.cs b/test/NumSharp.UnitTest/Logic/np_all_axis_Test.cs index 47cf01799..fc23cbccf 100644 --- a/test/NumSharp.UnitTest/Logic/np_all_axis_Test.cs +++ b/test/NumSharp.UnitTest/Logic/np_all_axis_Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Logic { + [TestClass] public class np_all_axis_Test { - [Test] + [TestMethod] public void np_all_axis_2D() { // Test array: [[true, false, true], [true, true, true]] @@ -26,7 +27,7 @@ public void np_all_axis_2D() Assert.IsTrue(np.array_equal(result_axis1, expected_axis1)); } - [Test] + [TestMethod] public void np_all_axis_3D() { // Create a 3D array for testing @@ -50,7 +51,7 @@ public void np_all_axis_3D() Assert.AreEqual(3, result_axis2.shape[1]); } - [Test] + [TestMethod] public void np_all_keepdims() { var arr = np.array(new bool[,] { { true, false, true }, { true, true, true } }); @@ -67,7 +68,7 @@ public void np_all_keepdims() Assert.AreEqual(1, result_keepdims1.shape[1]); // The reduced axis becomes size 1 } - [Test] + [TestMethod] public void np_all_different_types() { // Test with integer array diff --git a/test/NumSharp.UnitTest/LongIndexing/LongIndexingBroadcastTest.cs b/test/NumSharp.UnitTest/LongIndexing/LongIndexingBroadcastTest.cs index 27e929ec3..1fd3bd303 100644 --- a/test/NumSharp.UnitTest/LongIndexing/LongIndexingBroadcastTest.cs +++ b/test/NumSharp.UnitTest/LongIndexing/LongIndexingBroadcastTest.cs @@ -1,8 +1,6 @@ using System; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; -using TUnit.Core; namespace NumSharp.UnitTest.LongIndexing; @@ -22,8 +20,9 @@ namespace NumSharp.UnitTest.LongIndexing; /// even when input is broadcast, causing OutOfMemoryException /// /// NOTE: Marked [LargeMemoryTest] because iterating over 2.36 billion elements causes -/// excessive CPU/memory pressure when TUnit runs tests in parallel. +/// excessive CPU/memory pressure when MSTest runs tests in parallel. /// +[TestClass] public class LongIndexingBroadcastTest { /// @@ -54,8 +53,8 @@ private static NDArray BroadcastScalar(double value) // SHAPE AND INDEXING (all pass - no memory allocation needed) // ================================================================ - [Test, LargeMemoryTest] - public async Task Broadcast_HasCorrectSize() + [TestMethod, LargeMemoryTest] + public void Broadcast_HasCorrectSize() { var arr = BroadcastScalar((byte)42); Assert.AreEqual(LargeSize, arr.size); @@ -63,16 +62,16 @@ public async Task Broadcast_HasCorrectSize() Assert.AreEqual(LargeSize, arr.shape[0]); } - [Test, LargeMemoryTest] - public async Task Broadcast_IsBroadcasted() + [TestMethod, LargeMemoryTest] + public void Broadcast_IsBroadcasted() { var arr = BroadcastScalar((byte)42); Assert.IsTrue(arr.Shape.IsBroadcasted); Assert.IsFalse(arr.Shape.IsContiguous); } - [Test, LargeMemoryTest] - public async Task Broadcast_GetAtLargeIndex() + [TestMethod, LargeMemoryTest] + public void Broadcast_GetAtLargeIndex() { var arr = BroadcastScalar((byte)77); @@ -86,8 +85,8 @@ public async Task Broadcast_GetAtLargeIndex() // REDUCTIONS (these iterate over all elements logically - PASS) // ================================================================ - [Test, LargeMemoryTest] - public async Task Broadcast_Mean() + [TestMethod, LargeMemoryTest] + public void Broadcast_Mean() { var arr = BroadcastScalar((byte)42); var result = np.mean(arr); @@ -97,8 +96,8 @@ public async Task Broadcast_Mean() Assert.AreEqual(42.0, result.GetDouble(0), 0.001); } - [Test, LargeMemoryTest] - public async Task Broadcast_Min() + [TestMethod, LargeMemoryTest] + public void Broadcast_Min() { var arr = BroadcastScalar((byte)7); var result = np.min(arr); @@ -106,8 +105,8 @@ public async Task Broadcast_Min() Assert.AreEqual(7, result.GetByte(0)); } - [Test, LargeMemoryTest] - public async Task Broadcast_Max() + [TestMethod, LargeMemoryTest] + public void Broadcast_Max() { var arr = BroadcastScalar((byte)200); var result = np.max(arr); @@ -115,8 +114,8 @@ public async Task Broadcast_Max() Assert.AreEqual(200, result.GetByte(0)); } - [Test, LargeMemoryTest] - public async Task Broadcast_ArgMax() + [TestMethod, LargeMemoryTest] + public void Broadcast_ArgMax() { var arr = BroadcastScalar((byte)100); var result = np.argmax(arr); @@ -125,8 +124,8 @@ public async Task Broadcast_ArgMax() Assert.AreEqual(0L, result); } - [Test, LargeMemoryTest] - public async Task Broadcast_ArgMin() + [TestMethod, LargeMemoryTest] + public void Broadcast_ArgMin() { var arr = BroadcastScalar((byte)50); var result = np.argmin(arr); @@ -135,8 +134,8 @@ public async Task Broadcast_ArgMin() Assert.AreEqual(0L, result); } - [Test, LargeMemoryTest] - public async Task Broadcast_All() + [TestMethod, LargeMemoryTest] + public void Broadcast_All() { var arr = BroadcastScalar((byte)1); var result = np.all(arr); @@ -144,8 +143,8 @@ public async Task Broadcast_All() Assert.IsTrue(result); } - [Test, LargeMemoryTest] - public async Task Broadcast_All_Zero() + [TestMethod, LargeMemoryTest] + public void Broadcast_All_Zero() { var arr = BroadcastScalar((byte)0); var result = np.all(arr); @@ -153,8 +152,8 @@ public async Task Broadcast_All_Zero() Assert.IsFalse(result); } - [Test, LargeMemoryTest] - public async Task Broadcast_Any() + [TestMethod, LargeMemoryTest] + public void Broadcast_Any() { var arr = BroadcastScalar((byte)1); var result = np.any(arr); @@ -162,8 +161,8 @@ public async Task Broadcast_Any() Assert.IsTrue(result); } - [Test, LargeMemoryTest] - public async Task Broadcast_Any_Zero() + [TestMethod, LargeMemoryTest] + public void Broadcast_Any_Zero() { var arr = BroadcastScalar((byte)0); var result = np.any(arr); @@ -171,8 +170,8 @@ public async Task Broadcast_Any_Zero() Assert.IsFalse(result); } - [Test, LargeMemoryTest] - public async Task Broadcast_CountNonzero() + [TestMethod, LargeMemoryTest] + public void Broadcast_CountNonzero() { var arr = BroadcastScalar((byte)1); var result = np.count_nonzero(arr); @@ -181,8 +180,8 @@ public async Task Broadcast_CountNonzero() Assert.AreEqual(LargeSize, result); } - [Test, LargeMemoryTest] - public async Task Broadcast_CountNonzero_Zero() + [TestMethod, LargeMemoryTest] + public void Broadcast_CountNonzero_Zero() { var arr = BroadcastScalar((byte)0); var result = np.count_nonzero(arr); @@ -194,8 +193,8 @@ public async Task Broadcast_CountNonzero_Zero() // SHAPE MANIPULATION (most pass - only reshape with slice fails) // ================================================================ - [Test, LargeMemoryTest] - public async Task Broadcast_ExpandDims() + [TestMethod, LargeMemoryTest] + public void Broadcast_ExpandDims() { var arr = BroadcastScalar((byte)11); var result = np.expand_dims(arr, 0); @@ -206,8 +205,8 @@ public async Task Broadcast_ExpandDims() Assert.AreEqual(LargeSize, result.shape[1]); } - [Test, LargeMemoryTest] - public async Task Broadcast_Atleast2d() + [TestMethod, LargeMemoryTest] + public void Broadcast_Atleast2d() { var arr = BroadcastScalar((byte)22); var result = np.atleast_2d(arr); @@ -216,8 +215,8 @@ public async Task Broadcast_Atleast2d() Assert.AreEqual(2, result.ndim); } - [Test, LargeMemoryTest] - public async Task Broadcast_Atleast3d() + [TestMethod, LargeMemoryTest] + public void Broadcast_Atleast3d() { var arr = BroadcastScalar((byte)22); var result = np.atleast_3d(arr); @@ -230,8 +229,8 @@ public async Task Broadcast_Atleast3d() // 2D BROADCAST (tests multi-dimensional long indexing) // ================================================================ - [Test, LargeMemoryTest] - public async Task Broadcast2D_RowBroadcast() + [TestMethod, LargeMemoryTest] + public void Broadcast2D_RowBroadcast() { // Broadcast a single row to many rows long rows = LargeSize; @@ -245,8 +244,8 @@ public async Task Broadcast2D_RowBroadcast() Assert.AreEqual(77, arr.GetByte(rows - 1, cols - 1)); } - [Test, LargeMemoryTest] - public async Task Broadcast2D_ColumnBroadcast() + [TestMethod, LargeMemoryTest] + public void Broadcast2D_ColumnBroadcast() { // Broadcast a single column to many columns long rows = 10; @@ -260,8 +259,8 @@ public async Task Broadcast2D_ColumnBroadcast() Assert.AreEqual(88, arr.GetByte(rows - 1, cols - 1)); } - [Test, LargeMemoryTest] - public async Task Broadcast2D_Transpose() + [TestMethod, LargeMemoryTest] + public void Broadcast2D_Transpose() { // Test transpose of a broadcast array long rows = 10; @@ -286,8 +285,8 @@ public async Task Broadcast2D_Transpose() /// LIMITATION: SliceDef is limited to int indices. /// Slicing a broadcast array with indices > int.MaxValue throws OverflowException. /// - [Test] - public async Task Broadcast_SliceWithLargeIndices_Limited() + [TestMethod] + public void Broadcast_SliceWithLargeIndices_Limited() { var arr = BroadcastScalar((byte)99); @@ -303,8 +302,8 @@ public async Task Broadcast_SliceWithLargeIndices_Limited() /// LIMITATION: Binary operations allocate full output arrays. /// Even with broadcast inputs, the output is allocated at full size. /// - [Test] - public async Task Broadcast_Add_AllocatesFullOutput() + [TestMethod] + public void Broadcast_Add_AllocatesFullOutput() { var a = BroadcastScalar((byte)10); var b = BroadcastScalar((byte)20); @@ -317,8 +316,8 @@ public async Task Broadcast_Add_AllocatesFullOutput() /// /// LIMITATION: Unary operations allocate full output arrays. /// - [Test] - public async Task Broadcast_Square_AllocatesFullOutput() + [TestMethod] + public void Broadcast_Square_AllocatesFullOutput() { var arr = BroadcastScalar((byte)5); @@ -331,9 +330,9 @@ public async Task Broadcast_Square_AllocatesFullOutput() /// LIMITATION: Sum on broadcast uses inefficient iterator. /// Currently throws "index < Count, Memory corruption expected" for large broadcast. /// - [Test] + [TestMethod] [OpenBugs] - public async Task Broadcast_Sum_InternalError() + public void Broadcast_Sum_InternalError() { var arr = BroadcastScalar((byte)1); var result = np.sum(arr); @@ -347,10 +346,10 @@ public async Task Broadcast_Sum_InternalError() // Note: This DOES allocate full memory, so it's marked Explicit + LongIndexing // ================================================================ - [Test] - [Explicit("Allocates full 2.4GB array")] + [TestMethod] + [TestCategory("Explicit")] // Allocates full 2.4GB array [HighMemory] - public async Task Broadcast_Copy_MaterializesFullArray() + public void Broadcast_Copy_MaterializesFullArray() { var broadcast = BroadcastScalar((byte)123); diff --git a/test/NumSharp.UnitTest/LongIndexing/LongIndexingMasterTest.cs b/test/NumSharp.UnitTest/LongIndexing/LongIndexingMasterTest.cs index beccd7c2b..1a15a9b72 100644 --- a/test/NumSharp.UnitTest/LongIndexing/LongIndexingMasterTest.cs +++ b/test/NumSharp.UnitTest/LongIndexing/LongIndexingMasterTest.cs @@ -2,10 +2,8 @@ using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; -using TUnit.Core; namespace NumSharp.UnitTest.LongIndexing; @@ -29,6 +27,7 @@ namespace NumSharp.UnitTest.LongIndexing; /// 3. We don't exceed available system memory /// [HighMemory] +[TestClass] public class LongIndexingMasterTest { /// @@ -46,9 +45,9 @@ public class LongIndexingMasterTest /// Master test that exercises all np.* functions with large arrays. /// Runs sequentially to manage memory usage. /// - [Test] - [Explicit("Requires ~8GB+ RAM. Run manually with: dotnet test -- --treenode-filter \"/*/*/*/*[Category=LongIndexing]\"")] - public async Task AllNpFunctions_WithLargeArrays() + [TestMethod] + [TestCategory("Explicit")] // Requires ~8GB+ RAM. Run manually with: dotnet test --filter "TestCategory=LongIndexing" + public void AllNpFunctions_WithLargeArrays() { var results = new System.Collections.Generic.List<(string Operation, bool Success, string Error, TimeSpan Duration)>(); diff --git a/test/NumSharp.UnitTest/LongIndexing/LongIndexingSmokeTest.cs b/test/NumSharp.UnitTest/LongIndexing/LongIndexingSmokeTest.cs index 7161705f1..33e76eefd 100644 --- a/test/NumSharp.UnitTest/LongIndexing/LongIndexingSmokeTest.cs +++ b/test/NumSharp.UnitTest/LongIndexing/LongIndexingSmokeTest.cs @@ -1,8 +1,6 @@ using System; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; -using TUnit.Core; namespace NumSharp.UnitTest.LongIndexing; @@ -18,6 +16,7 @@ namespace NumSharp.UnitTest.LongIndexing; /// - Verifies Shape, NDArray, and np.* APIs accept long indices /// - Fast execution (~1-2 seconds total) /// +[TestClass] public class LongIndexingSmokeTest { /// @@ -25,8 +24,8 @@ public class LongIndexingSmokeTest /// private const long TestSize = 1_000_000L; - [Test] - public async Task Shape_AcceptsLongDimensions() + [TestMethod] + public void Shape_AcceptsLongDimensions() { var shape = new Shape(TestSize); Assert.AreEqual(TestSize, shape.Size); @@ -34,24 +33,24 @@ public async Task Shape_AcceptsLongDimensions() Assert.AreEqual(TestSize, shape.Dimensions[0]); } - [Test] - public async Task Shape_AcceptsLongMultiDimensions() + [TestMethod] + public void Shape_AcceptsLongMultiDimensions() { var shape = new Shape(1000L, 1000L); Assert.AreEqual(1_000_000L, shape.Size); Assert.AreEqual(2, shape.NDim); } - [Test] - public async Task Shape_GetOffset_AcceptsLongIndices() + [TestMethod] + public void Shape_GetOffset_AcceptsLongIndices() { var shape = new Shape(TestSize); var offset = shape.GetOffset(TestSize - 1); Assert.AreEqual(TestSize - 1, offset); } - [Test] - public async Task Shape_GetCoordinates_ReturnsLongArray() + [TestMethod] + public void Shape_GetCoordinates_ReturnsLongArray() { var shape = new Shape(1000L, 1000L); long[] coords = shape.GetCoordinates(999_999); @@ -60,8 +59,8 @@ public async Task Shape_GetCoordinates_ReturnsLongArray() Assert.AreEqual(999L, coords[1]); } - [Test] - public async Task NDArray_Zeros_AcceptsLongShape() + [TestMethod] + public void NDArray_Zeros_AcceptsLongShape() { var arr = np.zeros(new Shape(TestSize), np.uint8); Assert.AreEqual(TestSize, arr.size); @@ -69,8 +68,8 @@ public async Task NDArray_Zeros_AcceptsLongShape() Assert.AreEqual(0, arr.GetByte(TestSize - 1)); } - [Test] - public async Task NDArray_Ones_AcceptsLongShape() + [TestMethod] + public void NDArray_Ones_AcceptsLongShape() { var arr = np.ones(new Shape(TestSize), np.uint8); Assert.AreEqual(TestSize, arr.size); @@ -78,8 +77,8 @@ public async Task NDArray_Ones_AcceptsLongShape() Assert.AreEqual(1, arr.GetByte(TestSize - 1)); } - [Test] - public async Task NDArray_Full_AcceptsLongShape() + [TestMethod] + public void NDArray_Full_AcceptsLongShape() { var arr = np.full(new Shape(TestSize), (byte)42, np.uint8); Assert.AreEqual(TestSize, arr.size); @@ -87,16 +86,16 @@ public async Task NDArray_Full_AcceptsLongShape() Assert.AreEqual(42, arr.GetByte(TestSize - 1)); } - [Test] - public async Task NDArray_GetSet_AcceptsLongIndex() + [TestMethod] + public void NDArray_GetSet_AcceptsLongIndex() { var arr = np.zeros(new Shape(TestSize), np.uint8); arr.SetByte((byte)123, TestSize - 1); Assert.AreEqual(123, arr.GetByte(TestSize - 1)); } - [Test] - public async Task NDArray_Reshape_AcceptsLongDimensions() + [TestMethod] + public void NDArray_Reshape_AcceptsLongDimensions() { var arr = np.zeros(new Shape(TestSize), np.uint8); var reshaped = np.reshape(arr, new Shape(1000L, 1000L)); @@ -104,24 +103,24 @@ public async Task NDArray_Reshape_AcceptsLongDimensions() Assert.AreEqual(2, reshaped.ndim); } - [Test] - public async Task NDArray_Sum_ReturnsCorrectForLargeArray() + [TestMethod] + public void NDArray_Sum_ReturnsCorrectForLargeArray() { var arr = np.ones(new Shape(TestSize), np.uint8); var result = np.sum(arr); Assert.AreEqual(0, result.ndim); } - [Test] - public async Task NDArray_Mean_ReturnsCorrectForLargeArray() + [TestMethod] + public void NDArray_Mean_ReturnsCorrectForLargeArray() { var arr = np.ones(new Shape(TestSize), np.uint8); var result = np.mean(arr); Assert.AreEqual(1.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_ArgMax_ReturnsLongIndex() + [TestMethod] + public void NDArray_ArgMax_ReturnsLongIndex() { var arr = np.zeros(new Shape(TestSize), np.uint8); arr.SetByte((byte)255, TestSize - 100); @@ -129,8 +128,8 @@ public async Task NDArray_ArgMax_ReturnsLongIndex() Assert.AreEqual(TestSize - 100, result); } - [Test] - public async Task NDArray_ArgMin_ReturnsLongIndex() + [TestMethod] + public void NDArray_ArgMin_ReturnsLongIndex() { var arr = np.ones(new Shape(TestSize), np.uint8); arr.SetByte((byte)0, TestSize / 2); @@ -138,16 +137,16 @@ public async Task NDArray_ArgMin_ReturnsLongIndex() Assert.AreEqual(TestSize / 2, result); } - [Test] - public async Task NDArray_CountNonzero_ReturnsLongCount() + [TestMethod] + public void NDArray_CountNonzero_ReturnsLongCount() { var arr = np.ones(new Shape(TestSize), np.uint8); var count = np.count_nonzero(arr); Assert.AreEqual(TestSize, count); } - [Test] - public async Task NDArray_Slicing_WorksWithLargeIndices() + [TestMethod] + public void NDArray_Slicing_WorksWithLargeIndices() { var arr = np.full(new Shape(TestSize), (byte)99, np.uint8); long start = TestSize - 100; @@ -157,8 +156,8 @@ public async Task NDArray_Slicing_WorksWithLargeIndices() Assert.AreEqual(99, slice.GetByte(0)); } - [Test] - public async Task NDArray_BroadcastTo_WorksWithLongTarget() + [TestMethod] + public void NDArray_BroadcastTo_WorksWithLongTarget() { var scalar = np.full(new Shape(1L), (byte)77, np.uint8); var broadcast = np.broadcast_to(scalar, new Shape(TestSize)); @@ -167,8 +166,8 @@ public async Task NDArray_BroadcastTo_WorksWithLongTarget() Assert.AreEqual(77, broadcast.GetByte(TestSize - 1)); } - [Test] - public async Task NDArray_Add_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Add_WorksWithLargeArrays() { var a = np.ones(new Shape(TestSize), np.uint8); var b = np.ones(new Shape(TestSize), np.uint8); @@ -178,16 +177,16 @@ public async Task NDArray_Add_WorksWithLargeArrays() Assert.AreEqual(2, result.GetByte(TestSize - 1)); } - [Test] - public async Task NDArray_Cumsum_WorksWithLargeArray() + [TestMethod] + public void NDArray_Cumsum_WorksWithLargeArray() { var arr = np.ones(new Shape(TestSize), np.uint8); var result = np.cumsum(arr); Assert.AreEqual(TestSize, result.size); } - [Test] - public async Task NDArray_Roll_WorksWithLargeShift() + [TestMethod] + public void NDArray_Roll_WorksWithLargeShift() { var arr = np.zeros(new Shape(TestSize), np.uint8); arr.SetByte((byte)1, 0); @@ -196,8 +195,8 @@ public async Task NDArray_Roll_WorksWithLargeShift() Assert.AreEqual(1, result.GetByte(TestSize / 2)); } - [Test] - public async Task NDArray_Clip_WorksWithLargeArray() + [TestMethod] + public void NDArray_Clip_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), (byte)100, np.uint8); var result = np.clip(arr, 50, 75); @@ -205,8 +204,8 @@ public async Task NDArray_Clip_WorksWithLargeArray() Assert.AreEqual(75, result.GetByte(0)); } - [Test] - public async Task NDArray_BitwiseOps_WorkWithLargeArrays() + [TestMethod] + public void NDArray_BitwiseOps_WorkWithLargeArrays() { var a = np.full(new Shape(TestSize), (byte)0b11110000, np.uint8); var b = np.full(new Shape(TestSize), (byte)0b00001111, np.uint8); @@ -222,8 +221,8 @@ public async Task NDArray_BitwiseOps_WorkWithLargeArrays() Assert.AreEqual(255, xorResult.GetByte(0)); } - [Test] - public async Task NDArray_ExpandDims_WorksWithLargeArray() + [TestMethod] + public void NDArray_ExpandDims_WorksWithLargeArray() { var arr = np.zeros(new Shape(TestSize), np.uint8); var result = np.expand_dims(arr, 0); @@ -231,8 +230,8 @@ public async Task NDArray_ExpandDims_WorksWithLargeArray() Assert.AreEqual(2, result.ndim); } - [Test] - public async Task NDArray_Ravel_WorksWithLargeArray() + [TestMethod] + public void NDArray_Ravel_WorksWithLargeArray() { var arr = np.zeros(new Shape(1000L, 1000L), np.uint8); var result = np.ravel(arr); @@ -240,8 +239,8 @@ public async Task NDArray_Ravel_WorksWithLargeArray() Assert.AreEqual(1, result.ndim); } - [Test] - public async Task NDArray_Flatten_WorksWithLargeArray() + [TestMethod] + public void NDArray_Flatten_WorksWithLargeArray() { var arr = np.zeros(new Shape(1000L, 1000L), np.uint8); var result = arr.flatten(); @@ -249,16 +248,16 @@ public async Task NDArray_Flatten_WorksWithLargeArray() Assert.AreEqual(1, result.ndim); } - [Test] - public async Task NDArray_All_WorksWithLargeArray() + [TestMethod] + public void NDArray_All_WorksWithLargeArray() { var arr = np.ones(new Shape(TestSize), np.uint8); var result = np.all(arr); Assert.IsTrue(result); } - [Test] - public async Task NDArray_Any_WorksWithLargeArray() + [TestMethod] + public void NDArray_Any_WorksWithLargeArray() { var arr = np.zeros(new Shape(TestSize), np.uint8); arr.SetByte((byte)1, TestSize - 1); @@ -266,24 +265,24 @@ public async Task NDArray_Any_WorksWithLargeArray() Assert.IsTrue(result); } - [Test] - public async Task NDArray_Min_WorksWithLargeArray() + [TestMethod] + public void NDArray_Min_WorksWithLargeArray() { var arr = np.ones(new Shape(TestSize), np.uint8); var result = np.min(arr); Assert.AreEqual(1, result.GetByte(0)); } - [Test] - public async Task NDArray_Max_WorksWithLargeArray() + [TestMethod] + public void NDArray_Max_WorksWithLargeArray() { var arr = np.ones(new Shape(TestSize), np.uint8); var result = np.max(arr); Assert.AreEqual(1, result.GetByte(0)); } - [Test] - public async Task NDArray_Maximum_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Maximum_WorksWithLargeArrays() { var a = np.full(new Shape(TestSize), (byte)5, np.uint8); var b = np.full(new Shape(TestSize), (byte)10, np.uint8); @@ -291,8 +290,8 @@ public async Task NDArray_Maximum_WorksWithLargeArrays() Assert.AreEqual(10, result.GetByte(0)); } - [Test] - public async Task NDArray_Minimum_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Minimum_WorksWithLargeArrays() { var a = np.full(new Shape(TestSize), (byte)5, np.uint8); var b = np.full(new Shape(TestSize), (byte)10, np.uint8); @@ -300,40 +299,40 @@ public async Task NDArray_Minimum_WorksWithLargeArrays() Assert.AreEqual(5, result.GetByte(0)); } - [Test] - public async Task NDArray_LeftShift_WorksWithLargeArray() + [TestMethod] + public void NDArray_LeftShift_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), (byte)1, np.uint8); var result = np.left_shift(arr, 4); Assert.AreEqual(16, result.GetByte(0)); } - [Test] - public async Task NDArray_RightShift_WorksWithLargeArray() + [TestMethod] + public void NDArray_RightShift_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), (byte)16, np.uint8); var result = np.right_shift(arr, 4); Assert.AreEqual(1, result.GetByte(0)); } - [Test] - public async Task NDArray_Invert_WorksWithLargeArray() + [TestMethod] + public void NDArray_Invert_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), (byte)0b11110000, np.uint8); var result = np.invert(arr); Assert.AreEqual(0b00001111, result.GetByte(0)); } - [Test] - public async Task NDArray_Square_WorksWithLargeArray() + [TestMethod] + public void NDArray_Square_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), (byte)3, np.uint8); var result = np.square(arr); Assert.AreEqual(9, result.GetByte(0)); } - [Test] - public async Task NDArray_Multiply_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Multiply_WorksWithLargeArrays() { var a = np.full(new Shape(TestSize), (byte)3, np.uint8); var b = np.full(new Shape(TestSize), (byte)4, np.uint8); @@ -341,8 +340,8 @@ public async Task NDArray_Multiply_WorksWithLargeArrays() Assert.AreEqual(12, result.GetByte(0)); } - [Test] - public async Task NDArray_Subtract_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Subtract_WorksWithLargeArrays() { var a = np.full(new Shape(TestSize), (byte)10, np.uint8); var b = np.full(new Shape(TestSize), (byte)3, np.uint8); @@ -354,8 +353,8 @@ public async Task NDArray_Subtract_WorksWithLargeArrays() // UNARY MATH OPERATIONS // ================================================================ - [Test] - public async Task NDArray_Abs_WorksWithLargeArray() + [TestMethod] + public void NDArray_Abs_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), -5, np.int32); var result = np.abs(arr); @@ -363,8 +362,8 @@ public async Task NDArray_Abs_WorksWithLargeArray() Assert.AreEqual(5, result.GetInt32(0)); } - [Test] - public async Task NDArray_Absolute_WorksWithLargeArray() + [TestMethod] + public void NDArray_Absolute_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), -5, np.int32); var result = np.absolute(arr); @@ -372,8 +371,8 @@ public async Task NDArray_Absolute_WorksWithLargeArray() Assert.AreEqual(5, result.GetInt32(0)); } - [Test] - public async Task NDArray_Negative_WorksWithLargeArray() + [TestMethod] + public void NDArray_Negative_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 5, np.int32); var result = np.negative(arr); @@ -381,8 +380,8 @@ public async Task NDArray_Negative_WorksWithLargeArray() Assert.AreEqual(-5, result.GetInt32(0)); } - [Test] - public async Task NDArray_Positive_WorksWithLargeArray() + [TestMethod] + public void NDArray_Positive_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 5, np.int32); var result = np.positive(arr); @@ -390,8 +389,8 @@ public async Task NDArray_Positive_WorksWithLargeArray() Assert.AreEqual(5, result.GetInt32(0)); } - [Test] - public async Task NDArray_Sqrt_WorksWithLargeArray() + [TestMethod] + public void NDArray_Sqrt_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 16.0, np.float64); var result = np.sqrt(arr); @@ -399,8 +398,8 @@ public async Task NDArray_Sqrt_WorksWithLargeArray() Assert.AreEqual(4.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Cbrt_WorksWithLargeArray() + [TestMethod] + public void NDArray_Cbrt_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 27.0, np.float64); var result = np.cbrt(arr); @@ -408,8 +407,8 @@ public async Task NDArray_Cbrt_WorksWithLargeArray() Assert.AreEqual(3.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Reciprocal_WorksWithLargeArray() + [TestMethod] + public void NDArray_Reciprocal_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 4.0, np.float64); var result = np.reciprocal(arr); @@ -417,8 +416,8 @@ public async Task NDArray_Reciprocal_WorksWithLargeArray() Assert.AreEqual(0.25, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Floor_WorksWithLargeArray() + [TestMethod] + public void NDArray_Floor_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 3.7, np.float64); var result = np.floor(arr); @@ -426,8 +425,8 @@ public async Task NDArray_Floor_WorksWithLargeArray() Assert.AreEqual(3.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Ceil_WorksWithLargeArray() + [TestMethod] + public void NDArray_Ceil_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 3.7, np.float64); var result = np.ceil(arr); @@ -435,8 +434,9 @@ public async Task NDArray_Ceil_WorksWithLargeArray() Assert.AreEqual(4.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Trunc_WorksWithLargeArray() + [TestMethod] + [OpenBugs] // Vector512 SIMD: "Could not find Truncate for Vector512" on AVX-512 capable runners + public void NDArray_Trunc_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 3.7, np.float64); var result = np.trunc(arr); @@ -444,8 +444,8 @@ public async Task NDArray_Trunc_WorksWithLargeArray() Assert.AreEqual(3.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Sign_WorksWithLargeArray() + [TestMethod] + public void NDArray_Sign_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), -5, np.int32); var result = np.sign(arr); @@ -461,8 +461,8 @@ public async Task NDArray_Sign_WorksWithLargeArray() Assert.AreEqual(0, result.GetInt32(0)); } - [Test] - public async Task NDArray_Exp_WorksWithLargeArray() + [TestMethod] + public void NDArray_Exp_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 1.0, np.float64); var result = np.exp(arr); @@ -470,8 +470,8 @@ public async Task NDArray_Exp_WorksWithLargeArray() Assert.AreEqual(Math.E, result.GetDouble(0), 0.0001); } - [Test] - public async Task NDArray_Exp2_WorksWithLargeArray() + [TestMethod] + public void NDArray_Exp2_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 3.0, np.float64); var result = np.exp2(arr); @@ -479,8 +479,8 @@ public async Task NDArray_Exp2_WorksWithLargeArray() Assert.AreEqual(8.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Expm1_WorksWithLargeArray() + [TestMethod] + public void NDArray_Expm1_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 0.0, np.float64); var result = np.expm1(arr); @@ -488,8 +488,8 @@ public async Task NDArray_Expm1_WorksWithLargeArray() Assert.AreEqual(0.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Log_WorksWithLargeArray() + [TestMethod] + public void NDArray_Log_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), Math.E, np.float64); var result = np.log(arr); @@ -497,8 +497,8 @@ public async Task NDArray_Log_WorksWithLargeArray() Assert.AreEqual(1.0, result.GetDouble(0), 0.0001); } - [Test] - public async Task NDArray_Log10_WorksWithLargeArray() + [TestMethod] + public void NDArray_Log10_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 100.0, np.float64); var result = np.log10(arr); @@ -506,8 +506,8 @@ public async Task NDArray_Log10_WorksWithLargeArray() Assert.AreEqual(2.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Log1p_WorksWithLargeArray() + [TestMethod] + public void NDArray_Log1p_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 0.0, np.float64); var result = np.log1p(arr); @@ -515,8 +515,8 @@ public async Task NDArray_Log1p_WorksWithLargeArray() Assert.AreEqual(0.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Log2_WorksWithLargeArray() + [TestMethod] + public void NDArray_Log2_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 8.0, np.float64); var result = np.log2(arr); @@ -524,8 +524,8 @@ public async Task NDArray_Log2_WorksWithLargeArray() Assert.AreEqual(3.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Sin_WorksWithLargeArray() + [TestMethod] + public void NDArray_Sin_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 0.0, np.float64); var result = np.sin(arr); @@ -533,8 +533,8 @@ public async Task NDArray_Sin_WorksWithLargeArray() Assert.AreEqual(0.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Cos_WorksWithLargeArray() + [TestMethod] + public void NDArray_Cos_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 0.0, np.float64); var result = np.cos(arr); @@ -542,8 +542,8 @@ public async Task NDArray_Cos_WorksWithLargeArray() Assert.AreEqual(1.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Tan_WorksWithLargeArray() + [TestMethod] + public void NDArray_Tan_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 0.0, np.float64); var result = np.tan(arr); @@ -555,8 +555,8 @@ public async Task NDArray_Tan_WorksWithLargeArray() // BINARY MATH OPERATIONS // ================================================================ - [Test] - public async Task NDArray_Divide_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Divide_WorksWithLargeArrays() { var a = np.full(new Shape(TestSize), 10.0, np.float64); var b = np.full(new Shape(TestSize), 4.0, np.float64); @@ -565,8 +565,8 @@ public async Task NDArray_Divide_WorksWithLargeArrays() Assert.AreEqual(2.5, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_TrueDivide_WorksWithLargeArrays() + [TestMethod] + public void NDArray_TrueDivide_WorksWithLargeArrays() { var a = np.full(new Shape(TestSize), 10.0, np.float64); var b = np.full(new Shape(TestSize), 4.0, np.float64); @@ -575,8 +575,8 @@ public async Task NDArray_TrueDivide_WorksWithLargeArrays() Assert.AreEqual(2.5, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_FloorDivide_WorksWithLargeArrays() + [TestMethod] + public void NDArray_FloorDivide_WorksWithLargeArrays() { var a = np.full(new Shape(TestSize), 10.0, np.float64); var b = np.full(new Shape(TestSize), 4.0, np.float64); @@ -585,8 +585,8 @@ public async Task NDArray_FloorDivide_WorksWithLargeArrays() Assert.AreEqual(2.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Mod_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Mod_WorksWithLargeArrays() { var a = np.full(new Shape(TestSize), 10, np.int32); var b = np.full(new Shape(TestSize), 3, np.int32); @@ -595,8 +595,8 @@ public async Task NDArray_Mod_WorksWithLargeArrays() Assert.AreEqual(1, result.GetInt32(0)); } - [Test] - public async Task NDArray_Power_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Power_WorksWithLargeArrays() { var a = np.full(new Shape(TestSize), 2, np.int32); var b = np.full(new Shape(TestSize), 10, np.int32); @@ -605,8 +605,8 @@ public async Task NDArray_Power_WorksWithLargeArrays() Assert.AreEqual(1024, result.GetInt32(0)); } - [Test] - public async Task NDArray_Modf_WorksWithLargeArray() + [TestMethod] + public void NDArray_Modf_WorksWithLargeArray() { var arr = np.full(new Shape(TestSize), 3.5, np.float64); var (fractional, integer) = np.modf(arr); @@ -620,8 +620,8 @@ public async Task NDArray_Modf_WorksWithLargeArray() // ADDITIONAL REDUCTIONS // ================================================================ - [Test] - public async Task NDArray_Prod_WorksWithLargeArray() + [TestMethod] + public void NDArray_Prod_WorksWithLargeArray() { // Use small values to avoid overflow var arr = np.full(new Shape(10L), 2L, np.int64); @@ -630,8 +630,8 @@ public async Task NDArray_Prod_WorksWithLargeArray() Assert.AreEqual(1024L, result.GetInt64(0)); } - [Test] - public async Task NDArray_Std_WorksWithLargeArray() + [TestMethod] + public void NDArray_Std_WorksWithLargeArray() { var arr = np.array(new double[] { 1, 2, 3, 4, 5 }); var result = np.std(arr); @@ -639,8 +639,8 @@ public async Task NDArray_Std_WorksWithLargeArray() Assert.AreEqual(1.414214, result.GetDouble(0), 0.0001); } - [Test] - public async Task NDArray_Var_WorksWithLargeArray() + [TestMethod] + public void NDArray_Var_WorksWithLargeArray() { var arr = np.array(new double[] { 1, 2, 3, 4, 5 }); var result = np.var(arr); @@ -648,8 +648,8 @@ public async Task NDArray_Var_WorksWithLargeArray() Assert.AreEqual(2.0, result.GetDouble(0), 0.0001); } - [Test] - public async Task NDArray_Cumprod_WorksWithLargeArray() + [TestMethod] + public void NDArray_Cumprod_WorksWithLargeArray() { var arr = np.full(new Shape(5L), 2L, np.int64); var result = np.cumprod(arr); @@ -665,56 +665,56 @@ public async Task NDArray_Cumprod_WorksWithLargeArray() // NAN-AWARE FUNCTIONS // ================================================================ - [Test] - public async Task NDArray_Nansum_WorksWithLargeArray() + [TestMethod] + public void NDArray_Nansum_WorksWithLargeArray() { var arr = np.array(new double[] { 1.0, double.NaN, 3.0, double.NaN, 5.0 }); var result = np.nansum(arr); Assert.AreEqual(9.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Nanmean_WorksWithLargeArray() + [TestMethod] + public void NDArray_Nanmean_WorksWithLargeArray() { var arr = np.array(new double[] { 1.0, double.NaN, 3.0, double.NaN, 5.0 }); var result = np.nanmean(arr); Assert.AreEqual(3.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Nanmin_WorksWithLargeArray() + [TestMethod] + public void NDArray_Nanmin_WorksWithLargeArray() { var arr = np.array(new double[] { 1.0, double.NaN, 3.0, double.NaN, 5.0 }); var result = np.nanmin(arr); Assert.AreEqual(1.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Nanmax_WorksWithLargeArray() + [TestMethod] + public void NDArray_Nanmax_WorksWithLargeArray() { var arr = np.array(new double[] { 1.0, double.NaN, 3.0, double.NaN, 5.0 }); var result = np.nanmax(arr); Assert.AreEqual(5.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Nanprod_WorksWithLargeArray() + [TestMethod] + public void NDArray_Nanprod_WorksWithLargeArray() { var arr = np.array(new double[] { 1.0, double.NaN, 3.0, double.NaN, 5.0 }); var result = np.nanprod(arr); Assert.AreEqual(15.0, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Nanstd_WorksWithLargeArray() + [TestMethod] + public void NDArray_Nanstd_WorksWithLargeArray() { var arr = np.array(new double[] { 1.0, double.NaN, 3.0, double.NaN, 5.0 }); var result = np.nanstd(arr); Assert.AreEqual(1.632993, result.GetDouble(0), 0.0001); } - [Test] - public async Task NDArray_Nanvar_WorksWithLargeArray() + [TestMethod] + public void NDArray_Nanvar_WorksWithLargeArray() { var arr = np.array(new double[] { 1.0, double.NaN, 3.0, double.NaN, 5.0 }); var result = np.nanvar(arr); @@ -725,8 +725,8 @@ public async Task NDArray_Nanvar_WorksWithLargeArray() // COMPARISON & LOGIC // ================================================================ - [Test] - public async Task NDArray_Isnan_WorksWithLargeArray() + [TestMethod] + public void NDArray_Isnan_WorksWithLargeArray() { var arr = np.array(new double[] { 1.0, double.NaN, double.PositiveInfinity, double.NegativeInfinity, 0.0 }); var result = np.isnan(arr); @@ -738,9 +738,9 @@ public async Task NDArray_Isnan_WorksWithLargeArray() Assert.IsFalse(result.GetBoolean(4)); // 0.0 } - [Test] + [TestMethod] [OpenBugs] // isinf not implemented - returns null (Default.IsInf.cs) - public async Task NDArray_Isinf_WorksWithLargeArray() + public void NDArray_Isinf_WorksWithLargeArray() { var arr = np.array(new double[] { 1.0, double.NaN, double.PositiveInfinity, double.NegativeInfinity, 0.0 }); var result = np.isinf(arr); @@ -752,8 +752,8 @@ public async Task NDArray_Isinf_WorksWithLargeArray() Assert.IsFalse(result.GetBoolean(4)); // 0.0 } - [Test] - public async Task NDArray_Isfinite_WorksWithLargeArray() + [TestMethod] + public void NDArray_Isfinite_WorksWithLargeArray() { var arr = np.array(new double[] { 1.0, double.NaN, double.PositiveInfinity, double.NegativeInfinity, 0.0 }); var result = np.isfinite(arr); @@ -765,8 +765,8 @@ public async Task NDArray_Isfinite_WorksWithLargeArray() Assert.IsTrue(result.GetBoolean(4)); // 0.0 } - [Test] - public async Task NDArray_ArrayEqual_WorksWithLargeArrays() + [TestMethod] + public void NDArray_ArrayEqual_WorksWithLargeArrays() { var a = np.full(new Shape(TestSize), 1.0, np.float64); var b = np.full(new Shape(TestSize), 1.0, np.float64); @@ -776,16 +776,16 @@ public async Task NDArray_ArrayEqual_WorksWithLargeArrays() Assert.IsFalse(np.array_equal(a, b)); } - [Test] - public async Task NDArray_Allclose_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Allclose_WorksWithLargeArrays() { var a = np.array(new double[] { 1.0, 2.0, 3.0 }); var b = np.array(new double[] { 1.0, 2.0, 3.0000001 }); Assert.IsTrue(np.allclose(a, b)); } - [Test] - public async Task NDArray_Isclose_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Isclose_WorksWithLargeArrays() { var a = np.array(new double[] { 1.0, 2.0, 3.0 }); var b = np.array(new double[] { 1.0, 2.0, 3.0000001 }); @@ -800,8 +800,8 @@ public async Task NDArray_Isclose_WorksWithLargeArrays() // SHAPE MANIPULATION // ================================================================ - [Test] - public async Task NDArray_Concatenate_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Concatenate_WorksWithLargeArrays() { var a = np.full(new Shape(TestSize / 2), (byte)1, np.uint8); var b = np.full(new Shape(TestSize / 2), (byte)2, np.uint8); @@ -811,8 +811,8 @@ public async Task NDArray_Concatenate_WorksWithLargeArrays() Assert.AreEqual(2, result.GetByte(TestSize / 2)); } - [Test] - public async Task NDArray_Stack_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Stack_WorksWithLargeArrays() { var a = np.full(new Shape(1000L, 1000L), (byte)1, np.uint8); var b = np.full(new Shape(1000L, 1000L), (byte)2, np.uint8); @@ -822,8 +822,8 @@ public async Task NDArray_Stack_WorksWithLargeArrays() Assert.AreEqual(2, result.shape[0]); } - [Test] - public async Task NDArray_Hstack_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Hstack_WorksWithLargeArrays() { var a = np.full(new Shape(1000L, 500L), (byte)1, np.uint8); var b = np.full(new Shape(1000L, 500L), (byte)2, np.uint8); @@ -833,8 +833,8 @@ public async Task NDArray_Hstack_WorksWithLargeArrays() Assert.AreEqual(1000, result.shape[1]); } - [Test] - public async Task NDArray_Vstack_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Vstack_WorksWithLargeArrays() { var a = np.full(new Shape(500L, 1000L), (byte)1, np.uint8); var b = np.full(new Shape(500L, 1000L), (byte)2, np.uint8); @@ -844,8 +844,8 @@ public async Task NDArray_Vstack_WorksWithLargeArrays() Assert.AreEqual(1000, result.shape[1]); } - [Test] - public async Task NDArray_Dstack_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Dstack_WorksWithLargeArrays() { var a = np.full(new Shape(100L, 100L), (byte)1, np.uint8); var b = np.full(new Shape(100L, 100L), (byte)2, np.uint8); @@ -857,8 +857,8 @@ public async Task NDArray_Dstack_WorksWithLargeArrays() Assert.AreEqual(2, result.shape[2]); } - [Test] - public async Task NDArray_Moveaxis_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Moveaxis_WorksWithLargeArrays() { var arr = np.zeros(new Shape(100L, 200L, 300L), np.uint8); var result = np.moveaxis(arr, 0, -1); @@ -868,8 +868,8 @@ public async Task NDArray_Moveaxis_WorksWithLargeArrays() Assert.AreEqual(100, result.shape[2]); } - [Test] - public async Task NDArray_Rollaxis_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Rollaxis_WorksWithLargeArrays() { var arr = np.zeros(new Shape(100L, 200L, 300L), np.uint8); var result = np.rollaxis(arr, 2, 0); @@ -879,8 +879,8 @@ public async Task NDArray_Rollaxis_WorksWithLargeArrays() Assert.AreEqual(200, result.shape[2]); } - [Test] - public async Task NDArray_Repeat_WorksWithLargeArray() + [TestMethod] + public void NDArray_Repeat_WorksWithLargeArray() { var arr = np.array(new byte[] { 1, 2, 3 }); var result = np.repeat(arr, 2); @@ -895,8 +895,8 @@ public async Task NDArray_Repeat_WorksWithLargeArray() // SORTING & SEARCHING // ================================================================ - [Test] - public async Task NDArray_Argsort_WorksWithLargeArray() + [TestMethod] + public void NDArray_Argsort_WorksWithLargeArray() { var arr = np.array(new int[] { 3, 1, 4, 1, 5, 9, 2, 6 }); var result = np.argsort(arr); @@ -909,8 +909,8 @@ public async Task NDArray_Argsort_WorksWithLargeArray() Assert.AreEqual(0L, result.GetInt64(3)); // Index of 3 } - [Test] - public async Task NDArray_Nonzero_WorksWithLargeArray() + [TestMethod] + public void NDArray_Nonzero_WorksWithLargeArray() { var arr = np.array(new int[] { 0, 5, 0, 3, 0 }); var result = np.nonzero(arr); @@ -920,8 +920,8 @@ public async Task NDArray_Nonzero_WorksWithLargeArray() Assert.AreEqual(3, result[0].GetInt64(1)); // Index of 3 } - [Test] - public async Task NDArray_Searchsorted_WorksWithLargeArray() + [TestMethod] + public void NDArray_Searchsorted_WorksWithLargeArray() { var arr = np.array(new int[] { 1, 3, 5, 7, 9 }); var result = np.searchsorted(arr, 4); @@ -932,8 +932,8 @@ public async Task NDArray_Searchsorted_WorksWithLargeArray() // CREATION // ================================================================ - [Test] - public async Task NDArray_Eye_WorksWithLargeArray() + [TestMethod] + public void NDArray_Eye_WorksWithLargeArray() { var result = np.eye(1000); Assert.AreEqual(TestSize, result.size); @@ -943,8 +943,8 @@ public async Task NDArray_Eye_WorksWithLargeArray() Assert.AreEqual(1.0, result.GetDouble(1, 1)); } - [Test] - public async Task NDArray_Identity_WorksWithLargeArray() + [TestMethod] + public void NDArray_Identity_WorksWithLargeArray() { var result = np.identity(1000); Assert.AreEqual(TestSize, result.size); @@ -954,8 +954,8 @@ public async Task NDArray_Identity_WorksWithLargeArray() Assert.AreEqual(1.0, result.GetDouble(999, 999)); } - [Test] - public async Task NDArray_Array_WorksWithLargeArray() + [TestMethod] + public void NDArray_Array_WorksWithLargeArray() { var data = new byte[TestSize]; for (int i = 0; i < TestSize; i++) data[i] = (byte)(i % 256); @@ -969,8 +969,8 @@ public async Task NDArray_Array_WorksWithLargeArray() // OTHER // ================================================================ - [Test] - public async Task NDArray_Around_WorksWithLargeArray() + [TestMethod] + public void NDArray_Around_WorksWithLargeArray() { var arr = np.array(new double[] { 1.567, 2.345, 3.789 }); var result = np.around(arr, 1); @@ -980,8 +980,8 @@ public async Task NDArray_Around_WorksWithLargeArray() Assert.AreEqual(3.8, result.GetDouble(2), 0.001); } - [Test] - public async Task NDArray_Copyto_WorksWithLargeArray() + [TestMethod] + public void NDArray_Copyto_WorksWithLargeArray() { var dst = np.zeros(new Shape(TestSize), np.float64); var src = np.ones(new Shape(TestSize), np.float64); @@ -994,8 +994,8 @@ public async Task NDArray_Copyto_WorksWithLargeArray() // LINEAR ALGEBRA // ================================================================ - [Test] - public async Task NDArray_Dot_1D_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Dot_1D_WorksWithLargeArrays() { // dot product of two 1D vectors: sum of element-wise products var a = np.ones(new Shape(TestSize), np.float64); @@ -1005,8 +1005,8 @@ public async Task NDArray_Dot_1D_WorksWithLargeArrays() Assert.AreEqual((double)TestSize, result.GetDouble(0), 0.001); } - [Test] - public async Task NDArray_Dot_2D_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Dot_2D_WorksWithLargeArrays() { // Matrix multiplication: (100x100) @ (100x100) = (100x100) // Each element = sum of 100 ones = 100 @@ -1019,8 +1019,8 @@ public async Task NDArray_Dot_2D_WorksWithLargeArrays() Assert.AreEqual(100.0, result.GetDouble(0, 0), 0.001); } - [Test] - public async Task NDArray_Matmul_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Matmul_WorksWithLargeArrays() { // Matrix multiplication: (100x100) @ (100x100) = (100x100) var a = np.ones(new Shape(100L, 100L), np.float64); @@ -1032,8 +1032,8 @@ public async Task NDArray_Matmul_WorksWithLargeArrays() Assert.AreEqual(100.0, result.GetDouble(0, 0), 0.001); } - [Test] - public async Task NDArray_Outer_WorksWithLargeArrays() + [TestMethod] + public void NDArray_Outer_WorksWithLargeArrays() { // Outer product: (1000,) x (1000,) = (1000, 1000) // Each element = a[i] * b[j] = 2 * 3 = 6 diff --git a/test/NumSharp.UnitTest/Manipulation/NDArray.GetData.Test.cs b/test/NumSharp.UnitTest/Manipulation/NDArray.GetData.Test.cs index eb17c2684..27ec4afc0 100644 --- a/test/NumSharp.UnitTest/Manipulation/NDArray.GetData.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/NDArray.GetData.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class NDArrayGetData { - [Test] + [TestMethod] public void Case1_GetData_Nonslice() { var lhs = np.full(new Shape(3, 3), 5, NPTypeCode.Int32); @@ -21,7 +22,7 @@ public void Case1_GetData_Nonslice() new NDIterator(slice).Should().ContainInOrder(5, 5, 5); } - [Test] + [TestMethod] public void Case1_GetData_Slice() { var lhs = np.full(new Shape(3, 3, 3), 5, NPTypeCode.Int32); @@ -35,7 +36,7 @@ public void Case1_GetData_Slice() new NDIterator(slice).Should().ContainInOrder(5, 5, 5); } - [Test] + [TestMethod] public void Case1_GetData_Slice2() { var lhs = np.full(new Shape(6, 3, 3), 5, NPTypeCode.Int32); @@ -49,7 +50,7 @@ public void Case1_GetData_Slice2() new NDIterator(slice).Should().ContainInOrder(5, 5, 5); } - [Test] + [TestMethod] public void Case2_GetData_Scalar_Nonslice() { var lhs = np.full(new Shape(3, 3), 5, NPTypeCode.Int32); @@ -63,7 +64,7 @@ public void Case2_GetData_Scalar_Nonslice() new NDIterator(slice).Should().ContainInOrder(5); } - [Test] + [TestMethod] public void Case2_GetData_Scalar_Slice() { var lhs = np.full(new Shape(3, 3, 3), 5, NPTypeCode.Int32); @@ -79,7 +80,7 @@ public void Case2_GetData_Scalar_Slice() new NDIterator(slice).Should().ContainInOrder(5); } - [Test] + [TestMethod] public void Case2_GetData_Scalar_Slice2() { var lhs = np.full(new Shape(6, 3, 3), 5, NPTypeCode.Int32); @@ -94,7 +95,7 @@ public void Case2_GetData_Scalar_Slice2() new NDIterator(slice).Should().ContainInOrder(5); } - [Test] + [TestMethod] public void Case3_GetData_All_Slice2() { var lhs = np.full(new Shape(6, 3, 3), 5, NPTypeCode.Int32); @@ -109,7 +110,7 @@ public void Case3_GetData_All_Slice2() for (int i = 0; i < 3 * 3 * 3; i++, iter.HasNext()) iter.MoveNext().Should().Be(5); } - [Test] + [TestMethod] public void Case3_GetData_All() { var lhs = np.full(new Shape(6, 3, 3), 5, NPTypeCode.Int32); @@ -123,7 +124,7 @@ public void Case3_GetData_All() for (int i = 0; i < 6 * 3 * 3; i++, iter.HasNext()) iter.MoveNext().Should().Be(5); } - [Test] + [TestMethod] public void Case1_GetNDArrays_Axis0() { var a = np.full(new Shape(6, 3, 3), 5, NPTypeCode.Int32); @@ -133,7 +134,7 @@ public void Case1_GetNDArrays_Axis0() f.Shape.Should().Be((3, 3)); } - [Test] + [TestMethod] public void Case1_GetNDArrays_Axis1() { var a = np.full(new Shape(6, 3, 3), 5, NPTypeCode.Int32); @@ -143,7 +144,7 @@ public void Case1_GetNDArrays_Axis1() f.Shape.Should().Be(Shape.Vector(3)); } - [Test] + [TestMethod] public void Case1_GetNDArrays_Axis2() { var a = np.full(new Shape(6, 3, 3), 5, NPTypeCode.Int32); diff --git a/test/NumSharp.UnitTest/Manipulation/NDArray.SetData.Test.cs b/test/NumSharp.UnitTest/Manipulation/NDArray.SetData.Test.cs index 2714bd1ac..d58dc5e03 100644 --- a/test/NumSharp.UnitTest/Manipulation/NDArray.SetData.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/NDArray.SetData.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class NDArraySetData { - [Test] + [TestMethod] public void Case1_ND_Scalar() { var lhs = np.full(new Shape(3, 3), 5); @@ -23,7 +24,7 @@ public void Case1_ND_Scalar() lhs[0].flat.Cast().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case1_Scalar_Scalar() { var lhs = np.full(new Shape(3, 3), 5); @@ -38,7 +39,7 @@ public void Case1_Scalar_Scalar() ((int)lhs[0, 1]).Should().Be(1); } - [Test] + [TestMethod] public void Case1_ND_Scalar_ArraySlice() { var lhs = np.full(new Shape(3, 3), 5); @@ -51,7 +52,7 @@ public void Case1_ND_Scalar_ArraySlice() lhs[0].flat.Cast().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case1_Scalar_Scalar_ArraySlice() { var lhs = np.full(new Shape(3, 3), 5); @@ -64,7 +65,7 @@ public void Case1_Scalar_Scalar_ArraySlice() ((int)lhs[0, 1]).Should().Be(1); } - [Test] + [TestMethod] public void Case1_ND_ND() { var lhs = np.full(new Shape(2, 1, 3, 3), 5); @@ -81,7 +82,7 @@ public void Case1_ND_ND() } - [Test] + [TestMethod] public void Case1_ND_ND_ArraySlice() { var lhs = np.full(new Shape(2, 1, 3, 3), 5); @@ -95,7 +96,7 @@ public void Case1_ND_ND_ArraySlice() lhs[0].flat.Cast().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case2_ND_ScalaryND() { var lhs = np.full(new Shape(2, 1, 3, 3), 5); @@ -111,7 +112,7 @@ public void Case2_ND_ScalaryND() lhs[0].flat.Cast().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case2_ND_ScalaryND_ArraySlice() { var lhs = np.full(new Shape(2, 1, 3, 3), 5); @@ -125,7 +126,7 @@ public void Case2_ND_ScalaryND_ArraySlice() lhs[0].flat.Cast().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case1_ND_Scalar_Sliced() { var lhs = np.full(new Shape(3, 3), 5); @@ -143,7 +144,7 @@ public void Case1_ND_Scalar_Sliced() lhs[0].flat.Cast().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case1_Scalar_Scalar_Sliced() { var lhs = np.full(new Shape(3, 3), 5); @@ -161,7 +162,7 @@ public void Case1_Scalar_Scalar_Sliced() ((int)lhs[0, 1]).Should().Be(1); } - [Test] + [TestMethod] public void Case1_ND_ND_Sliced() { var lhs = np.full(new Shape(2, 1, 3, 3), 5); @@ -186,7 +187,7 @@ public void Case1_ND_ND_Sliced() slicedlhs[0].flat.Cast().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case2_ND_ScalaryND_Sliced() { var lhs = np.full(new Shape(2, 1, 3, 3), 5); @@ -206,7 +207,7 @@ public void Case2_ND_ScalaryND_Sliced() //--------------- - [Test] + [TestMethod] public void Case1_ND_Scalar_Cast() { var lhs = np.full(new Shape(3, 3), 5d); @@ -221,7 +222,7 @@ public void Case1_ND_Scalar_Cast() lhs[0].flat.Cast().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case1_Scalar_Scalar_Cast() { var lhs = np.full(new Shape(3, 3), 5d); @@ -236,7 +237,7 @@ public void Case1_Scalar_Scalar_Cast() ((double)lhs[0, 1]).Should().Be(1); } - [Test] + [TestMethod] public void Case1_ND_ND_Cast() { var lhs = np.full(new Shape(2, 1, 3, 3), 5d); @@ -251,7 +252,7 @@ public void Case1_ND_ND_Cast() lhs[0].Should().AllValuesBe(1); } - [Test] + [TestMethod] public void Case2_ND_ScalaryND_Cast() { var lhs = np.full(new Shape(2, 1, 3, 3), 5d); @@ -267,7 +268,7 @@ public void Case2_ND_ScalaryND_Cast() lhs[0].flat.Cast().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case1_ND_Scalar_Sliced_Cast() { var lhs = np.full(new Shape(3, 3), 5d); @@ -285,7 +286,7 @@ public void Case1_ND_Scalar_Sliced_Cast() lhs[0].flat.Cast().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case1_Scalar_Scalar_Sliced_Cast() { var lhs = np.full(new Shape(3, 3), 5d); @@ -303,7 +304,7 @@ public void Case1_Scalar_Scalar_Sliced_Cast() ((double)lhs[0, 1]).Should().Be(1); } - [Test] + [TestMethod] public void Case1_ND_ND_Sliced_Cast() { var lhs = np.full(new Shape(2, 1, 3, 3), 5d); @@ -328,7 +329,7 @@ public void Case1_ND_ND_Sliced_Cast() slicedlhs[0].flat.Cast().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case2_ND_ScalaryND_Sliced_Cast() { var lhs = np.full(new Shape(2, 1, 3, 3), 5d); diff --git a/test/NumSharp.UnitTest/Manipulation/NDArray.ToString.Test.cs b/test/NumSharp.UnitTest/Manipulation/NDArray.ToString.Test.cs index 1b9bb6a5e..bf7a6e39b 100644 --- a/test/NumSharp.UnitTest/Manipulation/NDArray.ToString.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/NDArray.ToString.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class NdArrayToStringTest : TestClass { - [Test] + [TestMethod] public void ReShape() { var nd = np.arange(6); diff --git a/test/NumSharp.UnitTest/Manipulation/NDArray.astype.Test.cs b/test/NumSharp.UnitTest/Manipulation/NDArray.astype.Test.cs index 699512ac1..0c9af14d5 100644 --- a/test/NumSharp.UnitTest/Manipulation/NDArray.astype.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/NDArray.astype.Test.cs @@ -5,9 +5,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class astypeTests { - [Test] + [TestMethod] public void Upcasting() { var nd = np.ones(new Shape(3, 3), np.int32); @@ -21,7 +22,7 @@ public void Upcasting() int64.GetTypeCode.Should().Be(NPTypeCode.Int64); } - [Test] + [TestMethod] public void UpcastingByteToLong() { var nd = np.ones(new Shape(3, 3), np.uint8); @@ -35,7 +36,7 @@ public void UpcastingByteToLong() int64.GetTypeCode.Should().Be(NPTypeCode.Int64); } - [Test] + [TestMethod] public void UpcastingCharsToLong() { var nd = np.ones(new Shape(3, 3), np.@char); @@ -49,7 +50,7 @@ public void UpcastingCharsToLong() int64.GetTypeCode.Should().Be(NPTypeCode.Int64); } - [Test] + [TestMethod] public void DowncastingIntToShort() { var nd = np.ones(new Shape(3, 3), np.int32); @@ -63,7 +64,7 @@ public void DowncastingIntToShort() int16.GetTypeCode.Should().Be(NPTypeCode.Int16); } - [Test] + [TestMethod] public void DowncastingDoubleToInt() { var nd = np.ones(new Shape(3, 3), np.float64); @@ -87,7 +88,7 @@ public void DowncastingDoubleToInt() } } - [Test] + [TestMethod] public void DowncastingIntToUShort() { var nd = np.ones(new Shape(3, 3), np.int32); @@ -102,7 +103,7 @@ public void DowncastingIntToUShort() int16.GetTypeCode.Should().Be(NPTypeCode.UInt16); } - [Test] + [TestMethod] public void CastEmptyNDArray() { var nd = new NDArray(NPTypeCode.Int32); @@ -111,7 +112,7 @@ public void CastEmptyNDArray() int16_copied.Shape.IsEmpty.Should().BeTrue(); } - [Test, Skip("String dtype is not supported")] + [TestMethod, Ignore("String dtype is not supported")] public void CastingStringToByte() { throw new NotSupportedException(); @@ -127,7 +128,7 @@ public void CastingStringToByte() //output.Array.GetType().GetElementType().Should().Be(); } - [Test, Skip("String dtype is not supported")] + [TestMethod, Ignore("String dtype is not supported")] public void CastingByteToString() { throw new NotSupportedException(); @@ -146,7 +147,7 @@ public void CastingByteToString() } - [Test, Skip("Complex dtype is not supported yet")] //TODO! + [TestMethod, Ignore("Complex dtype is not supported yet")] //TODO! public void CastingIntToComplex() { //var nd = np.ones(new Shape(3, 3), np.int32); diff --git a/test/NumSharp.UnitTest/Manipulation/NDArray.astype.Truncation.Test.cs b/test/NumSharp.UnitTest/Manipulation/NDArray.astype.Truncation.Test.cs index a55f8453b..317bacdb4 100644 --- a/test/NumSharp.UnitTest/Manipulation/NDArray.astype.Truncation.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/NDArray.astype.Truncation.Test.cs @@ -2,7 +2,6 @@ using AwesomeAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.Backends; -using TUnit.Core; namespace NumSharp.UnitTest.Manipulation { @@ -19,13 +18,14 @@ namespace NumSharp.UnitTest.Manipulation /// Fixed in commit 40a5c831 - changed Converts.Native.cs to use C# cast /// truncation instead of Convert.ToInt32. /// + [TestClass] public class astypeTruncationTests { // ================================================================ // BASIC TRUNCATION TESTS // ================================================================ - [Test] + [TestMethod] public void Float64_ToInt32_PositiveFractions_TruncateTowardZero() { // NumPy: np.array([2.1, 2.5, 2.9]).astype(np.int32) -> [2, 2, 2] @@ -38,7 +38,7 @@ public void Float64_ToInt32_PositiveFractions_TruncateTowardZero() result.GetAtIndex(2).Should().Be(2, "2.9 should truncate to 2"); } - [Test] + [TestMethod] public void Float64_ToInt32_NegativeFractions_TruncateTowardZero() { // NumPy: np.array([-2.1, -2.5, -2.9]).astype(np.int32) -> [-2, -2, -2] @@ -52,7 +52,7 @@ public void Float64_ToInt32_NegativeFractions_TruncateTowardZero() result.GetAtIndex(2).Should().Be(-2, "-2.9 should truncate to -2 (NOT -3)"); } - [Test] + [TestMethod] public void Float32_ToInt32_TruncateTowardZero() { // Same behavior for float32 @@ -72,7 +72,7 @@ public void Float32_ToInt32_TruncateTowardZero() // would give different results than truncation // ================================================================ - [Test] + [TestMethod] public void Float64_ToInt32_BankersRoundingEdgeCases() { // Banker's rounding would round these to even: @@ -88,7 +88,7 @@ public void Float64_ToInt32_BankersRoundingEdgeCases() result.GetAtIndex(4).Should().Be(4, "4.5 truncates to 4"); } - [Test] + [TestMethod] public void Float64_ToInt32_NegativeBankersRoundingEdgeCases() { // Banker's rounding for negatives: @@ -108,7 +108,7 @@ public void Float64_ToInt32_NegativeBankersRoundingEdgeCases() // VERY SMALL VALUES // ================================================================ - [Test] + [TestMethod] public void Float64_ToInt32_VerySmallPositive_TruncateToZero() { var arr = np.array(new double[] { 0.0001, 0.1, 0.9, 0.99999 }); @@ -120,7 +120,7 @@ public void Float64_ToInt32_VerySmallPositive_TruncateToZero() result.GetAtIndex(3).Should().Be(0, "0.99999 truncates to 0"); } - [Test] + [TestMethod] public void Float64_ToInt32_VerySmallNegative_TruncateToZero() { var arr = np.array(new double[] { -0.0001, -0.1, -0.9, -0.99999 }); @@ -136,7 +136,7 @@ public void Float64_ToInt32_VerySmallNegative_TruncateToZero() // TYPE BOUNDARY VALUES // ================================================================ - [Test] + [TestMethod] public void Float64_ToInt32_AtBoundaries() { // Values just inside Int32 range @@ -154,7 +154,7 @@ public void Float64_ToInt32_AtBoundaries() result.GetAtIndex(3).Should().Be(-2147483647, "-2147483647.9 truncates to -2147483647"); } - [Test] + [TestMethod] public void Float64_ToInt64_AtBoundaries() { // Int64 has a larger range @@ -172,7 +172,7 @@ public void Float64_ToInt64_AtBoundaries() result.GetAtIndex(2).Should().Be(9007199254740991L); } - [Test] + [TestMethod] public void Float64_ToByte_AtBoundaries() { var arr = np.array(new double[] { 0.9, 254.9, 127.5, 255.0 }); @@ -185,7 +185,7 @@ public void Float64_ToByte_AtBoundaries() result.GetAtIndex(3).Should().Be(255, "255.0 stays 255"); } - [Test] + [TestMethod] public void Float64_ToInt16_AtBoundaries() { var arr = np.array(new double[] { @@ -207,7 +207,7 @@ public void Float64_ToInt16_AtBoundaries() // OVERFLOW BEHAVIOR // ================================================================ - [Test] + [TestMethod] public void Float64_ToInt32_Overflow_ThrowsException() { var arr = np.array(new double[] { (double)int.MaxValue + 1000 }); @@ -218,7 +218,7 @@ public void Float64_ToInt32_Overflow_ThrowsException() "Converting value > int.MaxValue should throw OverflowException"); } - [Test] + [TestMethod] public void Float64_ToInt32_Underflow_ThrowsException() { var arr = np.array(new double[] { (double)int.MinValue - 1000 }); @@ -235,7 +235,7 @@ public void Float64_ToInt32_Underflow_ThrowsException() // and raises a warning. NumSharp should throw or have defined behavior. // ================================================================ - [Test] + [TestMethod] public void Float64_ToInt32_NaN_ThrowsOrReturnsZero() { // NumPy: RuntimeWarning and returns -2147483648 (or platform dependent) @@ -259,7 +259,7 @@ public void Float64_ToInt32_NaN_ThrowsOrReturnsZero() } } - [Test] + [TestMethod] public void Float64_ToInt32_PositiveInfinity_Throws() { var arr = np.array(new double[] { double.PositiveInfinity }); @@ -271,7 +271,7 @@ public void Float64_ToInt32_PositiveInfinity_Throws() "Converting +Infinity should throw OverflowException"); } - [Test] + [TestMethod] public void Float64_ToInt32_NegativeInfinity_Throws() { var arr = np.array(new double[] { double.NegativeInfinity }); @@ -288,7 +288,7 @@ public void Float64_ToInt32_NegativeInfinity_Throws() // Verify truncation works for all float->int conversion paths // ================================================================ - [Test] + [TestMethod] public void Float64_ToAllIntTypes_Truncation() { var arr = np.array(new double[] { 2.9, -2.9 }); @@ -334,7 +334,7 @@ public void Float64_ToAllIntTypes_Truncation() toUInt64.GetAtIndex(1).Should().Be(1000); } - [Test] + [TestMethod] public void Float32_ToAllIntTypes_Truncation() { var arr = np.array(new float[] { 2.9f, -2.9f }); @@ -359,7 +359,7 @@ public void Float32_ToAllIntTypes_Truncation() // MULTI-DIMENSIONAL ARRAYS // ================================================================ - [Test] + [TestMethod] public void Float64_ToInt32_2DArray_TruncatesAllElements() { var arr = np.array(new double[,] { @@ -382,7 +382,7 @@ public void Float64_ToInt32_2DArray_TruncatesAllElements() result[1, 2].GetInt32().Should().Be(-3); } - [Test] + [TestMethod] public void Float64_ToInt32_3DArray_TruncatesAllElements() { var arr = np.arange(24).astype(np.float64).reshape(2, 3, 4); @@ -402,7 +402,7 @@ public void Float64_ToInt32_3DArray_TruncatesAllElements() // SLICED/VIEW ARRAYS // ================================================================ - [Test] + [TestMethod] public void Float64_ToInt32_SlicedArray_TruncatesCorrectly() { var arr = np.array(new double[] { 0.9, 1.9, 2.9, 3.9, 4.9, 5.9 }); @@ -417,7 +417,7 @@ public void Float64_ToInt32_SlicedArray_TruncatesCorrectly() result.GetAtIndex(3).Should().Be(4); } - [Test] + [TestMethod] public void Float64_ToInt32_SteppedSlice_TruncatesCorrectly() { var arr = np.array(new double[] { 0.9, 1.9, 2.9, 3.9, 4.9, 5.9 }); @@ -435,7 +435,7 @@ public void Float64_ToInt32_SteppedSlice_TruncatesCorrectly() // COPY PARAMETER // ================================================================ - [Test] + [TestMethod] public void Float64_ToInt32_WithCopy_CreatesNewArray() { var arr = np.array(new double[] { 2.9, -2.9 }); @@ -450,7 +450,7 @@ public void Float64_ToInt32_WithCopy_CreatesNewArray() // MIXED VALUES // ================================================================ - [Test] + [TestMethod] public void Float64_ToInt32_MixedValues_AllTruncateCorrectly() { // NumPy reference: @@ -472,7 +472,7 @@ public void Float64_ToInt32_MixedValues_AllTruncateCorrectly() // DECIMAL TO INT (should also truncate) // ================================================================ - [Test] + [TestMethod] public void Decimal_ToInt32_Truncation() { var arr = np.array(new decimal[] { 2.9m, -2.9m, 1.5m, -1.5m }); @@ -488,7 +488,7 @@ public void Decimal_ToInt32_Truncation() // EXACT INTEGER VALUES (no truncation needed) // ================================================================ - [Test] + [TestMethod] public void Float64_ToInt32_ExactIntegers_PreservedExactly() { var arr = np.array(new double[] { 0.0, 1.0, -1.0, 100.0, -100.0, diff --git a/test/NumSharp.UnitTest/Manipulation/NDArray.flat.Test.cs b/test/NumSharp.UnitTest/Manipulation/NDArray.flat.Test.cs index 0b781c201..e684243af 100644 --- a/test/NumSharp.UnitTest/Manipulation/NDArray.flat.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/NDArray.flat.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class NDArray_flat_Test { - [Test] + [TestMethod] public void flat_3_3() { var nd = np.full(new Shape(3, 3), 5, NPTypeCode.Int32); @@ -21,7 +22,7 @@ public void flat_3_3() flat.Cast().Should().AllBeEquivalentTo(5); } - [Test] + [TestMethod] public void flat_3_3_sliced() { var nd = np.full(new Shape(3, 3), 5, NPTypeCode.Int32); @@ -34,7 +35,7 @@ public void flat_3_3_sliced() flat.Cast().Should().AllBeEquivalentTo(5); } - [Test] + [TestMethod] public void flat_scalar_sliced() { var nd = NDArray.Scalar(1); @@ -46,7 +47,7 @@ public void flat_scalar_sliced() flat.item().Should().Be(1); } - [Test] + [TestMethod] public void flat_1_3_1_3() { var nd = np.full(new Shape(1, 3, 1, 3), 5, NPTypeCode.Int32); @@ -58,7 +59,7 @@ public void flat_1_3_1_3() flat.Cast().Should().AllBeEquivalentTo(5); } - [Test] + [TestMethod] public void flat_2_3_1_3_sliced() { var nd = np.full(new Shape(2, 3, 1, 3), 5, NPTypeCode.Int32); @@ -71,7 +72,7 @@ public void flat_2_3_1_3_sliced() flat.Cast().Should().AllBeEquivalentTo(5); } - [Test] + [TestMethod] public void flat_3() { var nd = np.full(Shape.Vector(3), 5, NPTypeCode.Int32); @@ -83,7 +84,7 @@ public void flat_3() flat.Cast().Should().AllBeEquivalentTo(5); } - [Test] + [TestMethod] public void flat_scalar() { var nd = NDArray.Scalar(1); @@ -95,7 +96,7 @@ public void flat_scalar() flat.item().Should().Be(1); } - [Test] + [TestMethod] public void flat_broadcasted_Case1() { var a = np.arange(4 * 1 * 1 * 1).reshape(4, 1, 1, 1)["3, :"]; @@ -111,7 +112,7 @@ public void flat_broadcasted_Case1() b.flat.Should().BeShaped(10).And.BeOfValues(30, 31, 32, 33, 34, 35, 36, 37, 38, 39); } - [Test] + [TestMethod] public void flat_broadcasted_Case2() { var a = np.arange(2 * 1 * 3).reshape((2, 1, 3)); //0, 1 @@ -130,7 +131,7 @@ public void flat_broadcasted_Case2() bflat.Should().BeOfValues(9, 10, 11, 12, 13, 14, 15, 16, 17).And.BeShaped(3 * 3); } - [Test] + [TestMethod] public void flat_broadcasted_Case3() { var a = np.arange(3 * 1 * 3 * 3).reshape((3, 1, 3, 3)); //0, 1 diff --git a/test/NumSharp.UnitTest/Manipulation/NDArray.ravel.Test.cs b/test/NumSharp.UnitTest/Manipulation/NDArray.ravel.Test.cs index c50f4a4e8..2e28e60f9 100644 --- a/test/NumSharp.UnitTest/Manipulation/NDArray.ravel.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/NDArray.ravel.Test.cs @@ -3,9 +3,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class RavelTest { - [Test] + [TestMethod] public void Simple2DArray() { var nd1 = np.array(new int[][] {new int[] {3, 1, 1, 2}, new int[] {3, 1, 1, 2}}); diff --git a/test/NumSharp.UnitTest/Manipulation/NDArray.unique.Test.cs b/test/NumSharp.UnitTest/Manipulation/NDArray.unique.Test.cs index 0be997cd2..25b6c3d37 100644 --- a/test/NumSharp.UnitTest/Manipulation/NDArray.unique.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/NDArray.unique.Test.cs @@ -7,23 +7,24 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class NDArray_unique_Test : TestClass { - [Test] + [TestMethod] public void Case1() { arange(10).unique() .Should().BeShaped(10).And.BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); } - [Test] + [TestMethod] public void Case2() { np.repeat(arange(10), 10).reshape(10,10).unique() .Should().BeShaped(10).And.BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); } - [Test] + [TestMethod] public void Case2_Sliced() { var arr = np.repeat(arange(10), 10).reshape(10, 10)[":, 0"]; @@ -33,7 +34,7 @@ public void Case2_Sliced() Console.WriteLine((string)arr.unique()); } - [Test] + [TestMethod] public void Unique_ReturnsSorted_UnsortedInput() { // NumPy always returns sorted unique values @@ -43,7 +44,7 @@ public void Unique_ReturnsSorted_UnsortedInput() arr.unique().Should().BeShaped(5).And.BeOfValues(1, 2, 5, 8, 9); } - [Test] + [TestMethod] public void Unique_ReturnsSorted_FloatInput() { // Test with floats @@ -51,7 +52,7 @@ public void Unique_ReturnsSorted_FloatInput() arr.unique().Should().BeShaped(3).And.BeOfValues(1.41, 2.71, 3.14); } - [Test] + [TestMethod] public void Unique_ReturnsSorted_NegativeValues() { // Test with negative values diff --git a/test/NumSharp.UnitTest/Manipulation/NdArray.ReShape.Test.cs b/test/NumSharp.UnitTest/Manipulation/NdArray.ReShape.Test.cs index 774ee6b89..49549df4e 100644 --- a/test/NumSharp.UnitTest/Manipulation/NdArray.ReShape.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/NdArray.ReShape.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class NdArrayReShapeTest { - [Test] + [TestMethod] public void ReShape() { var nd = np.arange(6); @@ -43,7 +44,7 @@ public void ReShape() /// It simply means that it is an unknown dimension and we want numpy to figure it out. /// And numpy will figure this by looking at the 'length of the array and remaining dimensions' and making sure it satisfies the above mentioned criteria /// - [Test] + [TestMethod] public void ReshapeNegative() { NDArray nd; @@ -83,7 +84,7 @@ public void ReshapeNegative() Assert.IsTrue(np.shape[1] == 3);*/ } - [Test] + [TestMethod] public void ValueTest() { var x = np.arange(4).MakeGeneric(); @@ -92,21 +93,21 @@ public void ValueTest() Assert.AreEqual(x[1], y[0, 1]); } - [Test] + [TestMethod] public void TwoNegativeMinusOne() { var x = np.arange(9).reshape(3, 1, 1, 3); new Action(() => x.reshape(-1, 3, -1)).Should().Throw(); } - [Test] + [TestMethod] public void Case1_negativeone() { var x = np.full((3, 3, 1, 1, 3), 2); x.reshape((-1, 3)).shape.Should().BeEquivalentTo(new long[] { 9, 3 }); } - [Test] + [TestMethod] public void Case2_Slice() { var a = arange((3, 2, 2)); @@ -118,7 +119,7 @@ public void Case2_Slice() a[0, 2].Should().BeScalar(2); } - [Test, Skip("Broadcasting and then using -1 during resahping is not supported (has TODO).")] + [TestMethod, Ignore("Broadcasting and then using -1 during resahping is not supported (has TODO).")] public void Case2_Slice_Broadcast() { //alloc @@ -139,7 +140,7 @@ public void Case2_Slice_Broadcast() a.Should().BeShaped(1, 8); } - [Test] + [TestMethod] public void Case3_Slice_Broadcast() { //alloc @@ -162,7 +163,7 @@ public void Case3_Slice_Broadcast() resh.Should().BeShaped(1, 4).And.BeOfValues(0, 1, 2, 3); } - [Test] + [TestMethod] public void Case4_Slice_Broadcast() { //alloc @@ -184,7 +185,7 @@ public void Case4_Slice_Broadcast() resh.Should().BeShaped(1, 4).And.BeOfValues(4, 5, 6, 7); } - [Test] + [TestMethod] public void Case5_Slice_Broadcast() { //alloc diff --git a/test/NumSharp.UnitTest/Manipulation/ReshapeScalarTests.cs b/test/NumSharp.UnitTest/Manipulation/ReshapeScalarTests.cs index 600c00c14..6ebe60253 100644 --- a/test/NumSharp.UnitTest/Manipulation/ReshapeScalarTests.cs +++ b/test/NumSharp.UnitTest/Manipulation/ReshapeScalarTests.cs @@ -7,6 +7,7 @@ namespace NumSharp.UnitTest /// /// Tests for reshaping to scalar shape. /// + [TestClass] public class ReshapeScalarTests { /// @@ -16,7 +17,7 @@ public class ReshapeScalarTests /// Fixed: Works correctly /// Was: NullReferenceException /// - [Test] + [TestMethod] public void Reshape_ToScalarShape_SingleElement_Works() { var a = np.array(new int[] { 42 }); // shape (1,) @@ -33,7 +34,7 @@ public void Reshape_ToScalarShape_SingleElement_Works() /// /// Test reshaping from 2D single-element to scalar. /// - [Test] + [TestMethod] public void Reshape_FromMultiDim_ToScalar_Works() { var a = np.array(new int[,] { { 99 } }); // shape (1, 1) @@ -48,7 +49,7 @@ public void Reshape_FromMultiDim_ToScalar_Works() /// /// Test that reshaping non-single-element array to scalar throws. /// - [Test] + [TestMethod] public void Reshape_MultiElement_ToScalar_Throws() { var a = np.array(new int[] { 1, 2, 3 }); // size 3 diff --git a/test/NumSharp.UnitTest/Manipulation/TolistTests.cs b/test/NumSharp.UnitTest/Manipulation/TolistTests.cs index ca880a15b..4ce9c0f57 100644 --- a/test/NumSharp.UnitTest/Manipulation/TolistTests.cs +++ b/test/NumSharp.UnitTest/Manipulation/TolistTests.cs @@ -2,18 +2,18 @@ using System.Collections.Generic; using System.Linq; using AwesomeAssertions; -using TUnit.Core; namespace NumSharp.UnitTest.Manipulation { /// /// Battle tests for NDArray.tolist() - NumPy parity verification. /// + [TestClass] public class TolistTests { #region Basic Functionality - [Test] + [TestMethod] public void Tolist_Scalar_ReturnsScalarValue() { // NumPy: np.array(42).tolist() -> 42 @@ -23,7 +23,7 @@ public void Tolist_Scalar_ReturnsScalarValue() result.Should().Be(42L); // arange returns int64 } - [Test] + [TestMethod] public void Tolist_1D_ReturnsFlatList() { // NumPy: np.array([1, 2, 3, 4, 5]).tolist() -> [1, 2, 3, 4, 5] @@ -35,7 +35,7 @@ public void Tolist_1D_ReturnsFlatList() result[4].Should().Be(5); } - [Test] + [TestMethod] public void Tolist_2D_ReturnsNestedList() { // NumPy: np.arange(6).reshape(2, 3).tolist() -> [[0, 1, 2], [3, 4, 5]] @@ -57,7 +57,7 @@ public void Tolist_2D_ReturnsNestedList() row1[2].Should().Be(5L); } - [Test] + [TestMethod] public void Tolist_3D_ReturnsTriplyNestedList() { // NumPy: np.arange(24).reshape(2, 3, 4).tolist() @@ -79,7 +79,7 @@ public void Tolist_3D_ReturnsTriplyNestedList() #region Dtype Preservation - [Test] + [TestMethod] public void Tolist_Int32_PreservesType() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -88,7 +88,7 @@ public void Tolist_Int32_PreservesType() result[0].Should().BeOfType(); } - [Test] + [TestMethod] public void Tolist_Float64_PreservesType() { var arr = np.array(new double[] { 1.5, 2.5, 3.5 }); @@ -98,7 +98,7 @@ public void Tolist_Float64_PreservesType() result[0].Should().Be(1.5); } - [Test] + [TestMethod] public void Tolist_Bool_PreservesType() { var arr = np.array(new bool[] { true, false, true }); @@ -113,7 +113,7 @@ public void Tolist_Bool_PreservesType() #region Edge Cases - [Test] + [TestMethod] public void Tolist_SingleElement1D_ReturnsSingleElementList() { var arr = np.array(new int[] { 42 }); @@ -123,7 +123,7 @@ public void Tolist_SingleElement1D_ReturnsSingleElementList() result[0].Should().Be(42); } - [Test] + [TestMethod] public void Tolist_SlicedArray_WorksCorrectly() { // Test that sliced arrays produce correct nested lists @@ -142,7 +142,7 @@ public void Tolist_SlicedArray_WorksCorrectly() row1[1].Should().Be(10L); } - [Test] + [TestMethod] public void Tolist_TransposedArray_WorksCorrectly() { // NumPy: np.arange(6).reshape(2, 3).T.tolist() diff --git a/test/NumSharp.UnitTest/Manipulation/np.atleast.nd.cs b/test/NumSharp.UnitTest/Manipulation/np.atleast.nd.cs index e3e8310bc..71f88f348 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.atleast.nd.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.atleast.nd.cs @@ -3,9 +3,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class np_atleast_tests { - [Test] + [TestMethod] public void alteast_3d() { var a = np.atleast_3d(3.0); @@ -25,7 +26,7 @@ public void alteast_3d() a.Shape.Should().BeEquivalentTo(new Shape(4, 3, 1)); } - [Test] + [TestMethod] public void alteast_2d() { var a = np.atleast_2d(3.0); @@ -41,7 +42,7 @@ public void alteast_2d() a.Shape.Should().BeEquivalentTo(new Shape(1, 3)); } - [Test] + [TestMethod] public void alteast_1d() { var a = np.atleast_1d(3.0); diff --git a/test/NumSharp.UnitTest/Manipulation/np.dstack.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.dstack.Test.cs index 4c5ab30dd..e5888be20 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.dstack.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.dstack.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.Manipulation /// /// Tests following https://numpy.org/doc/stable/reference/generated/numpy.dstack.html /// + [TestClass] public class np_dstack_tests { - [Test] + [TestMethod] public void DStackNDArrays() { //1D diff --git a/test/NumSharp.UnitTest/Manipulation/np.expand_dims.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.expand_dims.Test.cs index f000b9d34..21d681402 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.expand_dims.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.expand_dims.Test.cs @@ -3,9 +3,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class ExpandDimsTest { - [Test] + [TestMethod] public void Simple1DArrayTo2DArray() { var input = np.array(1, 2, 3); @@ -19,7 +20,7 @@ public void Simple1DArrayTo2DArray() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), expected.Data())); } - [Test] + [TestMethod] public void Simple1DArrayToTransposed2D() { var input = np.array(1, 2, 3); @@ -33,7 +34,7 @@ public void Simple1DArrayToTransposed2D() Assert.IsTrue(Enumerable.SequenceEqual(result.Data(), expected.Data())); } - [Test] + [TestMethod] public void Simple1DArrayToTransposed3D() { var input = np.array(1, 2, 3); diff --git a/test/NumSharp.UnitTest/Manipulation/np.hstack.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.hstack.Test.cs index a304f4d90..d1a4de05e 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.hstack.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.hstack.Test.cs @@ -5,9 +5,10 @@ namespace NumSharp.UnitTest.Manipulation /// /// Tests following https://numpy.org/doc/stable/reference/generated/numpy.hstack.html /// + [TestClass] public class np_hstack_tests { - [Test] + [TestMethod] public void HStackNDArrays() { //1D diff --git a/test/NumSharp.UnitTest/Manipulation/np.moveaxis.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.moveaxis.Test.cs index 1d0a0277f..a43ed108a 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.moveaxis.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.moveaxis.Test.cs @@ -4,9 +4,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class np_moveaxis_Test { - [Test] + [TestMethod] public void Case1() { var x = np.zeros((3, 4, 5)); @@ -14,7 +15,7 @@ public void Case1() np.moveaxis(x, -1, 0).Should().BeShaped(5, 3, 4); // NumPy verified (was incorrectly 5,4,3) } - [Test] + [TestMethod] public void Case2() { var x = np.zeros((3, 4, 5)); diff --git a/test/NumSharp.UnitTest/Manipulation/np.ravel.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.ravel.Test.cs index db1881f8e..41035dd79 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.ravel.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.ravel.Test.cs @@ -4,13 +4,14 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class np_ravel_Test { // ================================================================ // VALUES: 1D arrays // ================================================================ - [Test] + [TestMethod] public void Ravel_1D_AlreadyFlat() { var a = np.array(new long[] { 1, 2, 3, 4, 5 }); @@ -20,7 +21,7 @@ public void Ravel_1D_AlreadyFlat() r.Should().BeOfValues(1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Ravel_1D_Instance() { var a = np.array(new long[] { 10, 20, 30 }); @@ -34,7 +35,7 @@ public void Ravel_1D_Instance() // VALUES: 2D arrays // ================================================================ - [Test] + [TestMethod] public void Ravel_2D_COrder() { // NumPy: np.ravel([[1,2,3],[4,5,6]]) = [1,2,3,4,5,6] @@ -45,7 +46,7 @@ public void Ravel_2D_COrder() r.Should().BeOfValues(1, 2, 3, 4, 5, 6); } - [Test] + [TestMethod] public void Ravel_2D_Instance() { var a = np.array(new long[,] { { 1, 2 }, { 3, 4 } }); @@ -55,7 +56,7 @@ public void Ravel_2D_Instance() r.Should().BeOfValues(1, 2, 3, 4); } - [Test] + [TestMethod] public void Ravel_2D_SingleRow() { var a = np.array(new long[,] { { 1, 2, 3, 4, 5 } }); @@ -65,7 +66,7 @@ public void Ravel_2D_SingleRow() r.Should().BeOfValues(1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Ravel_2D_SingleColumn() { var a = np.array(new long[,] { { 1 }, { 2 }, { 3 } }); @@ -79,7 +80,7 @@ public void Ravel_2D_SingleColumn() // VALUES: 3D and 4D arrays // ================================================================ - [Test] + [TestMethod] public void Ravel_3D() { // NumPy: np.ravel(np.arange(24).reshape(2,3,4)) = [0,1,...,23] @@ -92,7 +93,7 @@ public void Ravel_3D() 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23); } - [Test] + [TestMethod] public void Ravel_4D() { var a = np.arange(24).reshape(new Shape(1, 2, 3, 4)); @@ -108,7 +109,7 @@ public void Ravel_4D() // VALUES: scalar and empty // ================================================================ - [Test] + [TestMethod] public void Ravel_Scalar() { // NumPy: np.ravel(np.array(42)) = [42] shape=(1,) @@ -121,7 +122,7 @@ public void Ravel_Scalar() r.GetInt32(0).Should().Be(42); } - [Test] + [TestMethod] public void Ravel_Empty_1D() { // NumPy: np.ravel(np.array([])) = [] shape=(0,) @@ -132,7 +133,7 @@ public void Ravel_Empty_1D() r.size.Should().Be(0); } - [Test] + [TestMethod] public void Ravel_SingleElement() { var a = np.array(new long[,] { { 42 } }); @@ -146,7 +147,7 @@ public void Ravel_SingleElement() // VALUES: broadcast arrays // ================================================================ - [Test] + [TestMethod] public void Ravel_Broadcast_RowBroadcast() { // NumPy: np.ravel(np.broadcast_to([1,2,3], (3,3))) = [1,2,3,1,2,3,1,2,3] @@ -157,7 +158,7 @@ public void Ravel_Broadcast_RowBroadcast() r.Should().BeOfValues(1, 2, 3, 1, 2, 3, 1, 2, 3); } - [Test] + [TestMethod] public void Ravel_Broadcast_ColumnBroadcast() { // NumPy: np.ravel(np.broadcast_to([[10],[20],[30]], (3,3))) @@ -170,7 +171,7 @@ public void Ravel_Broadcast_ColumnBroadcast() r.Should().BeOfValues(10, 10, 10, 20, 20, 20, 30, 30, 30); } - [Test] + [TestMethod] public void Ravel_Broadcast_2x3_ColumnBroadcast() { // np.ravel(np.broadcast_to([[1],[2]], (2,3))) = [1,1,1,2,2,2] @@ -186,7 +187,7 @@ public void Ravel_Broadcast_2x3_ColumnBroadcast() // VALUES: sliced arrays // ================================================================ - [Test] + [TestMethod] public void Ravel_Sliced_2D_ColumnSlice() { // NumPy: np.ravel(np.arange(12).reshape(3,4)[:,1:3]) = [1,2,5,6,9,10] @@ -197,7 +198,7 @@ public void Ravel_Sliced_2D_ColumnSlice() r.Should().BeOfValues(1, 2, 5, 6, 9, 10); } - [Test] + [TestMethod] public void Ravel_Sliced_Step2() { // NumPy: np.ravel(np.arange(10)[::2]) = [0,2,4,6,8] @@ -208,7 +209,7 @@ public void Ravel_Sliced_Step2() r.Should().BeOfValues(0, 2, 4, 6, 8); } - [Test] + [TestMethod] public void Ravel_Sliced_Reversed() { // NumPy: np.ravel(np.arange(5)[::-1]) = [4,3,2,1,0] @@ -223,7 +224,7 @@ public void Ravel_Sliced_Reversed() // VALUES: transposed arrays // ================================================================ - [Test] + [TestMethod] public void Ravel_Transposed_2D() { // NumPy: np.ravel(np.array([[1,2,3],[4,5,6]]).T) = [1,4,2,5,3,6] @@ -234,7 +235,7 @@ public void Ravel_Transposed_2D() r.Should().BeOfValues(1, 4, 2, 5, 3, 6); } - [Test] + [TestMethod] public void Ravel_Swapaxes_3D() { // NumPy: np.ravel(np.arange(12).reshape(2,3,2).swapaxes(1,2)) @@ -251,7 +252,7 @@ public void Ravel_Swapaxes_3D() // VIEW SEMANTICS: contiguous array ravel is a view // ================================================================ - [Test] + [TestMethod] public void Ravel_Contiguous_IsView() { // NumPy: ravel of contiguous array returns view (shared memory) @@ -264,7 +265,7 @@ public void Ravel_Contiguous_IsView() "NumPy: modifying ravel output modifies original."); } - [Test] + [TestMethod] public void Ravel_Contiguous2D_IsView() { // NumPy: ravel of contiguous 2D array returns view @@ -281,7 +282,7 @@ public void Ravel_Contiguous2D_IsView() // VIEW SEMANTICS: non-contiguous ravel is a copy // ================================================================ - [Test] + [TestMethod] public void Ravel_StepSlice_IsCopy() { // NumPy: ravel of step-2 slice returns copy (not C-contiguous) @@ -295,7 +296,7 @@ public void Ravel_StepSlice_IsCopy() "NumPy: step-2 slice is not C-contiguous."); } - [Test] + [TestMethod] public void Ravel_Broadcast_IsCopy() { // NumPy: ravel of broadcast array returns copy @@ -309,7 +310,7 @@ public void Ravel_Broadcast_IsCopy() "NumPy: broadcast is not contiguous."); } - [Test] + [TestMethod] public void Ravel_ColumnSlice_IsCopy() { // NumPy: ravel of column slice returns copy (not C-contiguous) @@ -328,7 +329,7 @@ public void Ravel_ColumnSlice_IsCopy() // These are upstream Shape.IsContiguous issues, not ravel bugs. // ================================================================ - [Test] + [TestMethod] public void Ravel_ContiguousSlice1D_ShouldBeView() { // NumPy: a[2:7] is c_contiguous=True, ravel returns a VIEW @@ -345,7 +346,7 @@ public void Ravel_ContiguousSlice1D_ShouldBeView() "unnecessarily copy via CloneData."); } - [Test] + [TestMethod] public void Ravel_ContiguousRowSlice2D_ShouldBeView() { // NumPy: c[1:3] (row slice) is c_contiguous=True, ravel returns VIEW @@ -365,7 +366,7 @@ public void Ravel_ContiguousRowSlice2D_ShouldBeView() // FLATTEN: always returns a copy // ================================================================ - [Test] + [TestMethod] public void Flatten_Contiguous_IsCopy() { // NumPy: flatten always returns a copy, even for contiguous arrays @@ -378,7 +379,7 @@ public void Flatten_Contiguous_IsCopy() "NumPy: modifying flatten output never modifies original."); } - [Test] + [TestMethod] public void Flatten_2D_Values() { var a = np.array(new long[,] { { 1, 2, 3 }, { 4, 5, 6 } }); @@ -388,7 +389,7 @@ public void Flatten_2D_Values() f.Should().BeOfValues(1, 2, 3, 4, 5, 6); } - [Test] + [TestMethod] public void Flatten_Broadcast() { var bc = np.broadcast_to(np.array(new long[] { 1, 2, 3 }), new Shape(2, 3)); @@ -398,7 +399,7 @@ public void Flatten_Broadcast() f.Should().BeOfValues(1, 2, 3, 1, 2, 3); } - [Test] + [TestMethod] public void Flatten_Broadcast_IsCopy() { var src = np.array(new long[] { 1, 2, 3 }); @@ -414,70 +415,70 @@ public void Flatten_Broadcast_IsCopy() // DTYPE PRESERVATION // ================================================================ - [Test] + [TestMethod] public void Ravel_PreservesDtype_Int32() { var a = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); np.ravel(a).dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void Ravel_PreservesDtype_Int64() { var a = np.array(new long[,] { { 1, 2 }, { 3, 4 } }); np.ravel(a).dtype.Should().Be(typeof(long)); } - [Test] + [TestMethod] public void Ravel_PreservesDtype_Float32() { var a = np.array(new float[,] { { 1, 2 }, { 3, 4 } }); np.ravel(a).dtype.Should().Be(typeof(float)); } - [Test] + [TestMethod] public void Ravel_PreservesDtype_Float64() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); np.ravel(a).dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Ravel_PreservesDtype_Bool() { var a = np.array(new bool[,] { { true, false }, { false, true } }); np.ravel(a).dtype.Should().Be(typeof(bool)); } - [Test] + [TestMethod] public void Ravel_PreservesDtype_Byte() { var a = np.array(new byte[,] { { 1, 2 }, { 3, 4 } }); np.ravel(a).dtype.Should().Be(typeof(byte)); } - [Test] + [TestMethod] public void Ravel_PreservesDtype_Int16() { var a = np.array(new short[,] { { 1, 2 }, { 3, 4 } }); np.ravel(a).dtype.Should().Be(typeof(short)); } - [Test] + [TestMethod] public void Ravel_PreservesDtype_UInt16() { var a = np.array(new ushort[,] { { 1, 2 }, { 3, 4 } }); np.ravel(a).dtype.Should().Be(typeof(ushort)); } - [Test] + [TestMethod] public void Ravel_PreservesDtype_UInt32() { var a = np.array(new uint[,] { { 1, 2 }, { 3, 4 } }); np.ravel(a).dtype.Should().Be(typeof(uint)); } - [Test] + [TestMethod] public void Ravel_PreservesDtype_UInt64() { var a = np.array(new ulong[,] { { 1, 2 }, { 3, 4 } }); @@ -488,7 +489,7 @@ public void Ravel_PreservesDtype_UInt64() // NDIM AND SHAPE // ================================================================ - [Test] + [TestMethod] public void Ravel_AlwaysReturns1D() { np.ravel(np.arange(5)).ndim.Should().Be(1); @@ -496,7 +497,7 @@ public void Ravel_AlwaysReturns1D() np.ravel(np.arange(24).reshape(2, 3, 4)).ndim.Should().Be(1); } - [Test] + [TestMethod] public void Ravel_SizePreserved() { np.ravel(np.arange(5)).size.Should().Be(5); @@ -508,7 +509,7 @@ public void Ravel_SizePreserved() // ORIGINAL NOT MODIFIED (for copy cases) // ================================================================ - [Test] + [TestMethod] public void Ravel_Broadcast_OriginalNotModified() { var src = np.array(new long[] { 1, 2, 3 }); @@ -522,7 +523,7 @@ public void Ravel_Broadcast_OriginalNotModified() src.Should().BeOfValues(1, 2, 3); } - [Test] + [TestMethod] public void Ravel_StepSlice_OriginalNotModified() { var a = np.arange(10); @@ -539,7 +540,7 @@ public void Ravel_StepSlice_OriginalNotModified() // RAVEL vs FLATTEN EQUIVALENCE (values only) // ================================================================ - [Test] + [TestMethod] public void Ravel_EquivalentToFlatten_Values() { var a = np.array(new long[,] { { 1, 2, 3 }, { 4, 5, 6 } }); @@ -551,7 +552,7 @@ public void Ravel_EquivalentToFlatten_Values() "ravel and flatten should produce the same values for C-order"); } - [Test] + [TestMethod] public void Ravel_EquivalentToFlatten_Broadcast() { var bc = np.broadcast_to(np.array(new long[] { 1, 2, 3 }), new Shape(2, 3)); @@ -566,7 +567,7 @@ public void Ravel_EquivalentToFlatten_Broadcast() // RAVEL of various dtypes — values // ================================================================ - [Test] + [TestMethod] public void Ravel_BoolValues() { var a = np.array(new bool[,] { { true, false }, { false, true } }); @@ -576,7 +577,7 @@ public void Ravel_BoolValues() r.Should().BeOfValues(true, false, false, true); } - [Test] + [TestMethod] public void Ravel_DoubleValues() { var a = np.array(new double[,] { { 1.5, 2.5 }, { 3.5, 4.5 } }); @@ -586,7 +587,7 @@ public void Ravel_DoubleValues() r.Should().BeOfValues(1.5, 2.5, 3.5, 4.5); } - [Test] + [TestMethod] public void Ravel_FloatValues() { var a = np.array(new float[,] { { 1.5f, 2.5f }, { 3.5f, 4.5f } }); @@ -596,7 +597,7 @@ public void Ravel_FloatValues() r.Should().BeOfValues(1.5f, 2.5f, 3.5f, 4.5f); } - [Test] + [TestMethod] public void Ravel_Int64Values() { var a = np.array(new long[,] { { 100, 200 }, { 300, 400 } }); @@ -606,7 +607,7 @@ public void Ravel_Int64Values() r.Should().BeOfValues(100L, 200L, 300L, 400L); } - [Test] + [TestMethod] public void Ravel_ByteValues() { var a = np.array(new byte[,] { { 1, 2 }, { 3, 4 } }); @@ -620,7 +621,7 @@ public void Ravel_ByteValues() // LARGE ARRAY // ================================================================ - [Test] + [TestMethod] public void Ravel_LargeArray() { var a = np.arange(1000).reshape(10, 10, 10); diff --git a/test/NumSharp.UnitTest/Manipulation/np.repeat.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.repeat.Test.cs index d14174c8a..a2314a79b 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.repeat.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.repeat.Test.cs @@ -8,11 +8,12 @@ namespace NumSharp.UnitTest.Manipulation /// Tests for np.repeat matching NumPy 2.x behavior. /// Based on NumPy tests from numpy/_core/tests/test_multiarray.py and test_numeric.py. /// + [TestClass] public class np_repeat_tests { #region Basic Scalar Repeat Tests - [Test] + [TestMethod] public void Scalar_Int() { // np.repeat(3, 4) -> [3, 3, 3, 3] @@ -21,7 +22,7 @@ public void Scalar_Int() nd.ToArray().Should().ContainInOrder(3, 3, 3, 3); } - [Test] + [TestMethod] public void Scalar_Double() { var nd = np.repeat(2.5, 3); @@ -29,7 +30,7 @@ public void Scalar_Double() nd.ToArray().Should().ContainInOrder(2.5, 2.5, 2.5); } - [Test] + [TestMethod] public void Scalar_ZeroRepeats() { var nd = np.repeat(5, 0); @@ -40,7 +41,7 @@ public void Scalar_ZeroRepeats() #region Basic Array Repeat Tests (NumPy test_numeric.py) - [Test] + [TestMethod] public void Array_UniformRepeat() { // From NumPy: np.repeat([1, 2, 3], 2) -> [1, 1, 2, 2, 3, 3] @@ -49,7 +50,7 @@ public void Array_UniformRepeat() nd.ToArray().Should().ContainInOrder(1, 1, 2, 2, 3, 3); } - [Test] + [TestMethod] public void Array_ZeroRepeats() { var a = np.array(new int[] { 1, 2, 3 }); @@ -57,7 +58,7 @@ public void Array_ZeroRepeats() nd.size.Should().Be(0); } - [Test] + [TestMethod] public void Array_EmptyInput() { var a = np.array(new int[0]); @@ -69,7 +70,7 @@ public void Array_EmptyInput() #region 2D Array Tests (NumPy test_multiarray.py) - [Test] + [TestMethod] public void Array2D_Flattens() { // From NumPy: np.repeat([[1, 2, 3], [4, 5, 6]], 2) flattens then repeats @@ -78,7 +79,7 @@ public void Array2D_Flattens() nd.ToArray().Should().ContainInOrder(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6); } - [Test] + [TestMethod] public void Simple2DArray() { var x = np.array(new int[][] { new int[] { 1, 2 }, new int[] { 3, 4 } }); @@ -90,7 +91,7 @@ public void Simple2DArray() #region Per-Element Repeats Tests (NumPy test_multiarray.py) - [Test] + [TestMethod] public void ArrayRepeats_Basic() { // From NumPy: m.repeat([1, 3, 2, 1, 1, 2]) where m = [1, 2, 3, 4, 5, 6] @@ -100,7 +101,7 @@ public void ArrayRepeats_Basic() nd.ToArray().Should().ContainInOrder(1, 2, 2, 2, 3, 3, 4, 5, 6, 6); } - [Test] + [TestMethod] public void ArrayRepeats_AllZeros() { var a = np.array(new int[] { 1, 2, 3 }); @@ -109,7 +110,7 @@ public void ArrayRepeats_AllZeros() nd.size.Should().Be(0); } - [Test] + [TestMethod] public void ArrayRepeats_MixedZeroAndNonZero() { // np.repeat([1, 2, 3, 4], [0, 2, 0, 3]) -> [2, 2, 4, 4, 4] @@ -123,7 +124,7 @@ public void ArrayRepeats_MixedZeroAndNonZero() #region Non-Contiguous Array Tests - [Test] + [TestMethod] public void SlicedArray_StridedView() { // Sliced arrays should work correctly @@ -134,7 +135,7 @@ public void SlicedArray_StridedView() nd.ToArray().Should().ContainInOrder(0L, 0L, 2L, 2L, 4L, 4L, 6L, 6L, 8L, 8L); } - [Test] + [TestMethod] public void TransposedArray() { // Transposed arrays (non-contiguous) should work correctly @@ -148,7 +149,7 @@ public void TransposedArray() #region All Dtype Tests - [Test] + [TestMethod] public void Dtype_Boolean() { var a = np.array(new bool[] { true, false, true }); @@ -156,7 +157,7 @@ public void Dtype_Boolean() nd.ToArray().Should().ContainInOrder(true, true, false, false, true, true); } - [Test] + [TestMethod] public void Dtype_Byte() { var a = np.array(new byte[] { 1, 2, 3 }); @@ -164,7 +165,7 @@ public void Dtype_Byte() nd.ToArray().Should().ContainInOrder((byte)1, (byte)1, (byte)2, (byte)2, (byte)3, (byte)3); } - [Test] + [TestMethod] public void Dtype_Int16() { var a = np.array(new short[] { 1, 2, 3 }); @@ -172,7 +173,7 @@ public void Dtype_Int16() nd.ToArray().Should().ContainInOrder((short)1, (short)1, (short)2, (short)2, (short)3, (short)3); } - [Test] + [TestMethod] public void Dtype_UInt16() { var a = np.array(new ushort[] { 1, 2, 3 }); @@ -180,7 +181,7 @@ public void Dtype_UInt16() nd.ToArray().Should().ContainInOrder((ushort)1, (ushort)1, (ushort)2, (ushort)2, (ushort)3, (ushort)3); } - [Test] + [TestMethod] public void Dtype_Int32() { var a = np.array(new int[] { 1, 2, 3 }); @@ -188,7 +189,7 @@ public void Dtype_Int32() nd.ToArray().Should().ContainInOrder(1, 1, 2, 2, 3, 3); } - [Test] + [TestMethod] public void Dtype_UInt32() { var a = np.array(new uint[] { 1, 2, 3 }); @@ -196,7 +197,7 @@ public void Dtype_UInt32() nd.ToArray().Should().ContainInOrder(1u, 1u, 2u, 2u, 3u, 3u); } - [Test] + [TestMethod] public void Dtype_Int64() { var a = np.array(new long[] { 1, 2, 3 }); @@ -204,7 +205,7 @@ public void Dtype_Int64() nd.ToArray().Should().ContainInOrder(1L, 1L, 2L, 2L, 3L, 3L); } - [Test] + [TestMethod] public void Dtype_UInt64() { var a = np.array(new ulong[] { 1, 2, 3 }); @@ -212,7 +213,7 @@ public void Dtype_UInt64() nd.ToArray().Should().ContainInOrder(1UL, 1UL, 2UL, 2UL, 3UL, 3UL); } - [Test] + [TestMethod] public void Dtype_Char() { var a = np.array(new char[] { 'a', 'b', 'c' }); @@ -220,7 +221,7 @@ public void Dtype_Char() nd.ToArray().Should().ContainInOrder('a', 'a', 'b', 'b', 'c', 'c'); } - [Test] + [TestMethod] public void Dtype_Single() { var a = np.array(new float[] { 1.5f, 2.5f, 3.5f }); @@ -228,7 +229,7 @@ public void Dtype_Single() nd.ToArray().Should().ContainInOrder(1.5f, 1.5f, 2.5f, 2.5f, 3.5f, 3.5f); } - [Test] + [TestMethod] public void Dtype_Double() { var a = np.array(new double[] { 1.5, 2.5, 3.5 }); @@ -236,7 +237,7 @@ public void Dtype_Double() nd.ToArray().Should().ContainInOrder(1.5, 1.5, 2.5, 2.5, 3.5, 3.5); } - [Test] + [TestMethod] public void Dtype_Decimal() { var a = np.array(new decimal[] { 1.5m, 2.5m, 3.5m }); @@ -248,7 +249,7 @@ public void Dtype_Decimal() #region Array Repeats with All Dtypes - [Test] + [TestMethod] public void ArrayRepeats_Double() { var a = np.array(new double[] { 1.1, 2.2, 3.3 }); @@ -261,7 +262,7 @@ public void ArrayRepeats_Double() #region Large Repeat Counts - [Test] + [TestMethod] public void LargeRepeatCount() { var a = np.array(new int[] { 1, 2 }); @@ -275,7 +276,7 @@ public void LargeRepeatCount() #region Error Cases - [Test] + [TestMethod] public void Error_NegativeScalarRepeat() { var a = np.array(new int[] { 1, 2, 3 }); @@ -283,7 +284,7 @@ public void Error_NegativeScalarRepeat() act.Should().Throw(); } - [Test] + [TestMethod] public void Error_NegativeInArrayRepeat() { var a = np.array(new int[] { 1, 2, 3 }); @@ -292,7 +293,7 @@ public void Error_NegativeInArrayRepeat() act.Should().Throw(); } - [Test] + [TestMethod] public void Error_MismatchedArraySizes() { var a = np.array(new int[] { 1, 2, 3 }); @@ -301,7 +302,7 @@ public void Error_MismatchedArraySizes() act.Should().Throw(); } - [Test] + [TestMethod] public void Error_NegativeScalarRepeatValue() { Action act = () => np.repeat(5, -1); @@ -312,7 +313,7 @@ public void Error_NegativeScalarRepeatValue() #region Dtype Preservation Tests - [Test] + [TestMethod] public void DtypePreservation_Int32() { var a = np.array(new int[] { 1, 2, 3 }); @@ -320,7 +321,7 @@ public void DtypePreservation_Int32() nd.typecode.Should().Be(NPTypeCode.Int32); } - [Test] + [TestMethod] public void DtypePreservation_Double() { var a = np.array(new double[] { 1.0, 2.0, 3.0 }); @@ -328,7 +329,7 @@ public void DtypePreservation_Double() nd.typecode.Should().Be(NPTypeCode.Double); } - [Test] + [TestMethod] public void DtypePreservation_Boolean() { var a = np.array(new bool[] { true, false }); diff --git a/test/NumSharp.UnitTest/Manipulation/np.reshape.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.reshape.Test.cs index fbcb53082..edc2fba92 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.reshape.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.reshape.Test.cs @@ -9,11 +9,12 @@ namespace NumSharp.UnitTest.Manipulation /// Comprehensive tests for np.reshape and NDArray.reshape against NumPy 2.4.2 ground truth. /// All tests based on verified NumPy behavior. /// + [TestClass] public class np_reshape_Test : TestClass { #region Basic Reshapes - [Test] + [TestMethod] public void Reshape_1D_to_2D() { // NumPy: np.arange(6).reshape(2,3) = [[0,1,2],[3,4,5]] @@ -24,7 +25,7 @@ public void Reshape_1D_to_2D() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_1D_to_3D() { // NumPy: np.arange(6).reshape(2,1,3) = [[[0,1,2]],[[3,4,5]]] @@ -35,7 +36,7 @@ public void Reshape_1D_to_3D() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_2D_to_1D() { // NumPy: np.arange(6).reshape(2,3).reshape(6) = [0,1,2,3,4,5] @@ -46,7 +47,7 @@ public void Reshape_2D_to_1D() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_2D_to_3D() { // NumPy: np.arange(6).reshape(2,3).reshape(3,1,2) = [[[0,1]],[[2,3]],[[4,5]]] @@ -57,7 +58,7 @@ public void Reshape_2D_to_3D() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_3D_to_2D() { // NumPy: np.arange(24).reshape(2,3,4).reshape(6,4) @@ -77,7 +78,7 @@ public void Reshape_3D_to_2D() r.GetInt64(5, 3).Should().Be(23); } - [Test] + [TestMethod] public void Reshape_3D_to_1D() { // NumPy: np.arange(24).reshape(2,3,4).reshape(24) = [0..23] @@ -90,7 +91,7 @@ public void Reshape_3D_to_1D() 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23); } - [Test] + [TestMethod] public void Reshape_4D_to_2D() { // NumPy: np.arange(24).reshape(2,3,2,2).reshape(6,4) @@ -105,7 +106,7 @@ public void Reshape_4D_to_2D() r.GetInt64(5, 3).Should().Be(23); } - [Test] + [TestMethod] public void Reshape_SameShape() { // NumPy: np.arange(6).reshape(2,3).reshape(2,3) = [[0,1,2],[3,4,5]] (no-op) @@ -116,7 +117,7 @@ public void Reshape_SameShape() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_SingleElement() { // NumPy: np.array([42]).reshape(1,1,1) = value 42, shape (1,1,1) @@ -127,7 +128,7 @@ public void Reshape_SingleElement() r.GetInt64(0, 0, 0).Should().Be(42); } - [Test] + [TestMethod] public void Reshape_1x6_to_6x1() { // NumPy: np.arange(6).reshape(1,6).reshape(6,1) = [[0],[1],[2],[3],[4],[5]] @@ -147,7 +148,7 @@ public void Reshape_1x6_to_6x1() #region Minus-One Inference - [Test] + [TestMethod] public void Reshape_Neg1_First() { // NumPy: np.arange(12).reshape(-1,3) → shape (4,3) @@ -158,7 +159,7 @@ public void Reshape_Neg1_First() r.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); } - [Test] + [TestMethod] public void Reshape_Neg1_Last() { // NumPy: np.arange(12).reshape(3,-1) → shape (3,4) @@ -169,7 +170,7 @@ public void Reshape_Neg1_Last() r.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); } - [Test] + [TestMethod] public void Reshape_Neg1_Middle() { // NumPy: np.arange(12).reshape(2,-1,3) → shape (2,2,3) @@ -180,7 +181,7 @@ public void Reshape_Neg1_Middle() r.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); } - [Test] + [TestMethod] public void Reshape_Neg1_Flatten() { // NumPy: np.arange(12).reshape(-1) → shape (12,) @@ -191,7 +192,7 @@ public void Reshape_Neg1_Flatten() r.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); } - [Test] + [TestMethod] public void Reshape_Neg1_With1() { // NumPy: np.arange(5).reshape(-1,1) → shape (5,1) @@ -210,7 +211,7 @@ public void Reshape_Neg1_With1() #region View Semantics - [Test] + [TestMethod] public void Reshape_Contiguous_ReturnsView() { // NumPy: reshape of contiguous array returns view, modifications visible @@ -224,7 +225,7 @@ public void Reshape_Contiguous_ReturnsView() a.GetInt64(1).Should().Be(99); } - [Test] + [TestMethod] public void Reshape_DoubleReshape_SharesMemory() { // NumPy: arange(24)→(4,6)→(2,3,4), modify r2[0,1,2]=888 → original a[6]=888 @@ -237,7 +238,7 @@ public void Reshape_DoubleReshape_SharesMemory() a.GetInt64(6).Should().Be(888); } - [Test] + [TestMethod] public void Reshape_Back_SharesMemory() { // NumPy: arange(12)→(3,4)→(12) shares memory with original @@ -255,7 +256,7 @@ public void Reshape_Back_SharesMemory() #region Scalar / 0-dim - [Test] + [TestMethod] public void Reshape_ScalarTo1D() { // NumPy: np.array(42).reshape(1) → shape (1,), val [42] @@ -269,7 +270,7 @@ public void Reshape_ScalarTo1D() r.GetInt32(0).Should().Be(42); } - [Test] + [TestMethod] public void Reshape_ScalarTo2D() { // NumPy: np.array(42).reshape(1,1) → shape (1,1), val [[42]] @@ -282,7 +283,7 @@ public void Reshape_ScalarTo2D() r.GetInt32(0, 0).Should().Be(42); } - [Test] + [TestMethod] public void Reshape_1DToScalar() { // NumPy: np.array([42]).reshape(()) → scalar 42 @@ -297,7 +298,7 @@ public void Reshape_1DToScalar() #region Empty Arrays - [Test] + [TestMethod] public void Reshape_Empty_To0x3() { // NumPy: np.array([]).reshape(0,3) → shape (0,3), size 0 @@ -308,7 +309,7 @@ public void Reshape_Empty_To0x3() r.Should().BeOfSize(0); } - [Test] + [TestMethod] public void Reshape_Empty_To3x0() { // NumPy: np.array([]).reshape(3,0) → shape (3,0), size 0 @@ -319,7 +320,7 @@ public void Reshape_Empty_To3x0() r.Should().BeOfSize(0); } - [Test] + [TestMethod] public void Reshape_Empty_To0x0() { // NumPy: np.array([]).reshape(0,0) → shape (0,0), size 0 @@ -330,7 +331,7 @@ public void Reshape_Empty_To0x0() r.Should().BeOfSize(0); } - [Test] + [TestMethod] public void Reshape_0x3_To0() { // NumPy: np.empty((0,3)).reshape(0) → shape (0,) @@ -341,7 +342,7 @@ public void Reshape_0x3_To0() r.Should().BeOfSize(0); } - [Test] + [TestMethod] public void Reshape_Empty_Neg1() { // NumPy: np.array([]).reshape(-1,3) → shape (0,3) @@ -356,7 +357,7 @@ public void Reshape_Empty_Neg1() #region Sliced + Reshape - [Test] + [TestMethod] public void Reshape_ContiguousSlice_Values() { // NumPy: np.arange(10)[2:8].reshape(2,3) = [[2,3,4],[5,6,7]] @@ -368,7 +369,7 @@ public void Reshape_ContiguousSlice_Values() r.Should().BeOfValues(2, 3, 4, 5, 6, 7); } - [Test] + [TestMethod] public void Reshape_StepSlice_Values() { // NumPy: np.arange(10)[::2].reshape(1,5) = [[0,2,4,6,8]] @@ -380,7 +381,7 @@ public void Reshape_StepSlice_Values() r.Should().BeOfValues(0, 2, 4, 6, 8); } - [Test] + [TestMethod] public void Reshape_2D_ColSlice_Values() { // NumPy: np.arange(12).reshape(3,4)[:,1:3].reshape(6) = [1,2,5,6,9,10] @@ -392,7 +393,7 @@ public void Reshape_2D_ColSlice_Values() r.Should().BeOfValues(1, 2, 5, 6, 9, 10); } - [Test] + [TestMethod] public void Reshape_2D_RowSlice_Values() { // NumPy: np.arange(12).reshape(3,4)[1:3].reshape(8) = [4,5,6,7,8,9,10,11] @@ -404,7 +405,7 @@ public void Reshape_2D_RowSlice_Values() r.Should().BeOfValues(4, 5, 6, 7, 8, 9, 10, 11); } - [Test] + [TestMethod] public void Reshape_Reversed_Values() { // NumPy: np.arange(6)[::-1].reshape(2,3) = [[5,4,3],[2,1,0]] @@ -416,7 +417,7 @@ public void Reshape_Reversed_Values() r.Should().BeOfValues(5, 4, 3, 2, 1, 0); } - [Test] + [TestMethod] public void Reshape_Slice_WriteThrough() { // NumPy: slice a[2:8], reshape(2,3), set [0,0]=99 → original a[2] becomes 99 @@ -433,7 +434,7 @@ public void Reshape_Slice_WriteThrough() #region Broadcast + Reshape - [Test] + [TestMethod] public void Reshape_RowBroadcast_CopyReshape() { // NumPy: broadcast_to([1,2,3], (3,3)), copy then reshape(9) = [1,2,3,1,2,3,1,2,3] @@ -446,7 +447,7 @@ public void Reshape_RowBroadcast_CopyReshape() r.Should().BeOfValues(1, 2, 3, 1, 2, 3, 1, 2, 3); } - [Test] + [TestMethod] public void Reshape_ColBroadcast_CopyReshape() { // NumPy: broadcast_to([[10],[20],[30]], (3,3)), copy then reshape(9) @@ -460,7 +461,7 @@ public void Reshape_ColBroadcast_CopyReshape() r.Should().BeOfValues(10, 10, 10, 20, 20, 20, 30, 30, 30); } - [Test] + [TestMethod] public void Reshape_Broadcast_DirectReshape() { // NumPy: np.reshape(broadcast_to([1,2,3], (3,3)), 9) = [1,2,3,1,2,3,1,2,3] @@ -473,7 +474,7 @@ public void Reshape_Broadcast_DirectReshape() r.Should().BeOfValues(1, 2, 3, 1, 2, 3, 1, 2, 3); } - [Test] + [TestMethod] public void Reshape_ColBroadcast_DirectReshape() { // NumPy: broadcast_to column [[10],[20],[30]], reshape(9) @@ -490,7 +491,7 @@ public void Reshape_ColBroadcast_DirectReshape() #region Dtypes - [Test] + [TestMethod] public void Reshape_Boolean() { var a = np.array(new bool[] { true, false, true, false, true, false }); @@ -501,7 +502,7 @@ public void Reshape_Boolean() r.Should().BeOfValues(true, false, true, false, true, false); } - [Test] + [TestMethod] public void Reshape_Byte() { var a = np.array(new byte[] { 0, 1, 2, 3, 4, 5 }); @@ -512,7 +513,7 @@ public void Reshape_Byte() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_Int16() { var a = np.array(new short[] { 0, 1, 2, 3, 4, 5 }); @@ -523,7 +524,7 @@ public void Reshape_Int16() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_UInt16() { var a = np.array(new ushort[] { 0, 1, 2, 3, 4, 5 }); @@ -534,7 +535,7 @@ public void Reshape_UInt16() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_Int32() { var a = np.array(new int[] { 0, 1, 2, 3, 4, 5 }); @@ -545,7 +546,7 @@ public void Reshape_Int32() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_UInt32() { var a = np.array(new uint[] { 0, 1, 2, 3, 4, 5 }); @@ -556,7 +557,7 @@ public void Reshape_UInt32() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_Int64() { var a = np.array(new long[] { 0, 1, 2, 3, 4, 5 }); @@ -567,7 +568,7 @@ public void Reshape_Int64() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_UInt64() { var a = np.array(new ulong[] { 0, 1, 2, 3, 4, 5 }); @@ -578,7 +579,7 @@ public void Reshape_UInt64() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_Char() { var a = np.array(new char[] { 'a', 'b', 'c', 'd', 'e', 'f' }); @@ -589,7 +590,7 @@ public void Reshape_Char() r.Should().BeOfValues('a', 'b', 'c', 'd', 'e', 'f'); } - [Test] + [TestMethod] public void Reshape_Single() { var a = np.array(new float[] { 0f, 1f, 2f, 3f, 4f, 5f }); @@ -600,7 +601,7 @@ public void Reshape_Single() r.Should().BeOfValues(0f, 1f, 2f, 3f, 4f, 5f); } - [Test] + [TestMethod] public void Reshape_Double() { var a = np.array(new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }); @@ -611,7 +612,7 @@ public void Reshape_Double() r.Should().BeOfValues(0.0, 1.0, 2.0, 3.0, 4.0, 5.0); } - [Test] + [TestMethod] public void Reshape_Decimal() { var a = np.array(new decimal[] { 0m, 1m, 2m, 3m, 4m, 5m }); @@ -626,7 +627,7 @@ public void Reshape_Decimal() #region Large Arrays - [Test] + [TestMethod] public void Reshape_Large_100x100_to_10000() { // Test large array reshape @@ -649,7 +650,7 @@ public void Reshape_Large_100x100_to_10000() r.GetInt64(9999).Should().Be(9999); } - [Test] + [TestMethod] public void Reshape_Large_100x100_to_50x200() { // Test large array different shape @@ -670,7 +671,7 @@ public void Reshape_Large_100x100_to_50x200() #region Error Cases - [Test] + [TestMethod] public void Reshape_IncompatibleShape_Throws() { // NumPy: np.arange(6).reshape(2,4) → raises ValueError @@ -681,7 +682,7 @@ public void Reshape_IncompatibleShape_Throws() act.Should().Throw(); // Could be IncorrectShapeException or similar } - [Test] + [TestMethod] public void Reshape_TwoNeg1_Throws() { // NumPy: np.arange(6).reshape(-1,-1) → raises ValueError @@ -692,7 +693,7 @@ public void Reshape_TwoNeg1_Throws() act.Should().Throw(); } - [Test] + [TestMethod] public void Reshape_Neg1_NonDivisible_Throws() { // NumPy: np.arange(7).reshape(-1,3) → raises ValueError (7 not divisible by 3) @@ -707,7 +708,7 @@ public void Reshape_Neg1_NonDivisible_Throws() #region Static vs Instance - [Test] + [TestMethod] public void Reshape_Static_Equals_Instance() { // NumPy: np.reshape(a, (3,4)) == a.reshape(3,4) @@ -724,7 +725,7 @@ public void Reshape_Static_Equals_Instance() #region Transposed + Reshape - [Test] + [TestMethod] public void Reshape_Transposed_Values() { // NumPy: np.arange(6).reshape(2,3).T.reshape(6) = [0,3,1,4,2,5] @@ -737,7 +738,7 @@ public void Reshape_Transposed_Values() r.Should().BeOfValues(0, 3, 1, 4, 2, 5); } - [Test] + [TestMethod] public void Reshape_Transposed_NoWriteThrough() { // After transposed reshape, writing to result does NOT modify original @@ -756,7 +757,7 @@ public void Reshape_Transposed_NoWriteThrough() #region Fancy Combinations - [Test] + [TestMethod] public void Reshape_Slice_Reshape_Values() { // NumPy: np.arange(24).reshape(4,6)[1:3,2:5].reshape(6) = [8,9,10,14,15,16] @@ -768,7 +769,7 @@ public void Reshape_Slice_Reshape_Values() r.Should().BeOfValues(8, 9, 10, 14, 15, 16); } - [Test] + [TestMethod] public void Reshape_NewAxis_Values() { // NumPy: np.arange(6)[np.newaxis,:].reshape(2,3) = [[0,1,2],[3,4,5]] @@ -781,7 +782,7 @@ public void Reshape_NewAxis_Values() r.Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Reshape_Chain_4Steps() { // NumPy: arange(24)→(4,6)→(2,2,6)→(2,2,2,3)→(24), verify equal to original @@ -795,7 +796,7 @@ public void Reshape_Chain_4Steps() np.array_equal(r4, a).Should().BeTrue(); } - [Test] + [TestMethod] public void Reshape_Unsafe_ParamsInt() { // Test reshape_unsafe with int[] params works correctly @@ -806,7 +807,7 @@ public void Reshape_Unsafe_ParamsInt() r.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); } - [Test] + [TestMethod] public void Reshape_Unsafe_Shape() { // Test reshape_unsafe with Shape overload works correctly diff --git a/test/NumSharp.UnitTest/Manipulation/np.roll.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.roll.Test.cs index e30dc017d..cee00e101 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.roll.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.roll.Test.cs @@ -13,13 +13,14 @@ namespace NumSharp.UnitTest.Manipulation /// NumPy reference: https://numpy.org/doc/stable/reference/generated/numpy.roll.html /// NumPy test source: numpy/_core/tests/test_numeric.py, class TestRoll /// + [TestClass] public class np_roll_Test { // ================================================================ // 1D ARRAYS // ================================================================ - [Test] + [TestMethod] public void Roll_1D_PositiveShift() { // np.roll(np.arange(10), 2) => [8 9 0 1 2 3 4 5 6 7] @@ -30,7 +31,7 @@ public void Roll_1D_PositiveShift() result.Should().BeOfValues(8, 9, 0, 1, 2, 3, 4, 5, 6, 7); } - [Test] + [TestMethod] public void Roll_1D_NegativeShift() { // np.roll(np.arange(10), -2) => [2 3 4 5 6 7 8 9 0 1] @@ -41,7 +42,7 @@ public void Roll_1D_NegativeShift() result.Should().BeOfValues(2, 3, 4, 5, 6, 7, 8, 9, 0, 1); } - [Test] + [TestMethod] public void Roll_1D_ZeroShift() { // np.roll(np.arange(10), 0) => [0 1 2 3 4 5 6 7 8 9] @@ -52,7 +53,7 @@ public void Roll_1D_ZeroShift() result.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); } - [Test] + [TestMethod] public void Roll_1D_ShiftEqualsSize() { // np.roll(np.arange(10), 10) => [0 1 2 3 4 5 6 7 8 9] @@ -63,7 +64,7 @@ public void Roll_1D_ShiftEqualsSize() result.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); } - [Test] + [TestMethod] public void Roll_1D_ShiftEqualsNegativeSize() { // np.roll(np.arange(10), -10) => [0 1 2 3 4 5 6 7 8 9] @@ -74,7 +75,7 @@ public void Roll_1D_ShiftEqualsNegativeSize() result.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); } - [Test] + [TestMethod] public void Roll_1D_ShiftGreaterThanSize() { // np.roll(np.arange(10), 12) => [8 9 0 1 2 3 4 5 6 7] (12 % 10 = 2) @@ -85,7 +86,7 @@ public void Roll_1D_ShiftGreaterThanSize() result.Should().BeOfValues(8, 9, 0, 1, 2, 3, 4, 5, 6, 7); } - [Test] + [TestMethod] public void Roll_1D_ShiftLessThanNegativeSize() { // np.roll(np.arange(10), -12) => [2 3 4 5 6 7 8 9 0 1] (-12 % 10 = -2 => 8 effective) @@ -96,7 +97,7 @@ public void Roll_1D_ShiftLessThanNegativeSize() result.Should().BeOfValues(2, 3, 4, 5, 6, 7, 8, 9, 0, 1); } - [Test] + [TestMethod] public void Roll_1D_ShiftMuchLarger() { // np.roll(np.arange(10), 25) => [5 6 7 8 9 0 1 2 3 4] (25 % 10 = 5) @@ -107,7 +108,7 @@ public void Roll_1D_ShiftMuchLarger() result.Should().BeOfValues(5, 6, 7, 8, 9, 0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Roll_1D_VeryLargeShift() { // np.roll(np.arange(5), 1000000) => [0 1 2 3 4] (1000000 % 5 = 0) @@ -122,7 +123,7 @@ public void Roll_1D_VeryLargeShift() // 1D - NumPy test_roll1d (exact match) // ================================================================ - [Test] + [TestMethod] public void Roll_NumPy_test_roll1d() { // Exact replication of NumPy TestRoll.test_roll1d @@ -135,7 +136,7 @@ public void Roll_NumPy_test_roll1d() // 2D ARRAYS // ================================================================ - [Test] + [TestMethod] public void Roll_2D_NoAxis_Flattens() { // np.roll(x2, 1) flattens, rolls, restores shape @@ -148,7 +149,7 @@ public void Roll_2D_NoAxis_Flattens() result.Should().BeOfValues(9, 0, 1, 2, 3, 4, 5, 6, 7, 8); } - [Test] + [TestMethod] public void Roll_2D_Axis0() { // np.roll(x2, 1, axis=0) => [[5,6,7,8,9],[0,1,2,3,4]] @@ -159,7 +160,7 @@ public void Roll_2D_Axis0() result.Should().BeOfValues(5, 6, 7, 8, 9, 0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Roll_2D_Axis1() { // np.roll(x2, 1, axis=1) => [[4,0,1,2,3],[9,5,6,7,8]] @@ -170,7 +171,7 @@ public void Roll_2D_Axis1() result.Should().BeOfValues(4, 0, 1, 2, 3, 9, 5, 6, 7, 8); } - [Test] + [TestMethod] public void Roll_2D_NegativeAxis1() { // np.roll(x2, 1, axis=-1) == np.roll(x2, 1, axis=1) @@ -181,7 +182,7 @@ public void Roll_2D_NegativeAxis1() result.Should().BeOfValues(4, 0, 1, 2, 3, 9, 5, 6, 7, 8); } - [Test] + [TestMethod] public void Roll_2D_NegativeAxis2() { // np.roll(x2, 1, axis=-2) == np.roll(x2, 1, axis=0) @@ -192,7 +193,7 @@ public void Roll_2D_NegativeAxis2() result.Should().BeOfValues(5, 6, 7, 8, 9, 0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Roll_2D_NegativeShift_Axis0() { // np.roll(x2, -1, axis=0) => [[5,6,7,8,9],[0,1,2,3,4]] @@ -203,7 +204,7 @@ public void Roll_2D_NegativeShift_Axis0() result.Should().BeOfValues(5, 6, 7, 8, 9, 0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Roll_2D_NegativeShift_Axis1() { // np.roll(x2, -1, axis=1) => [[1,2,3,4,0],[6,7,8,9,5]] @@ -214,7 +215,7 @@ public void Roll_2D_NegativeShift_Axis1() result.Should().BeOfValues(1, 2, 3, 4, 0, 6, 7, 8, 9, 5); } - [Test] + [TestMethod] public void Roll_2D_ShiftGreaterThanDimSize_Axis1() { // np.roll(x2, 6, axis=1) => [[4,0,1,2,3],[9,5,6,7,8]] (6 % 5 = 1) @@ -225,7 +226,7 @@ public void Roll_2D_ShiftGreaterThanDimSize_Axis1() result.Should().BeOfValues(4, 0, 1, 2, 3, 9, 5, 6, 7, 8); } - [Test] + [TestMethod] public void Roll_2D_NegativeShiftWraps_Axis1() { // np.roll(x2, -4, axis=1) => [[4,0,1,2,3],[9,5,6,7,8]] (-4 % 5 = 1 effective) @@ -236,7 +237,7 @@ public void Roll_2D_NegativeShiftWraps_Axis1() result.Should().BeOfValues(4, 0, 1, 2, 3, 9, 5, 6, 7, 8); } - [Test] + [TestMethod] public void Roll_2D_NoAxis_VariousShifts() { // x = [[0,1,2],[3,4,5]] @@ -260,7 +261,7 @@ public void Roll_2D_NoAxis_VariousShifts() // NumPy test_roll2d (exact match) // ================================================================ - [Test] + [TestMethod] public void Roll_NumPy_test_roll2d_NoAxis() { var x2 = np.arange(10).reshape(2, 5); @@ -268,7 +269,7 @@ public void Roll_NumPy_test_roll2d_NoAxis() x2r.Should().Be(np.array(new long[,] { { 9, 0, 1, 2, 3 }, { 4, 5, 6, 7, 8 } })); } - [Test] + [TestMethod] public void Roll_NumPy_test_roll2d_Axis0() { var x2 = np.arange(10).reshape(2, 5); @@ -276,7 +277,7 @@ public void Roll_NumPy_test_roll2d_Axis0() x2r.Should().Be(np.array(new long[,] { { 5, 6, 7, 8, 9 }, { 0, 1, 2, 3, 4 } })); } - [Test] + [TestMethod] public void Roll_NumPy_test_roll2d_Axis1() { var x2 = np.arange(10).reshape(2, 5); @@ -284,7 +285,7 @@ public void Roll_NumPy_test_roll2d_Axis1() x2r.Should().Be(np.array(new long[,] { { 4, 0, 1, 2, 3 }, { 9, 5, 6, 7, 8 } })); } - [Test] + [TestMethod] public void Roll_NumPy_test_roll2d_MoreThanOneTurn_Positive() { var x2 = np.arange(10).reshape(2, 5); @@ -293,7 +294,7 @@ public void Roll_NumPy_test_roll2d_MoreThanOneTurn_Positive() x2r.Should().Be(np.array(new long[,] { { 4, 0, 1, 2, 3 }, { 9, 5, 6, 7, 8 } })); } - [Test] + [TestMethod] public void Roll_NumPy_test_roll2d_MoreThanOneTurn_Negative() { var x2 = np.arange(10).reshape(2, 5); @@ -306,7 +307,7 @@ public void Roll_NumPy_test_roll2d_MoreThanOneTurn_Negative() // 3D ARRAYS // ================================================================ - [Test] + [TestMethod] public void Roll_3D_NoAxis() { // x3 = arange(24).reshape(2,3,4) @@ -320,7 +321,7 @@ public void Roll_3D_NoAxis() 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22); } - [Test] + [TestMethod] public void Roll_3D_Axis0() { var x3 = np.arange(24).reshape(2, 3, 4); @@ -333,7 +334,7 @@ public void Roll_3D_Axis0() 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); } - [Test] + [TestMethod] public void Roll_3D_Axis1() { var x3 = np.arange(24).reshape(2, 3, 4); @@ -346,7 +347,7 @@ public void Roll_3D_Axis1() 20, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19); } - [Test] + [TestMethod] public void Roll_3D_Axis2() { var x3 = np.arange(24).reshape(2, 3, 4); @@ -359,7 +360,7 @@ public void Roll_3D_Axis2() 15, 12, 13, 14, 19, 16, 17, 18, 23, 20, 21, 22); } - [Test] + [TestMethod] public void Roll_3D_NegativeShift_Axis0() { // For 2-element dim, roll by -1 == roll by 1 @@ -372,7 +373,7 @@ public void Roll_3D_NegativeShift_Axis0() 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); } - [Test] + [TestMethod] public void Roll_3D_Shift2_Axis1() { var x3 = np.arange(24).reshape(2, 3, 4); @@ -385,7 +386,7 @@ public void Roll_3D_Shift2_Axis1() 16, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15); } - [Test] + [TestMethod] public void Roll_3D_NegativeAxis() { var x3 = np.arange(24).reshape(2, 3, 4); @@ -410,7 +411,7 @@ public void Roll_3D_NegativeAxis() // EMPTY ARRAYS // ================================================================ - [Test] + [TestMethod] public void Roll_EmptyArray_NoAxis() { // np.roll([], 1) => [] @@ -420,7 +421,7 @@ public void Roll_EmptyArray_NoAxis() result.ndim.Should().Be(1); } - [Test] + [TestMethod] public void Roll_EmptyArray_ZeroShift() { var x = np.array(new double[0]); @@ -428,7 +429,7 @@ public void Roll_EmptyArray_ZeroShift() result.size.Should().Be(0); } - [Test] + [TestMethod] public void Roll_EmptyArray_NegativeShift() { var x = np.array(new double[0]); @@ -436,7 +437,7 @@ public void Roll_EmptyArray_NegativeShift() result.size.Should().Be(0); } - [Test] + [TestMethod] public void Roll_Empty2D_NoAxis() { var x = np.empty(new Shape(0, 3)); @@ -444,7 +445,7 @@ public void Roll_Empty2D_NoAxis() result.Shape.dimensions.Should().BeEquivalentTo(new long[] { 0, 3 }); } - [Test] + [TestMethod] public void Roll_Empty2D_Axis0() { var x = np.empty(new Shape(0, 3)); @@ -452,7 +453,7 @@ public void Roll_Empty2D_Axis0() result.Shape.dimensions.Should().BeEquivalentTo(new long[] { 0, 3 }); } - [Test] + [TestMethod] [OpenBugs] public void Roll_Empty2D_Axis1() { @@ -470,7 +471,7 @@ public void Roll_Empty2D_Axis1() // SCALAR (0-dim) // ================================================================ - [Test] + [TestMethod] public void Roll_Scalar_ZeroShift() { // np.roll(np.array(42), 0) => array(42) @@ -482,7 +483,7 @@ public void Roll_Scalar_ZeroShift() result.GetInt32(0).Should().Be(42); } - [Test] + [TestMethod] public void Roll_Scalar_PositiveShift() { // np.roll(np.array(42), 1) => array(42) @@ -494,7 +495,7 @@ public void Roll_Scalar_PositiveShift() result.GetInt32(0).Should().Be(42); } - [Test] + [TestMethod] public void Roll_Scalar_NegativeShift() { // np.roll(np.array(42), -1) => array(42) @@ -510,7 +511,7 @@ public void Roll_Scalar_NegativeShift() // OUT-OF-BOUNDS AXIS // ================================================================ - [Test] + [TestMethod] public void Roll_OutOfBoundsAxis_Positive_Throws() { var x = np.arange(10); @@ -518,7 +519,7 @@ public void Roll_OutOfBoundsAxis_Positive_Throws() act.Should().Throw(); } - [Test] + [TestMethod] public void Roll_OutOfBoundsAxis_Negative_Throws() { var x = np.arange(10); @@ -526,7 +527,7 @@ public void Roll_OutOfBoundsAxis_Negative_Throws() act.Should().Throw(); } - [Test] + [TestMethod] public void Roll_Scalar_WithAxis_Throws() { // NumPy: axis 0 is out of bounds for array of dimension 0 @@ -539,7 +540,7 @@ public void Roll_Scalar_WithAxis_Throws() // ORIGINAL NOT MODIFIED (roll returns a copy) // ================================================================ - [Test] + [TestMethod] public void Roll_1D_DoesNotModifyOriginal() { var orig = np.arange(5); @@ -552,7 +553,7 @@ public void Roll_1D_DoesNotModifyOriginal() orig.Should().BeOfValues(0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Roll_2D_WithAxis_DoesNotModifyOriginal() { var orig = np.arange(6).reshape(2, 3); @@ -566,7 +567,7 @@ public void Roll_2D_WithAxis_DoesNotModifyOriginal() orig.GetInt64(1, 0).Should().Be(3); } - [Test] + [TestMethod] public void Roll_1D_MutatingResultDoesNotAffectOriginal() { var orig = np.arange(5); @@ -582,7 +583,7 @@ public void Roll_1D_MutatingResultDoesNotAffectOriginal() // SHIFT=0 RETURNS A COPY (not a view) // ================================================================ - [Test] + [TestMethod] public void Roll_ZeroShift_ReturnsCopy() { var a = np.arange(5); @@ -599,7 +600,7 @@ public void Roll_ZeroShift_ReturnsCopy() // SINGLE ELEMENT ARRAYS // ================================================================ - [Test] + [TestMethod] public void Roll_SingleElement_AnyShift() { var a = np.array(new long[] { 42 }); @@ -614,7 +615,7 @@ public void Roll_SingleElement_AnyShift() // DTYPE PRESERVATION // ================================================================ - [Test] + [TestMethod] public void Roll_PreservesDtype_Int32() { var a = np.array(new int[] { 1, 2, 3, 4, 5 }); @@ -623,7 +624,7 @@ public void Roll_PreservesDtype_Int32() r.Should().BeOfValues(4, 5, 1, 2, 3); } - [Test] + [TestMethod] public void Roll_PreservesDtype_Double() { var a = np.array(new double[] { 1.0, 2.0, 3.0, 4.0, 5.0 }); @@ -632,7 +633,7 @@ public void Roll_PreservesDtype_Double() r.Should().BeOfValues(4.0, 5.0, 1.0, 2.0, 3.0); } - [Test] + [TestMethod] public void Roll_PreservesDtype_Single() { var a = np.array(new float[] { 1f, 2f, 3f, 4f, 5f }); @@ -641,7 +642,7 @@ public void Roll_PreservesDtype_Single() r.Should().BeOfValues(4f, 5f, 1f, 2f, 3f); } - [Test] + [TestMethod] public void Roll_PreservesDtype_Int64() { var a = np.array(new long[] { 1L, 2L, 3L, 4L, 5L }); @@ -650,7 +651,7 @@ public void Roll_PreservesDtype_Int64() r.Should().BeOfValues(4L, 5L, 1L, 2L, 3L); } - [Test] + [TestMethod] public void Roll_PreservesDtype_Byte() { var a = np.array(new byte[] { 1, 2, 3, 4, 5 }); @@ -659,7 +660,7 @@ public void Roll_PreservesDtype_Byte() r.Should().BeOfValues((byte)4, (byte)5, (byte)1, (byte)2, (byte)3); } - [Test] + [TestMethod] public void Roll_PreservesDtype_Int16() { var a = np.array(new short[] { 1, 2, 3, 4, 5 }); @@ -668,7 +669,7 @@ public void Roll_PreservesDtype_Int16() r.Should().BeOfValues((short)4, (short)5, (short)1, (short)2, (short)3); } - [Test] + [TestMethod] public void Roll_PreservesDtype_UInt16() { var a = np.array(new ushort[] { 1, 2, 3, 4, 5 }); @@ -677,7 +678,7 @@ public void Roll_PreservesDtype_UInt16() r.Should().BeOfValues((ushort)4, (ushort)5, (ushort)1, (ushort)2, (ushort)3); } - [Test] + [TestMethod] public void Roll_PreservesDtype_UInt32() { var a = np.array(new uint[] { 1, 2, 3, 4, 5 }); @@ -686,7 +687,7 @@ public void Roll_PreservesDtype_UInt32() r.Should().BeOfValues(4u, 5u, 1u, 2u, 3u); } - [Test] + [TestMethod] public void Roll_PreservesDtype_UInt64() { var a = np.array(new ulong[] { 1, 2, 3, 4, 5 }); @@ -695,7 +696,7 @@ public void Roll_PreservesDtype_UInt64() r.Should().BeOfValues(4ul, 5ul, 1ul, 2ul, 3ul); } - [Test] + [TestMethod] public void Roll_PreservesDtype_Boolean() { var a = np.array(new bool[] { true, false, true, false, true }); @@ -705,7 +706,7 @@ public void Roll_PreservesDtype_Boolean() r.Should().BeOfValues(false, true, true, false, true); } - [Test] + [TestMethod] public void Roll_PreservesDtype_Boolean_Shift1() { var a = np.array(new bool[] { true, false, true, false, true }); @@ -715,7 +716,7 @@ public void Roll_PreservesDtype_Boolean_Shift1() r.Should().BeOfValues(true, true, false, true, false); } - [Test] + [TestMethod] public void Roll_PreservesDtype_Boolean_NegativeShift() { var a = np.array(new bool[] { true, false, true, false, true }); @@ -725,7 +726,7 @@ public void Roll_PreservesDtype_Boolean_NegativeShift() r.Should().BeOfValues(false, true, false, true, true); } - [Test] + [TestMethod] public void Roll_PreservesDtype_Char() { var a = np.array(new char[] { 'a', 'b', 'c', 'd', 'e' }); @@ -734,7 +735,7 @@ public void Roll_PreservesDtype_Char() r.Should().BeOfValues('d', 'e', 'a', 'b', 'c'); } - [Test] + [TestMethod] public void Roll_PreservesDtype_Decimal() { var a = np.array(new decimal[] { 1m, 2m, 3m, 4m, 5m }); @@ -747,7 +748,7 @@ public void Roll_PreservesDtype_Decimal() // SLICED ARRAYS (views) // ================================================================ - [Test] + [TestMethod] public void Roll_SlicedArray_1D() { // orig = [0,1,2,3,4,5,6,7,8,9] @@ -765,7 +766,7 @@ public void Roll_SlicedArray_1D() orig.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); } - [Test] + [TestMethod] public void Roll_SlicedArray_2D_Axis0() { // orig = arange(20).reshape(4,5) @@ -780,7 +781,7 @@ public void Roll_SlicedArray_2D_Axis0() result.Should().BeOfValues(10, 11, 12, 13, 14, 5, 6, 7, 8, 9); } - [Test] + [TestMethod] public void Roll_SlicedArray_2D_Axis1() { var orig = np.arange(20).reshape(4, 5); @@ -798,7 +799,7 @@ public void Roll_SlicedArray_2D_Axis1() // BROADCAST ARRAYS // ================================================================ - [Test] + [TestMethod] public void Roll_BroadcastArray_RowBroadcast_NoAxis() { // row = [[1,2,3,4,5]] broadcast to (3,5) @@ -814,7 +815,7 @@ public void Roll_BroadcastArray_RowBroadcast_NoAxis() result.Should().BeOfValues(5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Roll_BroadcastArray_RowBroadcast_Axis0() { // All rows identical, rolling along axis 0 just reorders identical rows @@ -828,7 +829,7 @@ public void Roll_BroadcastArray_RowBroadcast_Axis0() result.Should().BeOfValues(1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Roll_BroadcastArray_RowBroadcast_Axis1() { // Each row [1,2,3,4,5], rolled by 1 => [5,1,2,3,4] @@ -841,7 +842,7 @@ public void Roll_BroadcastArray_RowBroadcast_Axis1() result.Should().BeOfValues(5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Roll_BroadcastArray_RowBroadcast_NegativeAxis1() { // Each row [1,2,3,4,5], rolled by -1 => [2,3,4,5,1] @@ -854,7 +855,7 @@ public void Roll_BroadcastArray_RowBroadcast_NegativeAxis1() result.Should().BeOfValues(2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1); } - [Test] + [TestMethod] public void Roll_BroadcastArray_ColumnBroadcast_NoAxis() { // col = [[10],[20],[30]] broadcast to (3,4) @@ -870,7 +871,7 @@ public void Roll_BroadcastArray_ColumnBroadcast_NoAxis() result.Should().BeOfValues(30, 10, 10, 10, 10, 20, 20, 20, 20, 30, 30, 30); } - [Test] + [TestMethod] public void Roll_BroadcastArray_ColumnBroadcast_Axis0() { // col_bc: [[10,10,10,10],[20,20,20,20],[30,30,30,30]] @@ -884,7 +885,7 @@ public void Roll_BroadcastArray_ColumnBroadcast_Axis0() result.Should().BeOfValues(30, 30, 30, 30, 10, 10, 10, 10, 20, 20, 20, 20); } - [Test] + [TestMethod] public void Roll_BroadcastArray_ColumnBroadcast_Axis1() { // col_bc: [[10,10,10,10],[20,20,20,20],[30,30,30,30]] @@ -902,7 +903,7 @@ public void Roll_BroadcastArray_ColumnBroadcast_Axis1() // BOOLEAN 2D // ================================================================ - [Test] + [TestMethod] public void Roll_Bool2D_NoAxis() { // [[True, False],[False, True]] @@ -914,7 +915,7 @@ public void Roll_Bool2D_NoAxis() r.Should().BeOfValues(true, true, false, false); } - [Test] + [TestMethod] public void Roll_Bool2D_Axis0() { // [[True, False],[False, True]] @@ -925,7 +926,7 @@ public void Roll_Bool2D_Axis0() r.Should().BeOfValues(false, true, true, false); } - [Test] + [TestMethod] public void Roll_Bool2D_Axis1() { // [[True, False],[False, True]] @@ -940,7 +941,7 @@ public void Roll_Bool2D_Axis1() // INSTANCE METHODS: a.roll(shift, axis) and a.roll(shift) // ================================================================ - [Test] + [TestMethod] public void Roll_InstanceMethod_NoAxis() { var x = np.arange(10); @@ -950,7 +951,7 @@ public void Roll_InstanceMethod_NoAxis() result.Should().BeOfValues(8, 9, 0, 1, 2, 3, 4, 5, 6, 7); } - [Test] + [TestMethod] public void Roll_InstanceMethod_WithAxis() { var x = np.arange(10).reshape(2, 5); @@ -960,7 +961,7 @@ public void Roll_InstanceMethod_WithAxis() result.Should().BeOfValues(5, 6, 7, 8, 9, 0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Roll_InstanceMethod_WithAxis1() { var x = np.arange(10).reshape(2, 5); @@ -970,7 +971,7 @@ public void Roll_InstanceMethod_WithAxis1() result.Should().BeOfValues(4, 0, 1, 2, 3, 9, 5, 6, 7, 8); } - [Test] + [TestMethod] public void Roll_InstanceMethod_EquivalentToStaticMethod() { var x = np.arange(12).reshape(3, 4); @@ -988,7 +989,7 @@ public void Roll_InstanceMethod_EquivalentToStaticMethod() // 1D ARRAY WITH axis=0 // ================================================================ - [Test] + [TestMethod] public void Roll_1D_WithAxis0() { // np.roll(np.arange(5), 2, axis=0) => [3 4 0 1 2] @@ -1003,7 +1004,7 @@ public void Roll_1D_WithAxis0() // NumPy test_roll_empty (exact match) // ================================================================ - [Test] + [TestMethod] public void Roll_NumPy_test_roll_empty() { var x = np.array(new double[0]); @@ -1015,7 +1016,7 @@ public void Roll_NumPy_test_roll_empty() // SHAPE PRESERVATION // ================================================================ - [Test] + [TestMethod] public void Roll_2D_PreservesShape_NoAxis() { var x = np.arange(12).reshape(3, 4); @@ -1023,7 +1024,7 @@ public void Roll_2D_PreservesShape_NoAxis() result.Should().BeShaped(3, 4); } - [Test] + [TestMethod] public void Roll_3D_PreservesShape_NoAxis() { var x = np.arange(24).reshape(2, 3, 4); @@ -1031,7 +1032,7 @@ public void Roll_3D_PreservesShape_NoAxis() result.Should().BeShaped(2, 3, 4); } - [Test] + [TestMethod] public void Roll_2D_PreservesShape_WithAxis() { var x = np.arange(12).reshape(3, 4); @@ -1043,7 +1044,7 @@ public void Roll_2D_PreservesShape_WithAxis() // DTYPE PRESERVATION FOR 2D WITH AXIS // ================================================================ - [Test] + [TestMethod] public void Roll_2D_PreservesDtype_Float() { var a = np.array(new float[,] { { 1f, 2f, 3f }, { 4f, 5f, 6f } }); @@ -1051,7 +1052,7 @@ public void Roll_2D_PreservesDtype_Float() r.typecode.Should().Be(NPTypeCode.Single); } - [Test] + [TestMethod] public void Roll_2D_PreservesDtype_Double() { var a = np.array(new double[,] { { 1.0, 2.0, 3.0 }, { 4.0, 5.0, 6.0 } }); @@ -1065,7 +1066,7 @@ public void Roll_2D_PreservesDtype_Double() // since NumSharp only supports single int shift / single int axis. // ================================================================ - [Test] + [TestMethod] public void Roll_MultiAxis_ScalarShift_TupleAxis() { // NumPy: np.roll(x2, 1, axis=(0,1)) @@ -1084,7 +1085,7 @@ public void Roll_MultiAxis_ScalarShift_TupleAxis() result.Should().BeOfValues(9, 5, 6, 7, 8, 4, 0, 1, 2, 3); } - [Test] + [TestMethod] public void Roll_MultiAxis_TupleShift_TupleAxis() { // NumPy: np.roll(x2, (1, 0), axis=(0, 1)) @@ -1102,7 +1103,7 @@ public void Roll_MultiAxis_TupleShift_TupleAxis() result.Should().BeOfValues(5, 6, 7, 8, 9, 0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Roll_MultiAxis_NegativeShift_TupleAxis() { // NumPy: np.roll(x2, (-1, 0), axis=(0, 1)) @@ -1117,7 +1118,7 @@ public void Roll_MultiAxis_NegativeShift_TupleAxis() result.Should().BeOfValues(5, 6, 7, 8, 9, 0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Roll_MultiAxis_BothShift1() { // NumPy: np.roll(x2, (1, 1), axis=(0, 1)) @@ -1131,7 +1132,7 @@ public void Roll_MultiAxis_BothShift1() result.Should().BeOfValues(9, 5, 6, 7, 8, 4, 0, 1, 2, 3); } - [Test] + [TestMethod] public void Roll_MultiAxis_BothNegative() { // NumPy: np.roll(x2, (-1, -1), axis=(0, 1)) @@ -1145,7 +1146,7 @@ public void Roll_MultiAxis_BothNegative() result.Should().BeOfValues(6, 7, 8, 9, 5, 1, 2, 3, 4, 0); } - [Test] + [TestMethod] public void Roll_MultiAxis_SameAxis_Twice() { // NumPy: np.roll(x2, 1, axis=(0, 0)) @@ -1161,7 +1162,7 @@ public void Roll_MultiAxis_SameAxis_Twice() result.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); } - [Test] + [TestMethod] public void Roll_MultiAxis_SameAxis1_Twice() { // NumPy: np.roll(x2, 1, axis=(1, 1)) @@ -1176,7 +1177,7 @@ public void Roll_MultiAxis_SameAxis1_Twice() result.Should().BeOfValues(3, 4, 0, 1, 2, 8, 9, 5, 6, 7); } - [Test] + [TestMethod] public void Roll_MultiAxis_ZeroAndOne() { // NumPy: np.roll(x2, (0, 1), axis=(0, 1)) @@ -1191,7 +1192,7 @@ public void Roll_MultiAxis_ZeroAndOne() result.Should().BeOfValues(4, 0, 1, 2, 3, 9, 5, 6, 7, 8); } - [Test] + [TestMethod] public void Roll_MultiAxis_ZeroAndNegative() { // NumPy: np.roll(x2, (0, -1), axis=(0, 1)) @@ -1210,7 +1211,7 @@ public void Roll_MultiAxis_ZeroAndNegative() // DOUBLE VALUES (not just integers) // ================================================================ - [Test] + [TestMethod] public void Roll_1D_DoubleValues() { var a = np.array(new double[] { 1.5, 2.5, 3.5, 4.5, 5.5 }); @@ -1218,7 +1219,7 @@ public void Roll_1D_DoubleValues() r.Should().BeOfValues(4.5, 5.5, 1.5, 2.5, 3.5); } - [Test] + [TestMethod] public void Roll_2D_DoubleValues_WithAxis() { var a = np.array(new double[,] { { 1.1, 2.2, 3.3 }, { 4.4, 5.5, 6.6 } }); @@ -1230,7 +1231,7 @@ public void Roll_2D_DoubleValues_WithAxis() // REGRESSION: Existing tests from NdArray.Roll.Test.cs (re-verified) // ================================================================ - [Test] + [TestMethod] public void Roll_Regression_Base1DTest_Positive() { NDArray nd1 = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; @@ -1241,7 +1242,7 @@ public void Roll_Regression_Base1DTest_Positive() nd1.Should().BeOfValues(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0); } - [Test] + [TestMethod] public void Roll_Regression_Base1DTest_Negative() { NDArray nd1 = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; @@ -1251,7 +1252,7 @@ public void Roll_Regression_Base1DTest_Negative() nd1.Should().BeOfValues(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0); } - [Test] + [TestMethod] public void Roll_Regression_Base2DTest_ShapePreserved() { var nd1 = np.arange(10).reshape(2, 5); @@ -1262,7 +1263,7 @@ public void Roll_Regression_Base2DTest_ShapePreserved() nd3.Should().BeShaped(2, 5); } - [Test] + [TestMethod] public void Roll_Regression_RollWithAxis0() { var x2 = np.arange(10).reshape(2, 5); @@ -1272,7 +1273,7 @@ public void Roll_Regression_RollWithAxis0() x3.Should().BeOfValues(5, 6, 7, 8, 9, 0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Roll_Regression_RollWithAxis1() { var x2 = np.arange(10).reshape(2, 5); @@ -1286,7 +1287,7 @@ public void Roll_Regression_RollWithAxis1() // EDGE CASES // ================================================================ - [Test] + [TestMethod] public void Roll_LargeArray() { // Test with a larger array to ensure no off-by-one errors @@ -1300,7 +1301,7 @@ public void Roll_LargeArray() r.size.Should().Be(100); } - [Test] + [TestMethod] public void Roll_2D_LargeShift_Axis0() { // shift > dim size should wrap correctly @@ -1311,7 +1312,7 @@ public void Roll_2D_LargeShift_Axis0() np.array_equal(r, expected).Should().BeTrue(); } - [Test] + [TestMethod] public void Roll_2D_LargeNegativeShift_Axis1() { // shift < -dim_size should wrap correctly @@ -1322,7 +1323,7 @@ public void Roll_2D_LargeNegativeShift_Axis1() np.array_equal(r, expected).Should().BeTrue(); } - [Test] + [TestMethod] public void Roll_2D_ShiftEqualsAxisDim() { // shift == dim size => no change (same values) @@ -1331,7 +1332,7 @@ public void Roll_2D_ShiftEqualsAxisDim() np.array_equal(r, x).Should().BeTrue(); } - [Test] + [TestMethod] public void Roll_3D_ShiftEqualsAxisDim() { var x = np.arange(24).reshape(2, 3, 4); @@ -1343,7 +1344,7 @@ public void Roll_3D_ShiftEqualsAxisDim() // ASYMMETRIC 2D SHAPES // ================================================================ - [Test] + [TestMethod] public void Roll_2D_TallArray() { // 5x2 array @@ -1357,7 +1358,7 @@ public void Roll_2D_TallArray() r.Should().BeOfValues(6, 7, 8, 9, 0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Roll_2D_WideArray() { // 2x6 array diff --git a/test/NumSharp.UnitTest/Manipulation/np.rollaxis.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.rollaxis.Test.cs index 3ea706ad0..2f8d4624a 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.rollaxis.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.rollaxis.Test.cs @@ -3,9 +3,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class np_rollaxis_Test { - [Test] + [TestMethod] public void Case1() { var a = np.ones((3, 4, 5, 6)); diff --git a/test/NumSharp.UnitTest/Manipulation/np.split.BattleTest.cs b/test/NumSharp.UnitTest/Manipulation/np.split.BattleTest.cs index efc7dfbd4..381f5f09c 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.split.BattleTest.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.split.BattleTest.cs @@ -7,11 +7,12 @@ namespace NumSharp.UnitTest.Manipulation; /// Battle tests for np.hsplit, np.vsplit, np.dsplit to ensure NumPy alignment. /// Based on NumPy 2.4.2 behavior. /// +[TestClass] public class SplitBattleTests : TestClass { #region hsplit tests - [Test] + [TestMethod] public void Hsplit_2D_SplitsColumns() { // NumPy: a = np.arange(16).reshape(4,4); np.hsplit(a, 2) @@ -36,7 +37,7 @@ public void Hsplit_2D_SplitsColumns() Assert.AreEqual(7, (int)result[1][1, 1]); } - [Test] + [TestMethod] public void Hsplit_1D_SplitsAlongAxis0() { // NumPy: a = np.arange(6); np.hsplit(a, 3) @@ -57,7 +58,7 @@ public void Hsplit_1D_SplitsAlongAxis0() Assert.AreEqual(5, (int)result[2][1]); } - [Test] + [TestMethod] public void Hsplit_3D_SplitsAlongAxis1() { // NumPy: a = np.arange(24).reshape(2, 4, 3); np.hsplit(a, 2) @@ -70,7 +71,7 @@ public void Hsplit_3D_SplitsAlongAxis1() result[1].Should().BeShaped(2, 2, 3); } - [Test] + [TestMethod] public void Hsplit_WithIndices() { // NumPy: a = np.arange(16).reshape(4,4); np.hsplit(a, [1, 3]) @@ -84,7 +85,7 @@ public void Hsplit_WithIndices() result[2].Should().BeShaped(4, 1); } - [Test] + [TestMethod] public void Hsplit_0D_ThrowsArgumentException() { // NumPy: np.hsplit(np.array(5), 1) raises ValueError @@ -96,7 +97,7 @@ public void Hsplit_0D_ThrowsArgumentException() #region vsplit tests - [Test] + [TestMethod] public void Vsplit_2D_SplitsRows() { // NumPy: a = np.arange(16).reshape(4,4); np.vsplit(a, 2) @@ -121,7 +122,7 @@ public void Vsplit_2D_SplitsRows() Assert.AreEqual(15, (int)result[1][1, 3]); } - [Test] + [TestMethod] public void Vsplit_3D_SplitsAlongAxis0() { // NumPy: a = np.arange(8).reshape(2, 2, 2); np.vsplit(a, 2) @@ -134,7 +135,7 @@ public void Vsplit_3D_SplitsAlongAxis0() result[1].Should().BeShaped(1, 2, 2); } - [Test] + [TestMethod] public void Vsplit_WithIndices() { // NumPy: a = np.arange(16).reshape(4,4); np.vsplit(a, [3, 6]) @@ -148,7 +149,7 @@ public void Vsplit_WithIndices() result[2].Should().BeShaped(0, 4); // Empty array } - [Test] + [TestMethod] public void Vsplit_1D_ThrowsArgumentException() { // NumPy: np.vsplit(np.arange(6), 2) raises ValueError @@ -160,7 +161,7 @@ public void Vsplit_1D_ThrowsArgumentException() #region dsplit tests - [Test] + [TestMethod] public void Dsplit_3D_SplitsDepth() { // NumPy: a = np.arange(24).reshape(2, 3, 4); np.dsplit(a, 2) @@ -173,7 +174,7 @@ public void Dsplit_3D_SplitsDepth() result[1].Should().BeShaped(2, 3, 2); } - [Test] + [TestMethod] public void Dsplit_4D_SplitsAlongAxis2() { // NumPy: a = np.arange(48).reshape(2, 3, 4, 2); np.dsplit(a, 2) @@ -186,7 +187,7 @@ public void Dsplit_4D_SplitsAlongAxis2() result[1].Should().BeShaped(2, 3, 2, 2); } - [Test] + [TestMethod] public void Dsplit_WithIndices() { // NumPy: a = np.arange(16).reshape(2, 2, 4); np.dsplit(a, [3, 6]) @@ -200,7 +201,7 @@ public void Dsplit_WithIndices() result[2].Should().BeShaped(2, 2, 0); // Empty array } - [Test] + [TestMethod] public void Dsplit_2D_ThrowsArgumentException() { // NumPy: np.dsplit(np.arange(16).reshape(4,4), 2) raises ValueError @@ -208,7 +209,7 @@ public void Dsplit_2D_ThrowsArgumentException() Assert.ThrowsException(() => np.dsplit(a, 2)); } - [Test] + [TestMethod] public void Dsplit_1D_ThrowsArgumentException() { // NumPy: np.dsplit(np.arange(6), 2) raises ValueError diff --git a/test/NumSharp.UnitTest/Manipulation/np.split.Tests.cs b/test/NumSharp.UnitTest/Manipulation/np.split.Tests.cs index 5263304a9..354906f81 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.split.Tests.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.split.Tests.cs @@ -9,11 +9,12 @@ namespace NumSharp.UnitTest.Manipulation /// Tests for np.split and np.array_split functions. /// Based on NumPy 2.4.2 behavior. /// + [TestClass] public class np_split_Tests : TestClass { #region np.split - Equal Division - [Test] + [TestMethod] public void Split_1D_EqualParts() { // NumPy: np.split(np.arange(9), 3) -> [array([0, 1, 2]), array([3, 4, 5]), array([6, 7, 8])] @@ -26,7 +27,7 @@ public void Split_1D_EqualParts() result[2].ToArray().Should().ContainInOrder(6, 7, 8); } - [Test] + [TestMethod] public void Split_1D_UnequalDivision_ThrowsArgumentException() { // NumPy: np.split(np.arange(9), 4) raises ValueError @@ -35,7 +36,7 @@ public void Split_1D_UnequalDivision_ThrowsArgumentException() Assert.ThrowsException(() => np.split(a, 4)); } - [Test] + [TestMethod] public void Split_2D_Axis0() { // NumPy: np.split(np.arange(12).reshape(3, 4), 3, axis=0) @@ -49,7 +50,7 @@ public void Split_2D_Axis0() result[2].Should().BeShaped(1, 4); } - [Test] + [TestMethod] public void Split_2D_Axis1() { // NumPy: np.split(np.arange(12).reshape(3, 4), 2, axis=1) @@ -69,7 +70,7 @@ public void Split_2D_Axis1() result[1]["1, :"].ToArray().Should().ContainInOrder(6, 7); } - [Test] + [TestMethod] public void Split_NegativeAxis() { // NumPy: np.split(d, 3, axis=-2) == np.split(d, 3, axis=0) @@ -88,7 +89,7 @@ public void Split_NegativeAxis() #region np.split - With Indices - [Test] + [TestMethod] public void Split_WithIndices() { // NumPy: np.split(a, [3, 5, 7]) -> a[:3], a[3:5], a[5:7], a[7:] @@ -102,7 +103,7 @@ public void Split_WithIndices() result[3].ToArray().Should().ContainInOrder(7, 8); } - [Test] + [TestMethod] public void Split_WithIndices_EmptyAtStart() { // NumPy: np.split(a, [0, 3, 6]) -> [], a[:3], a[3:6], a[6:] @@ -116,7 +117,7 @@ public void Split_WithIndices_EmptyAtStart() result[3].size.Should().Be(3); } - [Test] + [TestMethod] public void Split_WithIndices_DuplicateIndices() { // NumPy: np.split(a, [3, 3, 6]) -> a[:3], [], a[3:6], a[6:] @@ -130,7 +131,7 @@ public void Split_WithIndices_DuplicateIndices() result[3].size.Should().Be(3); } - [Test] + [TestMethod] public void Split_WithIndices_EmptyIndicesArray() { // NumPy: np.split(a, []) -> [a] @@ -145,7 +146,7 @@ public void Split_WithIndices_EmptyIndicesArray() #region np.array_split - Unequal Division - [Test] + [TestMethod] public void ArraySplit_UnequalDivision_9Into4() { // NumPy: np.array_split(np.arange(9), 4) @@ -161,7 +162,7 @@ public void ArraySplit_UnequalDivision_9Into4() result[3].size.Should().Be(2); } - [Test] + [TestMethod] public void ArraySplit_UnequalDivision_10Into3() { // NumPy: np.array_split(np.arange(10), 3) @@ -176,7 +177,7 @@ public void ArraySplit_UnequalDivision_10Into3() result[2].size.Should().Be(3); } - [Test] + [TestMethod] public void ArraySplit_UnequalDivision_8Into3() { // NumPy: np.array_split(np.arange(8), 3) @@ -191,7 +192,7 @@ public void ArraySplit_UnequalDivision_8Into3() result[2].size.Should().Be(2); // 8//3 = 2 } - [Test] + [TestMethod] public void ArraySplit_2D_UnequalAxis0() { // NumPy: np.array_split(np.arange(12).reshape(3, 4), 2, axis=0) @@ -204,7 +205,7 @@ public void ArraySplit_2D_UnequalAxis0() result[1].Should().BeShaped(1, 4); } - [Test] + [TestMethod] public void ArraySplit_MoreSectionsThanElements() { // NumPy: np.array_split(np.array([1,2,3]), 5) @@ -220,7 +221,7 @@ public void ArraySplit_MoreSectionsThanElements() result[4].size.Should().Be(0); } - [Test] + [TestMethod] public void ArraySplit_ZeroSections_ThrowsArgumentException() { // NumPy: np.array_split(a, 0) raises ValueError @@ -229,7 +230,7 @@ public void ArraySplit_ZeroSections_ThrowsArgumentException() Assert.ThrowsException(() => np.array_split(a, 0)); } - [Test] + [TestMethod] public void ArraySplit_NegativeSections_ThrowsArgumentException() { // NumPy: np.array_split(a, -1) raises ValueError @@ -242,7 +243,7 @@ public void ArraySplit_NegativeSections_ThrowsArgumentException() #region Edge Cases - [Test] + [TestMethod] public void Split_SingleElement() { var single = np.array(new[] { 42 }); @@ -252,7 +253,7 @@ public void Split_SingleElement() result[0].ToArray().Should().ContainInOrder(42); } - [Test] + [TestMethod] public void Split_EmptyArray() { var empty = np.array(new double[0]); @@ -262,7 +263,7 @@ public void Split_EmptyArray() result[0].size.Should().Be(0); } - [Test] + [TestMethod] public void ArraySplit_EmptyArray_MultipleSections() { var empty = np.array(new double[0]); @@ -275,7 +276,7 @@ public void ArraySplit_EmptyArray_MultipleSections() } } - [Test] + [TestMethod] public void Split_3D_Array() { // NumPy: np.split(np.arange(24).reshape(2, 3, 4), 2, axis=0) @@ -287,7 +288,7 @@ public void Split_3D_Array() result[1].Should().BeShaped(1, 3, 4); } - [Test] + [TestMethod] public void Split_ReturnsViews() { // NumPy: split returns views, not copies @@ -299,7 +300,7 @@ public void Split_ReturnsViews() a.GetInt64(0).Should().Be(999); } - [Test] + [TestMethod] public void Split_DifferentDtypes() { // Test with float64 diff --git a/test/NumSharp.UnitTest/Manipulation/np.stack.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.stack.Test.cs index 259ca86c3..ac5894ec7 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.stack.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.stack.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.Manipulation /// /// Tests following https://numpy.org/doc/stable/reference/generated/numpy.dstack.html /// + [TestClass] public class np_stack_tests { - [Test] + [TestMethod] public void Case1() { //1D diff --git a/test/NumSharp.UnitTest/Manipulation/np.swapaxes.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.swapaxes.Test.cs index 0413a9201..f242fb33f 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.swapaxes.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.swapaxes.Test.cs @@ -3,9 +3,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class np_swapaxes_Test { - [Test] + [TestMethod] public void Case1() { var nd = np.array(1, 2, 3, 4).reshape(2, 2, 1); @@ -13,7 +14,7 @@ public void Case1() .BeOfValues(1, 3, 2, 4).And.BeShaped(1, 2, 2); } - [Test] + [TestMethod] public void Case2() { var nd = np.arange(3 * 2 * 4).reshape(3, 2, 4); @@ -22,7 +23,7 @@ public void Case2() .And.BeShaped(2, 3, 4); } - [Test] + [TestMethod] public void Case3() { var nd = np.arange(3 * 2 * 4).reshape(3, 2, 4); @@ -31,7 +32,7 @@ public void Case3() .And.BeShaped(4, 2, 3); } - [Test] + [TestMethod] public void Case4() { var nd = np.array(1, 2, 3).reshape(1, 3); @@ -40,7 +41,7 @@ public void Case4() .And.BeShaped(3, 1); } - [Test] + [TestMethod] public void Case5() { var nd = np.arange(8).reshape(2, 2, 2); diff --git a/test/NumSharp.UnitTest/Manipulation/np.transpose.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.transpose.Test.cs index e7d66c289..3aa07d570 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.transpose.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.transpose.Test.cs @@ -3,9 +3,10 @@ namespace NumSharp.UnitTest.Manipulation { + [TestClass] public class np_transpose_Test { - [Test] + [TestMethod] public void Case1() { var nd = np.array(1, 2, 3, 4).reshape(2, 2); @@ -13,7 +14,7 @@ public void Case1() .BeOfValues(1, 3, 2, 4).And.BeShaped(2, 2); } - [Test] + [TestMethod] public void Case2() { var nd = np.arange(3 * 2 * 4).reshape(3, 2, 4); @@ -22,7 +23,7 @@ public void Case2() .And.BeShaped(4, 2, 3); } - [Test] + [TestMethod] public void Case3() { var nd = np.arange(2 * 3).reshape(1, 2, 3); @@ -31,7 +32,7 @@ public void Case3() .And.BeShaped(2, 1, 3); } - [Test] + [TestMethod] public void Case4() { var nd = np.arange(12).reshape(6, 2); @@ -41,7 +42,7 @@ public void Case4() } - [Test] + [TestMethod] public void Case5() { var nd = np.broadcast_arrays(np.array(1), np.arange(9).reshape(3,3)).Lhs; diff --git a/test/NumSharp.UnitTest/Manipulation/np.unique.EdgeCases.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.unique.EdgeCases.Test.cs index 0aca5fc36..c0faaf21d 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.unique.EdgeCases.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.unique.EdgeCases.Test.cs @@ -3,7 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.Backends; -using TUnit.Core; namespace NumSharp.UnitTest.Manipulation; @@ -11,11 +10,12 @@ namespace NumSharp.UnitTest.Manipulation; /// Comprehensive edge case tests for np.unique sorting fix (commit c0eed5d1). /// Verifies that np.unique returns SORTED unique values, matching NumPy 2.x behavior. /// +[TestClass] public class np_unique_EdgeCases_Test { #region Empty Arrays - [Test] + [TestMethod] public void Unique_EmptyArray_Int32() { // >>> np.unique(np.array([], dtype=np.int32)) @@ -28,7 +28,7 @@ public void Unique_EmptyArray_Int32() result.dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void Unique_EmptyArray_Double() { var arr = np.array(Array.Empty()); @@ -38,7 +38,7 @@ public void Unique_EmptyArray_Double() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Unique_EmptyArray_Boolean() { var arr = np.array(Array.Empty()); @@ -52,7 +52,7 @@ public void Unique_EmptyArray_Boolean() #region Single Element - [Test] + [TestMethod] public void Unique_SingleElement_Int32() { // >>> np.unique(np.array([42])) @@ -63,7 +63,7 @@ public void Unique_SingleElement_Int32() result.Should().BeShaped(1).And.BeOfValues(42); } - [Test] + [TestMethod] public void Unique_SingleElement_Double() { var arr = np.array(new double[] { 3.14 }); @@ -72,7 +72,7 @@ public void Unique_SingleElement_Double() result.Should().BeShaped(1).And.BeOfValues(3.14); } - [Test] + [TestMethod] public void Unique_SingleElement_Boolean_True() { var arr = np.array(new bool[] { true }); @@ -81,7 +81,7 @@ public void Unique_SingleElement_Boolean_True() result.Should().BeShaped(1).And.BeOfValues(true); } - [Test] + [TestMethod] public void Unique_SingleElement_Boolean_False() { var arr = np.array(new bool[] { false }); @@ -94,7 +94,7 @@ public void Unique_SingleElement_Boolean_False() #region All Duplicates - [Test] + [TestMethod] public void Unique_AllDuplicates_Int32() { // >>> np.unique(np.array([5, 5, 5, 5])) @@ -105,7 +105,7 @@ public void Unique_AllDuplicates_Int32() result.Should().BeShaped(1).And.BeOfValues(5); } - [Test] + [TestMethod] public void Unique_AllDuplicates_Double() { var arr = np.array(new double[] { 2.71, 2.71, 2.71 }); @@ -114,7 +114,7 @@ public void Unique_AllDuplicates_Double() result.Should().BeShaped(1).And.BeOfValues(2.71); } - [Test] + [TestMethod] public void Unique_AllDuplicates_Boolean_AllTrue() { // >>> np.unique(np.array([True, True, True])) @@ -125,7 +125,7 @@ public void Unique_AllDuplicates_Boolean_AllTrue() result.Should().BeShaped(1).And.BeOfValues(true); } - [Test] + [TestMethod] public void Unique_AllDuplicates_Boolean_AllFalse() { // >>> np.unique(np.array([False, False, False])) @@ -140,7 +140,7 @@ public void Unique_AllDuplicates_Boolean_AllFalse() #region Boolean Arrays - [Test] + [TestMethod] public void Unique_Boolean_MixedValues() { // >>> np.unique(np.array([True, False, True, False, True])) @@ -159,7 +159,7 @@ public void Unique_Boolean_MixedValues() #region All 12 Supported Dtypes - [Test] + [TestMethod] public void Unique_AllDtypes_Byte() { var arr = np.array(new byte[] { 3, 1, 2, 1 }); @@ -169,7 +169,7 @@ public void Unique_AllDtypes_Byte() result.dtype.Should().Be(typeof(byte)); } - [Test] + [TestMethod] public void Unique_AllDtypes_Int16() { var arr = np.array(new short[] { 3, 1, 2, 1 }); @@ -179,7 +179,7 @@ public void Unique_AllDtypes_Int16() result.dtype.Should().Be(typeof(short)); } - [Test] + [TestMethod] public void Unique_AllDtypes_UInt16() { var arr = np.array(new ushort[] { 3, 1, 2, 1 }); @@ -189,7 +189,7 @@ public void Unique_AllDtypes_UInt16() result.dtype.Should().Be(typeof(ushort)); } - [Test] + [TestMethod] public void Unique_AllDtypes_Int32() { var arr = np.array(new int[] { 3, 1, 2, 1 }); @@ -199,7 +199,7 @@ public void Unique_AllDtypes_Int32() result.dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void Unique_AllDtypes_UInt32() { var arr = np.array(new uint[] { 3, 1, 2, 1 }); @@ -209,7 +209,7 @@ public void Unique_AllDtypes_UInt32() result.dtype.Should().Be(typeof(uint)); } - [Test] + [TestMethod] public void Unique_AllDtypes_Int64() { var arr = np.array(new long[] { 3, 1, 2, 1 }); @@ -219,7 +219,7 @@ public void Unique_AllDtypes_Int64() result.dtype.Should().Be(typeof(long)); } - [Test] + [TestMethod] public void Unique_AllDtypes_UInt64() { var arr = np.array(new ulong[] { 3, 1, 2, 1 }); @@ -229,7 +229,7 @@ public void Unique_AllDtypes_UInt64() result.dtype.Should().Be(typeof(ulong)); } - [Test] + [TestMethod] public void Unique_AllDtypes_Char() { var arr = np.array(new char[] { 'c', 'a', 'b', 'a' }); @@ -239,7 +239,7 @@ public void Unique_AllDtypes_Char() result.dtype.Should().Be(typeof(char)); } - [Test] + [TestMethod] public void Unique_AllDtypes_Single() { var arr = np.array(new float[] { 3.0f, 1.0f, 2.0f, 1.0f }); @@ -249,7 +249,7 @@ public void Unique_AllDtypes_Single() result.dtype.Should().Be(typeof(float)); } - [Test] + [TestMethod] public void Unique_AllDtypes_Double() { var arr = np.array(new double[] { 3.0, 1.0, 2.0, 1.0 }); @@ -259,7 +259,7 @@ public void Unique_AllDtypes_Double() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Unique_AllDtypes_Decimal() { var arr = np.array(new decimal[] { 3.0m, 1.0m, 2.0m, 1.0m }); @@ -273,7 +273,7 @@ public void Unique_AllDtypes_Decimal() #region NaN and Infinity (Float Types) - [Test] + [TestMethod] public void Unique_NaN_Double() { // >>> np.unique(np.array([1.0, np.nan, 2.0, np.nan, 1.0, np.inf, -np.inf])) @@ -293,7 +293,7 @@ public void Unique_NaN_Double() double.IsNaN(result.GetDouble(4)).Should().BeTrue(); } - [Test] + [TestMethod] public void Unique_NaN_Single() { // >>> np.unique(np.array([1.0, np.nan, 2.0, np.nan], dtype=np.float32)) @@ -307,7 +307,7 @@ public void Unique_NaN_Single() float.IsNaN(result.GetSingle(2)).Should().BeTrue(); } - [Test] + [TestMethod] public void Unique_Infinity_Only() { var arr = np.array(new double[] { double.PositiveInfinity, double.NegativeInfinity, double.PositiveInfinity }); @@ -318,7 +318,7 @@ public void Unique_Infinity_Only() result.GetDouble(1).Should().Be(double.PositiveInfinity); } - [Test] + [TestMethod] public void Unique_AllNaN() { // All NaN values should deduplicate to one @@ -333,7 +333,7 @@ public void Unique_AllNaN() #region Sliced/Non-Contiguous Arrays - [Test] + [TestMethod] public void Unique_SlicedArray_Column() { // Slicing a column creates a non-contiguous view @@ -345,7 +345,7 @@ public void Unique_SlicedArray_Column() result.Should().BeShaped(4).And.BeOfValues(0L, 5L, 10L, 15L); } - [Test] + [TestMethod] public void Unique_SlicedArray_StridedSlice() { // >>> arr = np.arange(20).reshape(4, 5) @@ -359,7 +359,7 @@ public void Unique_SlicedArray_StridedSlice() result.Should().BeShaped(4).And.BeOfValues(1L, 3L, 11L, 13L); } - [Test] + [TestMethod] public void Unique_SlicedArray_WithDuplicates() { // Create array with duplicates, then slice @@ -371,7 +371,7 @@ public void Unique_SlicedArray_WithDuplicates() result.Should().BeShaped(2).And.BeOfValues(3, 5); } - [Test] + [TestMethod] public void Unique_ReversedArray() { // >>> np.unique(np.array([9, 7, 5, 3, 1])[::-1]) @@ -388,7 +388,7 @@ public void Unique_ReversedArray() #region Negative Values - [Test] + [TestMethod] public void Unique_NegativeValues_Int32() { // >>> np.unique(np.array([-3, -1, -2, 0, 1, -1])) @@ -399,7 +399,7 @@ public void Unique_NegativeValues_Int32() result.Should().BeShaped(5).And.BeOfValues(-3, -2, -1, 0, 1); } - [Test] + [TestMethod] public void Unique_NegativeValues_Double() { var arr = np.array(new double[] { -3.5, -1.5, -2.5, 0.0, 1.5, -1.5 }); @@ -408,7 +408,7 @@ public void Unique_NegativeValues_Double() result.Should().BeShaped(5).And.BeOfValues(-3.5, -2.5, -1.5, 0.0, 1.5); } - [Test] + [TestMethod] public void Unique_AllNegative() { var arr = np.array(new int[] { -5, -3, -1, -3, -5 }); @@ -421,7 +421,7 @@ public void Unique_AllNegative() #region Large Values (Boundary Conditions) - [Test] + [TestMethod] public void Unique_LargeValues_Int64() { // >>> np.unique(np.array([2**62, -2**62, 0, 2**62], dtype=np.int64)) @@ -433,7 +433,7 @@ public void Unique_LargeValues_Int64() result.Should().BeShaped(3).And.BeOfValues(-large, 0L, large); } - [Test] + [TestMethod] public void Unique_LargeValues_UInt64() { ulong large = 1UL << 62; @@ -443,7 +443,7 @@ public void Unique_LargeValues_UInt64() result.Should().BeShaped(3).And.BeOfValues(0UL, large, ulong.MaxValue); } - [Test] + [TestMethod] public void Unique_MinMaxValues_Int32() { var arr = np.array(new int[] { int.MaxValue, int.MinValue, 0, int.MaxValue }); @@ -456,7 +456,7 @@ public void Unique_MinMaxValues_Int32() #region Sorting Verification - [Test] + [TestMethod] public void Unique_VerifySorting_UnsortedInput() { // This is the core test for the sorting fix @@ -468,7 +468,7 @@ public void Unique_VerifySorting_UnsortedInput() result.Should().BeShaped(5).And.BeOfValues(1, 2, 5, 8, 9); } - [Test] + [TestMethod] public void Unique_VerifySorting_ReverseInput() { // Input is in reverse order - verify output is sorted ascending @@ -478,7 +478,7 @@ public void Unique_VerifySorting_ReverseInput() result.Should().BeShaped(5).And.BeOfValues(2, 4, 6, 8, 10); } - [Test] + [TestMethod] public void Unique_VerifySorting_AlreadySorted() { // Input already sorted - verify it stays sorted @@ -492,7 +492,7 @@ public void Unique_VerifySorting_AlreadySorted() #region Multidimensional Arrays - [Test] + [TestMethod] public void Unique_2DArray_Flattens() { // np.unique flattens multidimensional arrays @@ -505,7 +505,7 @@ public void Unique_2DArray_Flattens() result.Should().BeShaped(3).And.BeOfValues(1, 2, 3); } - [Test] + [TestMethod] public void Unique_3DArray_Flattens() { var arr = np.array(new int[,,] { { { 3, 1 }, { 2, 1 } }, { { 3, 4 }, { 1, 2 } } }); diff --git a/test/NumSharp.UnitTest/Manipulation/np.vstack.Test.cs b/test/NumSharp.UnitTest/Manipulation/np.vstack.Test.cs index 264aa05ed..d81a83178 100644 --- a/test/NumSharp.UnitTest/Manipulation/np.vstack.Test.cs +++ b/test/NumSharp.UnitTest/Manipulation/np.vstack.Test.cs @@ -5,9 +5,10 @@ namespace NumSharp.UnitTest.Manipulation /// /// Tests following https://numpy.org/doc/stable/reference/generated/numpy.vstack.html /// + [TestClass] public class np_vstack_tests { - [Test] + [TestMethod] public void VStackNDArrays() { //1D diff --git a/test/NumSharp.UnitTest/Math/NDArray.Absolute.Test.cs b/test/NumSharp.UnitTest/Math/NDArray.Absolute.Test.cs index d45fcbb8a..1346009ff 100644 --- a/test/NumSharp.UnitTest/Math/NDArray.Absolute.Test.cs +++ b/test/NumSharp.UnitTest/Math/NDArray.Absolute.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.Extensions { + [TestClass] public class NDArrayAbsoluteTest { - [Test] + [TestMethod] public void absolute() { //2D - np.abs now correctly preserves int dtype (NumPy-aligned) diff --git a/test/NumSharp.UnitTest/Math/NDArray.Multiply.Test.cs b/test/NumSharp.UnitTest/Math/NDArray.Multiply.Test.cs index d3bb73440..fcb3ef08d 100644 --- a/test/NumSharp.UnitTest/Math/NDArray.Multiply.Test.cs +++ b/test/NumSharp.UnitTest/Math/NDArray.Multiply.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest { + [TestClass] public class MultiplyTest : TestClass { - [Test] + [TestMethod] public void UInt8MultiplyTest1() { var nd1 = np.arange(3).astype(np.uint8); @@ -18,7 +19,7 @@ public void UInt8MultiplyTest1() AssertAreEqual(new int[] {0, 2, 4}, nd2.Data()); } - [Test] + [TestMethod] public void UInt16MultiplyTest1() { var nd1 = np.arange(3).astype(np.uint16); diff --git a/test/NumSharp.UnitTest/Math/NDArray.cumprod.Test.cs b/test/NumSharp.UnitTest/Math/NDArray.cumprod.Test.cs index f338a29e0..7e0703877 100644 --- a/test/NumSharp.UnitTest/Math/NDArray.cumprod.Test.cs +++ b/test/NumSharp.UnitTest/Math/NDArray.cumprod.Test.cs @@ -13,13 +13,14 @@ namespace NumSharp.UnitTest.Maths /// Tests for cumulative product (cumprod) functionality. /// These test the ILKernelGenerator.Scan.cs CumProd implementation. /// + [TestClass] public class NDArrayCumprodTest : TestClass { /// /// Basic cumprod test with double array. /// NumPy: np.cumprod([1, 2, 3, 4, 5]) = [1, 2, 6, 24, 120] /// - [Test] + [TestMethod] public void CumprodBasicDouble() { NDArray arr = new double[] { 1, 2, 3, 4, 5 }; @@ -33,7 +34,7 @@ public void CumprodBasicDouble() /// Cumprod with zeros - product becomes 0 and stays 0. /// NumPy: np.cumprod([1, 2, 0, 4, 5]) = [1, 2, 0, 0, 0] /// - [Test] + [TestMethod] public void CumprodWithZero() { NDArray arr = new double[] { 1, 2, 0, 4, 5 }; @@ -47,7 +48,7 @@ public void CumprodWithZero() /// Cumprod with negative numbers. /// NumPy: np.cumprod([1, -2, 3, -4]) = [1, -2, -6, 24] /// - [Test] + [TestMethod] public void CumprodWithNegatives() { NDArray arr = new double[] { 1, -2, 3, -4 }; @@ -62,7 +63,7 @@ public void CumprodWithNegatives() /// NumPy: np.cumprod([[1, 2, 3], [4, 5, 6]]) = [1, 2, 6, 24, 120, 720] /// For int32 input, NumPy 2.x returns int64. /// - [Test] + [TestMethod] public void Cumprod2dFlattened() { NDArray arr = new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }; @@ -78,7 +79,7 @@ public void Cumprod2dFlattened() /// NumPy: np.cumprod([[1, 2, 3], [4, 5, 6]], axis=0) = [[1, 2, 3], [4, 10, 18]] /// For int32 input, NumPy 2.x returns int64. /// - [Test] + [TestMethod] public void Cumprod2dAxis0() { NDArray arr = new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }; @@ -94,7 +95,7 @@ public void Cumprod2dAxis0() /// NumPy: np.cumprod([[1, 2, 3], [4, 5, 6]], axis=1) = [[1, 2, 6], [4, 20, 120]] /// For int32 input, NumPy 2.x returns int64. /// - [Test] + [TestMethod] public void Cumprod2dAxis1() { NDArray arr = new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }; @@ -109,7 +110,7 @@ public void Cumprod2dAxis1() /// Cumprod with single element. /// NumPy: np.cumprod([42]) = [42] /// - [Test] + [TestMethod] public void CumprodSingleElement() { NDArray arr = new double[] { 42 }; @@ -123,7 +124,7 @@ public void CumprodSingleElement() /// Cumprod with all ones. /// NumPy: np.cumprod([1, 1, 1, 1]) = [1, 1, 1, 1] /// - [Test] + [TestMethod] public void CumprodAllOnes() { NDArray arr = new double[] { 1, 1, 1, 1 }; @@ -136,7 +137,7 @@ public void CumprodAllOnes() /// /// Cumprod with float32 type. /// - [Test] + [TestMethod] public void CumprodFloat32() { NDArray arr = np.array(new float[] { 1f, 2f, 3f, 4f }); diff --git a/test/NumSharp.UnitTest/Math/NDArray.cumsum.Test.cs b/test/NumSharp.UnitTest/Math/NDArray.cumsum.Test.cs index 62e8543a9..11822809f 100644 --- a/test/NumSharp.UnitTest/Math/NDArray.cumsum.Test.cs +++ b/test/NumSharp.UnitTest/Math/NDArray.cumsum.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.Maths { + [TestClass] public class NDArrayCumsumTest : TestClass { - [Test] + [TestMethod] public void CumsumStaticFunction() { NDArray arr = new double[] {0, 1, 4, 2, 5, 6, 2}; @@ -20,7 +21,7 @@ public void CumsumStaticFunction() np.cumsum(arr).Should().Be(expected); } - [Test] + [TestMethod] public void CumsumMemberFunction() { NDArray arr = new double[] {0, 1, 4, 2, 5, 6, 2}; @@ -29,7 +30,7 @@ public void CumsumMemberFunction() arr.cumsum().Should().Be(expected); } - [Test] + [TestMethod] public void Cumsum2d() { NDArray arr = new int[,] {{1, 2, 3}, {4, 5, 6}}; @@ -39,7 +40,7 @@ public void Cumsum2d() np.cumsum(arr).Should().Be(expected); } - [Test] + [TestMethod] public void Cumsum2dDtype() { NDArray arr = new int[,] {{1, 2, 3}, {4, 5, 6}}; @@ -48,7 +49,7 @@ public void Cumsum2dDtype() np.cumsum(arr, typeCode: NPTypeCode.Single).Should().Be(expected); } - [Test] + [TestMethod] public void Cumsum2dAxisRows() { NDArray arr = new int[,] {{1, 2, 3}, {4, 5, 6}}; @@ -58,7 +59,7 @@ public void Cumsum2dAxisRows() np.cumsum(arr, axis: 0).Should().Be(expected); } - [Test] + [TestMethod] public void Cumsum2dAxisCols() { NDArray arr = new int[,] {{1, 2, 3}, {4, 5, 6}}; @@ -73,7 +74,7 @@ public void Cumsum2dAxisCols() /// NumPy: cumsum([True, False, True, True, False]) = [1, 1, 2, 3, 3] /// Return type is int64 (NumPy 2.x behavior). /// - [Test] + [TestMethod] public void BooleanArray_TreatsAsIntAndReturnsInt64() { var a = np.array(new bool[] { true, false, true, true, false }); diff --git a/test/NumSharp.UnitTest/Math/NDArray.log.Test.cs b/test/NumSharp.UnitTest/Math/NDArray.log.Test.cs index 14f25d8fb..ee807d708 100644 --- a/test/NumSharp.UnitTest/Math/NDArray.log.Test.cs +++ b/test/NumSharp.UnitTest/Math/NDArray.log.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest { + [TestClass] public class LogTest { - [Test] + [TestMethod] public void Case1() { var np1 = np.array(new double[] {1, Math.E, Math.E * Math.E, 0}); // .MakeGeneric(); diff --git a/test/NumSharp.UnitTest/Math/NDArray.negate.Test.cs b/test/NumSharp.UnitTest/Math/NDArray.negate.Test.cs index 8124b33be..4ccf8a0d0 100644 --- a/test/NumSharp.UnitTest/Math/NDArray.negate.Test.cs +++ b/test/NumSharp.UnitTest/Math/NDArray.negate.Test.cs @@ -10,9 +10,10 @@ namespace NumSharp.UnitTest.Maths { + [TestClass] public class NDArrayNegateTest : TestClass { - [Test] + [TestMethod] public void NegateArray() { //initialization @@ -26,7 +27,7 @@ public void NegateArray() nd.Data().Should().BeEquivalentTo(new float[] {-1, 2, -3.3f}); } - [Test] + [TestMethod] public void NegateArray2() { //initialization @@ -40,7 +41,7 @@ public void NegateArray2() nd.Data().Should().BeEquivalentTo(new int[] {1, 0, -1}); } - [Test] + [TestMethod] public void NegateArray3() { //initialization @@ -55,7 +56,7 @@ public void NegateArray3() nd.Data().Should().BeEquivalentTo(new uint[] {0, 4294967295, 4294967294}); } - [Test] + [TestMethod] public void NegateArray4() { //initialization @@ -70,7 +71,7 @@ public void NegateArray4() nd.Data().Should().BeEquivalentTo(new ulong[] {0, 18446744073709551615, 18446744073709551614}); } - [Test] + [TestMethod] public void AddArray() { //initialization @@ -85,7 +86,7 @@ public void AddArray() nd.Data().Should().BeEquivalentTo(new float[] {1, -2, 3.3f}); } - [Test] + [TestMethod] public void NegateEmptyArray() { //initialization diff --git a/test/NumSharp.UnitTest/Math/NDArray.negative.Test.cs b/test/NumSharp.UnitTest/Math/NDArray.negative.Test.cs index 6a9247409..1b2a59b47 100644 --- a/test/NumSharp.UnitTest/Math/NDArray.negative.Test.cs +++ b/test/NumSharp.UnitTest/Math/NDArray.negative.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.Maths { + [TestClass] public class NDArrayNegativeTest { - [Test] + [TestMethod] public void Negative_FlipsSign() { // np.negative flips the sign of each element @@ -26,7 +27,7 @@ public void Negative_FlipsSign() Assert.AreEqual(-3.3f, data[2], 1e-5f); } - [Test] + [TestMethod] public void Negative_AllPositiveInput() { // When all inputs are positive, all outputs are negative @@ -35,7 +36,7 @@ public void Negative_AllPositiveInput() Assert.IsTrue(nd.Data().All(v => v < 0)); } - [Test] + [TestMethod] public void Negative_AllNegativeInput() { // When all inputs are negative, all outputs are positive diff --git a/test/NumSharp.UnitTest/Math/NDArray.positive.Test.cs b/test/NumSharp.UnitTest/Math/NDArray.positive.Test.cs index cdfc2a953..cb33144f9 100644 --- a/test/NumSharp.UnitTest/Math/NDArray.positive.Test.cs +++ b/test/NumSharp.UnitTest/Math/NDArray.positive.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.Maths { + [TestClass] public class NDArrayPositiveTest { - [Test] + [TestMethod] public void Positive_IsIdentity() { // np.positive is an identity function - returns unchanged values @@ -27,7 +28,7 @@ public void Positive_IsIdentity() Assert.AreEqual(3.3f, data[2], 1e-5f); } - [Test] + [TestMethod] public void Positive_PreservesNegatives() { // np.positive preserves negative values (identity function) @@ -39,7 +40,7 @@ public void Positive_PreservesNegatives() Assert.IsTrue(nd.Data().All(v => v < 0)); } - [Test] + [TestMethod] public void Positive_PreservesPositives() { // np.positive preserves positive values (identity function) diff --git a/test/NumSharp.UnitTest/Math/NDArray.power.Test.cs b/test/NumSharp.UnitTest/Math/NDArray.power.Test.cs index f51e93f63..f12206b46 100644 --- a/test/NumSharp.UnitTest/Math/NDArray.power.Test.cs +++ b/test/NumSharp.UnitTest/Math/NDArray.power.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest { + [TestClass] public class PowerTest { - [Test] + [TestMethod] public void PowerWithSingleValue() { // np.arange returns int64 by default (NumPy 2.x) diff --git a/test/NumSharp.UnitTest/Math/NDArray.sin.Test.cs b/test/NumSharp.UnitTest/Math/NDArray.sin.Test.cs index 4f67d5ebe..7d9f8a994 100644 --- a/test/NumSharp.UnitTest/Math/NDArray.sin.Test.cs +++ b/test/NumSharp.UnitTest/Math/NDArray.sin.Test.cs @@ -3,9 +3,10 @@ namespace NumSharp.UnitTest.Maths { + [TestClass] public class SinTest { - [Test] + [TestMethod] public void Simple1DArray() { var nd = np.array(new double[] {0D, 0.523598775598299D, diff --git a/test/NumSharp.UnitTest/Math/NdArray.Convolve.Test.cs b/test/NumSharp.UnitTest/Math/NdArray.Convolve.Test.cs index 8aea86dec..c368835c5 100644 --- a/test/NumSharp.UnitTest/Math/NdArray.Convolve.Test.cs +++ b/test/NumSharp.UnitTest/Math/NdArray.Convolve.Test.cs @@ -10,9 +10,10 @@ namespace NumSharp.UnitTest /// Test concolve with standard example from /// https://www.numpy.org/devdocs/reference/generated/numpy.convolve.html /// + [TestClass] public class NdArrayConvolveTest { - [Test] + [TestMethod] public void ConvoleFull() { var series1 = np.array(new double[] {1, 2, 3}); @@ -25,7 +26,7 @@ public void ConvoleFull() Assert.IsTrue(Enumerable.SequenceEqual(series3.Data(), expectedResult)); } - [Test] + [TestMethod] public void ConvoleValid() { var series1 = np.array(new double[] {1, 2, 3}); @@ -38,7 +39,7 @@ public void ConvoleValid() Assert.IsTrue(Enumerable.SequenceEqual(series3.Data(), expectedResult)); } - [Test] + [TestMethod] public void ConvoleSame() { var series1 = np.array(new double[] {1, 2, 3}); diff --git a/test/NumSharp.UnitTest/Math/NdArray.Sqrt.Test.cs b/test/NumSharp.UnitTest/Math/NdArray.Sqrt.Test.cs index fd0d9780d..f875f70ee 100644 --- a/test/NumSharp.UnitTest/Math/NdArray.Sqrt.Test.cs +++ b/test/NumSharp.UnitTest/Math/NdArray.Sqrt.Test.cs @@ -10,16 +10,17 @@ namespace NumSharp.UnitTest.Maths { + [TestClass] public class NDArraySqrtTest { - [Test] + [TestMethod] public void Case1() { var nd = np.array(new double[] {1, 4, 9}); np.sqrt(nd).Should().BeOfType().And.BeOfValues(1, 2, 3); } - /*[Test] + /*[TestMethod] public void ComplexSqrtTest() { var np = new NDArray(typeof(Complex),3); diff --git a/test/NumSharp.UnitTest/Math/SignDtypeTests.cs b/test/NumSharp.UnitTest/Math/SignDtypeTests.cs index 8cbf3659a..9a9fec5b4 100644 --- a/test/NumSharp.UnitTest/Math/SignDtypeTests.cs +++ b/test/NumSharp.UnitTest/Math/SignDtypeTests.cs @@ -6,6 +6,7 @@ namespace NumSharp.UnitTest /// /// Tests for np.sign dtype preservation. /// + [TestClass] public class SignDtypeTests { /// @@ -15,7 +16,7 @@ public class SignDtypeTests /// Fixed: Returns int32 /// Was: Returns Double /// - [Test] + [TestMethod] public void Sign_Int32_PreservesDtype() { var a = np.array(new int[] { -3, 0, 5 }); @@ -30,7 +31,7 @@ public void Sign_Int32_PreservesDtype() /// /// Test np.sign preserves dtype for other integer types. /// - [Test] + [TestMethod] public void Sign_Int64_PreservesDtype() { var a = np.array(new long[] { -100L, 0L, 100L }); @@ -45,7 +46,7 @@ public void Sign_Int64_PreservesDtype() /// /// Test np.sign preserves dtype for float types. /// - [Test] + [TestMethod] public void Sign_Double_PreservesDtype() { var a = np.array(new double[] { -2.5, 0.0, 3.7 }); @@ -60,7 +61,7 @@ public void Sign_Double_PreservesDtype() /// /// Test np.sign with byte type. /// - [Test] + [TestMethod] public void Sign_Byte_PreservesDtype() { // Byte is unsigned, so sign is always 0 or 1 diff --git a/test/NumSharp.UnitTest/Math/np.clip.Test.cs b/test/NumSharp.UnitTest/Math/np.clip.Test.cs index 89b54707d..c7e16f19e 100644 --- a/test/NumSharp.UnitTest/Math/np.clip.Test.cs +++ b/test/NumSharp.UnitTest/Math/np.clip.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest { + [TestClass] public class np_clip_test { - [Test] + [TestMethod] public void Case1() { var a = np.arange(12).reshape(3, 4); @@ -17,7 +18,7 @@ public void Case1() np.clip(a, 3, max).Should().BeOfValues(3, 3, 3, 3, 4, 5, 6, 7, 8, 8, 8, 8).And.BeShaped(3, 4); } - [Test] + [TestMethod] public void Case2() { var a = np.arange(12).reshape(3, 4); @@ -25,7 +26,7 @@ public void Case2() np.clip(a, max, null).Should().BeOfValues(8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 10, 11).And.BeShaped(3, 4); } - [Test] + [TestMethod] public void Case3() { var a = np.arange(12).reshape(3, 4); diff --git a/test/NumSharp.UnitTest/Math/np.math.Test.cs b/test/NumSharp.UnitTest/Math/np.math.Test.cs index 176bfcfc1..71b8469df 100644 --- a/test/NumSharp.UnitTest/Math/np.math.Test.cs +++ b/test/NumSharp.UnitTest/Math/np.math.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest.Maths { + [TestClass] public class ApiMathTest { - [Test] + [TestMethod] public void AddInt32() { var x = np.arange(3); @@ -24,7 +25,7 @@ public void AddInt32() z.Should().BeOfValues(0, 2, 4, 6, 8, 10, 12, 14, 16); } - [Test] + [TestMethod] public void DivideInt32() { var x = np.arange(1, 4); @@ -38,7 +39,7 @@ public void DivideInt32() z.Should().BeOfValues(1, 1, 1, 1, 1, 1, 1, 1, 1); } - [Test] + [TestMethod] public void Sum2x2Int32() { var data = new int[,] {{0, 1}, {0, 5}}; @@ -56,7 +57,7 @@ public void Sum2x2Int32() s1.Should().BeOfValues(1, 5).And.BeShaped(2); ; } - [Test] + [TestMethod] public void Sum2x3x2Int32() { var data = np.arange(12).reshape(2, 3, 2); @@ -77,7 +78,7 @@ public void Sum2x3x2Int32() s3.Should().BeOfValues(1, 5, 9, 13, 17, 21).And.BeShaped(2,3); } - [Test] + [TestMethod] public void AddUInt8() { var x = np.arange(3).astype(np.uint8); @@ -91,7 +92,7 @@ public void AddUInt8() z.Should().BeOfValues(0, 2, 4, 6, 8, 10, 12, 14, 16); } - [Test] + [TestMethod] public void DivideUInt8() { var x = np.arange(1, 4).astype(np.uint8); @@ -105,7 +106,7 @@ public void DivideUInt8() z.Should().BeOfValues(1, 1, 1, 1, 1, 1, 1, 1, 1); } - [Test] + [TestMethod] public void AddUInt16() { var x = np.arange(3).astype(np.uint16); @@ -119,7 +120,7 @@ public void AddUInt16() z.Should().BeOfValues(0, 2, 4, 6, 8, 10, 12, 14, 16); } - [Test] + [TestMethod] public void DivideUInt16() { var x = np.arange(1, 4).astype(np.uint16); @@ -133,7 +134,7 @@ public void DivideUInt16() z.Should().BeOfValues(1, 1, 1, 1, 1, 1, 1, 1, 1); } - [Test] + [TestMethod] public void Minimum_Slice() { //>>> boxes1 = np.array([12.875, 14.125, 39.75, 49]).reshape(1, 4) @@ -165,7 +166,7 @@ public void Minimum_Slice() z.Should().BeOfValues(27.125, 32.3125, 27.5, 33.375, 28.5625, 32.9375).And.BeShaped(3, 2); } - [Test] + [TestMethod] public void Maximum_Slice() { //>>> boxes1 = np.array([12.875, 14.125, 39.75, 49]).reshape(1, 4) diff --git a/test/NumSharp.UnitTest/Math/np.minimum.Test.cs b/test/NumSharp.UnitTest/Math/np.minimum.Test.cs index 6da2e9ce2..029c23e85 100644 --- a/test/NumSharp.UnitTest/Math/np.minimum.Test.cs +++ b/test/NumSharp.UnitTest/Math/np.minimum.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.MathTests; /// Tests for np.minimum element-wise minimum operation. /// All tests verified against NumPy v2.4.2. /// +[TestClass] public class NpMinimumTests : TestClass { - [Test] + [TestMethod] public void Minimum_IntBroadcast_CorrectValues() { // NumPy: minimum([1,5,3], [[2],[4]]) = [[1,2,2],[1,4,3]] @@ -24,7 +25,7 @@ public void Minimum_IntBroadcast_CorrectValues() "np.minimum with broadcast should compute element-wise min correctly"); } - [Test] + [TestMethod] public void Minimum_DoubleBroadcast_CorrectValues() { // NumPy: minimum([1.,5.,3.], [[2.],[4.]]) = [[1,2,2],[1,4,3]] @@ -39,7 +40,7 @@ public void Minimum_DoubleBroadcast_CorrectValues() "np.minimum with double broadcast should compute element-wise min correctly"); } - [Test] + [TestMethod] public void Minimum_FloatBroadcast_CorrectValues() { // NumPy: minimum([1f,5f,3f], [[2f],[4f]]) = [[1,2,2],[1,4,3]] @@ -54,7 +55,7 @@ public void Minimum_FloatBroadcast_CorrectValues() "np.minimum with float broadcast should compute element-wise min correctly"); } - [Test] + [TestMethod] public void Minimum_SameShape_CorrectValues() { var a = np.array(new int[] { 1, 5, 3, 8 }); @@ -65,7 +66,7 @@ public void Minimum_SameShape_CorrectValues() np.array_equal(r, expected).Should().BeTrue(); } - [Test] + [TestMethod] public void Minimum_ScalarBroadcast_CorrectValues() { var a = np.array(new int[] { 1, 5, 3, 8 }); @@ -76,7 +77,7 @@ public void Minimum_ScalarBroadcast_CorrectValues() np.array_equal(r, expected).Should().BeTrue(); } - [Test] + [TestMethod] public void Maximum_IntBroadcast_CorrectValues() { // Verify np.maximum also works correctly with broadcast diff --git a/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_BinaryReductions.cs b/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_BinaryReductions.cs index 5066946cb..f3a6438e2 100644 --- a/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_BinaryReductions.cs +++ b/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_BinaryReductions.cs @@ -11,11 +11,12 @@ namespace NumSharp.UnitTest.NpApiOverloads; /// Tests verifying that binary math operations and reduction overloads compile and work correctly /// after removing the `in` parameter modifier from method signatures. /// +[TestClass] public class NpApiOverloadTests_BinaryReductions { #region Basic Binary Operations - [Test] + [TestMethod] public void Add_TwoArrays_Compiles() { var a = np.array(new double[] { 1, 2, 3 }); @@ -27,7 +28,7 @@ public void Add_TwoArrays_Compiles() result.GetDouble(2).Should().Be(9.0); } - [Test] + [TestMethod] public void Subtract_TwoArrays_Compiles() { var a = np.array(new double[] { 5, 7, 9 }); @@ -39,7 +40,7 @@ public void Subtract_TwoArrays_Compiles() result.GetDouble(2).Should().Be(6.0); } - [Test] + [TestMethod] public void Multiply_TwoArrays_Compiles() { var a = np.array(new double[] { 2, 3, 4 }); @@ -51,7 +52,7 @@ public void Multiply_TwoArrays_Compiles() result.GetDouble(2).Should().Be(28.0); } - [Test] + [TestMethod] public void Divide_TwoArrays_Compiles() { var a = np.array(new double[] { 10, 20, 30 }); @@ -63,7 +64,7 @@ public void Divide_TwoArrays_Compiles() result.GetDouble(2).Should().Be(6.0); } - [Test] + [TestMethod] public void TrueDivide_TwoArrays_Compiles() { var a = np.array(new double[] { 10, 20, 30 }); @@ -75,7 +76,7 @@ public void TrueDivide_TwoArrays_Compiles() result.GetDouble(2).Should().Be(5.0); } - [Test] + [TestMethod] public void Mod_TwoArrays_Compiles() { var a = np.array(new double[] { 10, 20, 30 }); @@ -87,7 +88,7 @@ public void Mod_TwoArrays_Compiles() result.GetDouble(2).Should().Be(6.0); } - [Test] + [TestMethod] public void Mod_ArrayAndFloatScalar_Compiles() { var a = np.array(new double[] { 10, 20, 30 }); @@ -102,7 +103,7 @@ public void Mod_ArrayAndFloatScalar_Compiles() #region Power Operations - [Test] + [TestMethod] public void Power_ArrayAndValueTypeScalar_Compiles() { var a = np.array(new double[] { 2, 3, 4 }); @@ -114,7 +115,7 @@ public void Power_ArrayAndValueTypeScalar_Compiles() result.GetDouble(2).Should().Be(16.0); } - [Test] + [TestMethod] public void Power_ArrayAndValueTypeScalarWithDtype_Compiles() { var a = np.array(new double[] { 2, 3, 4 }); @@ -124,7 +125,7 @@ public void Power_ArrayAndValueTypeScalarWithDtype_Compiles() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Power_ArrayAndValueTypeScalarWithNPTypeCode_Compiles() { var a = np.array(new double[] { 2, 3, 4 }); @@ -134,7 +135,7 @@ public void Power_ArrayAndValueTypeScalarWithNPTypeCode_Compiles() result.typecode.Should().Be(NPTypeCode.Double); } - [Test] + [TestMethod] public void Power_TwoArrays_Compiles() { var a = np.array(new double[] { 2, 3, 4 }); @@ -146,7 +147,7 @@ public void Power_TwoArrays_Compiles() result.GetDouble(2).Should().Be(16.0); } - [Test] + [TestMethod] public void Power_TwoArraysWithDtype_Compiles() { var a = np.array(new double[] { 2, 3, 4 }); @@ -156,7 +157,7 @@ public void Power_TwoArraysWithDtype_Compiles() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Power_TwoArraysWithNPTypeCode_Compiles() { var a = np.array(new double[] { 2, 3, 4 }); @@ -170,7 +171,7 @@ public void Power_TwoArraysWithNPTypeCode_Compiles() #region Floor Division Operations - [Test] + [TestMethod] public void FloorDivide_TwoArrays_Compiles() { var a = np.array(new double[] { 7, 8, 9 }); @@ -182,7 +183,7 @@ public void FloorDivide_TwoArrays_Compiles() result.GetDouble(2).Should().Be(2.0); } - [Test] + [TestMethod] public void FloorDivide_TwoArraysWithDtype_Compiles() { var a = np.array(new double[] { 7, 8, 9 }); @@ -192,7 +193,7 @@ public void FloorDivide_TwoArraysWithDtype_Compiles() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void FloorDivide_TwoArraysWithNPTypeCode_Compiles() { var a = np.array(new double[] { 7, 8, 9 }); @@ -202,7 +203,7 @@ public void FloorDivide_TwoArraysWithNPTypeCode_Compiles() result.typecode.Should().Be(NPTypeCode.Double); } - [Test] + [TestMethod] public void FloorDivide_ArrayAndValueTypeScalar_Compiles() { var a = np.array(new double[] { 7, 8, 9 }); @@ -214,7 +215,7 @@ public void FloorDivide_ArrayAndValueTypeScalar_Compiles() result.GetDouble(2).Should().Be(4.0); } - [Test] + [TestMethod] public void FloorDivide_ArrayAndValueTypeScalarWithDtype_Compiles() { var a = np.array(new double[] { 7, 8, 9 }); @@ -224,7 +225,7 @@ public void FloorDivide_ArrayAndValueTypeScalarWithDtype_Compiles() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void FloorDivide_ArrayAndValueTypeScalarWithNPTypeCode_Compiles() { var a = np.array(new double[] { 7, 8, 9 }); @@ -238,7 +239,7 @@ public void FloorDivide_ArrayAndValueTypeScalarWithNPTypeCode_Compiles() #region Maximum Operations - [Test] + [TestMethod] public void Maximum_TwoArrays_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -250,7 +251,7 @@ public void Maximum_TwoArrays_Compiles() result.GetDouble(2).Should().Be(6.0); } - [Test] + [TestMethod] public void Maximum_TwoArraysWithDtype_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -260,7 +261,7 @@ public void Maximum_TwoArraysWithDtype_Compiles() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Maximum_TwoArraysWithOut_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -275,7 +276,7 @@ public void Maximum_TwoArraysWithOut_Compiles() #region Minimum Operations - [Test] + [TestMethod] public void Minimum_TwoArrays_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -287,7 +288,7 @@ public void Minimum_TwoArrays_Compiles() result.GetDouble(2).Should().Be(3.0); } - [Test] + [TestMethod] public void Minimum_TwoArraysWithDtype_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -297,7 +298,7 @@ public void Minimum_TwoArraysWithDtype_Compiles() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Minimum_TwoArraysWithOut_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -312,7 +313,7 @@ public void Minimum_TwoArraysWithOut_Compiles() #region Fmax Operations - [Test] + [TestMethod] public void Fmax_TwoArrays_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -324,7 +325,7 @@ public void Fmax_TwoArrays_Compiles() result.GetDouble(2).Should().Be(6.0); } - [Test] + [TestMethod] public void Fmax_TwoArraysWithDtype_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -334,7 +335,7 @@ public void Fmax_TwoArraysWithDtype_Compiles() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Fmax_TwoArraysWithOut_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -349,7 +350,7 @@ public void Fmax_TwoArraysWithOut_Compiles() #region Fmin Operations - [Test] + [TestMethod] public void Fmin_TwoArrays_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -361,7 +362,7 @@ public void Fmin_TwoArrays_Compiles() result.GetDouble(2).Should().Be(3.0); } - [Test] + [TestMethod] public void Fmin_TwoArraysWithDtype_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -371,7 +372,7 @@ public void Fmin_TwoArraysWithDtype_Compiles() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Fmin_TwoArraysWithOut_Compiles() { var a = np.array(new double[] { 1, 5, 3 }); @@ -386,7 +387,7 @@ public void Fmin_TwoArraysWithOut_Compiles() #region Clip Operations - [Test] + [TestMethod] public void Clip_MinMax_Compiles() { var a = np.array(new double[] { 1, 5, 3, 8, 2 }); @@ -401,7 +402,7 @@ public void Clip_MinMax_Compiles() result.GetDouble(4).Should().Be(2.0); // clipped to min } - [Test] + [TestMethod] public void Clip_MinMaxWithDtype_Compiles() { var a = np.array(new double[] { 1, 5, 3, 8, 2 }); @@ -412,7 +413,7 @@ public void Clip_MinMaxWithDtype_Compiles() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Clip_MinMaxWithOut_Compiles() { var a = np.array(new double[] { 1, 5, 3, 8, 2 }); @@ -428,7 +429,7 @@ public void Clip_MinMaxWithOut_Compiles() #region Bitwise Operations - [Test] + [TestMethod] public void LeftShift_TwoArrays_Compiles() { var a = np.array(new int[] { 1, 2, 4 }); @@ -440,7 +441,7 @@ public void LeftShift_TwoArrays_Compiles() result.GetInt32(2).Should().Be(32); // 4 << 3 = 32 } - [Test] + [TestMethod] public void LeftShift_ArrayAndIntScalar_Compiles() { var a = np.array(new int[] { 1, 2, 4 }); @@ -451,7 +452,7 @@ public void LeftShift_ArrayAndIntScalar_Compiles() result.GetInt32(2).Should().Be(16); // 4 << 2 = 16 } - [Test] + [TestMethod] public void RightShift_TwoArrays_Compiles() { var a = np.array(new int[] { 4, 8, 32 }); @@ -463,7 +464,7 @@ public void RightShift_TwoArrays_Compiles() result.GetInt32(2).Should().Be(4); // 32 >> 3 = 4 } - [Test] + [TestMethod] public void RightShift_ArrayAndIntScalar_Compiles() { var a = np.array(new int[] { 4, 8, 16 }); @@ -474,7 +475,7 @@ public void RightShift_ArrayAndIntScalar_Compiles() result.GetInt32(2).Should().Be(4); // 16 >> 2 = 4 } - [Test] + [TestMethod] public void Invert_Array_Compiles() { var a = np.array(new int[] { 0, 1, -1 }); @@ -485,7 +486,7 @@ public void Invert_Array_Compiles() result.GetInt32(2).Should().Be(0); // ~-1 = 0 } - [Test] + [TestMethod] public void Invert_ArrayWithDtype_Compiles() { var a = np.array(new int[] { 0, 1, -1 }); @@ -493,7 +494,7 @@ public void Invert_ArrayWithDtype_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void BitwiseNot_Array_Compiles() { var a = np.array(new int[] { 0, 1, -1 }); @@ -504,7 +505,7 @@ public void BitwiseNot_Array_Compiles() result.GetInt32(2).Should().Be(0); // ~-1 = 0 } - [Test] + [TestMethod] public void BitwiseNot_ArrayWithDtype_Compiles() { var a = np.array(new int[] { 0, 1, -1 }); @@ -516,7 +517,7 @@ public void BitwiseNot_ArrayWithDtype_Compiles() #region Arctan2 Operations - [Test] + [TestMethod] public void Arctan2_TwoArrays_Compiles() { var y = np.array(new double[] { 1, 0, -1 }); @@ -528,7 +529,7 @@ public void Arctan2_TwoArrays_Compiles() result.GetDouble(2).Should().BeApproximately(-Math.PI / 2, 1e-10); // arctan2(-1, 0) = -pi/2 } - [Test] + [TestMethod] public void Arctan2_TwoArraysWithDtype_Compiles() { var y = np.array(new double[] { 1, 0, -1 }); @@ -542,7 +543,7 @@ public void Arctan2_TwoArraysWithDtype_Compiles() #region Sum Reductions - [Test] + [TestMethod] public void Sum_NoParams_Compiles() { var a = np.array(new double[] { 1, 2, 3 }); @@ -550,7 +551,7 @@ public void Sum_NoParams_Compiles() result.GetDouble(0).Should().Be(6.0); } - [Test] + [TestMethod] public void Sum_WithAxis_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -560,7 +561,7 @@ public void Sum_WithAxis_Compiles() result.GetDouble(1).Should().Be(6.0); // 2 + 4 } - [Test] + [TestMethod] public void Sum_WithKeepdims_Compiles() { var a = np.array(new double[] { 1, 2, 3 }); @@ -569,7 +570,7 @@ public void Sum_WithKeepdims_Compiles() result.GetDouble(0).Should().Be(6.0); } - [Test] + [TestMethod] public void Sum_WithAxisAndKeepdims_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -578,7 +579,7 @@ public void Sum_WithAxisAndKeepdims_Compiles() result.ndim.Should().Be(2); } - [Test] + [TestMethod] public void Sum_WithAxisKeepdimsAndTypeDtype_Compiles() { var a = np.array(new int[] { 1, 2, 3 }); @@ -586,7 +587,7 @@ public void Sum_WithAxisKeepdimsAndTypeDtype_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Sum_WithAxisKeepdimsAndNPTypeCode_Compiles() { var a = np.array(new int[] { 1, 2, 3 }); @@ -594,7 +595,7 @@ public void Sum_WithAxisKeepdimsAndNPTypeCode_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Sum_WithAxisAndTypeDtype_Compiles() { var a = np.array(new int[] { 1, 2, 3 }); @@ -602,7 +603,7 @@ public void Sum_WithAxisAndTypeDtype_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Sum_WithAxisAndNPTypeCode_Compiles() { var a = np.array(new int[] { 1, 2, 3 }); @@ -610,7 +611,7 @@ public void Sum_WithAxisAndNPTypeCode_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Sum_WithTypeDtype_Compiles() { var a = np.array(new int[] { 1, 2, 3 }); @@ -618,7 +619,7 @@ public void Sum_WithTypeDtype_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Sum_WithNPTypeCode_Compiles() { var a = np.array(new int[] { 1, 2, 3 }); @@ -630,7 +631,7 @@ public void Sum_WithNPTypeCode_Compiles() #region Prod Reduction - [Test] + [TestMethod] public void Prod_WithAxisDtypeKeepdims_Compiles() { var a = np.array(new int[] { 1, 2, 3, 4 }); @@ -644,7 +645,7 @@ public void Prod_WithAxisDtypeKeepdims_Compiles() #region Mean Reductions - [Test] + [TestMethod] public void Mean_NoParams_Compiles() { var a = np.array(new double[] { 1, 2, 3, 4 }); @@ -653,7 +654,7 @@ public void Mean_NoParams_Compiles() result.GetDouble(0).Should().Be(2.5); } - [Test] + [TestMethod] public void Mean_WithAxis_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -663,7 +664,7 @@ public void Mean_WithAxis_Compiles() result.GetDouble(1).Should().Be(3.0); // (2+4)/2 } - [Test] + [TestMethod] public void Mean_WithKeepdims_Compiles() { var a = np.array(new double[] { 1, 2, 3, 4 }); @@ -672,7 +673,7 @@ public void Mean_WithKeepdims_Compiles() result.GetDouble(0).Should().Be(2.5); } - [Test] + [TestMethod] public void Mean_WithAxisDtypeKeepdims_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -680,7 +681,7 @@ public void Mean_WithAxisDtypeKeepdims_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Mean_WithAxisNPTypeCodeKeepdims_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -688,7 +689,7 @@ public void Mean_WithAxisNPTypeCodeKeepdims_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Mean_WithAxisAndKeepdims_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -701,7 +702,7 @@ public void Mean_WithAxisAndKeepdims_Compiles() #region Nan Reductions - [Test] + [TestMethod] public void NanSum_WithAxisAndKeepdims_Compiles() { var a = np.array(new double[] { 1, double.NaN, 3, 4 }); @@ -710,7 +711,7 @@ public void NanSum_WithAxisAndKeepdims_Compiles() result.GetDouble(0).Should().Be(8.0); // 1 + 3 + 4 = 8 (NaN ignored) } - [Test] + [TestMethod] public void NanProd_WithAxisAndKeepdims_Compiles() { var a = np.array(new double[] { 2, double.NaN, 3, 4 }); @@ -719,7 +720,7 @@ public void NanProd_WithAxisAndKeepdims_Compiles() result.GetDouble(0).Should().Be(24.0); // 2 * 3 * 4 = 24 (NaN ignored) } - [Test] + [TestMethod] public void NanMean_WithAxisAndKeepdims_Compiles() { var a = np.array(new double[] { 1, double.NaN, 3, 4 }); @@ -729,7 +730,7 @@ public void NanMean_WithAxisAndKeepdims_Compiles() result.GetDouble(0).Should().BeApproximately(8.0 / 3.0, 1e-10); } - [Test] + [TestMethod] public void NanMin_WithAxisAndKeepdims_Compiles() { var a = np.array(new double[] { 5, double.NaN, 3, 4 }); @@ -738,7 +739,7 @@ public void NanMin_WithAxisAndKeepdims_Compiles() result.GetDouble(0).Should().Be(3.0); // min ignoring NaN } - [Test] + [TestMethod] public void NanMax_WithAxisAndKeepdims_Compiles() { var a = np.array(new double[] { 1, double.NaN, 3, 4 }); @@ -751,7 +752,7 @@ public void NanMax_WithAxisAndKeepdims_Compiles() #region Std/Var Reductions - [Test] + [TestMethod] public void Std_WithKeepdimsDdofDtype_Compiles() { var a = np.array(new double[] { 1, 2, 3, 4, 5 }); @@ -761,7 +762,7 @@ public void Std_WithKeepdimsDdofDtype_Compiles() result.GetDouble(0).Should().BeApproximately(Math.Sqrt(2.0), 1e-10); } - [Test] + [TestMethod] public void Std_WithAxisTypeDtypeKeepdimsDdof_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -769,7 +770,7 @@ public void Std_WithAxisTypeDtypeKeepdimsDdof_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Std_WithAxisNPTypeCodeKeepdimsDdof_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -777,7 +778,7 @@ public void Std_WithAxisNPTypeCodeKeepdimsDdof_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Std_WithAxisKeepdimsDdofDtype_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -786,7 +787,7 @@ public void Std_WithAxisKeepdimsDdofDtype_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Var_WithKeepdimsDdofDtype_Compiles() { var a = np.array(new double[] { 1, 2, 3, 4, 5 }); @@ -796,7 +797,7 @@ public void Var_WithKeepdimsDdofDtype_Compiles() result.GetDouble(0).Should().Be(2.0); } - [Test] + [TestMethod] public void Var_WithAxisTypeDtypeKeepdimsDdof_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -804,7 +805,7 @@ public void Var_WithAxisTypeDtypeKeepdimsDdof_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Var_WithAxisNPTypeCodeKeepdimsDdof_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -812,7 +813,7 @@ public void Var_WithAxisNPTypeCodeKeepdimsDdof_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void Var_WithAxisKeepdimsDdofDtype_Compiles() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -821,7 +822,7 @@ public void Var_WithAxisKeepdimsDdofDtype_Compiles() result.Should().NotBeNull(); } - [Test] + [TestMethod] public void NanStd_WithAxisKeepdimsDdof_Compiles() { var a = np.array(new double[] { 1, double.NaN, 3, 4, 5 }); @@ -830,7 +831,7 @@ public void NanStd_WithAxisKeepdimsDdof_Compiles() // std of [1,3,4,5] ignoring NaN } - [Test] + [TestMethod] public void NanVar_WithAxisKeepdimsDdof_Compiles() { var a = np.array(new double[] { 1, double.NaN, 3, 4, 5 }); diff --git a/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_LogicManipulation.cs b/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_LogicManipulation.cs index e8af031a0..a00028b10 100644 --- a/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_LogicManipulation.cs +++ b/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_LogicManipulation.cs @@ -1,11 +1,7 @@ using System; -using System.Threading.Tasks; using NumSharp; using NumSharp.Generic; using NumSharp.UnitTest.Utilities; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.NpApiOverloads; @@ -17,276 +13,277 @@ namespace NumSharp.UnitTest.NpApiOverloads; /// These tests verify that the overloads compile and work correctly after /// removing the 'in' modifier from NDArray parameters. /// +[TestClass] public class NpApiOverloadTests_LogicManipulation { #region Comparison Operations - np.equal (3 overloads) - [Test] - public async Task Equal_TwoArrays_Compiles() + [TestMethod] + public void Equal_TwoArrays_Compiles() { // NumPy: np.equal([1, 2, 3], [1, 2, 4]) -> [True, True, False] var a = np.array(new int[] { 1, 2, 3 }); var b = np.array(new int[] { 1, 2, 4 }); var result = np.equal(a, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeFalse(); } - [Test] - public async Task Equal_ArrayAndScalar_Compiles() + [TestMethod] + public void Equal_ArrayAndScalar_Compiles() { // NumPy: np.equal([1, 2, 3], 2) -> [False, True, False] var a = np.array(new int[] { 1, 2, 3 }); var result = np.equal(a, 2); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeFalse(); } - [Test] - public async Task Equal_ScalarAndArray_Compiles() + [TestMethod] + public void Equal_ScalarAndArray_Compiles() { // NumPy: np.equal(2, [1, 2, 3]) -> [False, True, False] var b = np.array(new int[] { 1, 2, 3 }); var result = np.equal(2, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeFalse(); } #endregion #region Comparison Operations - np.not_equal (3 overloads) - [Test] - public async Task NotEqual_TwoArrays_Compiles() + [TestMethod] + public void NotEqual_TwoArrays_Compiles() { // NumPy: np.not_equal([1, 2, 3], [1, 2, 4]) -> [False, False, True] var a = np.array(new int[] { 1, 2, 3 }); var b = np.array(new int[] { 1, 2, 4 }); var result = np.not_equal(a, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] - public async Task NotEqual_ArrayAndScalar_Compiles() + [TestMethod] + public void NotEqual_ArrayAndScalar_Compiles() { // NumPy: np.not_equal([1, 2, 3], 2) -> [True, False, True] var a = np.array(new int[] { 1, 2, 3 }); var result = np.not_equal(a, 2); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] - public async Task NotEqual_ScalarAndArray_Compiles() + [TestMethod] + public void NotEqual_ScalarAndArray_Compiles() { // NumPy: np.not_equal(2, [1, 2, 3]) -> [True, False, True] var b = np.array(new int[] { 1, 2, 3 }); var result = np.not_equal(2, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } #endregion #region Comparison Operations - np.less (3 overloads) - [Test] - public async Task Less_TwoArrays_Compiles() + [TestMethod] + public void Less_TwoArrays_Compiles() { // NumPy: np.less([1, 2, 3], [2, 2, 2]) -> [True, False, False] var a = np.array(new int[] { 1, 2, 3 }); var b = np.array(new int[] { 2, 2, 2 }); var result = np.less(a, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeFalse(); } - [Test] - public async Task Less_ArrayAndScalar_Compiles() + [TestMethod] + public void Less_ArrayAndScalar_Compiles() { // NumPy: np.less([1, 2, 3], 2) -> [True, False, False] var a = np.array(new int[] { 1, 2, 3 }); var result = np.less(a, 2); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeFalse(); } - [Test] - public async Task Less_ScalarAndArray_Compiles() + [TestMethod] + public void Less_ScalarAndArray_Compiles() { // NumPy: np.less(2, [1, 2, 3]) -> [False, False, True] var b = np.array(new int[] { 1, 2, 3 }); var result = np.less(2, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } #endregion #region Comparison Operations - np.greater (3 overloads) - [Test] - public async Task Greater_TwoArrays_Compiles() + [TestMethod] + public void Greater_TwoArrays_Compiles() { // NumPy: np.greater([1, 2, 3], [2, 2, 2]) -> [False, False, True] var a = np.array(new int[] { 1, 2, 3 }); var b = np.array(new int[] { 2, 2, 2 }); var result = np.greater(a, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] - public async Task Greater_ArrayAndScalar_Compiles() + [TestMethod] + public void Greater_ArrayAndScalar_Compiles() { // NumPy: np.greater([1, 2, 3], 2) -> [False, False, True] var a = np.array(new int[] { 1, 2, 3 }); var result = np.greater(a, 2); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] - public async Task Greater_ScalarAndArray_Compiles() + [TestMethod] + public void Greater_ScalarAndArray_Compiles() { // NumPy: np.greater(2, [1, 2, 3]) -> [True, False, False] var b = np.array(new int[] { 1, 2, 3 }); var result = np.greater(2, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeFalse(); } #endregion #region Comparison Operations - np.less_equal (3 overloads) - [Test] - public async Task LessEqual_TwoArrays_Compiles() + [TestMethod] + public void LessEqual_TwoArrays_Compiles() { // NumPy: np.less_equal([1, 2, 3], [2, 2, 2]) -> [True, True, False] var a = np.array(new int[] { 1, 2, 3 }); var b = np.array(new int[] { 2, 2, 2 }); var result = np.less_equal(a, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeFalse(); } - [Test] - public async Task LessEqual_ArrayAndScalar_Compiles() + [TestMethod] + public void LessEqual_ArrayAndScalar_Compiles() { // NumPy: np.less_equal([1, 2, 3], 2) -> [True, True, False] var a = np.array(new int[] { 1, 2, 3 }); var result = np.less_equal(a, 2); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeFalse(); } - [Test] - public async Task LessEqual_ScalarAndArray_Compiles() + [TestMethod] + public void LessEqual_ScalarAndArray_Compiles() { // NumPy: np.less_equal(2, [1, 2, 3]) -> [False, True, True] var b = np.array(new int[] { 1, 2, 3 }); var result = np.less_equal(2, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeTrue(); } #endregion #region Comparison Operations - np.greater_equal (3 overloads) - [Test] - public async Task GreaterEqual_TwoArrays_Compiles() + [TestMethod] + public void GreaterEqual_TwoArrays_Compiles() { // NumPy: np.greater_equal([1, 2, 3], [2, 2, 2]) -> [False, True, True] var a = np.array(new int[] { 1, 2, 3 }); var b = np.array(new int[] { 2, 2, 2 }); var result = np.greater_equal(a, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] - public async Task GreaterEqual_ArrayAndScalar_Compiles() + [TestMethod] + public void GreaterEqual_ArrayAndScalar_Compiles() { // NumPy: np.greater_equal([1, 2, 3], 2) -> [False, True, True] var a = np.array(new int[] { 1, 2, 3 }); var result = np.greater_equal(a, 2); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] - public async Task GreaterEqual_ScalarAndArray_Compiles() + [TestMethod] + public void GreaterEqual_ScalarAndArray_Compiles() { // NumPy: np.greater_equal(2, [1, 2, 3]) -> [True, True, False] var b = np.array(new int[] { 1, 2, 3 }); var result = np.greater_equal(2, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeFalse(); } #endregion #region Logical Operations (4 overloads) - [Test] - public async Task LogicalAnd_TwoArrays_Compiles() + [TestMethod] + public void LogicalAnd_TwoArrays_Compiles() { // NumPy: np.logical_and([True, True, False, False], [True, False, True, False]) // -> [True, False, False, False] @@ -294,15 +291,15 @@ public async Task LogicalAnd_TwoArrays_Compiles() var y = np.array(new bool[] { true, false, true, false }); var result = np.logical_and(x, y); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsFalse(); - await Assert.That(result.GetBoolean(3)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeFalse(); + result.GetBoolean(3).Should().BeFalse(); } - [Test] - public async Task LogicalOr_TwoArrays_Compiles() + [TestMethod] + public void LogicalOr_TwoArrays_Compiles() { // NumPy: np.logical_or([True, True, False, False], [True, False, True, False]) // -> [True, True, True, False] @@ -310,29 +307,29 @@ public async Task LogicalOr_TwoArrays_Compiles() var y = np.array(new bool[] { true, false, true, false }); var result = np.logical_or(x, y); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsTrue(); - await Assert.That(result.GetBoolean(3)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeTrue(); + result.GetBoolean(3).Should().BeFalse(); } - [Test] - public async Task LogicalNot_Array_Compiles() + [TestMethod] + public void LogicalNot_Array_Compiles() { // NumPy: np.logical_not([True, True, False, False]) -> [False, False, True, True] var x = np.array(new bool[] { true, true, false, false }); var result = np.logical_not(x); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); - await Assert.That(result.GetBoolean(3)).IsTrue(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); + result.GetBoolean(3).Should().BeTrue(); } - [Test] - public async Task LogicalXor_TwoArrays_Compiles() + [TestMethod] + public void LogicalXor_TwoArrays_Compiles() { // NumPy: np.logical_xor([True, True, False, False], [True, False, True, False]) // -> [False, True, True, False] @@ -340,32 +337,32 @@ public async Task LogicalXor_TwoArrays_Compiles() var y = np.array(new bool[] { true, false, true, false }); var result = np.logical_xor(x, y); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsFalse(); - await Assert.That(result.GetBoolean(1)).IsTrue(); - await Assert.That(result.GetBoolean(2)).IsTrue(); - await Assert.That(result.GetBoolean(3)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeFalse(); + result.GetBoolean(1).Should().BeTrue(); + result.GetBoolean(2).Should().BeTrue(); + result.GetBoolean(3).Should().BeFalse(); } #endregion #region Axis Manipulation - np.moveaxis (4 overloads) - [Test] - public async Task MoveAxis_IntSource_IntDest_Compiles() + [TestMethod] + public void MoveAxis_IntSource_IntDest_Compiles() { // NumPy: np.moveaxis(np.zeros((2, 3, 4)), 0, -1).shape -> (3, 4, 2) var a = np.zeros(new Shape(2, 3, 4)); var result = np.moveaxis(a, 0, -1); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape[0]).IsEqualTo(3); - await Assert.That(result.shape[1]).IsEqualTo(4); - await Assert.That(result.shape[2]).IsEqualTo(2); + result.Should().NotBeNull(); + result.shape[0].Should().Be(3); + result.shape[1].Should().Be(4); + result.shape[2].Should().Be(2); } - [Test] - public async Task MoveAxis_ArraySource_IntDest_Compiles() + [TestMethod] + public void MoveAxis_ArraySource_IntDest_Compiles() { // NumPy: np.moveaxis(np.zeros((2, 3, 4)), [0, 1], 0) is not valid actually // Let's do a valid one: moveaxis with array source to single dest @@ -375,283 +372,283 @@ public async Task MoveAxis_ArraySource_IntDest_Compiles() // This should move axis 0 to position 2 (equivalent to int, int) var result = np.moveaxis(a, new int[] { 0 }, 2); - await Assert.That(result).IsNotNull(); - await Assert.That(result.ndim).IsEqualTo(3); + result.Should().NotBeNull(); + result.ndim.Should().Be(3); } - [Test] - public async Task MoveAxis_IntSource_ArrayDest_Compiles() + [TestMethod] + public void MoveAxis_IntSource_ArrayDest_Compiles() { // Similar - move single source to array of destinations var a = np.zeros(new Shape(2, 3, 4)); var result = np.moveaxis(a, 0, new int[] { 2 }); - await Assert.That(result).IsNotNull(); - await Assert.That(result.ndim).IsEqualTo(3); + result.Should().NotBeNull(); + result.ndim.Should().Be(3); } - [Test] - public async Task MoveAxis_ArraySource_ArrayDest_Compiles() + [TestMethod] + public void MoveAxis_ArraySource_ArrayDest_Compiles() { // NumPy: np.moveaxis(np.zeros((2, 3, 4)), [0, 1], [1, 0]).shape -> (3, 2, 4) var a = np.zeros(new Shape(2, 3, 4)); var result = np.moveaxis(a, new int[] { 0, 1 }, new int[] { 1, 0 }); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape[0]).IsEqualTo(3); - await Assert.That(result.shape[1]).IsEqualTo(2); - await Assert.That(result.shape[2]).IsEqualTo(4); + result.Should().NotBeNull(); + result.shape[0].Should().Be(3); + result.shape[1].Should().Be(2); + result.shape[2].Should().Be(4); } #endregion #region Axis Manipulation - np.rollaxis (1 overload) - [Test] - public async Task RollAxis_WithStart_Compiles() + [TestMethod] + public void RollAxis_WithStart_Compiles() { // NumPy: np.rollaxis(np.zeros((2, 3, 4)), 2, 0).shape -> (4, 2, 3) var a = np.zeros(new Shape(2, 3, 4)); var result = np.rollaxis(a, 2, 0); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape[0]).IsEqualTo(4); - await Assert.That(result.shape[1]).IsEqualTo(2); - await Assert.That(result.shape[2]).IsEqualTo(3); + result.Should().NotBeNull(); + result.shape[0].Should().Be(4); + result.shape[1].Should().Be(2); + result.shape[2].Should().Be(3); } - [Test] - public async Task RollAxis_DefaultStart_Compiles() + [TestMethod] + public void RollAxis_DefaultStart_Compiles() { // NumPy: np.rollaxis(np.zeros((2, 3, 4)), 2).shape -> (4, 2, 3) (start defaults to 0) var a = np.zeros(new Shape(2, 3, 4)); var result = np.rollaxis(a, 2); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape[0]).IsEqualTo(4); - await Assert.That(result.shape[1]).IsEqualTo(2); - await Assert.That(result.shape[2]).IsEqualTo(3); + result.Should().NotBeNull(); + result.shape[0].Should().Be(4); + result.shape[1].Should().Be(2); + result.shape[2].Should().Be(3); } #endregion #region Axis Manipulation - np.swapaxes (1 overload) - [Test] - public async Task SwapAxes_Compiles() + [TestMethod] + public void SwapAxes_Compiles() { // NumPy: np.swapaxes(np.zeros((2, 3, 4)), 0, 2).shape -> (4, 3, 2) var a = np.zeros(new Shape(2, 3, 4)); var result = np.swapaxes(a, 0, 2); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape[0]).IsEqualTo(4); - await Assert.That(result.shape[1]).IsEqualTo(3); - await Assert.That(result.shape[2]).IsEqualTo(2); + result.Should().NotBeNull(); + result.shape[0].Should().Be(4); + result.shape[1].Should().Be(3); + result.shape[2].Should().Be(2); } #endregion #region Axis Manipulation - np.transpose (2 overloads) - [Test] - public async Task Transpose_NoArgs_Compiles() + [TestMethod] + public void Transpose_NoArgs_Compiles() { // NumPy: np.transpose(np.arange(6).reshape(2, 3)).shape -> (3, 2) var a = np.arange(6).reshape(2, 3); var result = np.transpose(a); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape[0]).IsEqualTo(3); - await Assert.That(result.shape[1]).IsEqualTo(2); + result.Should().NotBeNull(); + result.shape[0].Should().Be(3); + result.shape[1].Should().Be(2); } - [Test] - public async Task Transpose_WithPermute_Compiles() + [TestMethod] + public void Transpose_WithPermute_Compiles() { // NumPy: np.transpose(np.arange(6).reshape(2, 3), [1, 0]).shape -> (3, 2) var a = np.arange(6).reshape(2, 3); var result = np.transpose(a, new int[] { 1, 0 }); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape[0]).IsEqualTo(3); - await Assert.That(result.shape[1]).IsEqualTo(2); + result.Should().NotBeNull(); + result.shape[0].Should().Be(3); + result.shape[1].Should().Be(2); } - [Test] - public async Task Transpose_3D_Compiles() + [TestMethod] + public void Transpose_3D_Compiles() { // NumPy: np.transpose(np.arange(24).reshape(2, 3, 4), [2, 0, 1]).shape -> (4, 2, 3) var a = np.arange(24).reshape(2, 3, 4); var result = np.transpose(a, new int[] { 2, 0, 1 }); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape[0]).IsEqualTo(4); - await Assert.That(result.shape[1]).IsEqualTo(2); - await Assert.That(result.shape[2]).IsEqualTo(3); + result.Should().NotBeNull(); + result.shape[0].Should().Be(4); + result.shape[1].Should().Be(2); + result.shape[2].Should().Be(3); } #endregion #region np.unique (1 overload) - [Test] - public async Task Unique_1D_Compiles() + [TestMethod] + public void Unique_1D_Compiles() { // NumPy: np.unique([1, 2, 2, 3, 3, 3]) -> [1, 2, 3] var a = np.array(new int[] { 1, 2, 2, 3, 3, 3 }); var result = np.unique(a); - await Assert.That(result).IsNotNull(); - await Assert.That(result.size).IsEqualTo(3); - await Assert.That(result.GetInt32(0)).IsEqualTo(1); - await Assert.That(result.GetInt32(1)).IsEqualTo(2); - await Assert.That(result.GetInt32(2)).IsEqualTo(3); + result.Should().NotBeNull(); + result.size.Should().Be(3); + result.GetInt32(0).Should().Be(1); + result.GetInt32(1).Should().Be(2); + result.GetInt32(2).Should().Be(3); } - [Test] - public async Task Unique_2D_Flattens_Compiles() + [TestMethod] + public void Unique_2D_Flattens_Compiles() { // NumPy: np.unique([[1, 1], [2, 3]]) -> [1, 2, 3] var a = np.array(new int[,] { { 1, 1 }, { 2, 3 } }); var result = np.unique(a); - await Assert.That(result).IsNotNull(); - await Assert.That(result.ndim).IsEqualTo(1); - await Assert.That(result.size).IsEqualTo(3); + result.Should().NotBeNull(); + result.ndim.Should().Be(1); + result.size.Should().Be(3); } #endregion #region Counting/Indexing - np.count_nonzero (2 overloads) - [Test] - public async Task CountNonzero_NoAxis_ReturnsInt_Compiles() + [TestMethod] + public void CountNonzero_NoAxis_ReturnsInt_Compiles() { // NumPy: np.count_nonzero([0, 1, 0, 2, 0, 3]) -> 3 var a = np.array(new int[] { 0, 1, 0, 2, 0, 3 }); long result = np.count_nonzero(a); - await Assert.That(result).IsEqualTo(3); + result.Should().Be(3); } - [Test] - public async Task CountNonzero_WithAxis_ReturnsNDArray_Compiles() + [TestMethod] + public void CountNonzero_WithAxis_ReturnsNDArray_Compiles() { // NumPy: np.count_nonzero([[0, 1, 2], [3, 0, 5]], axis=0) -> [1, 1, 2] var a = np.array(new int[,] { { 0, 1, 2 }, { 3, 0, 5 } }); var result = np.count_nonzero(a, axis: 0); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(1L); - await Assert.That(result.GetInt64(2)).IsEqualTo(2L); + result.Should().NotBeNull(); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(1L); + result.GetInt64(2).Should().Be(2L); } - [Test] - public async Task CountNonzero_WithAxisKeepdims_Compiles() + [TestMethod] + public void CountNonzero_WithAxisKeepdims_Compiles() { // NumPy: np.count_nonzero([[0, 1, 2], [3, 0, 5]], axis=1, keepdims=True) -> [[2], [2]] var a = np.array(new int[,] { { 0, 1, 2 }, { 3, 0, 5 } }); var result = np.count_nonzero(a, axis: 1, keepdims: true); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 2, 1 }); + result.Should().NotBeNull(); + result.shape.Should().BeEquivalentTo(new long[] { 2, 1 }); } #endregion #region Counting/Indexing - np.nonzero (1 overload) - [Test] - public async Task Nonzero_1D_ReturnsNDArrayIntArray_Compiles() + [TestMethod] + public void Nonzero_1D_ReturnsNDArrayIntArray_Compiles() { // NumPy: np.nonzero([0, 1, 0, 2]) -> (array([1, 3]),) var a = np.array(new int[] { 0, 1, 0, 2 }); NDArray[] result = np.nonzero(a); - await Assert.That(result).IsNotNull(); - await Assert.That(result.Length).IsEqualTo(1); - await Assert.That(result[0].size).IsEqualTo(2); - await Assert.That(result[0].GetInt64(0)).IsEqualTo(1L); - await Assert.That(result[0].GetInt64(1)).IsEqualTo(3L); + result.Should().NotBeNull(); + result.Length.Should().Be(1); + result[0].size.Should().Be(2); + result[0].GetInt64(0).Should().Be(1L); + result[0].GetInt64(1).Should().Be(3L); } - [Test] - public async Task Nonzero_2D_ReturnsMultipleArrays_Compiles() + [TestMethod] + public void Nonzero_2D_ReturnsMultipleArrays_Compiles() { // NumPy: np.nonzero([[0, 1], [2, 0]]) -> (array([0, 1]), array([1, 0])) var a = np.array(new int[,] { { 0, 1 }, { 2, 0 } }); NDArray[] result = np.nonzero(a); - await Assert.That(result).IsNotNull(); - await Assert.That(result.Length).IsEqualTo(2); + result.Should().NotBeNull(); + result.Length.Should().Be(2); // Row indices of nonzero elements - await Assert.That(result[0].size).IsEqualTo(2); + result[0].size.Should().Be(2); // Column indices of nonzero elements - await Assert.That(result[1].size).IsEqualTo(2); + result[1].size.Should().Be(2); } #endregion #region Linear Algebra - np.dot (1 overload) - [Test] - public async Task Dot_2DMatrices_Compiles() + [TestMethod] + public void Dot_2DMatrices_Compiles() { // NumPy: np.dot([[1, 2], [3, 4]], [[5, 6], [7, 8]]) -> [[19, 22], [43, 50]] var a = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); var b = np.array(new int[,] { { 5, 6 }, { 7, 8 } }); var result = np.dot(a, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 2, 2 }); - await Assert.That(result.GetInt32(0, 0)).IsEqualTo(19); - await Assert.That(result.GetInt32(0, 1)).IsEqualTo(22); - await Assert.That(result.GetInt32(1, 0)).IsEqualTo(43); - await Assert.That(result.GetInt32(1, 1)).IsEqualTo(50); + result.Should().NotBeNull(); + result.shape.Should().BeEquivalentTo(new long[] { 2, 2 }); + result.GetInt32(0, 0).Should().Be(19); + result.GetInt32(0, 1).Should().Be(22); + result.GetInt32(1, 0).Should().Be(43); + result.GetInt32(1, 1).Should().Be(50); } - [Test] - public async Task Dot_1DVectors_Compiles() + [TestMethod] + public void Dot_1DVectors_Compiles() { // NumPy: np.dot([1, 2, 3], [4, 5, 6]) -> 32 (1*4 + 2*5 + 3*6) var a = np.array(new int[] { 1, 2, 3 }); var b = np.array(new int[] { 4, 5, 6 }); var result = np.dot(a, b); - await Assert.That(result).IsNotNull(); + result.Should().NotBeNull(); // For 1D vectors, dot returns a scalar (0D array) - await Assert.That(result.size).IsEqualTo(1); + result.size.Should().Be(1); } #endregion #region Linear Algebra - np.matmul (1 overload) - [Test] - public async Task Matmul_2DMatrices_Compiles() + [TestMethod] + public void Matmul_2DMatrices_Compiles() { // NumPy: np.matmul([[1, 2], [3, 4]], [[5, 6], [7, 8]]) -> [[19, 22], [43, 50]] var a = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); var b = np.array(new int[,] { { 5, 6 }, { 7, 8 } }); var result = np.matmul(a, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 2, 2 }); - await Assert.That(result.GetInt32(0, 0)).IsEqualTo(19); - await Assert.That(result.GetInt32(0, 1)).IsEqualTo(22); - await Assert.That(result.GetInt32(1, 0)).IsEqualTo(43); - await Assert.That(result.GetInt32(1, 1)).IsEqualTo(50); + result.Should().NotBeNull(); + result.shape.Should().BeEquivalentTo(new long[] { 2, 2 }); + result.GetInt32(0, 0).Should().Be(19); + result.GetInt32(0, 1).Should().Be(22); + result.GetInt32(1, 0).Should().Be(43); + result.GetInt32(1, 1).Should().Be(50); } #endregion #region Linear Algebra - np.outer (1 overload) - [Test] - public async Task Outer_1DVectors_Compiles() + [TestMethod] + public void Outer_1DVectors_Compiles() { // NumPy: np.outer([1, 2, 3], [4, 5, 6]) -> // [[ 4, 5, 6], @@ -661,137 +658,137 @@ public async Task Outer_1DVectors_Compiles() var b = np.array(new int[] { 4, 5, 6 }); var result = np.outer(a, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3, 3 }); - await Assert.That(result.GetInt32(0, 0)).IsEqualTo(4); - await Assert.That(result.GetInt32(0, 1)).IsEqualTo(5); - await Assert.That(result.GetInt32(0, 2)).IsEqualTo(6); - await Assert.That(result.GetInt32(1, 0)).IsEqualTo(8); - await Assert.That(result.GetInt32(1, 1)).IsEqualTo(10); - await Assert.That(result.GetInt32(1, 2)).IsEqualTo(12); - await Assert.That(result.GetInt32(2, 0)).IsEqualTo(12); - await Assert.That(result.GetInt32(2, 1)).IsEqualTo(15); - await Assert.That(result.GetInt32(2, 2)).IsEqualTo(18); + result.Should().NotBeNull(); + result.shape.Should().BeEquivalentTo(new long[] { 3, 3 }); + result.GetInt32(0, 0).Should().Be(4); + result.GetInt32(0, 1).Should().Be(5); + result.GetInt32(0, 2).Should().Be(6); + result.GetInt32(1, 0).Should().Be(8); + result.GetInt32(1, 1).Should().Be(10); + result.GetInt32(1, 2).Should().Be(12); + result.GetInt32(2, 0).Should().Be(12); + result.GetInt32(2, 1).Should().Be(15); + result.GetInt32(2, 2).Should().Be(18); } #endregion #region Min with dtype - np.amin (2 overloads) - [Test] - public async Task AminGeneric_ReturnsT_Compiles() + [TestMethod] + public void AminGeneric_ReturnsT_Compiles() { // NumPy: np.amin([1, 2, 3, 4, 5]) -> 1 var a = np.array(new int[] { 1, 2, 3, 4, 5 }); int result = np.amin(a); - await Assert.That(result).IsEqualTo(1); + result.Should().Be(1); } - [Test] - public async Task AminGeneric_Float_Compiles() + [TestMethod] + public void AminGeneric_Float_Compiles() { // NumPy: np.amin([1.5, 2.5, 0.5]) -> 0.5 var a = np.array(new double[] { 1.5, 2.5, 0.5 }); double result = np.amin(a); - await Assert.That(result).IsEqualTo(0.5); + result.Should().Be(0.5); } - [Test] - public async Task Amin_WithAxis_Compiles() + [TestMethod] + public void Amin_WithAxis_Compiles() { // NumPy: np.amin([[0, 1, 2], [3, 0, 5]], axis=0) -> [0, 0, 2] var a = np.array(new int[,] { { 0, 1, 2 }, { 3, 0, 5 } }); var result = np.amin(a, axis: 0); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That(result.GetInt32(0)).IsEqualTo(0); - await Assert.That(result.GetInt32(1)).IsEqualTo(0); - await Assert.That(result.GetInt32(2)).IsEqualTo(2); + result.Should().NotBeNull(); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + result.GetInt32(0).Should().Be(0); + result.GetInt32(1).Should().Be(0); + result.GetInt32(2).Should().Be(2); } - [Test] - public async Task Amin_WithAxisKeepdims_Compiles() + [TestMethod] + public void Amin_WithAxisKeepdims_Compiles() { // NumPy: np.amin([[0, 1, 2], [3, 0, 5]], axis=1, keepdims=True) -> [[0], [0]] var a = np.array(new int[,] { { 0, 1, 2 }, { 3, 0, 5 } }); var result = np.amin(a, axis: 1, keepdims: true); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 2, 1 }); + result.Should().NotBeNull(); + result.shape.Should().BeEquivalentTo(new long[] { 2, 1 }); } - [Test] - public async Task Amin_WithDtype_Compiles() + [TestMethod] + public void Amin_WithDtype_Compiles() { // Test that dtype parameter compiles (behavior may vary) var a = np.array(new int[] { 1, 2, 3, 4, 5 }); var result = np.amin(a, dtype: typeof(double)); - await Assert.That(result).IsNotNull(); + result.Should().NotBeNull(); } #endregion #region Min with dtype - np.min (1 overload) - [Test] - public async Task Min_WithAxis_Compiles() + [TestMethod] + public void Min_WithAxis_Compiles() { // NumPy: np.min([[0, 1, 2], [3, 0, 5]], axis=0) -> [0, 0, 2] var a = np.array(new int[,] { { 0, 1, 2 }, { 3, 0, 5 } }); var result = np.min(a, axis: 0); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); - await Assert.That(result.GetInt32(0)).IsEqualTo(0); - await Assert.That(result.GetInt32(1)).IsEqualTo(0); - await Assert.That(result.GetInt32(2)).IsEqualTo(2); + result.Should().NotBeNull(); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); + result.GetInt32(0).Should().Be(0); + result.GetInt32(1).Should().Be(0); + result.GetInt32(2).Should().Be(2); } - [Test] - public async Task Min_WithDtype_Compiles() + [TestMethod] + public void Min_WithDtype_Compiles() { // Test that dtype parameter compiles (behavior may vary) var a = np.array(new int[] { 1, 2, 3, 4, 5 }); var result = np.min(a, dtype: typeof(double)); - await Assert.That(result).IsNotNull(); + result.Should().NotBeNull(); } - [Test] - public async Task Min_WithAxisKeepdimsDtype_Compiles() + [TestMethod] + public void Min_WithAxisKeepdimsDtype_Compiles() { // Test full signature with all optional parameters var a = np.array(new int[,] { { 0, 1, 2 }, { 3, 0, 5 } }); var result = np.min(a, axis: 1, keepdims: true, dtype: null); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 2, 1 }); + result.Should().NotBeNull(); + result.shape.Should().BeEquivalentTo(new long[] { 2, 1 }); } #endregion #region Additional Edge Cases - [Test] - public async Task Comparison_WithFloats_Compiles() + [TestMethod] + public void Comparison_WithFloats_Compiles() { // NumPy: np.equal([1.0, 2.0, 3.0], [1.0, 2.1, 3.0]) -> [True, False, True] var a = np.array(new double[] { 1.0, 2.0, 3.0 }); var b = np.array(new double[] { 1.0, 2.1, 3.0 }); var result = np.equal(a, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsTrue(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeTrue(); } - [Test] - public async Task Logical_WithIntArrays_Compiles() + [TestMethod] + public void Logical_WithIntArrays_Compiles() { // NumPy: np.logical_and([1, 0, 1], [1, 1, 0]) -> [True, False, False] // Nonzero integers are truthy @@ -799,37 +796,37 @@ public async Task Logical_WithIntArrays_Compiles() var y = np.array(new int[] { 1, 1, 0 }); var result = np.logical_and(x, y); - await Assert.That(result).IsNotNull(); - await Assert.That(result.GetBoolean(0)).IsTrue(); - await Assert.That(result.GetBoolean(1)).IsFalse(); - await Assert.That(result.GetBoolean(2)).IsFalse(); + result.Should().NotBeNull(); + result.GetBoolean(0).Should().BeTrue(); + result.GetBoolean(1).Should().BeFalse(); + result.GetBoolean(2).Should().BeFalse(); } - [Test] - public async Task Transpose_1D_ReturnsUnchanged_Compiles() + [TestMethod] + public void Transpose_1D_ReturnsUnchanged_Compiles() { // NumPy: np.transpose([1, 2, 3]).shape -> (3,) - unchanged for 1D var a = np.array(new int[] { 1, 2, 3 }); var result = np.transpose(a); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 3 }); + result.Should().NotBeNull(); + result.shape.Should().BeEquivalentTo(new long[] { 3 }); } - [Test] - public async Task Unique_EmptyArray_Compiles() + [TestMethod] + public void Unique_EmptyArray_Compiles() { // NumPy: np.unique([]) -> [] var a = np.array(new int[0]); var result = np.unique(a); - await Assert.That(result).IsNotNull(); - await Assert.That(result.size).IsEqualTo(0); + result.Should().NotBeNull(); + result.size.Should().Be(0); } - [Test] + [TestMethod] [OpenBugs] // np.dot(matrix, vector) has existing bug - memory corruption - public async Task Dot_MatrixVector_Compiles() + public void Dot_MatrixVector_Compiles() { // NumPy: np.dot([[1, 2], [3, 4]], [1, 1]) -> [3, 7] // Note: This test verifies the signature compiles correctly. @@ -838,10 +835,10 @@ public async Task Dot_MatrixVector_Compiles() var b = np.array(new int[] { 1, 1 }); var result = np.dot(a, b); - await Assert.That(result).IsNotNull(); - await Assert.That(result.shape).IsEquivalentTo(new long[] { 2 }); - await Assert.That(result.GetInt32(0)).IsEqualTo(3); - await Assert.That(result.GetInt32(1)).IsEqualTo(7); + result.Should().NotBeNull(); + result.shape.Should().BeEquivalentTo(new long[] { 2 }); + result.GetInt32(0).Should().Be(3); + result.GetInt32(1).Should().Be(7); } #endregion diff --git a/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_UnaryMath.cs b/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_UnaryMath.cs index 12fa2f5c5..8bdcb37f9 100644 --- a/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_UnaryMath.cs +++ b/test/NumSharp.UnitTest/NpApiOverloads/NpApiOverloadTests_UnaryMath.cs @@ -1,7 +1,6 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; -using TUnit.Core; namespace NumSharp.UnitTest.NpApiOverloads; @@ -14,13 +13,14 @@ namespace NumSharp.UnitTest.NpApiOverloads; /// 2. Returns the correct type /// 3. Produces approximately correct values /// +[TestClass] public class NpApiOverloadTests_UnaryMath { private const double Tolerance = 1e-10; #region Absolute - np.absolute (3 overloads) - [Test] + [TestMethod] public void Absolute_NoParams_Compiles() { var a = np.array(new double[] { -1.5, 2.3, -3.7 }); @@ -31,7 +31,7 @@ public void Absolute_NoParams_Compiles() Assert.AreEqual(3.7, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Absolute_WithType_Compiles() { var a = np.array(new double[] { -1.5, 2.3, -3.7 }); @@ -40,7 +40,7 @@ public void Absolute_WithType_Compiles() Assert.AreEqual(NPTypeCode.Single, result.typecode); } - [Test] + [TestMethod] public void Absolute_WithNPTypeCode_Compiles() { var a = np.array(new double[] { -1.5, 2.3, -3.7 }); @@ -53,7 +53,7 @@ public void Absolute_WithNPTypeCode_Compiles() #region Abs - np.abs (3 overloads) - [Test] + [TestMethod] public void Abs_NoParams_Compiles() { var a = np.array(new double[] { -1.5, 2.3, -3.7 }); @@ -64,7 +64,7 @@ public void Abs_NoParams_Compiles() Assert.AreEqual(3.7, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Abs_WithType_Compiles() { var a = np.array(new double[] { -1.5, 2.3, -3.7 }); @@ -73,7 +73,7 @@ public void Abs_WithType_Compiles() Assert.AreEqual(NPTypeCode.Single, result.typecode); } - [Test] + [TestMethod] public void Abs_WithNPTypeCode_Compiles() { var a = np.array(new double[] { -1.5, 2.3, -3.7 }); @@ -86,7 +86,7 @@ public void Abs_WithNPTypeCode_Compiles() #region Sign - np.sign (2 overloads) - [Test] + [TestMethod] public void Sign_NoParams_Compiles() { var a = np.array(new double[] { -1.5, 0.0, 3.7 }); @@ -97,7 +97,7 @@ public void Sign_NoParams_Compiles() Assert.AreEqual(1.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Sign_WithType_Compiles() { var a = np.array(new double[] { -1.5, 0.0, 3.7 }); @@ -110,7 +110,7 @@ public void Sign_WithType_Compiles() #region Sqrt - np.sqrt (2 overloads) - [Test] + [TestMethod] public void Sqrt_NoParams_Compiles() { var a = np.array(new double[] { 1.0, 4.0, 9.0 }); @@ -121,7 +121,7 @@ public void Sqrt_NoParams_Compiles() Assert.AreEqual(3.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Sqrt_WithType_Compiles() { var a = np.array(new double[] { 1.0, 4.0, 9.0 }); @@ -134,7 +134,7 @@ public void Sqrt_WithType_Compiles() #region Cbrt - np.cbrt (2 overloads) - [Test] + [TestMethod] public void Cbrt_NoParams_Compiles() { var a = np.array(new double[] { 1.0, 8.0, 27.0 }); @@ -145,7 +145,7 @@ public void Cbrt_NoParams_Compiles() Assert.AreEqual(3.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Cbrt_WithType_Compiles() { var a = np.array(new double[] { 1.0, 8.0, 27.0 }); @@ -158,7 +158,7 @@ public void Cbrt_WithType_Compiles() #region Square - np.square (1 overload) - [Test] + [TestMethod] public void Square_NoParams_Compiles() { var a = np.array(new double[] { 1.5, 2.0, 3.0 }); @@ -173,7 +173,7 @@ public void Square_NoParams_Compiles() #region Ceil - np.ceil (2 overloads) - [Test] + [TestMethod] public void Ceil_NoParams_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -184,7 +184,7 @@ public void Ceil_NoParams_Compiles() Assert.AreEqual(4.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Ceil_WithType_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -197,7 +197,7 @@ public void Ceil_WithType_Compiles() #region Floor - np.floor (2 overloads) - [Test] + [TestMethod] public void Floor_NoParams_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -208,7 +208,7 @@ public void Floor_NoParams_Compiles() Assert.AreEqual(3.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Floor_WithType_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -221,7 +221,8 @@ public void Floor_WithType_Compiles() #region Trunc - np.trunc (2 overloads) - [Test] + [TestMethod] + [OpenBugs] // Vector512 SIMD: "Could not find Truncate for Vector512" on AVX-512 capable runners public void Trunc_NoParams_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -232,7 +233,7 @@ public void Trunc_NoParams_Compiles() Assert.AreEqual(3.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Trunc_WithType_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -245,7 +246,8 @@ public void Trunc_WithType_Compiles() #region Round_ - np.round_ (4 overloads) - [Test] + [TestMethod] + [OpenBugs] // Vector512 SIMD: "Could not find Round for Vector512" on AVX-512 capable runners public void Round_NoParams_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -257,7 +259,7 @@ public void Round_NoParams_Compiles() Assert.AreEqual(4.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Round_WithDecimals_Compiles() { var a = np.array(new double[] { 1.567, -2.345, 3.789 }); @@ -267,7 +269,7 @@ public void Round_WithDecimals_Compiles() Assert.AreEqual(3.8, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Round_WithType_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -276,7 +278,7 @@ public void Round_WithType_Compiles() Assert.AreEqual(NPTypeCode.Single, result.typecode); } - [Test] + [TestMethod] public void Round_WithDecimalsAndType_Compiles() { var a = np.array(new double[] { 1.567, -2.345, 3.789 }); @@ -289,7 +291,8 @@ public void Round_WithDecimalsAndType_Compiles() #region Around - np.around (4 overloads) - [Test] + [TestMethod] + [OpenBugs] // Vector512 SIMD: "Could not find Round for Vector512" on AVX-512 capable runners public void Around_NoParams_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -300,7 +303,7 @@ public void Around_NoParams_Compiles() Assert.AreEqual(4.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Around_WithDecimals_Compiles() { var a = np.array(new double[] { 1.567, -2.345, 3.789 }); @@ -310,7 +313,7 @@ public void Around_WithDecimals_Compiles() Assert.AreEqual(3.8, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Around_WithType_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -319,7 +322,7 @@ public void Around_WithType_Compiles() Assert.AreEqual(NPTypeCode.Single, result.typecode); } - [Test] + [TestMethod] public void Around_WithDecimalsAndType_Compiles() { var a = np.array(new double[] { 1.567, -2.345, 3.789 }); @@ -332,7 +335,7 @@ public void Around_WithDecimalsAndType_Compiles() #region Exp - np.exp (3 overloads) - [Test] + [TestMethod] public void Exp_NoParams_Compiles() { var a = np.array(new double[] { 0.0, 1.0, 2.0 }); @@ -343,7 +346,7 @@ public void Exp_NoParams_Compiles() Assert.AreEqual(Math.E * Math.E, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Exp_WithType_Compiles() { var a = np.array(new double[] { 0.0, 1.0, 2.0 }); @@ -352,7 +355,7 @@ public void Exp_WithType_Compiles() Assert.AreEqual(NPTypeCode.Single, result.typecode); } - [Test] + [TestMethod] public void Exp_WithNPTypeCode_Compiles() { var a = np.array(new double[] { 0.0, 1.0, 2.0 }); @@ -365,7 +368,7 @@ public void Exp_WithNPTypeCode_Compiles() #region Exp2 - np.exp2 (3 overloads) - [Test] + [TestMethod] public void Exp2_NoParams_Compiles() { var a = np.array(new double[] { 0.0, 1.0, 2.0 }); @@ -376,7 +379,7 @@ public void Exp2_NoParams_Compiles() Assert.AreEqual(4.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] [OpenBugs] // ILKernelGenerator Exp2 type conversion bug - InvalidProgramException public void Exp2_WithType_Compiles() { @@ -386,7 +389,7 @@ public void Exp2_WithType_Compiles() Assert.AreEqual(NPTypeCode.Single, result.typecode); } - [Test] + [TestMethod] [OpenBugs] // ILKernelGenerator Exp2 type conversion bug - InvalidProgramException public void Exp2_WithNPTypeCode_Compiles() { @@ -400,7 +403,7 @@ public void Exp2_WithNPTypeCode_Compiles() #region Expm1 - np.expm1 (3 overloads) - [Test] + [TestMethod] public void Expm1_NoParams_Compiles() { var a = np.array(new double[] { 0.0, 1.0, 2.0 }); @@ -410,7 +413,7 @@ public void Expm1_NoParams_Compiles() Assert.AreEqual(Math.E - 1, result.GetDouble(1), Tolerance); } - [Test] + [TestMethod] public void Expm1_WithType_Compiles() { var a = np.array(new double[] { 0.0, 1.0, 2.0 }); @@ -419,7 +422,7 @@ public void Expm1_WithType_Compiles() Assert.AreEqual(NPTypeCode.Single, result.typecode); } - [Test] + [TestMethod] public void Expm1_WithNPTypeCode_Compiles() { var a = np.array(new double[] { 0.0, 1.0, 2.0 }); @@ -432,7 +435,7 @@ public void Expm1_WithNPTypeCode_Compiles() #region Log - np.log (3 overloads) - [Test] + [TestMethod] public void Log_NoParams_Compiles() { var a = np.array(new double[] { 1.0, Math.E, Math.E * Math.E }); @@ -443,7 +446,7 @@ public void Log_NoParams_Compiles() Assert.AreEqual(2.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Log_WithType_Compiles() { var a = np.array(new double[] { 1.0, Math.E, Math.E * Math.E }); @@ -452,7 +455,7 @@ public void Log_WithType_Compiles() // Note: log(a, Type) doesn't convert dtype in current implementation } - [Test] + [TestMethod] public void Log_WithNPTypeCode_Compiles() { var a = np.array(new double[] { 1.0, Math.E, Math.E * Math.E }); @@ -464,7 +467,7 @@ public void Log_WithNPTypeCode_Compiles() #region Log2 - np.log2 (3 overloads) - [Test] + [TestMethod] public void Log2_NoParams_Compiles() { var a = np.array(new double[] { 1.0, 2.0, 4.0 }); @@ -475,7 +478,7 @@ public void Log2_NoParams_Compiles() Assert.AreEqual(2.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Log2_WithType_Compiles() { var a = np.array(new double[] { 1.0, 2.0, 4.0 }); @@ -483,7 +486,7 @@ public void Log2_WithType_Compiles() Assert.IsNotNull(result); } - [Test] + [TestMethod] public void Log2_WithNPTypeCode_Compiles() { var a = np.array(new double[] { 1.0, 2.0, 4.0 }); @@ -495,7 +498,7 @@ public void Log2_WithNPTypeCode_Compiles() #region Log10 - np.log10 (3 overloads) - [Test] + [TestMethod] public void Log10_NoParams_Compiles() { var a = np.array(new double[] { 1.0, 10.0, 100.0 }); @@ -506,7 +509,7 @@ public void Log10_NoParams_Compiles() Assert.AreEqual(2.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Log10_WithType_Compiles() { var a = np.array(new double[] { 1.0, 10.0, 100.0 }); @@ -514,7 +517,7 @@ public void Log10_WithType_Compiles() Assert.IsNotNull(result); } - [Test] + [TestMethod] public void Log10_WithNPTypeCode_Compiles() { var a = np.array(new double[] { 1.0, 10.0, 100.0 }); @@ -526,7 +529,7 @@ public void Log10_WithNPTypeCode_Compiles() #region Log1p - np.log1p (3 overloads) - [Test] + [TestMethod] public void Log1p_NoParams_Compiles() { var a = np.array(new double[] { 0.0, Math.E - 1, Math.E * Math.E - 1 }); @@ -536,7 +539,7 @@ public void Log1p_NoParams_Compiles() Assert.AreEqual(1.0, result.GetDouble(1), Tolerance); } - [Test] + [TestMethod] public void Log1p_WithType_Compiles() { var a = np.array(new double[] { 0.0, Math.E - 1, Math.E * Math.E - 1 }); @@ -544,7 +547,7 @@ public void Log1p_WithType_Compiles() Assert.IsNotNull(result); } - [Test] + [TestMethod] public void Log1p_WithNPTypeCode_Compiles() { var a = np.array(new double[] { 0.0, Math.E - 1, Math.E * Math.E - 1 }); @@ -556,7 +559,7 @@ public void Log1p_WithNPTypeCode_Compiles() #region Sin - np.sin (2 overloads) - [Test] + [TestMethod] public void Sin_NoParams_Compiles() { var a = np.array(new double[] { 0.0, Math.PI / 2, Math.PI }); @@ -567,7 +570,7 @@ public void Sin_NoParams_Compiles() Assert.AreEqual(0.0, result.GetDouble(2), 1e-9); // sin(pi) is approximately 0 } - [Test] + [TestMethod] public void Sin_WithType_Compiles() { var a = np.array(new double[] { 0.0, Math.PI / 2, Math.PI }); @@ -580,7 +583,7 @@ public void Sin_WithType_Compiles() #region Cos - np.cos (2 overloads) - [Test] + [TestMethod] public void Cos_NoParams_Compiles() { var a = np.array(new double[] { 0.0, Math.PI / 2, Math.PI }); @@ -591,7 +594,7 @@ public void Cos_NoParams_Compiles() Assert.AreEqual(-1.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Cos_WithType_Compiles() { var a = np.array(new double[] { 0.0, Math.PI / 2, Math.PI }); @@ -604,7 +607,7 @@ public void Cos_WithType_Compiles() #region Tan - np.tan (2 overloads) - [Test] + [TestMethod] public void Tan_NoParams_Compiles() { var a = np.array(new double[] { 0.0, Math.PI / 4 }); @@ -614,7 +617,7 @@ public void Tan_NoParams_Compiles() Assert.AreEqual(1.0, result.GetDouble(1), Tolerance); } - [Test] + [TestMethod] public void Tan_WithType_Compiles() { var a = np.array(new double[] { 0.0, Math.PI / 4 }); @@ -627,7 +630,7 @@ public void Tan_WithType_Compiles() #region Arcsin - np.arcsin (2 overloads) - [Test] + [TestMethod] public void Arcsin_NoParams_Compiles() { var a = np.array(new double[] { 0.0, 0.5, 1.0 }); @@ -637,7 +640,7 @@ public void Arcsin_NoParams_Compiles() Assert.AreEqual(Math.PI / 2, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Arcsin_WithType_Compiles() { var a = np.array(new double[] { 0.0, 0.5, 1.0 }); @@ -650,7 +653,7 @@ public void Arcsin_WithType_Compiles() #region Arccos - np.arccos (2 overloads) - [Test] + [TestMethod] public void Arccos_NoParams_Compiles() { var a = np.array(new double[] { 1.0, 0.5, 0.0 }); @@ -660,7 +663,7 @@ public void Arccos_NoParams_Compiles() Assert.AreEqual(Math.PI / 2, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Arccos_WithType_Compiles() { var a = np.array(new double[] { 1.0, 0.5, 0.0 }); @@ -673,7 +676,7 @@ public void Arccos_WithType_Compiles() #region Arctan - np.arctan (2 overloads) - [Test] + [TestMethod] public void Arctan_NoParams_Compiles() { var a = np.array(new double[] { 0.0, 1.0 }); @@ -683,7 +686,7 @@ public void Arctan_NoParams_Compiles() Assert.AreEqual(Math.PI / 4, result.GetDouble(1), Tolerance); } - [Test] + [TestMethod] public void Arctan_WithType_Compiles() { var a = np.array(new double[] { 0.0, 1.0 }); @@ -696,7 +699,7 @@ public void Arctan_WithType_Compiles() #region Sinh - np.sinh (2 overloads) - [Test] + [TestMethod] public void Sinh_NoParams_Compiles() { var a = np.array(new double[] { 0.0, 1.0 }); @@ -706,7 +709,7 @@ public void Sinh_NoParams_Compiles() Assert.AreEqual(Math.Sinh(1.0), result.GetDouble(1), Tolerance); } - [Test] + [TestMethod] public void Sinh_WithType_Compiles() { var a = np.array(new double[] { 0.0, 1.0 }); @@ -719,7 +722,7 @@ public void Sinh_WithType_Compiles() #region Cosh - np.cosh (2 overloads) - [Test] + [TestMethod] public void Cosh_NoParams_Compiles() { var a = np.array(new double[] { 0.0, 1.0 }); @@ -729,7 +732,7 @@ public void Cosh_NoParams_Compiles() Assert.AreEqual(Math.Cosh(1.0), result.GetDouble(1), Tolerance); } - [Test] + [TestMethod] public void Cosh_WithType_Compiles() { var a = np.array(new double[] { 0.0, 1.0 }); @@ -742,7 +745,7 @@ public void Cosh_WithType_Compiles() #region Tanh - np.tanh (2 overloads) - [Test] + [TestMethod] public void Tanh_NoParams_Compiles() { var a = np.array(new double[] { 0.0, 1.0 }); @@ -752,7 +755,7 @@ public void Tanh_NoParams_Compiles() Assert.AreEqual(Math.Tanh(1.0), result.GetDouble(1), Tolerance); } - [Test] + [TestMethod] public void Tanh_WithType_Compiles() { var a = np.array(new double[] { 0.0, 1.0 }); @@ -765,7 +768,7 @@ public void Tanh_WithType_Compiles() #region Deg2Rad - np.deg2rad (2 overloads) - [Test] + [TestMethod] public void Deg2Rad_NoParams_Compiles() { var a = np.array(new double[] { 0.0, 90.0, 180.0 }); @@ -776,7 +779,7 @@ public void Deg2Rad_NoParams_Compiles() Assert.AreEqual(Math.PI, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Deg2Rad_WithType_Compiles() { var a = np.array(new double[] { 0.0, 90.0, 180.0 }); @@ -789,7 +792,7 @@ public void Deg2Rad_WithType_Compiles() #region Rad2Deg - np.rad2deg (2 overloads) - [Test] + [TestMethod] public void Rad2Deg_NoParams_Compiles() { var a = np.array(new double[] { 0.0, Math.PI / 2, Math.PI }); @@ -800,7 +803,7 @@ public void Rad2Deg_NoParams_Compiles() Assert.AreEqual(180.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Rad2Deg_WithType_Compiles() { var a = np.array(new double[] { 0.0, Math.PI / 2, Math.PI }); @@ -813,7 +816,7 @@ public void Rad2Deg_WithType_Compiles() #region Radians - np.radians (2 overloads) - [Test] + [TestMethod] public void Radians_NoParams_Compiles() { var a = np.array(new double[] { 0.0, 90.0, 180.0 }); @@ -824,7 +827,7 @@ public void Radians_NoParams_Compiles() Assert.AreEqual(Math.PI, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Radians_WithType_Compiles() { var a = np.array(new double[] { 0.0, 90.0, 180.0 }); @@ -837,7 +840,7 @@ public void Radians_WithType_Compiles() #region Degrees - np.degrees (2 overloads) - [Test] + [TestMethod] public void Degrees_NoParams_Compiles() { var a = np.array(new double[] { 0.0, Math.PI / 2, Math.PI }); @@ -848,7 +851,7 @@ public void Degrees_NoParams_Compiles() Assert.AreEqual(180.0, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Degrees_WithType_Compiles() { var a = np.array(new double[] { 0.0, Math.PI / 2, Math.PI }); @@ -861,7 +864,7 @@ public void Degrees_WithType_Compiles() #region Positive - np.positive (1 overload) - [Test] + [TestMethod] public void Positive_NoParams_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -877,7 +880,7 @@ public void Positive_NoParams_Compiles() #region Negative - np.negative (1 overload) - [Test] + [TestMethod] public void Negative_NoParams_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -892,7 +895,7 @@ public void Negative_NoParams_Compiles() #region Reciprocal - np.reciprocal (2 overloads) - [Test] + [TestMethod] public void Reciprocal_NoParams_Compiles() { var a = np.array(new double[] { 1.0, 2.0, 4.0 }); @@ -903,7 +906,7 @@ public void Reciprocal_NoParams_Compiles() Assert.AreEqual(0.25, result.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Reciprocal_WithType_Compiles() { var a = np.array(new double[] { 1.0, 2.0, 4.0 }); @@ -916,7 +919,7 @@ public void Reciprocal_WithType_Compiles() #region Modf - np.modf (2 overloads) - [Test] + [TestMethod] public void Modf_NoParams_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); @@ -932,7 +935,7 @@ public void Modf_NoParams_Compiles() Assert.AreEqual(3.0, integral.GetDouble(2), Tolerance); } - [Test] + [TestMethod] public void Modf_WithType_Compiles() { var a = np.array(new double[] { 1.5, -2.3, 3.7 }); diff --git a/test/NumSharp.UnitTest/NumPyPortedTests/ArgMaxArgMinEdgeCaseTests.cs b/test/NumSharp.UnitTest/NumPyPortedTests/ArgMaxArgMinEdgeCaseTests.cs index 96509a174..c971ad330 100644 --- a/test/NumSharp.UnitTest/NumPyPortedTests/ArgMaxArgMinEdgeCaseTests.cs +++ b/test/NumSharp.UnitTest/NumPyPortedTests/ArgMaxArgMinEdgeCaseTests.cs @@ -3,7 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.Backends; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.NumPyPortedTests { @@ -11,11 +10,12 @@ namespace NumSharp.UnitTest.NumPyPortedTests /// Tests ported from NumPy for np.argmax and np.argmin. /// Covers edge cases including NaN handling, axis combinations, and keepdims. /// + [TestClass] public class ArgMaxArgMinEdgeCaseTests { #region Basic ArgMax Tests - [Test] + [TestMethod] public void ArgMax_1DArray() { // NumPy: argmax([1,3,2,4,0]) = 3 @@ -24,7 +24,7 @@ public void ArgMax_1DArray() Assert.AreEqual(3, (int)result); } - [Test] + [TestMethod] public void ArgMin_1DArray() { // NumPy: argmin([1,3,2,4,0]) = 4 @@ -37,7 +37,7 @@ public void ArgMin_1DArray() #region 2D Array Tests - [Test] + [TestMethod] public void ArgMax_2DArray_Flattened() { // NumPy: argmax([[1,5,3],[4,2,6]]) = 5 (flattened index) @@ -46,7 +46,7 @@ public void ArgMax_2DArray_Flattened() Assert.AreEqual(5, (int)result); } - [Test] + [TestMethod] public void ArgMax_2DArray_Axis0() { // NumPy: argmax([[1,5,3],[4,2,6]], axis=0) = [1, 0, 1] @@ -56,7 +56,7 @@ public void ArgMax_2DArray_Axis0() result.Should().BeOfValues(1, 0, 1); } - [Test] + [TestMethod] public void ArgMax_2DArray_Axis1() { // NumPy: argmax([[1,5,3],[4,2,6]], axis=1) = [1, 2] @@ -66,7 +66,7 @@ public void ArgMax_2DArray_Axis1() result.Should().BeOfValues(1, 2); } - [Test] + [TestMethod] public void ArgMin_2DArray_Axis0() { // NumPy: argmin([[1,5,3],[4,2,6]], axis=0) = [0, 1, 0] @@ -76,7 +76,7 @@ public void ArgMin_2DArray_Axis0() result.Should().BeOfValues(0, 1, 0); } - [Test] + [TestMethod] public void ArgMin_2DArray_Axis1() { // NumPy: argmin([[1,5,3],[4,2,6]], axis=1) = [0, 1] @@ -90,7 +90,7 @@ public void ArgMin_2DArray_Axis1() #region keepdims Tests - [Test] + [TestMethod] public void ArgMax_Keepdims_True() { // NumPy: argmax([[1,5,3],[4,2,6]], axis=1, keepdims=True) = [[1],[2]] @@ -100,7 +100,7 @@ public void ArgMax_Keepdims_True() result.Should().BeOfValues(1, 2); } - [Test] + [TestMethod] public void ArgMax_Keepdims_False() { var a = np.array(new int[,] { { 1, 5, 3 }, { 4, 2, 6 } }); @@ -108,7 +108,7 @@ public void ArgMax_Keepdims_False() result.Should().BeShaped(2); } - [Test] + [TestMethod] public void ArgMin_Keepdims_True() { var a = np.array(new int[,] { { 1, 5, 3 }, { 4, 2, 6 } }); @@ -120,7 +120,7 @@ public void ArgMin_Keepdims_True() #region Negative Axis Tests - [Test] + [TestMethod] public void ArgMax_NegativeAxis_Minus1() { var a = np.array(new int[,] { { 1, 5, 3 }, { 4, 2, 6 } }); @@ -129,7 +129,7 @@ public void ArgMax_NegativeAxis_Minus1() result.Should().BeOfValues(1, 2); } - [Test] + [TestMethod] public void ArgMax_NegativeAxis_Minus2() { var a = np.array(new int[,] { { 1, 5, 3 }, { 4, 2, 6 } }); @@ -142,7 +142,7 @@ public void ArgMax_NegativeAxis_Minus2() #region NaN Handling Tests - [Test] + [TestMethod] public void ArgMax_FirstNaN_ReturnsNaNIndex() { // NumPy: argmax([1, nan, 3, 2]) = 1 (first NaN wins) @@ -151,7 +151,7 @@ public void ArgMax_FirstNaN_ReturnsNaNIndex() Assert.AreEqual(1, (int)result); } - [Test] + [TestMethod] public void ArgMin_FirstNaN_ReturnsNaNIndex() { // NumPy: argmin([1, nan, 3, 2]) = 1 (first NaN wins) @@ -160,7 +160,7 @@ public void ArgMin_FirstNaN_ReturnsNaNIndex() Assert.AreEqual(1, (int)result); } - [Test] + [TestMethod] public void ArgMax_NaNLater_ReturnsNaNIndex() { // NumPy: argmax([1, 3, nan, 2]) = 2 (NaN index) @@ -169,7 +169,7 @@ public void ArgMax_NaNLater_ReturnsNaNIndex() Assert.AreEqual(2, (int)result); } - [Test] + [TestMethod] public void ArgMax_AllNaN_ReturnsFirst() { // NumPy: argmax([nan, nan]) = 0 @@ -182,7 +182,7 @@ public void ArgMax_AllNaN_ReturnsFirst() #region 3D Array Shape Tests - [Test] + [TestMethod] public void ArgMax_3DArray_Axis0() { var a = np.arange(24).reshape(2, 3, 4); @@ -190,7 +190,7 @@ public void ArgMax_3DArray_Axis0() result.Should().BeShaped(3, 4); } - [Test] + [TestMethod] public void ArgMax_3DArray_Axis1() { var a = np.arange(24).reshape(2, 3, 4); @@ -198,7 +198,7 @@ public void ArgMax_3DArray_Axis1() result.Should().BeShaped(2, 4); } - [Test] + [TestMethod] public void ArgMax_3DArray_Axis2() { var a = np.arange(24).reshape(2, 3, 4); @@ -210,7 +210,7 @@ public void ArgMax_3DArray_Axis2() #region Tie-Breaking Tests (First Wins) - [Test] + [TestMethod] public void ArgMax_TieBreaking_FirstWins() { // NumPy: argmax([3,1,3,2,3]) = 0 (first max wins) @@ -219,7 +219,7 @@ public void ArgMax_TieBreaking_FirstWins() Assert.AreEqual(0, (int)result); } - [Test] + [TestMethod] public void ArgMin_TieBreaking_FirstWins() { // NumPy: argmin([1,3,1,2,1]) = 0 (first min wins) @@ -232,7 +232,7 @@ public void ArgMin_TieBreaking_FirstWins() #region Result Dtype Tests - [Test] + [TestMethod] public void ArgMax_ResultDtype_IsInt() { var a = np.arange(1000); @@ -244,7 +244,7 @@ public void ArgMax_ResultDtype_IsInt() #region Single Element - [Test] + [TestMethod] public void ArgMax_SingleElement() { var a = np.array(new int[] { 42 }); @@ -252,7 +252,7 @@ public void ArgMax_SingleElement() Assert.AreEqual(0, (int)result); } - [Test] + [TestMethod] public void ArgMin_SingleElement() { var a = np.array(new int[] { 42 }); @@ -264,7 +264,7 @@ public void ArgMin_SingleElement() #region Negative Values - [Test] + [TestMethod] public void ArgMax_WithNegativeValues() { var a = np.array(new int[] { -5, -2, -8, -1, -3 }); @@ -272,7 +272,7 @@ public void ArgMax_WithNegativeValues() Assert.AreEqual(3, (int)result); // -1 is the max } - [Test] + [TestMethod] public void ArgMin_WithNegativeValues() { var a = np.array(new int[] { -5, -2, -8, -1, -3 }); @@ -284,7 +284,7 @@ public void ArgMin_WithNegativeValues() #region Float Values - [Test] + [TestMethod] public void ArgMax_FloatArray() { var a = np.array(new double[] { 1.1, 3.3, 2.2, 4.4, 0.0 }); @@ -292,7 +292,7 @@ public void ArgMax_FloatArray() Assert.AreEqual(3, (int)result); } - [Test] + [TestMethod] public void ArgMin_FloatArray() { var a = np.array(new double[] { 1.1, 3.3, 2.2, 4.4, 0.0 }); @@ -304,7 +304,7 @@ public void ArgMin_FloatArray() #region Infinity Handling - [Test] + [TestMethod] public void ArgMax_WithPositiveInf() { var a = np.array(new double[] { 1.0, double.PositiveInfinity, 3.0, 2.0 }); @@ -312,7 +312,7 @@ public void ArgMax_WithPositiveInf() Assert.AreEqual(1, (int)result); } - [Test] + [TestMethod] public void ArgMin_WithNegativeInf() { var a = np.array(new double[] { 1.0, double.NegativeInfinity, 3.0, 2.0 }); @@ -324,7 +324,7 @@ public void ArgMin_WithNegativeInf() #region All Same Values - [Test] + [TestMethod] public void ArgMax_AllSameValues_ReturnsFirst() { var a = np.full(new Shape(7), 5); @@ -332,7 +332,7 @@ public void ArgMax_AllSameValues_ReturnsFirst() Assert.AreEqual(0, (int)result); } - [Test] + [TestMethod] public void ArgMin_AllSameValues_ReturnsFirst() { var a = np.full(new Shape(7), 5); @@ -344,7 +344,7 @@ public void ArgMin_AllSameValues_ReturnsFirst() #region Boolean Array - [Test] + [TestMethod] public void ArgMax_BooleanArray() { var a = np.array(new bool[] { false, true, false, true, false }); @@ -352,7 +352,7 @@ public void ArgMax_BooleanArray() Assert.AreEqual(1, (int)result); } - [Test] + [TestMethod] public void ArgMin_BooleanArray() { var a = np.array(new bool[] { true, false, true, false, true }); @@ -364,7 +364,7 @@ public void ArgMin_BooleanArray() #region Strided Array - [Test] + [TestMethod] public void ArgMax_StridedArray() { var a = np.array(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -377,7 +377,7 @@ public void ArgMax_StridedArray() #region Large Array - [Test] + [TestMethod] public void ArgMax_LargeArray() { var a = np.arange(10000); @@ -385,7 +385,7 @@ public void ArgMax_LargeArray() Assert.AreEqual(9999, (int)result); } - [Test] + [TestMethod] public void ArgMin_LargeArray() { var a = np.arange(10000); @@ -397,7 +397,7 @@ public void ArgMin_LargeArray() #region Multiple Dtypes - [Test] + [TestMethod] public void ArgMax_Int32() { var a = np.array(new int[] { 1, 3, 2 }); @@ -405,7 +405,7 @@ public void ArgMax_Int32() Assert.AreEqual(1, (int)result); } - [Test] + [TestMethod] public void ArgMax_Int64() { var a = np.array(new long[] { 1, 3, 2 }); @@ -413,7 +413,7 @@ public void ArgMax_Int64() Assert.AreEqual(1, (int)result); } - [Test] + [TestMethod] public void ArgMax_Float32() { var a = np.array(new float[] { 1f, 3f, 2f }); @@ -421,7 +421,7 @@ public void ArgMax_Float32() Assert.AreEqual(1, (int)result); } - [Test] + [TestMethod] public void ArgMax_Byte() { var a = np.array(new byte[] { 1, 3, 2 }); diff --git a/test/NumSharp.UnitTest/NumPyPortedTests/ClipEdgeCaseTests.cs b/test/NumSharp.UnitTest/NumPyPortedTests/ClipEdgeCaseTests.cs index 33012200f..34860ee5e 100644 --- a/test/NumSharp.UnitTest/NumPyPortedTests/ClipEdgeCaseTests.cs +++ b/test/NumSharp.UnitTest/NumPyPortedTests/ClipEdgeCaseTests.cs @@ -3,7 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.Backends; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.NumPyPortedTests { @@ -11,11 +10,12 @@ namespace NumSharp.UnitTest.NumPyPortedTests /// Tests ported from NumPy test_numeric.py TestClip class. /// Covers edge cases for np.clip operation. /// + [TestClass] public class ClipEdgeCaseTests { #region Basic Clip Tests - [Test] + [TestMethod] public void Clip_BasicIntArray() { // NumPy: clip([-1,5,2,3,10,-4,-9], 2, 7) = [2, 5, 2, 3, 7, 2, 2] @@ -24,7 +24,7 @@ public void Clip_BasicIntArray() result.Should().BeOfValues(2, 5, 2, 3, 7, 2, 2); } - [Test] + [TestMethod] public void Clip_2DArray() { // NumPy: clip(arange(12).reshape(3,4), 3, 8) @@ -38,7 +38,7 @@ public void Clip_2DArray() #region Clip with None Tests - [Test] + [TestMethod] public void Clip_NoneMin_OnlyMaxApplied() { // NumPy: clip(arange(10), None, 5) = [0,1,2,3,4,5,5,5,5,5] @@ -47,7 +47,7 @@ public void Clip_NoneMin_OnlyMaxApplied() result.Should().BeOfValues(0, 1, 2, 3, 4, 5, 5, 5, 5, 5); } - [Test] + [TestMethod] public void Clip_NoneMax_OnlyMinApplied() { // NumPy: clip(arange(10), 3, None) = [3,3,3,3,4,5,6,7,8,9] @@ -56,7 +56,7 @@ public void Clip_NoneMax_OnlyMinApplied() result.Should().BeOfValues(3, 3, 3, 3, 4, 5, 6, 7, 8, 9); } - [Test] + [TestMethod] public void Clip_BothNone_ReturnsOriginal() { // NumPy: clip(arange(10), None, None) = arange(10) @@ -69,7 +69,7 @@ public void Clip_BothNone_ReturnsOriginal() #region Min > Max Edge Case (from test_clip_value_min_max_flip) - [Test] + [TestMethod] public void Clip_MinGreaterThanMax_UsesMaxValue() { // NumPy: clip(arange(10), 5, 3) = all 3s @@ -83,7 +83,7 @@ public void Clip_MinGreaterThanMax_UsesMaxValue() #region NaN Handling (from test_clip_nan) - [Test] + [TestMethod] public void Clip_NaNMin_ReturnsAllNaN() { // NumPy: clip(arange(7.), min=np.nan) = [nan, nan, ...] @@ -97,7 +97,7 @@ public void Clip_NaNMin_ReturnsAllNaN() } } - [Test] + [TestMethod] public void Clip_NaNMax_ReturnsAllNaN() { // NumPy: clip(arange(7.), max=np.nan) = [nan, nan, ...] @@ -115,7 +115,7 @@ public void Clip_NaNMax_ReturnsAllNaN() #region Dtype Preservation Tests - [Test] + [TestMethod] public void Clip_Int32_PreservesDtype() { // Explicit int32 array for testing dtype preservation @@ -124,7 +124,7 @@ public void Clip_Int32_PreservesDtype() Assert.AreEqual(np.int32, result.dtype); } - [Test] + [TestMethod] public void Clip_Int64_PreservesDtype() { // np.arange returns int64 by default (NumPy 2.x) @@ -133,7 +133,7 @@ public void Clip_Int64_PreservesDtype() Assert.AreEqual(np.int64, result.dtype); } - [Test] + [TestMethod] public void Clip_Float32_PreservesDtype() { var arr = np.arange(10f); // float32 from float overload @@ -141,7 +141,7 @@ public void Clip_Float32_PreservesDtype() Assert.AreEqual(np.float32, result.dtype); } - [Test] + [TestMethod] public void Clip_Float64_PreservesDtype() { var arr = np.arange(10.0); // float64 from double overload @@ -153,7 +153,7 @@ public void Clip_Float64_PreservesDtype() #region Strided Array Tests (from test_clip_non_contig) - [Test] + [TestMethod] public void Clip_StridedArray() { // NumPy: clip(a[::2], 3, 15) where a = arange(20) @@ -168,7 +168,7 @@ public void Clip_StridedArray() #region Transposed Array Tests (from test_clip_with_out_transposed) - [Test] + [TestMethod] public void Clip_TransposedArray() { // NumPy: clip(arange(16).reshape(4,4).T, 4, 10) @@ -183,7 +183,7 @@ public void Clip_TransposedArray() #region Broadcasting Tests - [Test] + [TestMethod] public void Clip_BroadcastMin() { var a = np.arange(12).reshape(3, 4); @@ -194,7 +194,7 @@ public void Clip_BroadcastMin() result.Should().BeOfValues(3, 3, 3, 3, 4, 5, 6, 7, 8, 8, 8, 8); } - [Test] + [TestMethod] public void Clip_BroadcastMax() { var a = np.arange(12).reshape(3, 4); @@ -209,7 +209,7 @@ public void Clip_BroadcastMax() #region Special Float Values - [Test] + [TestMethod] public void Clip_WithInfinity() { var a = np.array(new double[] { -100.0, -1.0, 0.0, 1.0, 100.0 }); @@ -221,7 +221,7 @@ public void Clip_WithInfinity() result2.Should().BeOfValues(-50.0, -1.0, 0.0, 1.0, 100.0); } - [Test] + [TestMethod] public void Clip_InfiniteValuesInArray() { var a = np.array(new double[] { double.NegativeInfinity, -1.0, 0.0, 1.0, double.PositiveInfinity }); @@ -234,7 +234,7 @@ public void Clip_InfiniteValuesInArray() #region Empty Array - [Test] + [TestMethod] public void Clip_EmptyArray_ReturnsEmptyArray() { var a = np.array(new double[0]); @@ -247,7 +247,7 @@ public void Clip_EmptyArray_ReturnsEmptyArray() #region Single Element - [Test] + [TestMethod] public void Clip_SingleElement_BelowMin() { var a = np.array(new double[] { -5.0 }); @@ -255,7 +255,7 @@ public void Clip_SingleElement_BelowMin() result.Should().BeOfValues(0.0); } - [Test] + [TestMethod] public void Clip_SingleElement_AboveMax() { var a = np.array(new double[] { 15.0 }); @@ -263,7 +263,7 @@ public void Clip_SingleElement_AboveMax() result.Should().BeOfValues(10.0); } - [Test] + [TestMethod] public void Clip_SingleElement_InRange() { var a = np.array(new double[] { 5.0 }); @@ -275,7 +275,7 @@ public void Clip_SingleElement_InRange() #region Scalar Min/Max - [Test] + [TestMethod] public void Clip_ScalarMinMax() { var a = np.arange(10); @@ -287,7 +287,7 @@ public void Clip_ScalarMinMax() #region All Same Value - [Test] + [TestMethod] public void Clip_AllSameValue_BelowMin() { // NumPy-aligned: np.full(shape, fill_value) @@ -296,7 +296,7 @@ public void Clip_AllSameValue_BelowMin() result.GetData().Should().AllBeEquivalentTo(0L); } - [Test] + [TestMethod] public void Clip_AllSameValue_AboveMax() { var a = np.full(new Shape(10), 15); @@ -304,7 +304,7 @@ public void Clip_AllSameValue_AboveMax() result.GetData().Should().AllBeEquivalentTo(10L); } - [Test] + [TestMethod] public void Clip_AllSameValue_InRange() { var a = np.full(new Shape(10), 5); diff --git a/test/NumSharp.UnitTest/NumPyPortedTests/ClipNDArrayTests.cs b/test/NumSharp.UnitTest/NumPyPortedTests/ClipNDArrayTests.cs index b5d684967..9a6673d2b 100644 --- a/test/NumSharp.UnitTest/NumPyPortedTests/ClipNDArrayTests.cs +++ b/test/NumSharp.UnitTest/NumPyPortedTests/ClipNDArrayTests.cs @@ -9,11 +9,12 @@ namespace NumSharp.UnitTest.NumPyPortedTests /// Tests for np.clip with array-valued min/max bounds. /// Validates the IL kernel migration of Default.ClipNDArray.cs. /// + [TestClass] public class ClipNDArrayTests { #region Basic Array Bounds Tests - [Test] + [TestMethod] public void ClipNDArray_BasicArrayBounds_MatchesNumPy() { // NumPy: np.clip([1,2,3,4,5,6,7,8,9], [2,2,2,3,3,3,4,4,4], [5,5,5,6,6,6,7,7,7]) @@ -27,7 +28,7 @@ public void ClipNDArray_BasicArrayBounds_MatchesNumPy() result.Should().BeOfValues(2, 2, 3, 4, 5, 6, 7, 7, 7); } - [Test] + [TestMethod] public void ClipNDArray_MinArrayOnly_MatchesNumPy() { // NumPy: np.clip([1,2,3,4,5], [2,2,2,2,2], None) = [2,2,3,4,5] @@ -39,7 +40,7 @@ public void ClipNDArray_MinArrayOnly_MatchesNumPy() result.Should().BeOfValues(2, 2, 3, 4, 5); } - [Test] + [TestMethod] public void ClipNDArray_MaxArrayOnly_MatchesNumPy() { // NumPy: np.clip([1,2,3,4,5], None, [3,3,3,3,3]) = [1,2,3,3,3] @@ -55,7 +56,7 @@ public void ClipNDArray_MaxArrayOnly_MatchesNumPy() #region Broadcasting Tests - [Test] + [TestMethod] public void ClipNDArray_BroadcastMinAlongAxis0_MatchesNumPy() { // NumPy: @@ -71,7 +72,7 @@ public void ClipNDArray_BroadcastMinAlongAxis0_MatchesNumPy() result.Should().BeOfValues(2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 10, 11); } - [Test] + [TestMethod] public void ClipNDArray_BroadcastMaxAlongAxis0_MatchesNumPy() { // NumPy: @@ -87,7 +88,7 @@ public void ClipNDArray_BroadcastMaxAlongAxis0_MatchesNumPy() result.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10); } - [Test] + [TestMethod] public void ClipNDArray_ScalarMinArrayMax_MatchesNumPy() { // Mixed: scalar min, array max @@ -100,7 +101,7 @@ public void ClipNDArray_ScalarMinArrayMax_MatchesNumPy() result.Should().BeOfValues(3, 3, 3, 3, 4, 5, 6, 7, 8, 8, 8, 8); } - [Test] + [TestMethod] public void ClipNDArray_ArrayMinNullMax_MatchesNumPy() { // From np.clip.Test.cs Case2 @@ -113,7 +114,7 @@ public void ClipNDArray_ArrayMinNullMax_MatchesNumPy() result.Should().BeOfValues(8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 10, 11); } - [Test] + [TestMethod] public void ClipNDArray_NullMinArrayMax_MatchesNumPy() { // From np.clip.Test.cs Case3 @@ -130,7 +131,7 @@ public void ClipNDArray_NullMinArrayMax_MatchesNumPy() #region Edge Cases - [Test] + [TestMethod] public void ClipNDArray_MinGreaterThanMax_UsesMaxValue() { // NumPy behavior: when min[i] > max[i], result is max[i] @@ -144,7 +145,7 @@ public void ClipNDArray_MinGreaterThanMax_UsesMaxValue() result.Should().BeOfValues(3, 3, 3, 3, 3); } - [Test] + [TestMethod] [Misaligned] public void ClipNDArray_NaNInBoundsArray_PropagatesNaN() { @@ -167,7 +168,7 @@ public void ClipNDArray_NaNInBoundsArray_PropagatesNaN() Assert.AreEqual(5.0, data[4]); } - [Test] + [TestMethod] public void ClipNDArray_EmptyArray_ReturnsEmpty() { var a = np.array(new double[0]); @@ -179,7 +180,7 @@ public void ClipNDArray_EmptyArray_ReturnsEmpty() Assert.AreEqual(0, result.size); } - [Test] + [TestMethod] public void ClipNDArray_BothNone_ReturnsCopy() { var a = np.arange(10); @@ -192,7 +193,7 @@ public void ClipNDArray_BothNone_ReturnsCopy() #region Dtype Tests - [Test] + [TestMethod] public void ClipNDArray_Float64Array_PreservesDtype() { var a = np.arange(10.0); @@ -205,7 +206,7 @@ public void ClipNDArray_Float64Array_PreservesDtype() result.Should().BeOfValues(2.0, 2.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 7.0, 7.0); } - [Test] + [TestMethod] public void ClipNDArray_Int32Array_PreservesDtype() { // Explicit int32 array for testing dtype preservation @@ -223,7 +224,7 @@ public void ClipNDArray_Int32Array_PreservesDtype() #region Contiguous vs Non-Contiguous Tests - [Test] + [TestMethod] public void ClipNDArray_TransposedArray_MatchesNumPy() { // Non-contiguous input (transposed) @@ -239,7 +240,7 @@ public void ClipNDArray_TransposedArray_MatchesNumPy() result.Should().BeOfValues(2, 4, 8, 2, 5, 8, 2, 6, 8, 3, 7, 8); } - [Test] + [TestMethod] public void ClipNDArray_SlicedArray_MatchesNumPy() { // Sliced input (every other element) diff --git a/test/NumSharp.UnitTest/NumPyPortedTests/CumSumEdgeCaseTests.cs b/test/NumSharp.UnitTest/NumPyPortedTests/CumSumEdgeCaseTests.cs index cdbdc3f26..b13d9affd 100644 --- a/test/NumSharp.UnitTest/NumPyPortedTests/CumSumEdgeCaseTests.cs +++ b/test/NumSharp.UnitTest/NumPyPortedTests/CumSumEdgeCaseTests.cs @@ -3,7 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.Backends; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.NumPyPortedTests { @@ -11,11 +10,12 @@ namespace NumSharp.UnitTest.NumPyPortedTests /// Tests for np.cumsum covering edge cases. /// Ported from NumPy test patterns. /// + [TestClass] public class CumSumEdgeCaseTests { #region Basic Tests - [Test] + [TestMethod] public void CumSum_1DArray_Int32() { // NumPy: cumsum([1,2,3,4,5]) = [1, 3, 6, 10, 15] @@ -25,7 +25,7 @@ public void CumSum_1DArray_Int32() result.Should().BeOfValues(1L, 3L, 6L, 10L, 15L); } - [Test] + [TestMethod] public void CumSum_1DArray_Float64() { var a = np.array(new double[] { 1.0, 2.0, 3.0, 4.0, 5.0 }); @@ -37,7 +37,7 @@ public void CumSum_1DArray_Float64() #region 2D Array Tests - [Test] + [TestMethod] public void CumSum_2DArray_Flattened() { // NumPy: cumsum([[1,2,3],[4,5,6]]) = [1, 3, 6, 10, 15, 21] @@ -47,7 +47,7 @@ public void CumSum_2DArray_Flattened() result.Should().BeOfValues(1L, 3L, 6L, 10L, 15L, 21L); } - [Test] + [TestMethod] public void CumSum_2DArray_Axis0() { // NumPy: cumsum([[1,2,3],[4,5,6]], axis=0) = [[1,2,3],[5,7,9]] @@ -57,7 +57,7 @@ public void CumSum_2DArray_Axis0() result.Should().BeOfValues(1L, 2L, 3L, 5L, 7L, 9L); } - [Test] + [TestMethod] public void CumSum_2DArray_Axis1() { // NumPy: cumsum([[1,2,3],[4,5,6]], axis=1) = [[1,3,6],[4,9,15]] @@ -71,7 +71,7 @@ public void CumSum_2DArray_Axis1() #region Dtype Handling - [Test] + [TestMethod] public void CumSum_Int32_ReturnsInt64() { // NumPy 2.x: cumsum(int32) returns int64 @@ -80,7 +80,7 @@ public void CumSum_Int32_ReturnsInt64() Assert.AreEqual(np.int64, result.dtype); } - [Test] + [TestMethod] public void CumSum_Int64_ReturnsInt64() { var arr = np.array(new long[] { 1, 2, 3 }); @@ -88,7 +88,7 @@ public void CumSum_Int64_ReturnsInt64() Assert.AreEqual(np.int64, result.dtype); } - [Test] + [TestMethod] public void CumSum_Float32_ReturnsFloat32() { var arr = np.array(new float[] { 1f, 2f, 3f }); @@ -96,7 +96,7 @@ public void CumSum_Float32_ReturnsFloat32() Assert.AreEqual(np.float32, result.dtype); } - [Test] + [TestMethod] public void CumSum_Float64_ReturnsFloat64() { var arr = np.array(new double[] { 1.0, 2.0, 3.0 }); @@ -104,7 +104,7 @@ public void CumSum_Float64_ReturnsFloat64() Assert.AreEqual(np.float64, result.dtype); } - [Test] + [TestMethod] public void CumSum_WithExplicitDtype() { var arr = np.array(new int[] { 1, 2, 3, 4, 5, 6 }); @@ -117,7 +117,7 @@ public void CumSum_WithExplicitDtype() #region Empty Array - [Test] + [TestMethod] public void CumSum_EmptyArray_ReturnsEmptyArray() { // NumPy: cumsum([]) = array([], dtype=float64) @@ -130,7 +130,7 @@ public void CumSum_EmptyArray_ReturnsEmptyArray() #region Single Element - [Test] + [TestMethod] public void CumSum_SingleElement() { // NumPy: cumsum([5]) = array([5]) @@ -143,7 +143,7 @@ public void CumSum_SingleElement() #region 3D Array - [Test] + [TestMethod] public void CumSum_3DArray_Axis0() { // NumPy: cumsum(arange(24).reshape(2,3,4), axis=0).shape = (2, 3, 4) @@ -152,7 +152,7 @@ public void CumSum_3DArray_Axis0() result.Should().BeShaped(2, 3, 4); } - [Test] + [TestMethod] public void CumSum_3DArray_Axis1() { var a = np.arange(24).reshape(2, 3, 4); @@ -160,7 +160,7 @@ public void CumSum_3DArray_Axis1() result.Should().BeShaped(2, 3, 4); } - [Test] + [TestMethod] public void CumSum_3DArray_Axis2() { var a = np.arange(24).reshape(2, 3, 4); @@ -172,7 +172,7 @@ public void CumSum_3DArray_Axis2() #region Negative Axis - [Test] + [TestMethod] public void CumSum_NegativeAxis_Minus1() { // NumPy: cumsum(a, axis=-1) is same as axis=last dimension @@ -182,7 +182,7 @@ public void CumSum_NegativeAxis_Minus1() result.Should().BeOfValues(1L, 3L, 6L, 4L, 9L, 15L); } - [Test] + [TestMethod] public void CumSum_NegativeAxis_Minus2() { // NumPy: cumsum(a, axis=-2) for 2D is same as axis=0 @@ -196,7 +196,7 @@ public void CumSum_NegativeAxis_Minus2() #region Strided Array - [Test] + [TestMethod] public void CumSum_StridedArray() { // NumPy: cumsum(arange(10)[::2]) = cumsum([0,2,4,6,8]) = [0,2,6,12,20] @@ -210,7 +210,7 @@ public void CumSum_StridedArray() #region Transposed Array - [Test] + [TestMethod] public void CumSum_TransposedArray_Axis1() { // NumPy: cumsum([[1,2,3],[4,5,6]].T, axis=1) @@ -226,7 +226,7 @@ public void CumSum_TransposedArray_Axis1() #region All Zeros - [Test] + [TestMethod] public void CumSum_AllZeros() { var a = np.zeros(new int[] { 5 }); @@ -238,7 +238,7 @@ public void CumSum_AllZeros() #region All Ones - [Test] + [TestMethod] public void CumSum_AllOnes() { var a = np.ones([5]); @@ -250,7 +250,7 @@ public void CumSum_AllOnes() #region Large Values (Overflow potential) - [Test] + [TestMethod] public void CumSum_LargeValues_Int64() { // Test that large values don't overflow with int64 @@ -263,7 +263,7 @@ public void CumSum_LargeValues_Int64() #region Mixed Positive/Negative Values - [Test] + [TestMethod] public void CumSum_MixedValues() { var a = np.array(new int[] { 1, -2, 3, -4, 5 }); @@ -276,7 +276,7 @@ public void CumSum_MixedValues() #region Float Special Values - [Test] + [TestMethod] public void CumSum_WithNaN() { var a = np.array(new double[] { 1.0, double.NaN, 3.0 }); @@ -287,7 +287,7 @@ public void CumSum_WithNaN() Assert.IsTrue(double.IsNaN(data[2])); // NaN propagates } - [Test] + [TestMethod] public void CumSum_WithInf() { var a = np.array(new double[] { 1.0, double.PositiveInfinity, 3.0 }); @@ -302,7 +302,7 @@ public void CumSum_WithInf() #region Numerical Precision - [Test] + [TestMethod] public void CumSum_FloatPrecision() { // Test with values that might lose precision diff --git a/test/NumSharp.UnitTest/NumPyPortedTests/ModfEdgeCaseTests.cs b/test/NumSharp.UnitTest/NumPyPortedTests/ModfEdgeCaseTests.cs index 52ccb1023..fa582ce00 100644 --- a/test/NumSharp.UnitTest/NumPyPortedTests/ModfEdgeCaseTests.cs +++ b/test/NumSharp.UnitTest/NumPyPortedTests/ModfEdgeCaseTests.cs @@ -3,7 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.Backends; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.NumPyPortedTests { @@ -11,11 +10,12 @@ namespace NumSharp.UnitTest.NumPyPortedTests /// Tests for np.modf operation covering edge cases. /// modf returns (fractional_part, integer_part). /// + [TestClass] public class ModfEdgeCaseTests { #region Basic Tests - [Test] + [TestMethod] public void Modf_PositiveValues() { // NumPy: modf([1.5, 2.7]) = ([0.5, 0.7], [1., 2.]) @@ -31,7 +31,7 @@ public void Modf_PositiveValues() Assert.AreEqual(2.0, intgData[1]); } - [Test] + [TestMethod] public void Modf_NegativeValues() { // NumPy: modf(-3.2) = (-0.2, -3.) @@ -45,7 +45,7 @@ public void Modf_NegativeValues() Assert.AreEqual(-3.0, intgData[0]); } - [Test] + [TestMethod] public void Modf_MixedValues() { // NumPy: modf([1.5, 2.7, -3.2, 0.0]) @@ -70,7 +70,7 @@ public void Modf_MixedValues() #region Zero Tests - [Test] + [TestMethod] public void Modf_PositiveZero() { var x = np.array(new double[] { 0.0 }); @@ -80,7 +80,7 @@ public void Modf_PositiveZero() Assert.AreEqual(0.0, intg.GetData()[0]); } - [Test] + [TestMethod] public void Modf_NegativeZero() { // NumPy: modf(-0.0) = (-0.0, -0.0) @@ -99,7 +99,7 @@ public void Modf_NegativeZero() #region Special Values (Inf, NaN) - [Test] + [TestMethod] public void Modf_PositiveInfinity() { // NumPy: modf(inf) = (0.0, inf) @@ -110,7 +110,7 @@ public void Modf_PositiveInfinity() Assert.IsTrue(double.IsPositiveInfinity(intg.GetData()[0])); } - [Test] + [TestMethod] public void Modf_NegativeInfinity() { // NumPy: modf(-inf) = (-0.0, -inf) @@ -122,7 +122,7 @@ public void Modf_NegativeInfinity() Assert.IsTrue(double.IsNegativeInfinity(intg.GetData()[0])); } - [Test] + [TestMethod] public void Modf_NaN() { // NumPy: modf(nan) = (nan, nan) @@ -133,7 +133,7 @@ public void Modf_NaN() Assert.IsTrue(double.IsNaN(intg.GetData()[0])); } - [Test] + [TestMethod] public void Modf_MixedSpecialValues() { // NumPy: modf([inf, -inf, nan]) @@ -157,7 +157,7 @@ public void Modf_MixedSpecialValues() #region Dtype Tests - [Test] + [TestMethod] public void Modf_Float32_PreservesDtype() { var x = np.array(new float[] { 1.5f, 2.7f }); @@ -167,7 +167,7 @@ public void Modf_Float32_PreservesDtype() Assert.AreEqual(np.float32, intg.dtype); } - [Test] + [TestMethod] public void Modf_Float64_PreservesDtype() { var x = np.array(new double[] { 1.5, 2.7 }); @@ -181,7 +181,7 @@ public void Modf_Float64_PreservesDtype() #region Large Values - [Test] + [TestMethod] public void Modf_LargeValues() { // NumPy: modf([1e10 + 0.5, -1e10 - 0.5]) @@ -201,7 +201,7 @@ public void Modf_LargeValues() #region Multi-dimensional Arrays - [Test] + [TestMethod] public void Modf_2DArray() { // NumPy: modf([[1.5, 2.7], [3.1, 4.9]]) @@ -228,7 +228,7 @@ public void Modf_2DArray() #region Whole Numbers - [Test] + [TestMethod] public void Modf_WholeNumbers() { // Whole numbers should have fractional part = 0 @@ -249,7 +249,7 @@ public void Modf_WholeNumbers() #region Empty Array - [Test] + [TestMethod] public void Modf_EmptyArray() { var x = np.array(new double[0]); @@ -263,7 +263,7 @@ public void Modf_EmptyArray() #region Single Element - [Test] + [TestMethod] public void Modf_SingleElement() { var x = np.array(new double[] { 3.14159 }); @@ -277,7 +277,7 @@ public void Modf_SingleElement() #region Very Small Fractional Parts - [Test] + [TestMethod] public void Modf_VerySmallFraction() { // Values very close to integers diff --git a/test/NumSharp.UnitTest/NumPyPortedTests/NonzeroEdgeCaseTests.cs b/test/NumSharp.UnitTest/NumPyPortedTests/NonzeroEdgeCaseTests.cs index 76b435512..4e0ec61a4 100644 --- a/test/NumSharp.UnitTest/NumPyPortedTests/NonzeroEdgeCaseTests.cs +++ b/test/NumSharp.UnitTest/NumPyPortedTests/NonzeroEdgeCaseTests.cs @@ -3,7 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.Backends; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.NumPyPortedTests { @@ -11,11 +10,12 @@ namespace NumSharp.UnitTest.NumPyPortedTests /// Tests ported from NumPy test_numeric.py TestNonzero class. /// Covers edge cases for np.nonzero operation. /// + [TestClass] public class NonzeroEdgeCaseTests { #region Trivial Cases (from test_nonzero_trivial) - [Test] + [TestMethod] public void Nonzero_EmptyArray_ReturnsEmptyTuple() { // NumPy: nonzero([]) = (array([], dtype=int64),) @@ -25,7 +25,7 @@ public void Nonzero_EmptyArray_ReturnsEmptyTuple() Assert.AreEqual(0, result[0].size); } - [Test] + [TestMethod] public void Nonzero_SingleZero_ReturnsEmpty() { // NumPy: nonzero([0]) = (array([], dtype=int64),) @@ -35,7 +35,7 @@ public void Nonzero_SingleZero_ReturnsEmpty() Assert.AreEqual(0, result[0].size); } - [Test] + [TestMethod] public void Nonzero_SingleOne_ReturnsIndexZero() { // NumPy: nonzero([1]) = (array([0]),) @@ -49,7 +49,7 @@ public void Nonzero_SingleOne_ReturnsIndexZero() #region 1D Array Tests (from test_nonzero_onedim) - [Test] + [TestMethod] public void Nonzero_1DArray_MixedValues() { // NumPy: nonzero([1,0,2,-1,0,0,8]) = (array([0, 2, 3, 6]),) @@ -60,7 +60,7 @@ public void Nonzero_1DArray_MixedValues() result[0].Should().BeOfValues(0, 2, 3, 6); } - [Test] + [TestMethod] public void Nonzero_1DArray_AllZeros() { var x = np.zeros(new int[] { 5 }); @@ -70,7 +70,7 @@ public void Nonzero_1DArray_AllZeros() Assert.AreEqual(0, result[0].size); } - [Test] + [TestMethod] public void Nonzero_1DArray_AllNonzero() { var x = np.array(new int[] { 1, 2, 3, 4, 5 }); @@ -84,7 +84,7 @@ public void Nonzero_1DArray_AllNonzero() #region 2D Array Tests (from test_nonzero_twodim) - [Test] + [TestMethod] public void Nonzero_2DArray_SparseValues() { // NumPy: nonzero([[0,1,0],[2,0,3]]) = (array([0, 1, 1]), array([1, 0, 2])) @@ -96,7 +96,7 @@ public void Nonzero_2DArray_SparseValues() result[1].Should().BeOfValues(1, 0, 2); } - [Test] + [TestMethod] public void Nonzero_EyeMatrix() { // NumPy: nonzero(eye(3)) = (array([0, 1, 2]), array([0, 1, 2])) @@ -108,7 +108,7 @@ public void Nonzero_EyeMatrix() result[1].Should().BeOfValues(0, 1, 2); } - [Test] + [TestMethod] public void Nonzero_2DArray_Arange() { // NumPy test Case2: arange(9).reshape(3,3) - 0 is only nonzero at position 0 @@ -125,7 +125,7 @@ public void Nonzero_2DArray_Arange() #region 3D Array Tests - [Test] + [TestMethod] public void Nonzero_3DArray() { // NumPy: nonzero([[[0,1],[0,0]],[[1,0],[0,1]]]) = @@ -143,7 +143,7 @@ public void Nonzero_3DArray() #region Boolean Array Tests - [Test] + [TestMethod] public void Nonzero_BooleanArray() { // NumPy: nonzero([True, False, True, False, True]) = (array([0, 2, 4]),) @@ -154,7 +154,7 @@ public void Nonzero_BooleanArray() result[0].Should().BeOfValues(0, 2, 4); } - [Test] + [TestMethod] public void Nonzero_AllTrue() { var x = np.ones([5]); @@ -164,7 +164,7 @@ public void Nonzero_AllTrue() result[0].Should().BeOfValues(0, 1, 2, 3, 4); } - [Test] + [TestMethod] public void Nonzero_AllFalse() { var x = np.zeros(new int[] { 5 }); @@ -178,7 +178,7 @@ public void Nonzero_AllFalse() #region Float Array Tests (from test_nonzero_float_dtypes) - [Test] + [TestMethod] public void Nonzero_Float32Array() { var x = np.array(new float[] { 0f, 1.5f, 0f, -2.3f, 0f }); @@ -188,7 +188,7 @@ public void Nonzero_Float32Array() result[0].Should().BeOfValues(1, 3); } - [Test] + [TestMethod] public void Nonzero_Float64Array() { var x = np.array(new double[] { 0.0, 1.5, 0.0, -2.3, 0.0 }); @@ -198,7 +198,7 @@ public void Nonzero_Float64Array() result[0].Should().BeOfValues(1, 3); } - [Test] + [TestMethod] public void Nonzero_NegativeZero_TreatedAsZero() { // NumPy: nonzero([0.0, -0.0, 1.0]) = (array([2]),) @@ -213,7 +213,7 @@ public void Nonzero_NegativeZero_TreatedAsZero() #region Integer Dtype Tests (from test_nonzero_integer_dtypes) - [Test] + [TestMethod] public void Nonzero_Int16Array() { var x = np.array(new short[] { 0, 1, 0, -1, 2 }); @@ -222,7 +222,7 @@ public void Nonzero_Int16Array() result[0].Should().BeOfValues(1, 3, 4); } - [Test] + [TestMethod] public void Nonzero_Int32Array() { var x = np.array(new int[] { 0, 1, 0, -1, 2 }); @@ -231,7 +231,7 @@ public void Nonzero_Int32Array() result[0].Should().BeOfValues(1, 3, 4); } - [Test] + [TestMethod] public void Nonzero_Int64Array() { var x = np.array(new long[] { 0, 1, 0, -1, 2 }); @@ -240,7 +240,7 @@ public void Nonzero_Int64Array() result[0].Should().BeOfValues(1, 3, 4); } - [Test] + [TestMethod] public void Nonzero_UInt8Array() { var x = np.array(new byte[] { 0, 1, 0, 5, 2 }); @@ -249,7 +249,7 @@ public void Nonzero_UInt8Array() result[0].Should().BeOfValues(1, 3, 4); } - [Test] + [TestMethod] public void Nonzero_UInt16Array() { var x = np.array(new ushort[] { 0, 1, 0, 5, 2 }); @@ -258,7 +258,7 @@ public void Nonzero_UInt16Array() result[0].Should().BeOfValues(1, 3, 4); } - [Test] + [TestMethod] public void Nonzero_UInt32Array() { var x = np.array(new uint[] { 0, 1, 0, 5, 2 }); @@ -267,7 +267,7 @@ public void Nonzero_UInt32Array() result[0].Should().BeOfValues(1, 3, 4); } - [Test] + [TestMethod] public void Nonzero_UInt64Array() { var x = np.array(new ulong[] { 0, 1, 0, 5, 2 }); @@ -280,7 +280,7 @@ public void Nonzero_UInt64Array() #region Transposed Array Tests - [Test] + [TestMethod] public void Nonzero_TransposedArray() { // NumPy: nonzero([[0,1,0],[2,0,3]].T) = (array([0, 1, 2]), array([1, 0, 1])) @@ -296,7 +296,7 @@ public void Nonzero_TransposedArray() #region Using Result for Indexing - [Test] + [TestMethod] public void Nonzero_UseResultForIndexing() { // NumPy: x[nonzero(x)] returns the non-zero values @@ -311,7 +311,7 @@ public void Nonzero_UseResultForIndexing() #region Sparse Pattern Tests (from test_sparse) - [Test] + [TestMethod] public void Nonzero_SparsePattern_SingleTruePerBlock() { // Test sparse boolean pattern @@ -329,7 +329,7 @@ public void Nonzero_SparsePattern_SingleTruePerBlock() #region Large Array Tests - [Test] + [TestMethod] public void Nonzero_LargeArray() { // Create array with known non-zero pattern @@ -346,7 +346,7 @@ public void Nonzero_LargeArray() #region Edge Cases with Slices - [Test] + [TestMethod] public void Nonzero_SlicedArray() { var x = np.arange(10); @@ -357,7 +357,7 @@ public void Nonzero_SlicedArray() result[0].Should().BeOfValues(0, 1, 2, 3, 4, 5); } - [Test] + [TestMethod] public void Nonzero_StridedSlice() { var x = np.array(new int[] { 0, 1, 0, 2, 0, 3, 0, 4 }); @@ -371,7 +371,7 @@ public void Nonzero_StridedSlice() #region NaN Handling - [Test] + [TestMethod] public void Nonzero_NaN_TreatedAsNonzero() { // NaN is non-zero (it's not equal to zero) @@ -381,7 +381,7 @@ public void Nonzero_NaN_TreatedAsNonzero() result[0].Should().BeOfValues(1, 3); } - [Test] + [TestMethod] public void Nonzero_Inf_TreatedAsNonzero() { var x = np.array(new double[] { 0.0, double.PositiveInfinity, 0.0, double.NegativeInfinity }); diff --git a/test/NumSharp.UnitTest/NumPyPortedTests/PowerEdgeCaseTests.cs b/test/NumSharp.UnitTest/NumPyPortedTests/PowerEdgeCaseTests.cs index ed5748b97..5968f6b79 100644 --- a/test/NumSharp.UnitTest/NumPyPortedTests/PowerEdgeCaseTests.cs +++ b/test/NumSharp.UnitTest/NumPyPortedTests/PowerEdgeCaseTests.cs @@ -4,7 +4,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.Backends; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.NumPyPortedTests { @@ -12,11 +11,12 @@ namespace NumSharp.UnitTest.NumPyPortedTests /// Tests ported from NumPy test_umath.py TestPower class. /// Covers edge cases for np.power operation. /// + [TestClass] public class PowerEdgeCaseTests { #region Float Power Tests (from test_power_float) - [Test] + [TestMethod] public void Power_Float_ZeroExponent_ReturnsOnes() { // NumPy: x**0 = [1., 1., 1.] @@ -25,7 +25,7 @@ public void Power_Float_ZeroExponent_ReturnsOnes() result.Should().BeOfValues(1.0, 1.0, 1.0); } - [Test] + [TestMethod] public void Power_Float_OneExponent_ReturnsOriginal() { // NumPy: x**1 = x @@ -34,7 +34,7 @@ public void Power_Float_OneExponent_ReturnsOriginal() result.Should().BeOfValues(1.0, 2.0, 3.0); } - [Test] + [TestMethod] public void Power_Float_TwoExponent_ReturnsSquares() { // NumPy: x**2 = [1., 4., 9.] @@ -43,7 +43,7 @@ public void Power_Float_TwoExponent_ReturnsSquares() result.Should().BeOfValues(1.0, 4.0, 9.0); } - [Test] + [TestMethod] public void Power_Float_NegativeOneExponent_ReturnsReciprocals() { // NumPy: x**(-1) = [1., 0.5, 0.33333333] @@ -55,7 +55,7 @@ public void Power_Float_NegativeOneExponent_ReturnsReciprocals() Assert.IsTrue(Math.Abs(data[2] - (1.0 / 3.0)) < 1e-10); } - [Test] + [TestMethod] public void Power_Float_HalfExponent_ReturnsSqrt() { // NumPy: x**(0.5) = [1., sqrt(2), sqrt(3)] @@ -71,7 +71,7 @@ public void Power_Float_HalfExponent_ReturnsSqrt() #region Integer Power Tests (from test_integer_power*) - [Test] + [TestMethod] [Misaligned] // NumSharp uses Math.Pow (double precision) which loses precision for large integers public void Power_Integer_LargeValues() { @@ -87,7 +87,7 @@ public void Power_Integer_LargeValues() Assert.IsTrue(relativeError < 1e-14, $"Expected ~{expected}, got {actual}, relative error {relativeError}"); } - [Test] + [TestMethod] public void Power_Int32_ZeroExponent_ReturnsOnes() { // NumPy: power(arr, 0) returns ones_like(arr) for all integer types @@ -97,7 +97,7 @@ public void Power_Int32_ZeroExponent_ReturnsOnes() result.Should().BeOfValues(expected.GetData().Cast().ToArray()); } - [Test] + [TestMethod] public void Power_Int64_ZeroExponent_ReturnsOnes() { var arr = np.arange(-10, 10).astype(np.int64); @@ -106,7 +106,7 @@ public void Power_Int64_ZeroExponent_ReturnsOnes() result.Should().BeOfValues(expected.GetData().Cast().ToArray()); } - [Test] + [TestMethod] public void Power_UInt32_ZeroExponent_ReturnsOnes() { var arr = np.arange(10).astype(np.uint32); @@ -115,7 +115,7 @@ public void Power_UInt32_ZeroExponent_ReturnsOnes() result.Should().BeOfValues(expected.GetData().Cast().ToArray()); } - [Test] + [TestMethod] public void Power_OneBase_AnyExponent_ReturnsOnes() { // NumPy: power(1, arr) returns ones_like(arr) @@ -124,7 +124,7 @@ public void Power_OneBase_AnyExponent_ReturnsOnes() result.Should().BeOfValues(1, 1, 1, 1, 1, 1, 1, 1, 1, 1); } - [Test] + [TestMethod] public void Power_ZeroBase_PositiveExponent_ReturnsZeros() { // NumPy: power(0, arr) returns zeros for positive exponents @@ -137,7 +137,7 @@ public void Power_ZeroBase_PositiveExponent_ReturnsZeros() #region Float to Inf Power Tests (from test_float_to_inf_power) - [Test] + [TestMethod] public void Power_Float32_InfExponents() { // NumPy: power with inf exponents @@ -157,7 +157,7 @@ public void Power_Float32_InfExponents() Assert.AreEqual(0f, data[7]); } - [Test] + [TestMethod] public void Power_Float64_InfExponents() { var a = np.array(new double[] { 1.0, 1.0, 2.0, 2.0, -2.0, -2.0, double.PositiveInfinity, double.NegativeInfinity }); @@ -180,7 +180,7 @@ public void Power_Float64_InfExponents() #region Fast Power Path Tests (from test_fast_power) - [Test] + [TestMethod] public void Power_Int16_FloatExponent_ReturnsFloat64() { // NumPy: int16**2.0 returns float64 @@ -191,7 +191,7 @@ public void Power_Int16_FloatExponent_ReturnsFloat64() result.Should().BeOfValues(1.0, 4.0, 9.0); } - [Test] + [TestMethod] public void Power_Int32_FloatExponent_ReturnsFloat64() { var x = np.array(new int[] { 1, 2, 3, 4 }); @@ -205,7 +205,7 @@ public void Power_Int32_FloatExponent_ReturnsFloat64() #region Special Cases (0^0, negative base) - [Test] + [TestMethod] public void Power_ZeroToZero_ReturnsOne() { // NumPy: 0^0 = 1 (by convention) @@ -214,7 +214,7 @@ public void Power_ZeroToZero_ReturnsOne() Assert.AreEqual(1.0, (double)np.power(0.0, 0)); } - [Test] + [TestMethod] public void Power_NegativeBase_IntegerExponent() { // NumPy: (-2)^3 = -8, (-2)^4 = 16 @@ -224,7 +224,7 @@ public void Power_NegativeBase_IntegerExponent() Assert.AreEqual(-8.0, (double)np.power(-2.0, 3.0)); } - [Test] + [TestMethod] public void Power_NegativeBase_FractionalExponent_ReturnsNaN() { // NumPy: (-2.0)^0.5 = nan, (-1.0)^0.5 = nan @@ -239,7 +239,7 @@ public void Power_NegativeBase_FractionalExponent_ReturnsNaN() #region Square Root via Power - [Test] + [TestMethod] public void Power_HalfExponent_MatchesSqrt() { // NumPy: power([1,4,9,16,25], 0.5) = [1,2,3,4,5] @@ -248,7 +248,7 @@ public void Power_HalfExponent_MatchesSqrt() result.Should().BeOfValues(1.0, 2.0, 3.0, 4.0, 5.0); } - [Test] + [TestMethod] public void Power_NegativeHalfExponent() { // NumPy: power([1,4,9], -0.5) = [1, 0.5, 0.33333...] @@ -265,7 +265,7 @@ public void Power_NegativeHalfExponent() #region Broadcasting Tests - [Test] + [TestMethod] public void Power_Broadcasting_2DArray_1DExponent() { // NumPy: power([[1,2],[3,4]], [2,3]) = [[1,8],[9,64]] @@ -277,7 +277,7 @@ public void Power_Broadcasting_2DArray_1DExponent() result.Should().BeOfValues(1, 8, 9, 64); } - [Test] + [TestMethod] public void Power_Broadcasting_1DArray_2DExponent() { // NumPy: power([1,2,3,4], [[1],[2],[3]]).shape = (3,4) @@ -292,7 +292,7 @@ public void Power_Broadcasting_1DArray_2DExponent() #region Strided Array Tests - [Test] + [TestMethod] public void Power_StridedArray() { // NumPy: power(a[::2], 2) where a = [0,1,2,3,4,5,6,7,8,9] @@ -308,7 +308,7 @@ public void Power_StridedArray() #region Dtype Preservation Tests - [Test] + [TestMethod] public void Power_Int32_Int32_ReturnsInt32() { var a = np.array(new int[] { 2, 3, 4 }); @@ -316,7 +316,7 @@ public void Power_Int32_Int32_ReturnsInt32() Assert.AreEqual(np.int32, result.dtype); } - [Test] + [TestMethod] public void Power_Int64_Int64_ReturnsInt64() { var a = np.array(new long[] { 2, 3, 4 }); @@ -324,7 +324,7 @@ public void Power_Int64_Int64_ReturnsInt64() Assert.AreEqual(np.int64, result.dtype); } - [Test] + [TestMethod] public void Power_Float32_Float32_ReturnsFloat32() { var a = np.array(new float[] { 2f, 3f, 4f }); @@ -332,7 +332,7 @@ public void Power_Float32_Float32_ReturnsFloat32() Assert.AreEqual(np.float32, result.dtype); } - [Test] + [TestMethod] public void Power_Float64_Float64_ReturnsFloat64() { var a = np.array(new double[] { 2.0, 3.0, 4.0 }); @@ -344,7 +344,7 @@ public void Power_Float64_Float64_ReturnsFloat64() #region Cube Root and Other Fractional Powers - [Test] + [TestMethod] public void Power_CubeRoot() { // NumPy: power([1,8,27,64], 1/3) = [1,2,3,4] @@ -362,7 +362,7 @@ public void Power_CubeRoot() #region Very Large/Small Exponent Tests - [Test] + [TestMethod] public void Power_LargeExponent() { // NumPy: power([1, 1.0001, 0.9999], 10000) diff --git a/test/NumSharp.UnitTest/NumPyPortedTests/VarStdEdgeCaseTests.cs b/test/NumSharp.UnitTest/NumPyPortedTests/VarStdEdgeCaseTests.cs index 6e75cac5e..40393b14f 100644 --- a/test/NumSharp.UnitTest/NumPyPortedTests/VarStdEdgeCaseTests.cs +++ b/test/NumSharp.UnitTest/NumPyPortedTests/VarStdEdgeCaseTests.cs @@ -3,7 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.Backends; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.NumPyPortedTests { @@ -11,11 +10,12 @@ namespace NumSharp.UnitTest.NumPyPortedTests /// Tests ported from NumPy test_numeric.py for np.std and np.var. /// Covers edge cases including empty arrays, ddof, keepdims, and axis combinations. /// + [TestClass] public class VarStdEdgeCaseTests { #region Basic std Tests (from test_std) - [Test] + [TestMethod] public void Std_2DArray_Global() { // NumPy: std([[1,2,3],[4,5,6]]) = 1.707825127659933 @@ -25,7 +25,7 @@ public void Std_2DArray_Global() Assert.IsTrue(Math.Abs(value - 1.707825127659933) <1e-10); } - [Test] + [TestMethod] public void Std_2DArray_Axis0() { // NumPy: std([[1,2,3],[4,5,6]], axis=0) = [1.5, 1.5, 1.5] @@ -38,7 +38,7 @@ public void Std_2DArray_Axis0() Assert.IsTrue(Math.Abs(data[2] - 1.5) <1e-10); } - [Test] + [TestMethod] public void Std_2DArray_Axis1() { // NumPy: std([[1,2,3],[4,5,6]], axis=1) = [0.81649658, 0.81649658] @@ -54,7 +54,7 @@ public void Std_2DArray_Axis1() #region Basic var Tests (from test_var) - [Test] + [TestMethod] public void Var_2DArray_Global() { // NumPy: var([[1,2,3],[4,5,6]]) = 2.9166666666666665 @@ -64,7 +64,7 @@ public void Var_2DArray_Global() Assert.IsTrue(Math.Abs(value - 2.9166666666666665) <1e-10); } - [Test] + [TestMethod] public void Var_2DArray_Axis0() { // NumPy: var([[1,2,3],[4,5,6]], axis=0) = [2.25, 2.25, 2.25] @@ -77,7 +77,7 @@ public void Var_2DArray_Axis0() Assert.IsTrue(Math.Abs(data[2] - 2.25) <1e-10); } - [Test] + [TestMethod] public void Var_2DArray_Axis1() { // NumPy: var([[1,2,3],[4,5,6]], axis=1) = [0.66666667, 0.66666667] @@ -93,7 +93,7 @@ public void Var_2DArray_Axis1() #region ddof Tests (Sample vs Population) - [Test] + [TestMethod] public void Std_Ddof0_PopulationStd() { // NumPy: std([1,2,3,4,5], ddof=0) = 1.4142135623730951 @@ -103,7 +103,7 @@ public void Std_Ddof0_PopulationStd() Assert.IsTrue(Math.Abs(value - 1.4142135623730951) <1e-10); } - [Test] + [TestMethod] public void Std_Ddof1_SampleStd() { // NumPy: std([1,2,3,4,5], ddof=1) = 1.5811388300841898 @@ -113,7 +113,7 @@ public void Std_Ddof1_SampleStd() Assert.IsTrue(Math.Abs(value - 1.5811388300841898) <1e-10); } - [Test] + [TestMethod] public void Var_Ddof0_PopulationVar() { // NumPy: var([1,2,3,4,5], ddof=0) = 2.0 @@ -123,7 +123,7 @@ public void Var_Ddof0_PopulationVar() Assert.AreEqual(2.0, value); } - [Test] + [TestMethod] public void Var_Ddof1_SampleVar() { // NumPy: var([1,2,3,4,5], ddof=1) = 2.5 @@ -137,7 +137,7 @@ public void Var_Ddof1_SampleVar() #region keepdims Tests - [Test] + [TestMethod] public void Std_Keepdims_True() { // NumPy: std(arange(12).reshape(3,4), axis=1, keepdims=True).shape = (3, 1) @@ -146,7 +146,7 @@ public void Std_Keepdims_True() result.Should().BeShaped(3, 1); } - [Test] + [TestMethod] public void Std_Keepdims_False() { // NumPy: std(arange(12).reshape(3,4), axis=1, keepdims=False).shape = (3,) @@ -155,7 +155,7 @@ public void Std_Keepdims_False() result.Should().BeShaped(3); } - [Test] + [TestMethod] public void Var_Keepdims_True() { var a = np.arange(12).reshape(3, 4); @@ -163,7 +163,7 @@ public void Var_Keepdims_True() result.Should().BeShaped(3, 1); } - [Test] + [TestMethod] public void Var_Keepdims_False() { var a = np.arange(12).reshape(3, 4); @@ -175,7 +175,7 @@ public void Var_Keepdims_False() #region Empty Array Tests - [Test] + [TestMethod] public void Std_EmptyArray_ReturnsNaN() { // NumPy: std([]) = nan (with RuntimeWarning) @@ -184,7 +184,7 @@ public void Std_EmptyArray_ReturnsNaN() Assert.IsTrue(double.IsNaN((double)result)); } - [Test] + [TestMethod] public void Var_EmptyArray_ReturnsNaN() { // NumPy: var([]) = nan (with RuntimeWarning) @@ -197,7 +197,7 @@ public void Var_EmptyArray_ReturnsNaN() #region Single Element Tests - [Test] + [TestMethod] public void Std_SingleElement_ReturnsZero() { // NumPy: std([5]) = 0.0 @@ -206,7 +206,7 @@ public void Std_SingleElement_ReturnsZero() Assert.AreEqual(0.0, (double)result); } - [Test] + [TestMethod] public void Var_SingleElement_ReturnsZero() { // NumPy: var([5]) = 0.0 @@ -215,7 +215,7 @@ public void Var_SingleElement_ReturnsZero() Assert.AreEqual(0.0, (double)result); } - [Test] + [TestMethod] public void Std_SingleElement_Ddof1_ReturnsNaN() { // NumPy: std([5], ddof=1) = nan (division by zero) @@ -224,7 +224,7 @@ public void Std_SingleElement_Ddof1_ReturnsNaN() Assert.IsTrue(double.IsNaN((double)result)); } - [Test] + [TestMethod] public void Var_SingleElement_Ddof1_ReturnsNaN() { // NumPy: var([5], ddof=1) = nan (division by zero) @@ -237,7 +237,7 @@ public void Var_SingleElement_Ddof1_ReturnsNaN() #region Dtype Handling - [Test] + [TestMethod] public void Std_Int32_ReturnsFloat64() { // NumPy: std(int32 array) returns float64 @@ -246,7 +246,7 @@ public void Std_Int32_ReturnsFloat64() Assert.AreEqual(np.float64, result.dtype); } - [Test] + [TestMethod] public void Std_Int64_ReturnsFloat64() { var arr = np.array(new long[] { 1, 2, 3, 4, 5 }); @@ -254,7 +254,7 @@ public void Std_Int64_ReturnsFloat64() Assert.AreEqual(np.float64, result.dtype); } - [Test] + [TestMethod] public void Std_Float32_ReturnsFloat32() { // NumPy: std(float32 array) returns float32 @@ -263,7 +263,7 @@ public void Std_Float32_ReturnsFloat32() Assert.AreEqual(np.float32, result.dtype); } - [Test] + [TestMethod] public void Std_Float64_ReturnsFloat64() { var arr = np.array(new double[] { 1.0, 2.0, 3.0, 4.0, 5.0 }); @@ -275,7 +275,7 @@ public void Std_Float64_ReturnsFloat64() #region 3D Array Axis Combinations - [Test] + [TestMethod] public void Std_3DArray_Axis0() { // NumPy: std(arange(24).reshape(2,3,4), axis=0).shape = (3, 4) @@ -284,7 +284,7 @@ public void Std_3DArray_Axis0() result.Should().BeShaped(3, 4); } - [Test] + [TestMethod] public void Std_3DArray_Axis1() { // NumPy: std(arange(24).reshape(2,3,4), axis=1).shape = (2, 4) @@ -293,7 +293,7 @@ public void Std_3DArray_Axis1() result.Should().BeShaped(2, 4); } - [Test] + [TestMethod] public void Std_3DArray_Axis2() { // NumPy: std(arange(24).reshape(2,3,4), axis=2).shape = (2, 3) @@ -302,7 +302,7 @@ public void Std_3DArray_Axis2() result.Should().BeShaped(2, 3); } - [Test] + [TestMethod] public void Std_3DArray_AxisNone() { // NumPy: std(arange(24).reshape(2,3,4), axis=None).shape = () @@ -315,7 +315,7 @@ public void Std_3DArray_AxisNone() #region NaN in Data - [Test] + [TestMethod] public void Std_WithNaN_ReturnsNaN() { // NumPy: std([1,2,nan,4,5]) = nan @@ -324,7 +324,7 @@ public void Std_WithNaN_ReturnsNaN() Assert.IsTrue(double.IsNaN((double)result)); } - [Test] + [TestMethod] public void Var_WithNaN_ReturnsNaN() { // NumPy: var([1,2,nan,4,5]) = nan @@ -337,7 +337,7 @@ public void Var_WithNaN_ReturnsNaN() #region Negative Axis - [Test] + [TestMethod] public void Std_NegativeAxis() { // NumPy: std(a, axis=-1) is same as axis=last dimension @@ -359,7 +359,7 @@ public void Std_NegativeAxis() #region All Same Values - [Test] + [TestMethod] public void Std_AllSameValues_ReturnsZero() { var a = np.full(10, 5.0); // full(shape, fill_value) @@ -367,7 +367,7 @@ public void Std_AllSameValues_ReturnsZero() Assert.AreEqual(0.0, (double)result); } - [Test] + [TestMethod] public void Var_AllSameValues_ReturnsZero() { var a = np.full(10, 5.0); // full(shape, fill_value) @@ -379,7 +379,7 @@ public void Var_AllSameValues_ReturnsZero() #region Large Array - [Test] + [TestMethod] public void Std_LargeArray() { // Test numerical stability with large arrays @@ -395,7 +395,7 @@ public void Std_LargeArray() #region Strided Array - [Test] + [TestMethod] public void Std_StridedArray() { var a = np.arange(20); diff --git a/test/NumSharp.UnitTest/NumSharp.Bitmap/BitmapExtensionsTests.cs b/test/NumSharp.UnitTest/NumSharp.Bitmap/BitmapExtensionsTests.cs index 59c650b79..7e6930216 100644 --- a/test/NumSharp.UnitTest/NumSharp.Bitmap/BitmapExtensionsTests.cs +++ b/test/NumSharp.UnitTest/NumSharp.Bitmap/BitmapExtensionsTests.cs @@ -8,7 +8,7 @@ namespace NumSharp.UnitTest { [WindowsOnly] - [SkipOnNonWindows] + [TestClass] public class BitmapExtensionsTests : TestClass { // ================================================================ @@ -39,7 +39,7 @@ public class BitmapExtensionsTests : TestClass #region ToNDArray — dtype and contiguity - [Test] + [TestMethod] public void ToNDArray_Copy_ReturnsContiguousByteArray() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -48,7 +48,7 @@ public void ToNDArray_Copy_ReturnsContiguousByteArray() nd.Shape.IsContiguous.Should().BeTrue("copy mode should produce contiguous memory"); } - [Test] + [TestMethod] public void ToNDArray_NoCopy_ReturnsByteArray() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -60,7 +60,7 @@ public void ToNDArray_NoCopy_ReturnsByteArray() #region ToNDArray — size consistency - [Test] + [TestMethod] public void ToNDArray_Copy_TotalSizeMatchesDimensions() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -68,7 +68,7 @@ public void ToNDArray_Copy_TotalSizeMatchesDimensions() nd.size.Should().Be(nd.shape[0] * nd.shape[1] * nd.shape[2] * nd.shape[3]); } - [Test] + [TestMethod] public void ToNDArray_NoCopy_TotalSizeMatchesDimensions() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -80,7 +80,7 @@ public void ToNDArray_NoCopy_TotalSizeMatchesDimensions() #region ToNDArray — discardAlpha reduces 4th dimension - [Test] + [TestMethod] public void ToNDArray_Copy_DiscardAlpha_Reduces4thDimFrom4To3() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -93,7 +93,7 @@ public void ToNDArray_Copy_DiscardAlpha_Reduces4thDimFrom4To3() noAlpha.shape[2].Should().Be(withAlpha.shape[2], "width unchanged"); } - [Test] + [TestMethod] public void ToNDArray_NoCopy_DiscardAlpha_Reduces4thDimFrom4To3() { // Must use separate bitmaps because copy:false holds the lock @@ -110,7 +110,7 @@ public void ToNDArray_NoCopy_DiscardAlpha_Reduces4thDimFrom4To3() #region ToNDArray — flat output - [Test] + [TestMethod] public void ToNDArray_Flat_Copy_Is1D() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -118,7 +118,7 @@ public void ToNDArray_Flat_Copy_Is1D() nd.ndim.Should().Be(1, "flat=true should produce 1-d array"); } - [Test] + [TestMethod] public void ToNDArray_Flat_NoCopy_Is1D() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -126,7 +126,7 @@ public void ToNDArray_Flat_NoCopy_Is1D() nd.ndim.Should().Be(1); } - [Test] + [TestMethod] public void ToNDArray_Flat_SizeMatchesShaped() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -139,7 +139,7 @@ public void ToNDArray_Flat_SizeMatchesShaped() #region ToNDArray — pixel data correctness - [Test] + [TestMethod] public void ToNDArray_Copy_And_NoCopy_ProduceSameData() { var bitmap1 = EmbeddedBitmap("captcha-a"); @@ -161,7 +161,7 @@ public void ToNDArray_Copy_And_NoCopy_ProduceSameData() np.array_equal(rowN_copy, rowN_wrap).Should().BeTrue("last row should be identical between copy and no-copy"); } - [Test] + [TestMethod] public void ToNDArray_PixelValues_AreInByteRange() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -172,7 +172,7 @@ public void ToNDArray_PixelValues_AreInByteRange() min.Should().BeGreaterThanOrEqualTo((byte)0); } - [Test] + [TestMethod] public void ToNDArray_DiscardAlpha_PixelDataMatchesFirstThreeChannels() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -184,7 +184,7 @@ public void ToNDArray_DiscardAlpha_PixelDataMatchesFirstThreeChannels() np.array_equal(trimmed, fullRgb).Should().BeTrue("discardAlpha should be equivalent to slicing [:,:,:,:3]"); } - [Test] + [TestMethod] public void ToNDArray_NotAllZeros() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -197,7 +197,7 @@ public void ToNDArray_NotAllZeros() #region ToNDArray — odd width (stride padding) - [Test] + [TestMethod] public void ToNDArray_OddWidth_NoCopy_ShapeMatchesBitmap() { // copy:false uses ReshapeFlatData which handles stride padding correctly @@ -207,7 +207,7 @@ public void ToNDArray_OddWidth_NoCopy_ShapeMatchesBitmap() nd.shape[2].Should().Be(bitmap.Width); } - [Test] + [TestMethod] public void ToNDArray_OddWidth_NoCopy_Flat_Is1D() { var bitmap = EmbeddedBitmap("odd-width"); @@ -220,7 +220,7 @@ public void ToNDArray_OddWidth_NoCopy_Flat_Is1D() #region ToBitmap — round-trip with 32bpp (no stride padding issues) - [Test] + [TestMethod] public void ToBitmap_RoundTrip_32bpp_PreservesPixelData() { // 32bpp ARGB: 4 bytes per pixel, stride is always width*4 (no padding) @@ -238,7 +238,7 @@ public void ToBitmap_RoundTrip_32bpp_PreservesPixelData() np.array_equal(pixels, recovered).Should().BeTrue("32bpp round-trip should preserve all channels including alpha"); } - [Test] + [TestMethod] public void ToBitmap_RoundTrip_24bpp_EvenWidth() { // Use width=4 (multiple of 4) to avoid stride padding issues @@ -254,7 +254,7 @@ public void ToBitmap_RoundTrip_24bpp_EvenWidth() np.array_equal(pixels, recovered).Should().BeTrue("24bpp round-trip with even width should preserve data"); } - [Test] + [TestMethod] public void ToBitmap_RoundTrip_FromEmbedded_32bpp() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -269,7 +269,7 @@ public void ToBitmap_RoundTrip_FromEmbedded_32bpp() np.array_equal(nd, nd2).Should().BeTrue("embedded image round-trip should be lossless"); } - [Test] + [TestMethod] public void ToBitmap_RoundTrip_OddWidth_NoCopy() { // Use copy:false to avoid stride padding bug in copy path @@ -284,7 +284,7 @@ public void ToBitmap_RoundTrip_OddWidth_NoCopy() #region ToBitmap — auto format detection - [Test] + [TestMethod] public void ToBitmap_DontCare_3Channel_Infers24bpp() { var nd = np.zeros(new Shape(1, 4, 4, 3)).astype(NPTypeCode.Byte); @@ -292,7 +292,7 @@ public void ToBitmap_DontCare_3Channel_Infers24bpp() bmp.PixelFormat.Should().Be(PixelFormat.Format24bppRgb); } - [Test] + [TestMethod] public void ToBitmap_DontCare_4Channel_Infers32bpp() { var nd = np.zeros(new Shape(1, 4, 4, 4)).astype(NPTypeCode.Byte); @@ -300,7 +300,7 @@ public void ToBitmap_DontCare_4Channel_Infers32bpp() bmp.PixelFormat.Should().Be(PixelFormat.Format32bppArgb); } - [Test] + [TestMethod] public void ToBitmap_WithExplicitFormat_Uses24bpp() { // Use 4-pixel width to avoid stride padding @@ -311,7 +311,7 @@ public void ToBitmap_WithExplicitFormat_Uses24bpp() bmp.Height.Should().Be(3); } - [Test] + [TestMethod] public void ToBitmap_WithExplicitFormat_Uses32bpp() { var nd = np.arange(0, 3 * 3 * 4).reshape(1, 3, 3, 4).astype(NPTypeCode.Byte); @@ -323,7 +323,7 @@ public void ToBitmap_WithExplicitFormat_Uses32bpp() #region ToBitmap — flat input with explicit format - [Test] + [TestMethod] public void ToBitmap_FlatInput_WithFormat_ReshapesCorrectly() { // 4x3 image, 32bpp = 48 bytes (no stride padding for 32bpp) @@ -339,7 +339,7 @@ public void ToBitmap_FlatInput_WithFormat_ReshapesCorrectly() #region ToBitmap — error handling - [Test] + [TestMethod] public void ToBitmap_NullNDArray_ThrowsArgumentNull() { NDArray nd = null; @@ -347,7 +347,7 @@ public void ToBitmap_NullNDArray_ThrowsArgumentNull() act.Should().Throw(); } - [Test] + [TestMethod] public void ToBitmap_WrongNdim_ThrowsArgumentException() { var nd = np.zeros(new Shape(3, 3, 3)).astype(NPTypeCode.Byte); @@ -355,7 +355,7 @@ public void ToBitmap_WrongNdim_ThrowsArgumentException() act.Should().Throw(); } - [Test] + [TestMethod] public void ToBitmap_MultiplePictures_ThrowsArgumentException() { var nd = np.zeros(new Shape(2, 3, 3, 3)).astype(NPTypeCode.Byte); @@ -363,7 +363,7 @@ public void ToBitmap_MultiplePictures_ThrowsArgumentException() act.Should().Throw(); } - [Test] + [TestMethod] public void ToBitmap_FormatMismatch_ThrowsArgumentException() { // 3-channel data but requesting 32bpp (4 channels) @@ -376,7 +376,7 @@ public void ToBitmap_FormatMismatch_ThrowsArgumentException() #region ToNDArray — error handling - [Test] + [TestMethod] public void ToNDArray_NullBitmap_ThrowsArgumentNull() { Bitmap bmp = null; @@ -384,7 +384,7 @@ public void ToNDArray_NullBitmap_ThrowsArgumentNull() act.Should().Throw(); } - [Test] + [TestMethod] public void ToNDArray_NullImage_ThrowsArgumentNull() { Image img = null; @@ -396,7 +396,7 @@ public void ToNDArray_NullImage_ThrowsArgumentNull() #region Image.ToNDArray — delegates to Bitmap - [Test] + [TestMethod] public void ImageToNDArray_ProducesSameResultAsBitmapToNDArray() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -413,7 +413,7 @@ public void ImageToNDArray_ProducesSameResultAsBitmapToNDArray() #region AsNDArray — BitmapData wrapper - [Test] + [TestMethod] public unsafe void AsNDArray_WrapsLockBitsWithoutCopy() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -435,7 +435,7 @@ public unsafe void AsNDArray_WrapsLockBitsWithoutCopy() } } - [Test] + [TestMethod] public unsafe void AsNDArray_Shaped_DiscardAlpha() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -455,7 +455,7 @@ public unsafe void AsNDArray_Shaped_DiscardAlpha() } } - [Test] + [TestMethod] public void AsNDArray_NullBitmapData_ThrowsArgumentNull() { BitmapData bmpData = null; @@ -467,49 +467,49 @@ public void AsNDArray_NullBitmapData_ThrowsArgumentNull() #region ToBytesPerPixel - [Test] + [TestMethod] public void ToBytesPerPixel_24bppRgb_Returns3() { PixelFormat.Format24bppRgb.ToBytesPerPixel().Should().Be(3); } - [Test] + [TestMethod] public void ToBytesPerPixel_32bppArgb_Returns4() { PixelFormat.Format32bppArgb.ToBytesPerPixel().Should().Be(4); } - [Test] + [TestMethod] public void ToBytesPerPixel_32bppPArgb_Returns4() { PixelFormat.Format32bppPArgb.ToBytesPerPixel().Should().Be(4); } - [Test] + [TestMethod] public void ToBytesPerPixel_32bppRgb_Returns4() { PixelFormat.Format32bppRgb.ToBytesPerPixel().Should().Be(4); } - [Test] + [TestMethod] public void ToBytesPerPixel_48bppRgb_Returns6() { PixelFormat.Format48bppRgb.ToBytesPerPixel().Should().Be(6); } - [Test] + [TestMethod] public void ToBytesPerPixel_64bppArgb_Returns8() { PixelFormat.Format64bppArgb.ToBytesPerPixel().Should().Be(8); } - [Test] + [TestMethod] public void ToBytesPerPixel_64bppPArgb_Returns8() { PixelFormat.Format64bppPArgb.ToBytesPerPixel().Should().Be(8); } - [Test] + [TestMethod] public void ToBytesPerPixel_16bppFormats_Return2() { PixelFormat.Format16bppGrayScale.ToBytesPerPixel().Should().Be(2); @@ -518,14 +518,14 @@ public void ToBytesPerPixel_16bppFormats_Return2() PixelFormat.Format16bppArgb1555.ToBytesPerPixel().Should().Be(2); } - [Test] + [TestMethod] public void ToBytesPerPixel_IndexedFormat_ThrowsArgumentException() { Action act = () => PixelFormat.Format8bppIndexed.ToBytesPerPixel(); act.Should().Throw(); } - [Test] + [TestMethod] public void ToBytesPerPixel_DontCare_ThrowsArgumentException() { Action act = () => PixelFormat.DontCare.ToBytesPerPixel(); @@ -536,7 +536,7 @@ public void ToBytesPerPixel_DontCare_ThrowsArgumentException() #region Multiple embedded resources - [Test] + [TestMethod] public void ToNDArray_DifferentImages_HaveDifferentShapes() { var captcha = EmbeddedBitmap("captcha-a"); @@ -563,7 +563,7 @@ public void ToNDArray_DifferentImages_HaveDifferentShapes() .Should().BeFalse("different images should have different dimensions"); } - [Test] + [TestMethod] public void ToNDArray_AllCaptchaImages_Load() { // Verify all 4 captcha images can be loaded and converted @@ -583,7 +583,7 @@ public void ToNDArray_AllCaptchaImages_Load() #region Zeros and ones images - [Test] + [TestMethod] public void ToBitmap_AllBlack_RoundTripsCorrectly() { var black = np.zeros(new Shape(1, 8, 8, 3)).astype(NPTypeCode.Byte); @@ -592,7 +592,7 @@ public void ToBitmap_AllBlack_RoundTripsCorrectly() recovered.Should().AllValuesBe((byte)0); } - [Test] + [TestMethod] public void ToBitmap_AllWhite_RoundTripsCorrectly() { var white = (np.zeros(new Shape(1, 8, 8, 3)) + 255).astype(NPTypeCode.Byte); @@ -601,7 +601,7 @@ public void ToBitmap_AllWhite_RoundTripsCorrectly() recovered.Should().AllValuesBe((byte)255); } - [Test] + [TestMethod] public void ToBitmap_32bpp_AllBlack_RoundTripsCorrectly() { var black = np.zeros(new Shape(1, 8, 8, 4)).astype(NPTypeCode.Byte); @@ -611,7 +611,7 @@ public void ToBitmap_32bpp_AllBlack_RoundTripsCorrectly() recovered.Should().AllValuesBe((byte)0); } - [Test] + [TestMethod] public void ToBitmap_32bpp_AllWhite_RoundTripsCorrectly() { var white = (np.zeros(new Shape(1, 8, 8, 4)) + 255).astype(NPTypeCode.Byte); @@ -625,7 +625,7 @@ public void ToBitmap_32bpp_AllWhite_RoundTripsCorrectly() #region ToBitmap — specific pixel values - [Test] + [TestMethod] public void ToBitmap_32bpp_SpecificPixels_RoundTrip() { // Create a 2x2 image with known BGRA values @@ -648,7 +648,7 @@ public void ToBitmap_32bpp_SpecificPixels_RoundTrip() } } - [Test] + [TestMethod] public void ToBitmap_SizeProperty_MatchesDimensions() { var nd = np.zeros(new Shape(1, 10, 20, 4)).astype(NPTypeCode.Byte); diff --git a/test/NumSharp.UnitTest/NumSharp.Bitmap/BitmapWithAlphaTests.cs b/test/NumSharp.UnitTest/NumSharp.Bitmap/BitmapWithAlphaTests.cs index 74cee0f73..4bac89ee6 100644 --- a/test/NumSharp.UnitTest/NumSharp.Bitmap/BitmapWithAlphaTests.cs +++ b/test/NumSharp.UnitTest/NumSharp.Bitmap/BitmapWithAlphaTests.cs @@ -8,10 +8,10 @@ namespace NumSharp.UnitTest { [WindowsOnly] - [SkipOnNonWindows] + [TestClass] public class BitmapWithAlphaTests : TestClass { - [Test] + [TestMethod] public void ToNDArray_Case1() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -19,7 +19,7 @@ public void ToNDArray_Case1() nd.Should().BeShaped(1, 165, 400, 3); } - [Test] + [TestMethod] public void ToNDArray_Case2() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -27,7 +27,7 @@ public void ToNDArray_Case2() nd.Should().BeShaped(1, 165, 400, 3); } - [Test] + [TestMethod] public void ToNDArray_Case3() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -35,7 +35,7 @@ public void ToNDArray_Case3() nd.Should().BeShaped(1, 165, 400, 4); } - [Test] + [TestMethod] public void ToNDArray_Case4() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -44,7 +44,7 @@ public void ToNDArray_Case4() } - [Test] + [TestMethod] public void ToNDArray_Odd_Width() { var bitmap = EmbeddedBitmap("odd-width"); @@ -52,7 +52,7 @@ public void ToNDArray_Odd_Width() nd.Should().BeShaped(1, 554, 475, 3); } - [Test] + [TestMethod] public void ToBitmap_Odd_Width() { var bitmap = EmbeddedBitmap("odd-width"); @@ -62,7 +62,7 @@ public void ToBitmap_Odd_Width() bitmap2.Height.Should().Be(bitmap.Height); } - [Test] + [TestMethod] public void ToNDArray_Case5_flat() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -70,7 +70,7 @@ public void ToNDArray_Case5_flat() nd.Should().BeShaped(1 * 165 * 400 * 3); } - [Test] + [TestMethod] public void ToNDArray_Case6_flat() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -78,7 +78,7 @@ public void ToNDArray_Case6_flat() nd.Should().BeShaped(1 * 165 * 400 * 3); } - [Test] + [TestMethod] public void ToNDArray_Case7_flat() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -86,7 +86,7 @@ public void ToNDArray_Case7_flat() nd.Should().BeShaped(1 * 165 * 400 * 4); } - [Test] + [TestMethod] public void ToNDArray_Case8_flat() { var bitmap = EmbeddedBitmap("captcha-a"); @@ -94,14 +94,14 @@ public void ToNDArray_Case8_flat() nd.Should().BeShaped(1 * 165 * 400 * 4); } - [Test] + [TestMethod] public void ToBitmap_PixelFormat_DontCare_Case1() { var bm = np.arange(0, 3 * 3 * 3).reshape(1, 3, 3, 3).astype(NPTypeCode.Byte).ToBitmap(); bm.PixelFormat.Should().Be(PixelFormat.Format24bppRgb); } - [Test] + [TestMethod] public void ToBitmap_PixelFormat_DontCare_Case2() { var bm = np.arange(0, 3 * 3 * 4).reshape(1, 3, 3, 4).astype(NPTypeCode.Byte).ToBitmap(); diff --git a/test/NumSharp.UnitTest/NumSharp.UnitTest.csproj b/test/NumSharp.UnitTest/NumSharp.UnitTest.csproj index 7fbac58fd..96b331f45 100644 --- a/test/NumSharp.UnitTest/NumSharp.UnitTest.csproj +++ b/test/NumSharp.UnitTest/NumSharp.UnitTest.csproj @@ -1,9 +1,7 @@  - - - net10.0 + net8.0;net10.0 Exe false true @@ -11,7 +9,6 @@ AnyCPU Open.snk Debug;Release;Publish - false @@ -33,8 +30,7 @@ - - + diff --git a/test/NumSharp.UnitTest/OpenBugs.ApiAudit.cs b/test/NumSharp.UnitTest/OpenBugs.ApiAudit.cs index 4573d69cb..3219862b8 100644 --- a/test/NumSharp.UnitTest/OpenBugs.ApiAudit.cs +++ b/test/NumSharp.UnitTest/OpenBugs.ApiAudit.cs @@ -26,7 +26,7 @@ public partial class OpenBugs /// NumPy: sign(int32[]).dtype = int32 /// NumSharp: FIXED — sign(int32[]).dtype = int32 /// - [Test] + [TestMethod] public void Bug64_Sign_PreservesDtype() { var a = np.array(new int[] { -3, 0, 5 }); @@ -56,7 +56,7 @@ public void Bug64_Sign_PreservesDtype() /// NumPy: arange(5)[mask] = [0, 2, 4] /// NumSharp: FIXED — returns [0, 2, 4] (size=3) /// - [Test] + [TestMethod] public void Bug69_BooleanMaskGetter_ReturnsSelection() { var a = np.arange(5); // [0, 1, 2, 3, 4] @@ -77,7 +77,7 @@ public void Bug69_BooleanMaskGetter_ReturnsSelection() /// NumPy: a[mask] = 99 -> [99, 20, 99, 40, 99] /// NumSharp: FIXED — correctly sets masked elements /// - [Test] + [TestMethod] public void Bug70_BooleanMaskSetter_Works() { var a = np.array(new int[] { 10, 20, 30, 40, 50 }); @@ -136,7 +136,7 @@ public void Bug70_BooleanMaskSetter_Works() /// NumPy: float(np.sum(np.arange(10))) = 45.0 /// NumSharp: returns ~6.95e-310 (int32 bytes read as double) /// - [Test] + [TestMethod] public void Bug_DoubleCast_Int32NDArray_ReturnsGarbage() { // np.sum returns a scalar NDArray (ndim=0) @@ -168,7 +168,7 @@ public void Bug_DoubleCast_Int32NDArray_ReturnsGarbage() /// NumPy: np.array([42]).reshape(()) = array(42), ndim=0 /// NumSharp: FIXED — correctly creates scalar array /// - [Test] + [TestMethod] public void Bug73_Reshape_ScalarShape_Works() { var a = np.array(new int[] { 42 }); // shape (1,) @@ -200,7 +200,7 @@ public void Bug73_Reshape_ScalarShape_Works() /// NumPy: sign([NaN, inf, -inf, 0]) = [NaN, 1, -1, 0] /// NumSharp: FIXED — returns correct values including NaN /// - [Test] + [TestMethod] public void Bug77_Sign_NaN_ReturnsNaN() { var a = np.array(new double[] { double.NaN, 1.0, double.PositiveInfinity, double.NegativeInfinity, 0.0 }); @@ -220,7 +220,7 @@ public void Bug77_Sign_NaN_ReturnsNaN() /// NumPy: std([]) = NaN (with warning) /// NumSharp: FIXED — returns NaN /// - [Test] + [TestMethod] public void Bug78a_Std_EmptyArray_ReturnsNaN() { var empty = np.array(new double[0]); @@ -236,7 +236,7 @@ public void Bug78a_Std_EmptyArray_ReturnsNaN() /// NumPy: var([]) = NaN (with warning) /// NumSharp: FIXED — returns NaN /// - [Test] + [TestMethod] public void Bug78b_Var_EmptyArray_ReturnsNaN() { var empty = np.array(new double[0]); @@ -259,7 +259,7 @@ public void Bug78b_Var_EmptyArray_ReturnsNaN() /// NumPy: a[[1,3]] = [99,88] -> [10,99,30,88,50] /// NumSharp: FIXED — correctly sets indexed elements /// - [Test] + [TestMethod] public void Bug80_FancyIndexSetter_Works() { var a = np.array(new int[] { 10, 20, 30, 40, 50 }); diff --git a/test/NumSharp.UnitTest/OpenBugs.Bitmap.cs b/test/NumSharp.UnitTest/OpenBugs.Bitmap.cs index 2e1f2c39c..bcb6a52e6 100644 --- a/test/NumSharp.UnitTest/OpenBugs.Bitmap.cs +++ b/test/NumSharp.UnitTest/OpenBugs.Bitmap.cs @@ -55,7 +55,6 @@ namespace NumSharp.UnitTest /// Total: 8 distinct bugs, 10 test methods. /// [WindowsOnly] - [SkipOnNonWindows] public class OpenBugsBitmap : TestClass { @@ -92,7 +91,7 @@ public class OpenBugsBitmap : TestClass /// stride=12, width=3, stride/width=4 → shape (1,2,3,4) instead of (1,2,3,3). /// The image has 3 channels (RGB) but gets reshaped as 4 channels. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug1a_ToNDArray_CopyTrue_OddWidth24bpp_WrongShape() { var bmp = new Bitmap(3, 2, PixelFormat.Format24bppRgb); @@ -115,7 +114,7 @@ public void Bug1a_ToNDArray_CopyTrue_OddWidth24bpp_WrongShape() /// The division happens to give 3 (correct bpp), but stride*height=32 /// does not equal height*width*3=30, so the reshape may produce wrong data. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug1b_ToNDArray_CopyTrue_5pxWide24bpp_ExtraPaddingBytes() { var bmp = new Bitmap(5, 2, PixelFormat.Format24bppRgb); @@ -158,7 +157,7 @@ public void Bug1b_ToNDArray_CopyTrue_5pxWide24bpp_ExtraPaddingBytes() /// stride=8, width=2, stride/width=4 → shape (1,2,2,4) instead of (1,2,2,3). /// Round-trip pixel values are corrupted because channel boundaries shift. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug2_ToNDArray_CopyTrue_2pxWide24bpp_WrongBpp() { var bmp = new Bitmap(2, 2, PixelFormat.Format24bppRgb); @@ -194,7 +193,7 @@ public void Bug2_ToNDArray_CopyTrue_2pxWide24bpp_WrongBpp() /// /// BUG 3a: AsNDArray(flat:true) crashes accessing shape[3] on 1-d array. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug3a_AsNDArray_FlatTrue_IndexOutOfRange() { var bmp = new Bitmap(4, 4, PixelFormat.Format32bppArgb); @@ -221,7 +220,7 @@ public void Bug3a_AsNDArray_FlatTrue_IndexOutOfRange() /// BUG 3b: AsNDArray(flat:true, discardAlpha:true) crashes the same way. /// The discardAlpha path also accesses shape[3] before reshaping. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug3b_AsNDArray_FlatTrue_DiscardAlpha_IndexOutOfRange() { var bmp = new Bitmap(4, 4, PixelFormat.Format32bppArgb); @@ -269,7 +268,7 @@ public void Bug3b_AsNDArray_FlatTrue_DiscardAlpha_IndexOutOfRange() /// BUG 4: ToBitmap with sliced (non-contiguous) NDArray throws /// IncorrectShapeException from MultiIterator broadcast. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug4_ToBitmap_SlicedNDArray_BroadcastMismatch() { var full = np.arange(0, 4 * 4 * 4).reshape(1, 4, 4, 4).astype(NPTypeCode.Byte); @@ -310,7 +309,7 @@ public void Bug4_ToBitmap_SlicedNDArray_BroadcastMismatch() /// BUG 5: ToBitmap with int32 NDArray throws cryptic InvalidCastException /// instead of a helpful error or auto-converting to byte. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug5_ToBitmap_NonByteDtype_InvalidCastException() { var nd = np.arange(0, 1 * 3 * 4 * 3).reshape(1, 3, 4, 3); // int32 @@ -357,7 +356,7 @@ public void Bug5_ToBitmap_NonByteDtype_InvalidCastException() /// BUG 6a: ToBitmap crashes on 1px wide 24bpp image. /// stride=4 (1*3=3, padded to 4), width*bpp=3 → concat triggers. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug6a_ToBitmap_1pxWide24bpp_StridePaddingCrash() { var nd = np.ones(new Shape(1, 2, 1, 3)).astype(NPTypeCode.Byte); @@ -380,7 +379,7 @@ public void Bug6a_ToBitmap_1pxWide24bpp_StridePaddingCrash() /// BUG 6b: ToBitmap crashes on 5px wide 24bpp image. /// stride=16 (5*3=15, padded to 16), width*bpp=15 → concat triggers. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug6b_ToBitmap_5pxWide24bpp_StridePaddingCrash() { var nd = np.ones(new Shape(1, 2, 5, 3)).astype(NPTypeCode.Byte); @@ -422,7 +421,7 @@ public void Bug6b_ToBitmap_5pxWide24bpp_StridePaddingCrash() /// /// BUG 7: Round-trip 24bpp 2px wide — pixel values corrupted. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug7_ToNDArray_CopyTrue_2pxWide24bpp_RoundTripCorruption() { var bmp = new Bitmap(2, 2, PixelFormat.Format24bppRgb); @@ -464,7 +463,7 @@ public void Bug7_ToNDArray_CopyTrue_2pxWide24bpp_RoundTripCorruption() /// BUG 8: ToBitmap with 2-channel NDArray throws unhelpful GDI+ error. /// extractFormatNumber() doesn't handle bbp=2, leaving format as DontCare. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug8_ToBitmap_UnsupportedBpp_UnhelpfulError() { var nd = np.zeros(new Shape(1, 2, 2, 2)).astype(NPTypeCode.Byte); diff --git a/test/NumSharp.UnitTest/OpenBugs.ILKernelBattle.cs b/test/NumSharp.UnitTest/OpenBugs.ILKernelBattle.cs index 2c0da8f9f..34c3678fb 100644 --- a/test/NumSharp.UnitTest/OpenBugs.ILKernelBattle.cs +++ b/test/NumSharp.UnitTest/OpenBugs.ILKernelBattle.cs @@ -2,7 +2,6 @@ using System.Linq; using AwesomeAssertions; using NumSharp; -using TUnit.Core; namespace NumSharp.UnitTest { @@ -61,7 +60,7 @@ public class ILKernelBattleTests /// /// BUG 84: prod(empty bool) should return int64, not bool. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug84_Prod_EmptyBool_ReturnsInt64() { var a = np.array(new bool[0]); @@ -89,7 +88,7 @@ public class ILKernelPassingTests { // ----- STD/VAR TESTS ----- - [Test, OpenBugs] + [TestMethod, OpenBugs] public void StdVar_BasicDtypes_MatchNumPy() { var a_int32 = np.array(new int[] { 1, 2, 3, 4, 5 }); @@ -108,7 +107,7 @@ public void StdVar_BasicDtypes_MatchNumPy() np.var(a_float64).GetDouble(0).Should().BeApproximately(2.0, 1e-10); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void StdVar_WithAxis_MatchNumPy() { var a = np.array(new double[,] { { 1, 2, 3 }, { 4, 5, 6 } }); @@ -125,7 +124,7 @@ public void StdVar_WithAxis_MatchNumPy() std_axis1.GetDouble(1).Should().BeApproximately(0.81649658, 1e-6); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void StdVar_EmptyArray_ReturnsNaN() { var empty = np.array(new double[0]); @@ -133,7 +132,7 @@ public void StdVar_EmptyArray_ReturnsNaN() double.IsNaN(np.var(empty).GetDouble(0)).Should().BeTrue("var(empty) = NaN"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void StdVar_SingleElement_Ddof1_ReturnsNaN() { var single = np.array(new double[] { 5.0 }); @@ -143,7 +142,7 @@ public void StdVar_SingleElement_Ddof1_ReturnsNaN() // ----- CUMSUM TESTS ----- - [Test, OpenBugs] + [TestMethod, OpenBugs] public void CumSum_TypePromotion_MatchNumPy() { // int32 -> int64 @@ -162,7 +161,7 @@ public void CumSum_TypePromotion_MatchNumPy() cs_float32.dtype.Should().Be(typeof(float), "cumsum(float32) -> float32"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void CumSum_WithAxis_MatchNumPy() { var a = np.array(new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }); @@ -180,7 +179,7 @@ public void CumSum_WithAxis_MatchNumPy() cs_axis1.GetInt64(1, 2).Should().Be(15L); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void CumSum_BoolArray_MatchNumPy() { var a = np.array(new bool[] { true, false, true, true, false }); @@ -197,7 +196,7 @@ public void CumSum_BoolArray_MatchNumPy() // ----- SHIFT TESTS ----- - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Shift_BasicOperations_MatchNumPy() { var a = np.array(new int[] { 1, 2, 4, 8, 16 }); @@ -213,7 +212,7 @@ public void Shift_BasicOperations_MatchNumPy() rs.GetInt32(4).Should().Be(8); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Shift_SignedRightShift_IsArithmetic() { // NumPy uses arithmetic right shift for signed types @@ -232,7 +231,7 @@ public void Shift_SignedRightShift_IsArithmetic() // These tests verify the fix for Bug 81 where shift by >= bit width // returned the original value instead of 0 (due to C# masking behavior). - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Shift_FullBitWidth_ReturnsZero() { // int32 << 32 should return 0 (not original value) @@ -253,7 +252,7 @@ public void Shift_FullBitWidth_ReturnsZero() result.GetInt32(0).Should().Be(0, "NumPy: 1 << 64 = 0 for int32"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Shift_UInt32_FullBitWidth_ReturnsZero() { var a = np.array(new uint[] { 0xFFFFFFFF }); @@ -261,7 +260,7 @@ public void Shift_UInt32_FullBitWidth_ReturnsZero() result.GetUInt32(0).Should().Be(0u, "NumPy: 0xFFFFFFFF << 32 = 0 for uint32"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Shift_NegativeRightShift_FullBitWidth_ReturnsMinusOne() { // Negative values right-shifted by >= bit width should return -1 @@ -271,7 +270,7 @@ public void Shift_NegativeRightShift_FullBitWidth_ReturnsMinusOne() result.GetInt32(1).Should().Be(-1, "NumPy: -100 >> 32 = -1 for int32"); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Shift_ArrayShifts_WithOverflow() { // Test array shift amounts where some are >= bit width @@ -290,7 +289,7 @@ public void Shift_ArrayShifts_WithOverflow() // ----- DOT TESTS (contiguous) ----- - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Dot_1Dx1D_InnerProduct() { var a = np.array(new double[] { 1, 2, 3 }); @@ -301,7 +300,7 @@ public void Dot_1Dx1D_InnerProduct() result.GetDouble(0).Should().Be(32.0); } - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Dot_2Dx2D_MatrixMultiply() { var a = np.array(new double[,] { { 1, 2 }, { 3, 4 } }); @@ -321,7 +320,7 @@ public void Dot_2Dx2D_MatrixMultiply() /// BUG 82 (FIXED): Dot product with both operands transposed. /// Previously produced wrong results due to incorrect stride handling. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Dot_BothTransposed_MatchNumPy() { // Original arrays before transpose @@ -357,7 +356,7 @@ public void Dot_BothTransposed_MatchNumPy() /// /// BUG 82b (FIXED): Dot with one transposed operand. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Dot_OneTransposed_MatchNumPy() { // One contiguous, one transposed @@ -390,7 +389,7 @@ public void Dot_OneTransposed_MatchNumPy() // ----- BOOL PROD TESTS ----- - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Prod_BoolArray_MatchNumPy() { // prod([True, True, True]) = 1 diff --git a/test/NumSharp.UnitTest/OpenBugs.Random.cs b/test/NumSharp.UnitTest/OpenBugs.Random.cs index 0bde9d5db..e8e1db82f 100644 --- a/test/NumSharp.UnitTest/OpenBugs.Random.cs +++ b/test/NumSharp.UnitTest/OpenBugs.Random.cs @@ -19,6 +19,7 @@ namespace NumSharp.UnitTest /// print(np.random.rand()) # etc. /// /// + [TestClass] public class OpenBugsRandom : TestClass { // ===== CRITICAL: RNG Algorithm Mismatch ===== @@ -32,7 +33,7 @@ public class OpenBugsRandom : TestClass /// NumPy seed=42: 0.3745401188473625 /// NumSharp seed=42: 0.668106465911542 (WRONG - different algorithm) /// - [Test] + [TestMethod] [OpenBugs] public void Rand_Seed42_ShouldMatchNumPy() { @@ -52,7 +53,7 @@ public void Rand_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42: [0.37454012, 0.95071431, 0.73199394, 0.59865848, 0.15601864] /// - [Test] + [TestMethod] public void Rand5_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); @@ -81,7 +82,7 @@ public void Rand5_Seed42_ShouldMatchNumPy() /// NumPy seed=42: 0.4967141530112327 /// NumSharp seed=42: Different value (wrong RNG + Box-Muller may differ) /// - [Test] + [TestMethod] [OpenBugs] public void Randn_Seed42_ShouldMatchNumPy() { @@ -102,7 +103,7 @@ public void Randn_Seed42_ShouldMatchNumPy() /// NumPy seed=42: [0.4967141530112327, -0.13826430117118466, 0.6476885381006925, /// 1.5230298564080254, -0.23415337472333597] /// - [Test] + [TestMethod] public void Randn5_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); @@ -129,7 +130,7 @@ public void Randn5_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42, randint(0,10): 6 /// - [Test] + [TestMethod] public void Randint_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); @@ -147,7 +148,7 @@ public void Randint_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42: [6, 3, 7, 4, 6] /// - [Test] + [TestMethod] public void Randint5_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); @@ -168,7 +169,7 @@ public void Randint5_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42: 0.4967141530112327 /// - [Test] + [TestMethod] public void Normal_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); @@ -186,7 +187,7 @@ public void Normal_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42: 0.3745401188473625 /// - [Test] + [TestMethod] public void Uniform_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); @@ -204,7 +205,7 @@ public void Uniform_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42: 6 /// - [Test] + [TestMethod] public void Choice_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); @@ -222,7 +223,7 @@ public void Choice_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42: [1, 4, 2, 0, 3] /// - [Test] + [TestMethod] [OpenBugs] public void Permutation_Seed42_ShouldMatchNumPy() { @@ -248,7 +249,7 @@ public void Permutation_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42: 0.4692680899768591 /// - [Test] + [TestMethod] public void Exponential_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); @@ -266,7 +267,7 @@ public void Exponential_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42: 5 /// - [Test] + [TestMethod] public void Poisson_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); @@ -284,7 +285,7 @@ public void Poisson_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42: 4 /// - [Test] + [TestMethod] public void Binomial_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); @@ -302,7 +303,7 @@ public void Binomial_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42: 0.5992069666276891 /// - [Test] + [TestMethod] public void Beta_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); @@ -320,7 +321,7 @@ public void Beta_Seed42_ShouldMatchNumPy() /// /// NumPy seed=42: 2.3936793898692366 /// - [Test] + [TestMethod] public void Gamma_Seed42_ShouldMatchNumPy() { var rng = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/OpenBugs.cs b/test/NumSharp.UnitTest/OpenBugs.cs index 87e6c641a..613765bed 100644 --- a/test/NumSharp.UnitTest/OpenBugs.cs +++ b/test/NumSharp.UnitTest/OpenBugs.cs @@ -61,6 +61,7 @@ namespace NumSharp.UnitTest /// Bug 68: swapaxes on empty arrays crashes (NDIterator limitation) /// Bug 69: Out-of-bounds axis error is IndexOutOfRangeException, not AxisError /// + [TestClass] public partial class OpenBugs : TestClass { // ================================================================ @@ -128,7 +129,7 @@ public partial class OpenBugs : TestClass /// means the logical element order is reversed from the physical /// memory layout. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_ToString_ReversedSliceBroadcast() { var rev = np.arange(3)["::-1"]; // [2, 1, 0] @@ -164,7 +165,7 @@ public void Bug_ToString_ReversedSliceBroadcast() /// the broadcast stride and the view stride are being multiplied /// or combined incorrectly. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_ToString_StepSliceBroadcast() { var stepped = np.arange(6)["::2"]; // [0, 2, 4] @@ -201,7 +202,7 @@ public void Bug_ToString_StepSliceBroadcast() /// appears to walk linearly with some stride that misses offset 36 /// and lands in zeroed/garbage memory beyond the allocation. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_ToString_SlicedColumnBroadcast() { var x = np.arange(12).reshape(3, 4); @@ -243,7 +244,7 @@ public void Bug_ToString_SlicedColumnBroadcast() /// creates a compound stride that the ToString iterator fails /// to resolve correctly. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_ToString_DoubleSlicedBroadcast() { var x = np.arange(12).reshape(3, 4); @@ -303,7 +304,7 @@ public void Bug_ToString_DoubleSlicedBroadcast() /// NumPy: y[0,0] = 999 raises ValueError. /// NumSharp: SetInt32(999, 0, 0) succeeds silently. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_BroadcastTo_NoReadOnlyProtection() { var x = np.array(new int[] { 1, 2, 3, 4 }); @@ -364,7 +365,7 @@ public void Bug_BroadcastTo_NoReadOnlyProtection() /// NumPy: broadcast_to(ones(1,2), (2,1)) raises ValueError. /// NumSharp: Returns shape (2,2) — stretched both. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_BroadcastTo_BilateralSemantics() { // NumPy: broadcast_to(ones(3), (1,)) must throw @@ -426,7 +427,7 @@ public void Bug_BroadcastTo_BilateralSemantics() /// new leading dimension with stride=0, but the IsBroadcasted /// guard blocks it. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_ReBroadcast_Inconsistency() { var x = np.ones(new Shape(1, 3)); @@ -495,7 +496,7 @@ public void Bug_ReBroadcast_Inconsistency() /// NumPy: Returns (3,3) bool with False on diagonal. /// NumSharp: InvalidCastException: Unable to cast 'NDArray' to 'IConvertible'. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_NotEquals_NDArrayBroadcast_Throws() { var a = np.array(new int[] { 1, 2, 3 }); @@ -563,7 +564,7 @@ public void Bug_NotEquals_NDArrayBroadcast_Throws() /// NumPy: allclose(a, a) returns True. /// NumSharp: NullReferenceException at np.all.cs:line 29. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Allclose_AlwaysThrows() { var a = np.array(new double[] { 1.0, 2.0, 3.0 }); @@ -586,7 +587,7 @@ public void Bug_Allclose_AlwaysThrows() /// NumPy: allclose(shape(3,), shape(2,3)) returns True when all elements match. /// NumSharp: NullReferenceException. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Allclose_BroadcastThrows() { var a = np.array(new double[] { 1.0, 2.0, 3.0 }); // shape (3,) @@ -652,7 +653,7 @@ public void Bug_Allclose_BroadcastThrows() /// NumPy: array([1,5,3]) > array([2,4,3]) = [False,True,False] /// NumSharp: IncorrectShapeException /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_GreaterThan_NDArrayVsNDArray_SameShape() { var a = np.array(new int[] { 1, 5, 3 }); @@ -677,7 +678,7 @@ public void Bug_GreaterThan_NDArrayVsNDArray_SameShape() /// NumPy: array([1,5,3]) < array([2,4,3]) = [True,False,False] /// NumSharp: IncorrectShapeException /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_LessThan_NDArrayVsNDArray_SameShape() { var a = np.array(new int[] { 1, 5, 3 }); @@ -703,7 +704,7 @@ public void Bug_LessThan_NDArrayVsNDArray_SameShape() /// NumPy: array([1,5,3]) > array([[2],[4]]) = [[F,T,T],[F,T,F]] /// NumSharp: IncorrectShapeException /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_GreaterThan_NDArrayVsNDArray_Broadcast() { var a = np.array(new int[] { 1, 5, 3 }); // (3,) @@ -761,8 +762,8 @@ public void Bug_GreaterThan_NDArrayVsNDArray_Broadcast() /// NumPy: unique([3,1,2,1,3]) = [1,2,3] (always sorted). /// Fix: Added Span.Sort() after collecting unique values. /// - [Test] - [Category("Fixed")] + [TestMethod] + [TestCategory("Fixed")] public void Bug_Unique_NotSorted() { var a = np.array(new int[] { 3, 1, 2, 1, 3 }); @@ -829,7 +830,7 @@ public void Bug_Unique_NotSorted() /// Note: ravel() returns correct results for the same input, /// suggesting it uses a different iteration path than flatten(). /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Flatten_ColumnBroadcast_WrongOrder() { var a = np.array(new int[,] { { 1 }, { 2 }, { 3 } }); // (3,1) @@ -902,7 +903,7 @@ public void Bug_Flatten_ColumnBroadcast_WrongOrder() /// NumPy: [[1,2,3], [2,4,6], [3,6,9]] /// NumSharp: [[garbage, garbage, garbage], ...] (uninitialized memory) /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Cumsum_Axis0_RowBroadcast_Garbage() { var a = np.broadcast_to(np.array(new int[] { 1, 2, 3 }), new Shape(3, 3)); @@ -941,7 +942,7 @@ public void Bug_Cumsum_Axis0_RowBroadcast_Garbage() /// NumPy: [[1,1,1], [3,3,3], [6,6,6]] /// NumSharp: [[garbage, garbage, garbage], ...] /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Cumsum_Axis0_ColBroadcast_Garbage() { var col = np.array(new int[,] { { 1 }, { 2 }, { 3 } }); @@ -983,7 +984,7 @@ public void Bug_Cumsum_Axis0_ColBroadcast_Garbage() /// The values suggest cumsum reads with wrong strides — it appears /// to be accumulating along axis=0 instead of axis=1. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Cumsum_Axis1_ColBroadcast_Wrong() { var col = np.array(new int[,] { { 1 }, { 2 }, { 3 } }); @@ -1055,7 +1056,7 @@ public void Bug_Cumsum_Axis1_ColBroadcast_Wrong() /// NumPy: [[3,1,2], [3,1,2]] /// NumSharp: [[3,1,2], [0,0,0]] /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Roll_RowBroadcast_ZerosInSecondRow() { var a = np.broadcast_to(np.array(new int[] { 1, 2, 3 }), new Shape(2, 3)); @@ -1087,7 +1088,7 @@ public void Bug_Roll_RowBroadcast_ZerosInSecondRow() /// NumPy: [[30,30,30], [10,10,10], [20,20,20]] /// NumSharp: [[30,30,30], [0,0,0], [0,0,0]] /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Roll_ColBroadcast_ZerosAfterFirstRow() { var col = np.array(new int[,] { { 10 }, { 20 }, { 30 } }); @@ -1175,7 +1176,7 @@ public void Bug_Roll_ColBroadcast_ZerosAfterFirstRow() /// NumPy: [600, 600, 600] /// NumSharp: [300, 300, 300] (under-counts, appears to miss row 2) /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Sum_Axis0_ColBroadcast_WrongValues() { var col = np.array(new int[,] { { 100 }, { 200 }, { 300 } }); @@ -1201,7 +1202,7 @@ public void Bug_Sum_Axis0_ColBroadcast_WrongValues() /// NumPy: mean = [2.0, 2.0, 2.0] /// NumSharp: mean = [1.0, 1.0, 1.0] /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Mean_Axis0_ColBroadcast_WrongValues() { var col = np.array(new double[,] { { 1.0 }, { 2.0 }, { 3.0 } }); @@ -1224,7 +1225,7 @@ public void Bug_Mean_Axis0_ColBroadcast_WrongValues() /// NumPy: var = [0.6667, 0.6667, 0.6667] /// NumSharp: var = [0.0, 0.0, 0.0] /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Var_Axis0_ColBroadcast_WrongValues() { var col = np.array(new double[,] { { 1.0 }, { 2.0 }, { 3.0 } }); @@ -1247,7 +1248,7 @@ public void Bug_Var_Axis0_ColBroadcast_WrongValues() /// NumPy: std = [0.8165, 0.8165, 0.8165] /// NumSharp: std = [0.0, 0.0, 0.0] /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Std_Axis0_ColBroadcast_WrongValues() { var col = np.array(new double[,] { { 1.0 }, { 2.0 }, { 3.0 } }); @@ -1272,7 +1273,7 @@ public void Bug_Std_Axis0_ColBroadcast_WrongValues() /// NumPy: sum(axis=0) = [15, 15, 15] (1+2+3+4+5) /// NumSharp: sum(axis=0) = [7, 7, 7] /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Sum_Axis0_ColBroadcast_5x3_WrongValues() { var col = np.array(new int[,] { { 1 }, { 2 }, { 3 }, { 4 }, { 5 } }); @@ -1321,7 +1322,7 @@ public void Bug_Sum_Axis0_ColBroadcast_5x3_WrongValues() /// NumPy: argsort([[3,1,2],[6,4,5]]) = [[1,2,0],[1,2,0]] /// NumSharp: InvalidOperationException: Failed to compare two elements /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Argsort_2D_Crashes() { var a = np.array(new int[,] { { 3, 1, 2 }, { 6, 4, 5 } }); @@ -1356,7 +1357,7 @@ public void Bug_Argsort_2D_Crashes() /// NumPy: argsort([[3.0,1.0,2.0]]) = [[1,2,0]] /// NumSharp: InvalidOperationException /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Argsort_2D_Double_Crashes() { var a = np.array(new double[,] { { 3.0, 1.0, 2.0 } }); @@ -1398,7 +1399,7 @@ public void Bug_Argsort_2D_Double_Crashes() /// NumPy: clip(broadcast, 2, 7) = [[2,5,7],[2,5,7]] /// NumSharp: NotSupportedException: Unable to broadcast already broadcasted shape. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Clip_Broadcast_ThrowsNotSupported() { var a = np.broadcast_to(np.array(new double[] { 1.0, 5.0, 9.0 }), new Shape(2, 3)); @@ -1516,7 +1517,7 @@ public void Bug_Clip_Broadcast_ThrowsNotSupported() /// of 0, 3, 6 (using stride 3), so it reads data[0..2] which /// are all 100 (row 0 repeated 3 times in the contiguous clone). /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SliceBroadcast_StrideMismatch_ColumnBroadcast_SliceColumn() { // Setup: column vector [[100],[200],[300]] broadcast to (3,3) @@ -1557,7 +1558,7 @@ public void Bug_SliceBroadcast_StrideMismatch_ColumnBroadcast_SliceColumn() /// correctly materializes the data; the bug is purely that /// _shape.Slice(slices) attaches broadcast strides to the clone. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SliceBroadcast_CopyWorkaround_Proves_StrideMismatch() { var col = np.array(new int[,] { { 100 }, { 200 }, { 300 } }); @@ -1611,7 +1612,7 @@ public void Bug_SliceBroadcast_CopyWorkaround_Proves_StrideMismatch() /// We use np.copy as the control path: copy materializes with /// clean strides, then slicing works correctly. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SliceBroadcast_StrideMismatch_SlicedSourceRows() { // arange(12).reshape(3,4) = [[ 0, 1, 2, 3], @@ -1680,7 +1681,7 @@ public void Bug_SliceBroadcast_StrideMismatch_SlicedSourceRows() /// the same slice that the reduction code does, proving that the /// slice itself returns wrong values. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SliceBroadcast_StrideMismatch_Causes_Sum_Axis0_Bug() { var col = np.array(new int[,] { { 100 }, { 200 }, { 300 } }); @@ -1765,7 +1766,7 @@ public void Bug_SliceBroadcast_StrideMismatch_Causes_Sum_Axis0_Bug() /// NumPy: cumsum(broadcast_to([1,2,3],(3,3)), axis=0) = [[1,2,3],[2,4,6],[3,6,9]] /// NumSharp: uninitialized memory (e.g. [43060696, 32766, 0]) /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Cumsum_OutputBroadcastShape_RowBroadcast_Axis0() { var a = np.broadcast_to(np.array(new int[] { 1, 2, 3 }), new Shape(3, 3)); @@ -1800,7 +1801,7 @@ public void Bug_Cumsum_OutputBroadcastShape_RowBroadcast_Axis0() /// NumPy: cumsum(broadcast_to([[1],[2],[3]],(3,3)), axis=1) = [[1,2,3],[2,4,6],[3,6,9]] /// NumSharp: garbage /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Cumsum_OutputBroadcastShape_ColBroadcast_Axis1() { var col = np.array(new int[,] { { 1 }, { 2 }, { 3 } }); @@ -1872,7 +1873,7 @@ public void Bug_Cumsum_OutputBroadcastShape_ColBroadcast_Axis1() /// NumPy: roll(broadcast_to([1,2,3],(2,3)), 1, axis=1) = [[3,1,2],[3,1,2]] /// NumSharp: row 0 may be correct, row 1 contains zeros/garbage /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Roll_DataT_RowBroadcast() { var a = np.broadcast_to(np.array(new int[] { 1, 2, 3 }), new Shape(2, 3)); @@ -1898,7 +1899,7 @@ public void Bug_Roll_DataT_RowBroadcast() /// NumPy: roll(broadcast_to([[1],[2],[3]],(3,3)), 1, axis=0) = [[3,3,3],[1,1,1],[2,2,2]] /// NumSharp: garbage values /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Roll_DataT_ColBroadcast() { var col = np.array(new int[,] { { 1 }, { 2 }, { 3 } }); @@ -1972,7 +1973,7 @@ public void Bug_Roll_DataT_ColBroadcast() /// This is a root cause contributing to Bug 19 (roll) and /// Bug 5/9 (np.minimum via TransformOffset → GetAtIndex). /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_GetCoordinates_BroadcastStrides_RowBroadcast() { // Row broadcast: [1,2,3] → (3,3), strides [0, 1] @@ -2008,7 +2009,7 @@ public void Bug_GetCoordinates_BroadcastStrides_RowBroadcast() /// BUG 20b: GetCoordinates for col-broadcast (3,3) strides [1, 0]. /// Flat index 1 maps to [1, 0] instead of [0, 1]. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_GetCoordinates_BroadcastStrides_ColBroadcast() { var col = np.array(new int[,] { { 1 }, { 2 }, { 3 } }); @@ -2061,7 +2062,7 @@ public void Bug_GetCoordinates_BroadcastStrides_ColBroadcast() /// NumPy: arr[mask] where mask has 3 True values → shape (3,) /// NumSharp: returns shape (3, ...) — treats True as row selector /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_BooleanMask_2D_WrongShape() { var a = np.array(new int[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }); @@ -2113,7 +2114,7 @@ public void Bug_BooleanMask_2D_WrongShape() /// NumPy: np.any([[T,F],[F,T]], axis=0) = [True, True] /// NumSharp: InvalidCastException: Unable to cast NDArray to NDArray<Boolean> /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Any_WithAxis_AlwaysThrows() { var a = np.array(new bool[,] { { true, false }, { false, true } }); @@ -2134,7 +2135,7 @@ public void Bug_Any_WithAxis_AlwaysThrows() /// /// BUG 22b: np.any with axis=1 also throws. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Any_WithAxis1_AlwaysThrows() { var a = np.array(new bool[,] { { true, false }, { false, false } }); @@ -2185,7 +2186,7 @@ public void Bug_Any_WithAxis1_AlwaysThrows() /// NumPy: [10,10,10,20,20,20,30,30,30] /// NumSharp: [10,20,30,10,20,30,10,20,30] /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Reshape_ColBroadcast_WrongOrder() { var col = np.array(new int[,] { { 10 }, { 20 }, { 30 } }); @@ -2219,7 +2220,7 @@ public void Bug_Reshape_ColBroadcast_WrongOrder() /// NumPy: abs(broadcast_to([-1,2,-3], (2,3))) = [[1,2,3],[1,2,3]] /// NumSharp: IncorrectShapeException /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Abs_Broadcast_Throws() { var a = np.broadcast_to(np.array(new int[] { -1, 2, -3 }), new Shape(2, 3)); @@ -2285,7 +2286,7 @@ public void Bug_Abs_Broadcast_Throws() /// contiguous [10,10,10,20,20,20,30,30,30] then creates a plain /// shape with strides [3,1], losing the broadcast semantics. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Transpose_ColBroadcast_WrongValues() { var col = np.array(new int[,] { { 10 }, { 20 }, { 30 } }); @@ -2350,7 +2351,7 @@ public void Bug_Transpose_ColBroadcast_WrongValues() /// NumPy: t[0,0] = 999 → a[0,0] == 999 (shared memory) /// NumSharp: t[0,0] = 999 → a[0,0] == 0 (independent copy) /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_Transpose_ReturnsPhysicalCopy_ShouldBeView() { var a = np.arange(6).reshape(2, 3); @@ -2384,7 +2385,7 @@ public void Bug_Transpose_ReturnsPhysicalCopy_ShouldBeView() /// NumPy: s[0,0,0] = 999 → a[0,0,0] == 999 (shared memory) /// NumSharp: s[0,0,0] = 999 → a[0,0,0] == 0 (independent copy) /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SwapAxes_ReturnsPhysicalCopy_ShouldBeView() { var a = np.arange(24).reshape(2, 3, 4); @@ -2442,7 +2443,7 @@ public void Bug_SwapAxes_ReturnsPhysicalCopy_ShouldBeView() /// NumPy reports c_contiguous=True. NumSharp now correctly optimizes this /// by slicing the InternalArray and creating a fresh shape with offset=0. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_IsContiguous_FalseForContiguousSlice1D() { var a = np.arange(10); @@ -2461,7 +2462,7 @@ public void Bug_IsContiguous_FalseForContiguousSlice1D() /// row-major array — the data is contiguous in memory. /// NumPy reports c_contiguous=True. NumSharp now correctly optimizes this. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_IsContiguous_FalseForContiguousRowSlice2D() { var a = np.arange(12).reshape(3, 4); @@ -2514,7 +2515,7 @@ public void Bug_IsContiguous_FalseForContiguousRowSlice2D() /// NumPy swapaxes(0,2): strides = [1, 4, 12] (swap strides[0] and strides[2]) /// NumSharp swapaxes(0,2): strides = [6, 2, 1] (C-contiguous for shape (4,3,2)) /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SwapAxes_Strides_WrongForAxis02() { var a = np.arange(24).reshape(2, 3, 4); @@ -2539,7 +2540,7 @@ public void Bug_SwapAxes_Strides_WrongForAxis02() /// NumPy swapaxes(0,1): strides = [4, 12, 1] (swap strides[0] and strides[1]) /// NumSharp swapaxes(0,1): strides = [8, 4, 1] (C-contiguous for shape (3,2,4)) /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SwapAxes_Strides_WrongForAxis01() { var a = np.arange(24).reshape(2, 3, 4); @@ -2559,7 +2560,7 @@ public void Bug_SwapAxes_Strides_WrongForAxis01() /// NumPy swapaxes(1,2): strides = [12, 1, 4] (swap strides[1] and strides[2]) /// NumSharp swapaxes(1,2): strides = [12, 3, 1] (C-contiguous for shape (2,4,3)) /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SwapAxes_Strides_WrongForAxis12() { var a = np.arange(24).reshape(2, 3, 4); @@ -2601,7 +2602,7 @@ public void Bug_SwapAxes_Strides_WrongForAxis12() /// NumPy: np.swapaxes(np.array(42), 0, 0) → AxisError /// NumSharp: np.swapaxes(np.array(42), 0, 0) → shape=[1], no error /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SwapAxes_0DScalar_ShouldThrow() { var s = np.array(42); @@ -2648,7 +2649,7 @@ public void Bug_SwapAxes_0DScalar_ShouldThrow() /// NumPy: Returns empty array with shape (4,3,0). /// NumSharp: InvalidOperationException — NDIterator can't handle empty shape. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SwapAxes_EmptyArray_Crashes() { var empty = np.empty(new Shape(0, 3, 4)); @@ -2671,7 +2672,7 @@ public void Bug_SwapAxes_EmptyArray_Crashes() /// NumPy: Returns empty array with shape (4,0,2). /// NumSharp: InvalidOperationException — same root cause. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SwapAxes_EmptyArray_MiddleDimZero_Crashes() { var empty = np.empty(new Shape(2, 0, 4)); @@ -2724,7 +2725,7 @@ public void Bug_SwapAxes_EmptyArray_MiddleDimZero_Crashes() /// NumPy: AxisError: axis2: axis 3 is out of bounds for array of dimension 3 /// NumSharp: IndexOutOfRangeException: Index was outside the bounds of the array. /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SwapAxes_OutOfBoundsAxis_BadErrorMessage() { var a = np.arange(24).reshape(2, 3, 4); @@ -2752,7 +2753,7 @@ public void Bug_SwapAxes_OutOfBoundsAxis_BadErrorMessage() /// NumPy: AxisError: axis1: axis -4 is out of bounds for array of dimension 3 /// NumSharp: IndexOutOfRangeException (from array access with negative index) /// - [Test, OpenBugs] + [TestMethod, OpenBugs] public void Bug_SwapAxes_NegativeOutOfBoundsAxis_BadErrorMessage() { var a = np.arange(24).reshape(2, 3, 4); diff --git a/test/NumSharp.UnitTest/Operations/EmptyArrayComparisonTests.cs b/test/NumSharp.UnitTest/Operations/EmptyArrayComparisonTests.cs index 04180ce4d..9b8316226 100644 --- a/test/NumSharp.UnitTest/Operations/EmptyArrayComparisonTests.cs +++ b/test/NumSharp.UnitTest/Operations/EmptyArrayComparisonTests.cs @@ -1,10 +1,6 @@ using System; using System.Linq; -using System.Threading.Tasks; using NumSharp; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.Operations; @@ -20,126 +16,127 @@ namespace NumSharp.UnitTest.Operations; /// >>> (np.array([], dtype=int) > 0).shape /// (0,) /// +[TestClass] public class EmptyArrayComparisonTests { - [Test] - public async Task EmptyArray_Equals_Scalar_ReturnsEmptyArray() + [TestMethod] + public void EmptyArray_Equals_Scalar_ReturnsEmptyArray() { // NumPy: (np.array([], dtype=int) == 0).shape returns (0,) var emptyInt = np.array(Array.Empty()); var result = emptyInt == 0; - await Assert.That(result.shape.SequenceEqual(new long[] { 0 })).IsTrue(); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(bool)); + result.shape.SequenceEqual(new long[] { 0 }).Should().BeTrue(); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(bool)); } - [Test] - public async Task EmptyArray_NotEquals_Scalar_ReturnsEmptyArray() + [TestMethod] + public void EmptyArray_NotEquals_Scalar_ReturnsEmptyArray() { // NumPy: (np.array([], dtype=int) != 0).shape returns (0,) var emptyInt = np.array(Array.Empty()); var result = emptyInt != 0; - await Assert.That(result.shape.SequenceEqual(new long[] { 0 })).IsTrue(); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(bool)); + result.shape.SequenceEqual(new long[] { 0 }).Should().BeTrue(); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(bool)); } - [Test] - public async Task EmptyArray_GreaterThan_Scalar_ReturnsEmptyArray() + [TestMethod] + public void EmptyArray_GreaterThan_Scalar_ReturnsEmptyArray() { // NumPy: (np.array([], dtype=int) > 0).shape returns (0,) var emptyInt = np.array(Array.Empty()); var result = emptyInt > 0; - await Assert.That(result.shape.SequenceEqual(new long[] { 0 })).IsTrue(); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(bool)); + result.shape.SequenceEqual(new long[] { 0 }).Should().BeTrue(); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(bool)); } - [Test] - public async Task EmptyArray_GreaterThanOrEqual_Scalar_ReturnsEmptyArray() + [TestMethod] + public void EmptyArray_GreaterThanOrEqual_Scalar_ReturnsEmptyArray() { // NumPy: (np.array([], dtype=int) >= 0).shape returns (0,) var emptyInt = np.array(Array.Empty()); var result = emptyInt >= 0; - await Assert.That(result.shape.SequenceEqual(new long[] { 0 })).IsTrue(); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(bool)); + result.shape.SequenceEqual(new long[] { 0 }).Should().BeTrue(); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(bool)); } - [Test] - public async Task EmptyArray_LessThan_Scalar_ReturnsEmptyArray() + [TestMethod] + public void EmptyArray_LessThan_Scalar_ReturnsEmptyArray() { // NumPy: (np.array([], dtype=int) < 0).shape returns (0,) var emptyInt = np.array(Array.Empty()); var result = emptyInt < 0; - await Assert.That(result.shape.SequenceEqual(new long[] { 0 })).IsTrue(); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(bool)); + result.shape.SequenceEqual(new long[] { 0 }).Should().BeTrue(); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(bool)); } - [Test] - public async Task EmptyArray_LessThanOrEqual_Scalar_ReturnsEmptyArray() + [TestMethod] + public void EmptyArray_LessThanOrEqual_Scalar_ReturnsEmptyArray() { // NumPy: (np.array([], dtype=int) <= 0).shape returns (0,) var emptyInt = np.array(Array.Empty()); var result = emptyInt <= 0; - await Assert.That(result.shape.SequenceEqual(new long[] { 0 })).IsTrue(); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(bool)); + result.shape.SequenceEqual(new long[] { 0 }).Should().BeTrue(); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(bool)); } - [Test] - public async Task Empty2DArray_Equals_Scalar_PreservesShape() + [TestMethod] + public void Empty2DArray_Equals_Scalar_PreservesShape() { // NumPy: (np.zeros((0,3), dtype=int) == 0).shape returns (0, 3) var empty2D = np.zeros(new Shape(0, 3), NPTypeCode.Int32); var result = empty2D == 0; - await Assert.That(result.shape.SequenceEqual(new long[] { 0, 3 })).IsTrue(); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(bool)); + result.shape.SequenceEqual(new long[] { 0, 3 }).Should().BeTrue(); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(bool)); } - [Test] - public async Task Empty2DArray_Reverse_Equals_Scalar_PreservesShape() + [TestMethod] + public void Empty2DArray_Reverse_Equals_Scalar_PreservesShape() { // NumPy: (np.zeros((3,0), dtype=int) == 0).shape returns (3, 0) var empty2D = np.zeros(new Shape(3, 0), NPTypeCode.Int32); var result = empty2D == 0; - await Assert.That(result.shape.SequenceEqual(new long[] { 3, 0 })).IsTrue(); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(bool)); + result.shape.SequenceEqual(new long[] { 3, 0 }).Should().BeTrue(); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(bool)); } - [Test] - public async Task EmptyFloatArray_Equals_Scalar_ReturnsEmptyArray() + [TestMethod] + public void EmptyFloatArray_Equals_Scalar_ReturnsEmptyArray() { // NumPy: (np.array([], dtype=float) == 0.0).shape returns (0,) var emptyFloat = np.array(Array.Empty()); var result = emptyFloat == 0.0; - await Assert.That(result.shape.SequenceEqual(new long[] { 0 })).IsTrue(); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(bool)); + result.shape.SequenceEqual(new long[] { 0 }).Should().BeTrue(); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(bool)); } - [Test] - public async Task EmptyArray_ArrayEquals_Preserves_Shape() + [TestMethod] + public void EmptyArray_ArrayEquals_Preserves_Shape() { // Compare two empty arrays var empty1 = np.array(Array.Empty()); var empty2 = np.array(Array.Empty()); var result = empty1 == empty2; - await Assert.That(result.shape.SequenceEqual(new long[] { 0 })).IsTrue(); - await Assert.That(result.size).IsEqualTo(0); - await Assert.That(result.dtype).IsEqualTo(typeof(bool)); + result.shape.SequenceEqual(new long[] { 0 }).Should().BeTrue(); + result.size.Should().Be(0); + result.dtype.Should().Be(typeof(bool)); } } diff --git a/test/NumSharp.UnitTest/Operations/NDArray.AND.Test.cs b/test/NumSharp.UnitTest/Operations/NDArray.AND.Test.cs index b45a514e5..d0ebdab3c 100644 --- a/test/NumSharp.UnitTest/Operations/NDArray.AND.Test.cs +++ b/test/NumSharp.UnitTest/Operations/NDArray.AND.Test.cs @@ -10,9 +10,10 @@ namespace NumSharp.UnitTest.Operations { + [TestClass] public class NDArrayAndTest { - [Test] + [TestMethod] public void BoolTwo1D_NDArrayAND() { var np1 = new NDArray(new[] {true, true, false, false}, new Shape(4)); @@ -23,7 +24,7 @@ public void BoolTwo1D_NDArrayAND() Assert.IsTrue(Enumerable.SequenceEqual(new[] {true, false, false, false}, np3.Data())); } - [Test] + [TestMethod] public void BoolTwo2D_NDArrayAND() { var np1 = new NDArray(typeof(bool), new Shape(2, 3)); @@ -40,7 +41,7 @@ public void BoolTwo2D_NDArrayAND() Assert.IsTrue(Enumerable.SequenceEqual(np3.Data(), np4)); } - [Test] + [TestMethod] public void Byte1D_NDArrayAND() { var np1 = new NDArray(new[] {1, 2, 3, 4}, new Shape(4)); diff --git a/test/NumSharp.UnitTest/Operations/NDArray.Equals.Test.cs b/test/NumSharp.UnitTest/Operations/NDArray.Equals.Test.cs index ad6f03a7c..cb9f49c35 100644 --- a/test/NumSharp.UnitTest/Operations/NDArray.Equals.Test.cs +++ b/test/NumSharp.UnitTest/Operations/NDArray.Equals.Test.cs @@ -11,9 +11,10 @@ namespace NumSharp.UnitTest.Operations { + [TestClass] public class NDArrayEqualsTest { - [Test] + [TestMethod] public void IntTwo1D_NDArrayEquals() { var np0 = new NDArray(new[] {0, 0, 0, 0}, new Shape(4)); @@ -31,7 +32,7 @@ public void IntTwo1D_NDArrayEquals() Assert.IsFalse(np4S); } - [Test] + [TestMethod] public void IntAnd1D_NDArrayEquals() { var np1 = new NDArray(new[] {1, 2, 3, 4}, new Shape(4)); @@ -40,7 +41,7 @@ public void IntAnd1D_NDArrayEquals() Assert.IsTrue(Enumerable.SequenceEqual(new[] {false, true, false, false}, np2.Data())); } - [Test] + [TestMethod] public void IntTwo2D_NDArrayEquals() { var np1 = new NDArray(typeof(int), new Shape(2, 3)); @@ -69,7 +70,7 @@ public void IntTwo2D_NDArrayEquals() Assert.IsTrue(Enumerable.SequenceEqual(np6.Data(), np7)); } - [Test] + [TestMethod] public void IntAnd2D_NDArrayEquals() { var np1 = new NDArray(typeof(int), new Shape(2, 3)); @@ -86,7 +87,7 @@ public void IntAnd2D_NDArrayEquals() %a = except(supported_dtypes, "NDArray") %b = [true,"1","1","1","1","1u","1L","1UL","1","1d","1f","1m"] %foreach forevery(a,a,true), forevery(b,b,true)% - [Test] + [TestMethod] public void Compare_#1_To_#2() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.#1.AsType()).reshape(new Shape(3, 2)); @@ -107,7 +108,7 @@ public void IntAnd2D_NDArrayEquals() % #else - [Test] + [TestMethod] public void Compare_Boolean_To_Byte() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Boolean.AsType()).reshape(new Shape(3, 2)); @@ -125,7 +126,7 @@ public void Compare_Boolean_To_Byte() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Boolean_To_Int16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Boolean.AsType()).reshape(new Shape(3, 2)); @@ -143,7 +144,7 @@ public void Compare_Boolean_To_Int16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Boolean_To_UInt16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Boolean.AsType()).reshape(new Shape(3, 2)); @@ -161,7 +162,7 @@ public void Compare_Boolean_To_UInt16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Boolean_To_Int32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Boolean.AsType()).reshape(new Shape(3, 2)); @@ -179,7 +180,7 @@ public void Compare_Boolean_To_Int32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Boolean_To_UInt32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Boolean.AsType()).reshape(new Shape(3, 2)); @@ -197,7 +198,7 @@ public void Compare_Boolean_To_UInt32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Boolean_To_Int64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Boolean.AsType()).reshape(new Shape(3, 2)); @@ -215,7 +216,7 @@ public void Compare_Boolean_To_Int64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Boolean_To_UInt64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Boolean.AsType()).reshape(new Shape(3, 2)); @@ -233,7 +234,7 @@ public void Compare_Boolean_To_UInt64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Boolean_To_Char() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Boolean.AsType()).reshape(new Shape(3, 2)); @@ -251,7 +252,7 @@ public void Compare_Boolean_To_Char() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Boolean_To_Double() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Boolean.AsType()).reshape(new Shape(3, 2)); @@ -269,7 +270,7 @@ public void Compare_Boolean_To_Double() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Boolean_To_Single() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Boolean.AsType()).reshape(new Shape(3, 2)); @@ -287,7 +288,7 @@ public void Compare_Boolean_To_Single() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Boolean_To_Decimal() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Boolean.AsType()).reshape(new Shape(3, 2)); @@ -305,7 +306,7 @@ public void Compare_Boolean_To_Decimal() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Byte_To_Boolean() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Byte.AsType()).reshape(new Shape(3, 2)); @@ -323,7 +324,7 @@ public void Compare_Byte_To_Boolean() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Byte_To_Int16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Byte.AsType()).reshape(new Shape(3, 2)); @@ -341,7 +342,7 @@ public void Compare_Byte_To_Int16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Byte_To_UInt16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Byte.AsType()).reshape(new Shape(3, 2)); @@ -359,7 +360,7 @@ public void Compare_Byte_To_UInt16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Byte_To_Int32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Byte.AsType()).reshape(new Shape(3, 2)); @@ -377,7 +378,7 @@ public void Compare_Byte_To_Int32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Byte_To_UInt32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Byte.AsType()).reshape(new Shape(3, 2)); @@ -395,7 +396,7 @@ public void Compare_Byte_To_UInt32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Byte_To_Int64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Byte.AsType()).reshape(new Shape(3, 2)); @@ -413,7 +414,7 @@ public void Compare_Byte_To_Int64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Byte_To_UInt64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Byte.AsType()).reshape(new Shape(3, 2)); @@ -431,7 +432,7 @@ public void Compare_Byte_To_UInt64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Byte_To_Char() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Byte.AsType()).reshape(new Shape(3, 2)); @@ -449,7 +450,7 @@ public void Compare_Byte_To_Char() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Byte_To_Double() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Byte.AsType()).reshape(new Shape(3, 2)); @@ -467,7 +468,7 @@ public void Compare_Byte_To_Double() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Byte_To_Single() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Byte.AsType()).reshape(new Shape(3, 2)); @@ -485,7 +486,7 @@ public void Compare_Byte_To_Single() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Byte_To_Decimal() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Byte.AsType()).reshape(new Shape(3, 2)); @@ -503,7 +504,7 @@ public void Compare_Byte_To_Decimal() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int16_To_Boolean() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int16.AsType()).reshape(new Shape(3, 2)); @@ -521,7 +522,7 @@ public void Compare_Int16_To_Boolean() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int16_To_Byte() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int16.AsType()).reshape(new Shape(3, 2)); @@ -539,7 +540,7 @@ public void Compare_Int16_To_Byte() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int16_To_UInt16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int16.AsType()).reshape(new Shape(3, 2)); @@ -557,7 +558,7 @@ public void Compare_Int16_To_UInt16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int16_To_Int32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int16.AsType()).reshape(new Shape(3, 2)); @@ -575,7 +576,7 @@ public void Compare_Int16_To_Int32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int16_To_UInt32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int16.AsType()).reshape(new Shape(3, 2)); @@ -593,7 +594,7 @@ public void Compare_Int16_To_UInt32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int16_To_Int64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int16.AsType()).reshape(new Shape(3, 2)); @@ -611,7 +612,7 @@ public void Compare_Int16_To_Int64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int16_To_UInt64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int16.AsType()).reshape(new Shape(3, 2)); @@ -629,7 +630,7 @@ public void Compare_Int16_To_UInt64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int16_To_Char() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int16.AsType()).reshape(new Shape(3, 2)); @@ -647,7 +648,7 @@ public void Compare_Int16_To_Char() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int16_To_Double() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int16.AsType()).reshape(new Shape(3, 2)); @@ -665,7 +666,7 @@ public void Compare_Int16_To_Double() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int16_To_Single() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int16.AsType()).reshape(new Shape(3, 2)); @@ -683,7 +684,7 @@ public void Compare_Int16_To_Single() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int16_To_Decimal() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int16.AsType()).reshape(new Shape(3, 2)); @@ -701,7 +702,7 @@ public void Compare_Int16_To_Decimal() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt16_To_Boolean() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt16.AsType()).reshape(new Shape(3, 2)); @@ -719,7 +720,7 @@ public void Compare_UInt16_To_Boolean() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt16_To_Byte() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt16.AsType()).reshape(new Shape(3, 2)); @@ -737,7 +738,7 @@ public void Compare_UInt16_To_Byte() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt16_To_Int16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt16.AsType()).reshape(new Shape(3, 2)); @@ -755,7 +756,7 @@ public void Compare_UInt16_To_Int16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt16_To_Int32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt16.AsType()).reshape(new Shape(3, 2)); @@ -773,7 +774,7 @@ public void Compare_UInt16_To_Int32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt16_To_UInt32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt16.AsType()).reshape(new Shape(3, 2)); @@ -791,7 +792,7 @@ public void Compare_UInt16_To_UInt32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt16_To_Int64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt16.AsType()).reshape(new Shape(3, 2)); @@ -809,7 +810,7 @@ public void Compare_UInt16_To_Int64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt16_To_UInt64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt16.AsType()).reshape(new Shape(3, 2)); @@ -827,7 +828,7 @@ public void Compare_UInt16_To_UInt64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt16_To_Char() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt16.AsType()).reshape(new Shape(3, 2)); @@ -845,7 +846,7 @@ public void Compare_UInt16_To_Char() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt16_To_Double() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt16.AsType()).reshape(new Shape(3, 2)); @@ -863,7 +864,7 @@ public void Compare_UInt16_To_Double() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt16_To_Single() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt16.AsType()).reshape(new Shape(3, 2)); @@ -881,7 +882,7 @@ public void Compare_UInt16_To_Single() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt16_To_Decimal() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt16.AsType()).reshape(new Shape(3, 2)); @@ -899,7 +900,7 @@ public void Compare_UInt16_To_Decimal() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int32_To_Boolean() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int32.AsType()).reshape(new Shape(3, 2)); @@ -917,7 +918,7 @@ public void Compare_Int32_To_Boolean() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int32_To_Byte() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int32.AsType()).reshape(new Shape(3, 2)); @@ -935,7 +936,7 @@ public void Compare_Int32_To_Byte() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int32_To_Int16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int32.AsType()).reshape(new Shape(3, 2)); @@ -953,7 +954,7 @@ public void Compare_Int32_To_Int16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int32_To_UInt16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int32.AsType()).reshape(new Shape(3, 2)); @@ -971,7 +972,7 @@ public void Compare_Int32_To_UInt16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int32_To_UInt32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int32.AsType()).reshape(new Shape(3, 2)); @@ -989,7 +990,7 @@ public void Compare_Int32_To_UInt32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int32_To_Int64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int32.AsType()).reshape(new Shape(3, 2)); @@ -1007,7 +1008,7 @@ public void Compare_Int32_To_Int64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int32_To_UInt64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int32.AsType()).reshape(new Shape(3, 2)); @@ -1025,7 +1026,7 @@ public void Compare_Int32_To_UInt64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int32_To_Char() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int32.AsType()).reshape(new Shape(3, 2)); @@ -1043,7 +1044,7 @@ public void Compare_Int32_To_Char() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int32_To_Double() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int32.AsType()).reshape(new Shape(3, 2)); @@ -1061,7 +1062,7 @@ public void Compare_Int32_To_Double() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int32_To_Single() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int32.AsType()).reshape(new Shape(3, 2)); @@ -1079,7 +1080,7 @@ public void Compare_Int32_To_Single() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int32_To_Decimal() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int32.AsType()).reshape(new Shape(3, 2)); @@ -1097,7 +1098,7 @@ public void Compare_Int32_To_Decimal() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt32_To_Boolean() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt32.AsType()).reshape(new Shape(3, 2)); @@ -1115,7 +1116,7 @@ public void Compare_UInt32_To_Boolean() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt32_To_Byte() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt32.AsType()).reshape(new Shape(3, 2)); @@ -1133,7 +1134,7 @@ public void Compare_UInt32_To_Byte() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt32_To_Int16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt32.AsType()).reshape(new Shape(3, 2)); @@ -1151,7 +1152,7 @@ public void Compare_UInt32_To_Int16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt32_To_UInt16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt32.AsType()).reshape(new Shape(3, 2)); @@ -1169,7 +1170,7 @@ public void Compare_UInt32_To_UInt16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt32_To_Int32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt32.AsType()).reshape(new Shape(3, 2)); @@ -1187,7 +1188,7 @@ public void Compare_UInt32_To_Int32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt32_To_Int64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt32.AsType()).reshape(new Shape(3, 2)); @@ -1205,7 +1206,7 @@ public void Compare_UInt32_To_Int64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt32_To_UInt64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt32.AsType()).reshape(new Shape(3, 2)); @@ -1223,7 +1224,7 @@ public void Compare_UInt32_To_UInt64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt32_To_Char() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt32.AsType()).reshape(new Shape(3, 2)); @@ -1241,7 +1242,7 @@ public void Compare_UInt32_To_Char() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt32_To_Double() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt32.AsType()).reshape(new Shape(3, 2)); @@ -1259,7 +1260,7 @@ public void Compare_UInt32_To_Double() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt32_To_Single() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt32.AsType()).reshape(new Shape(3, 2)); @@ -1277,7 +1278,7 @@ public void Compare_UInt32_To_Single() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt32_To_Decimal() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt32.AsType()).reshape(new Shape(3, 2)); @@ -1295,7 +1296,7 @@ public void Compare_UInt32_To_Decimal() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int64_To_Boolean() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int64.AsType()).reshape(new Shape(3, 2)); @@ -1313,7 +1314,7 @@ public void Compare_Int64_To_Boolean() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int64_To_Byte() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int64.AsType()).reshape(new Shape(3, 2)); @@ -1331,7 +1332,7 @@ public void Compare_Int64_To_Byte() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int64_To_Int16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int64.AsType()).reshape(new Shape(3, 2)); @@ -1349,7 +1350,7 @@ public void Compare_Int64_To_Int16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int64_To_UInt16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int64.AsType()).reshape(new Shape(3, 2)); @@ -1367,7 +1368,7 @@ public void Compare_Int64_To_UInt16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int64_To_Int32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int64.AsType()).reshape(new Shape(3, 2)); @@ -1385,7 +1386,7 @@ public void Compare_Int64_To_Int32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int64_To_UInt32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int64.AsType()).reshape(new Shape(3, 2)); @@ -1403,7 +1404,7 @@ public void Compare_Int64_To_UInt32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int64_To_UInt64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int64.AsType()).reshape(new Shape(3, 2)); @@ -1421,7 +1422,7 @@ public void Compare_Int64_To_UInt64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int64_To_Char() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int64.AsType()).reshape(new Shape(3, 2)); @@ -1439,7 +1440,7 @@ public void Compare_Int64_To_Char() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int64_To_Double() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int64.AsType()).reshape(new Shape(3, 2)); @@ -1457,7 +1458,7 @@ public void Compare_Int64_To_Double() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int64_To_Single() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int64.AsType()).reshape(new Shape(3, 2)); @@ -1475,7 +1476,7 @@ public void Compare_Int64_To_Single() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Int64_To_Decimal() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Int64.AsType()).reshape(new Shape(3, 2)); @@ -1493,7 +1494,7 @@ public void Compare_Int64_To_Decimal() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt64_To_Boolean() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt64.AsType()).reshape(new Shape(3, 2)); @@ -1511,7 +1512,7 @@ public void Compare_UInt64_To_Boolean() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt64_To_Byte() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt64.AsType()).reshape(new Shape(3, 2)); @@ -1529,7 +1530,7 @@ public void Compare_UInt64_To_Byte() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt64_To_Int16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt64.AsType()).reshape(new Shape(3, 2)); @@ -1547,7 +1548,7 @@ public void Compare_UInt64_To_Int16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt64_To_UInt16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt64.AsType()).reshape(new Shape(3, 2)); @@ -1565,7 +1566,7 @@ public void Compare_UInt64_To_UInt16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt64_To_Int32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt64.AsType()).reshape(new Shape(3, 2)); @@ -1583,7 +1584,7 @@ public void Compare_UInt64_To_Int32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt64_To_UInt32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt64.AsType()).reshape(new Shape(3, 2)); @@ -1601,7 +1602,7 @@ public void Compare_UInt64_To_UInt32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt64_To_Int64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt64.AsType()).reshape(new Shape(3, 2)); @@ -1619,7 +1620,7 @@ public void Compare_UInt64_To_Int64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt64_To_Char() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt64.AsType()).reshape(new Shape(3, 2)); @@ -1637,7 +1638,7 @@ public void Compare_UInt64_To_Char() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt64_To_Double() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt64.AsType()).reshape(new Shape(3, 2)); @@ -1655,7 +1656,7 @@ public void Compare_UInt64_To_Double() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt64_To_Single() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt64.AsType()).reshape(new Shape(3, 2)); @@ -1673,7 +1674,7 @@ public void Compare_UInt64_To_Single() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_UInt64_To_Decimal() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.UInt64.AsType()).reshape(new Shape(3, 2)); @@ -1691,7 +1692,7 @@ public void Compare_UInt64_To_Decimal() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Char_To_Boolean() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Char.AsType()).reshape(new Shape(3, 2)); @@ -1709,7 +1710,7 @@ public void Compare_Char_To_Boolean() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Char_To_Byte() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Char.AsType()).reshape(new Shape(3, 2)); @@ -1727,7 +1728,7 @@ public void Compare_Char_To_Byte() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Char_To_Int16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Char.AsType()).reshape(new Shape(3, 2)); @@ -1745,7 +1746,7 @@ public void Compare_Char_To_Int16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Char_To_UInt16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Char.AsType()).reshape(new Shape(3, 2)); @@ -1763,7 +1764,7 @@ public void Compare_Char_To_UInt16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Char_To_Int32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Char.AsType()).reshape(new Shape(3, 2)); @@ -1781,7 +1782,7 @@ public void Compare_Char_To_Int32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Char_To_UInt32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Char.AsType()).reshape(new Shape(3, 2)); @@ -1799,7 +1800,7 @@ public void Compare_Char_To_UInt32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Char_To_Int64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Char.AsType()).reshape(new Shape(3, 2)); @@ -1817,7 +1818,7 @@ public void Compare_Char_To_Int64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Char_To_UInt64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Char.AsType()).reshape(new Shape(3, 2)); @@ -1835,7 +1836,7 @@ public void Compare_Char_To_UInt64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Char_To_Double() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Char.AsType()).reshape(new Shape(3, 2)); @@ -1853,7 +1854,7 @@ public void Compare_Char_To_Double() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Char_To_Single() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Char.AsType()).reshape(new Shape(3, 2)); @@ -1871,7 +1872,7 @@ public void Compare_Char_To_Single() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Char_To_Decimal() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Char.AsType()).reshape(new Shape(3, 2)); @@ -1889,7 +1890,7 @@ public void Compare_Char_To_Decimal() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Double_To_Boolean() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Double.AsType()).reshape(new Shape(3, 2)); @@ -1907,7 +1908,7 @@ public void Compare_Double_To_Boolean() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Double_To_Byte() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Double.AsType()).reshape(new Shape(3, 2)); @@ -1925,7 +1926,7 @@ public void Compare_Double_To_Byte() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Double_To_Int16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Double.AsType()).reshape(new Shape(3, 2)); @@ -1943,7 +1944,7 @@ public void Compare_Double_To_Int16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Double_To_UInt16() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Double.AsType()).reshape(new Shape(3, 2)); @@ -1961,7 +1962,7 @@ public void Compare_Double_To_UInt16() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Double_To_Int32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Double.AsType()).reshape(new Shape(3, 2)); @@ -1979,7 +1980,7 @@ public void Compare_Double_To_Int32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Double_To_UInt32() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Double.AsType()).reshape(new Shape(3, 2)); @@ -1997,7 +1998,7 @@ public void Compare_Double_To_UInt32() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Double_To_Int64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Double.AsType()).reshape(new Shape(3, 2)); @@ -2015,7 +2016,7 @@ public void Compare_Double_To_Int64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Double_To_UInt64() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Double.AsType()).reshape(new Shape(3, 2)); @@ -2033,7 +2034,7 @@ public void Compare_Double_To_UInt64() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Double_To_Char() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Double.AsType()).reshape(new Shape(3, 2)); @@ -2051,7 +2052,7 @@ public void Compare_Double_To_Char() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Double_To_Single() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Double.AsType()).reshape(new Shape(3, 2)); @@ -2069,7 +2070,7 @@ public void Compare_Double_To_Single() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Double_To_Decimal() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Double.AsType()).reshape(new Shape(3, 2)); @@ -2087,7 +2088,7 @@ public void Compare_Double_To_Decimal() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Single_To_Boolean() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Single.AsType()).reshape(new Shape(3, 2)); @@ -2105,7 +2106,7 @@ public void Compare_Single_To_Boolean() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void Compare_Single_To_Byte() { var left = np.array(new int[] {0, 0, 1, 1, 0, 0}, dtype: NPTypeCode.Single.AsType()).reshape(new Shape(3, 2)); @@ -2123,7 +2124,7 @@ public void Compare_Single_To_Byte() ret.Data().Should().Equal(a.Data()); } - [Test] + [TestMethod] public void EqualsNull() { NDArray nd = null; diff --git a/test/NumSharp.UnitTest/Operations/NDArray.LessThan.Test.cs b/test/NumSharp.UnitTest/Operations/NDArray.LessThan.Test.cs index 50e0fa0f5..d34d9066a 100644 --- a/test/NumSharp.UnitTest/Operations/NDArray.LessThan.Test.cs +++ b/test/NumSharp.UnitTest/Operations/NDArray.LessThan.Test.cs @@ -5,6 +5,7 @@ namespace NumSharp.UnitTest.Operations { + [TestClass] public class NDArrayLessThanTest : TestClass { private void PerformLessThanTests(NDArray nd) @@ -14,28 +15,28 @@ private void PerformLessThanTests(NDArray nd) (nd < 7).Should().BeOfValues(true, true, true, true, true, true); } - [Test] + [TestMethod] public void DoublesLessThanTest() { NDArray nd = new double[,] { { 1, 2, 3 }, { 4, 5, 6 } }; PerformLessThanTests(nd); } - [Test] + [TestMethod] public void FloatsLessThanTest() { NDArray nd = new float[,] { { 1, 2, 3 }, { 4, 5, 6 } }; PerformLessThanTests(nd); } - [Test] + [TestMethod] public void IntsLessThanTest() { NDArray nd = new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }; PerformLessThanTests(nd); } - [Test] + [TestMethod] public void LongsLessThanTest() { NDArray nd = new long[,] { { 1, 2, 3 }, { 4, 5, 6 } }; diff --git a/test/NumSharp.UnitTest/Operations/NDArray.NOT.Test.cs b/test/NumSharp.UnitTest/Operations/NDArray.NOT.Test.cs index 525c5be31..5184729f6 100644 --- a/test/NumSharp.UnitTest/Operations/NDArray.NOT.Test.cs +++ b/test/NumSharp.UnitTest/Operations/NDArray.NOT.Test.cs @@ -2,9 +2,10 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; namespace NumSharp.UnitTest.Operations { + [TestClass] public class NDArrayNotTest { - [Test] + [TestMethod] public void not_1d() { var np1 = new NDArray(new[] { false, false, false, false}, new Shape(4)); @@ -14,7 +15,7 @@ public void not_1d() Assert.IsTrue(Enumerable.SequenceEqual(new[] {true, true, true, true}, np3.Data().MemoryBlock)); } - [Test] + [TestMethod] public void BoolTwo2D_NDArrayOR() { var np1 = new NDArray(new[] { false, true, false, false }, new Shape(2,2)); diff --git a/test/NumSharp.UnitTest/Operations/NDArray.OR.Test.cs b/test/NumSharp.UnitTest/Operations/NDArray.OR.Test.cs index bd713ffa7..b7a7bcb37 100644 --- a/test/NumSharp.UnitTest/Operations/NDArray.OR.Test.cs +++ b/test/NumSharp.UnitTest/Operations/NDArray.OR.Test.cs @@ -4,9 +4,10 @@ namespace NumSharp.UnitTest.Operations { + [TestClass] public class NDArrayOrTest { - [Test] + [TestMethod] public void BoolTwo1D_NDArrayOR() { var np1 = new NDArray(new[] {true, true, false, false}, new Shape(4)); @@ -17,7 +18,7 @@ public void BoolTwo1D_NDArrayOR() Assert.IsTrue(Enumerable.SequenceEqual(new[] {true, true, true, false}, np3.Data())); } - [Test] + [TestMethod] public void BoolTwo2D_NDArrayOR() { var np1 = new NDArray(typeof(bool), new Shape(2, 3)); diff --git a/test/NumSharp.UnitTest/Operations/NDArrayGreaterThanTest.cs b/test/NumSharp.UnitTest/Operations/NDArrayGreaterThanTest.cs index 6235d66cf..87a1a26ce 100644 --- a/test/NumSharp.UnitTest/Operations/NDArrayGreaterThanTest.cs +++ b/test/NumSharp.UnitTest/Operations/NDArrayGreaterThanTest.cs @@ -5,6 +5,7 @@ namespace NumSharp.UnitTest.Operations { + [TestClass] public class NDArrayGreaterThanTest : TestClass { private void PerformGreaterThanTests (NDArray nd) @@ -14,28 +15,28 @@ private void PerformGreaterThanTests (NDArray nd) (nd > 7).Should().BeOfValues(false, false, false, false, false, false); } - [Test] + [TestMethod] public void DoublesGreaterThanTest() { NDArray nd = new double[,] { { 1, 2, 3 }, { 4, 5, 6 } }; PerformGreaterThanTests(nd); } - [Test] + [TestMethod] public void FloatsGreaterThanTest() { NDArray nd = new float[,] { { 1, 2, 3 }, { 4, 5, 6 } }; PerformGreaterThanTests(nd); } - [Test] + [TestMethod] public void IntsGreaterThanTest() { NDArray nd = new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }; PerformGreaterThanTests(nd); } - [Test] + [TestMethod] public void LongsGreaterThanTest() { NDArray nd = new long[,] { { 1, 2, 3 }, { 4, 5, 6 } }; diff --git a/test/NumSharp.UnitTest/Operations/NDArrayNotEqualTest.cs b/test/NumSharp.UnitTest/Operations/NDArrayNotEqualTest.cs index 597100714..b845ffe86 100644 --- a/test/NumSharp.UnitTest/Operations/NDArrayNotEqualTest.cs +++ b/test/NumSharp.UnitTest/Operations/NDArrayNotEqualTest.cs @@ -5,6 +5,7 @@ namespace NumSharp.UnitTest.Operations { + [TestClass] public class NDArrayNotEqualTest : TestClass { private void PerformNotEqualTests(NDArray nd) @@ -14,28 +15,28 @@ private void PerformNotEqualTests(NDArray nd) (nd != 7).Should().BeOfValues(true, true, true, true, true, true); } - [Test] + [TestMethod] public void DoublesNotEqualTest() { NDArray nd = new double[,] { { 1, 2, 3 }, { 4, 5, 6 } }; PerformNotEqualTests(nd); } - [Test] + [TestMethod] public void FloatsNotEqualTest() { NDArray nd = new float[,] { { 1, 2, 3 }, { 4, 5, 6 } }; PerformNotEqualTests(nd); } - [Test] + [TestMethod] public void IntsNotEqualTest() { NDArray nd = new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }; PerformNotEqualTests(nd); } - [Test] + [TestMethod] public void LongsGreaterThanTest() { NDArray nd = new long[,] { { 1, 2, 3 }, { 4, 5, 6 } }; diff --git a/test/NumSharp.UnitTest/Random/np.random.choice.Test.cs b/test/NumSharp.UnitTest/Random/np.random.choice.Test.cs index 7a58fe3f2..34ec08537 100644 --- a/test/NumSharp.UnitTest/Random/np.random.choice.Test.cs +++ b/test/NumSharp.UnitTest/Random/np.random.choice.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomChoiceTests : TestClass { - [Test] + [TestMethod] [OpenBugs] // BUG: default(Shape) handling causes "index < Count" error public void UniformOneSample() { @@ -31,7 +32,7 @@ public void UniformOneSample() } } - [Test] + [TestMethod] [OpenBugs] // BUG: default(Shape) handling causes "index < Count" error public void UniformMultipleSample() { @@ -53,7 +54,7 @@ public void UniformMultipleSample() } } - [Test] + [TestMethod] public void NonUniformSample() { // Generate a non-uniform random sample from np.arange(5) of size 3: @@ -76,7 +77,7 @@ public void NonUniformSample() } } - [Test] + [TestMethod] [OpenBugs] // Choice without replacement not implemented yet public void UniformSampleWithoutReplace() { @@ -84,7 +85,7 @@ public void UniformSampleWithoutReplace() Assert.Fail("Not implemented"); } - [Test] + [TestMethod] [OpenBugs] // Choice without replacement not implemented yet public void NonUniformSampleWithoutReplace() { @@ -93,8 +94,8 @@ public void NonUniformSampleWithoutReplace() Assert.Fail("Not implemented"); } - [Test] - [Skip("Choice with string arrays not implemented yet")] + [TestMethod] + [Ignore("Choice with string arrays not implemented yet")] public void StringArraySample1() { //int nrSamples = 5; @@ -113,7 +114,7 @@ public void StringArraySample1() //} } - [Test] + [TestMethod] public void IntegerArraySample() { int nrSamples = 5; diff --git a/test/NumSharp.UnitTest/Random/np.random.seed.Test.cs b/test/NumSharp.UnitTest/Random/np.random.seed.Test.cs index d0e61e4ad..fff4ee75c 100644 --- a/test/NumSharp.UnitTest/Random/np.random.seed.Test.cs +++ b/test/NumSharp.UnitTest/Random/np.random.seed.Test.cs @@ -11,16 +11,17 @@ namespace NumSharp.UnitTest.RandomSampling /// same seed is applied. No testing of the actual output from the random state is expected here. Just test /// the consistent output after repeatedly setting the same seed value. /// + [TestClass] public class NpRandomSeedTests : TestClass { - [Test] + [TestMethod] public void SeedTest() { NumPyRandom rando = np.random.RandomState(1000); Assert.AreEqual(1000, rando.Seed, "The seed value given in the ctor does not match the seed value attribute."); } - [Test] + [TestMethod] public void UniformOneSample() { NumPyRandom rando = np.random.RandomState(1000); @@ -39,7 +40,7 @@ public void UniformOneSample() } - [Test] + [TestMethod] [OpenBugs] // BUG: default(Shape) handling causes "index < Count" error public void UniformMultipleSample() { @@ -61,7 +62,7 @@ public void UniformMultipleSample() } } - [Test] + [TestMethod] public void NonUniformSample() { NumPyRandom rando = np.random.RandomState(1000); @@ -83,7 +84,7 @@ public void NonUniformSample() } - [Test] + [TestMethod] [OpenBugs] // BUG: default(Shape) handling causes "index < Count" error public void IntegerArraySample() { diff --git a/test/NumSharp.UnitTest/RandomSampling/Randomizer.Tests.cs b/test/NumSharp.UnitTest/RandomSampling/Randomizer.Tests.cs index 57434df21..40b47cd7b 100644 --- a/test/NumSharp.UnitTest/RandomSampling/Randomizer.Tests.cs +++ b/test/NumSharp.UnitTest/RandomSampling/Randomizer.Tests.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling /// Tests for the MT19937 Mersenne Twister random number generator. /// These tests verify NumPy compatibility. /// + [TestClass] public class MT19937Tests { - [Test] + [TestMethod] public void SaveAndRestore() { var original = np.random.RandomState(42); @@ -21,7 +22,7 @@ public void SaveAndRestore() copy.randomizer.NextDouble().Should().Be(expectedNext); } - [Test] + [TestMethod] public void Seed42_ProducesConsistentSequence() { var mt = new MT19937(42); @@ -38,7 +39,7 @@ public void Seed42_ProducesConsistentSequence() mt.NextUInt32().Should().Be(v3); } - [Test] + [TestMethod] public void Clone_ProducesIdenticalSequence() { var mt1 = new MT19937(42); @@ -53,7 +54,7 @@ public void Clone_ProducesIdenticalSequence() mt1.NextUInt32().Should().Be(mt2.NextUInt32()); } - [Test] + [TestMethod] public void SetState_RestoresExactState() { var mt1 = new MT19937(42); @@ -76,7 +77,7 @@ public void SetState_RestoresExactState() mt2.NextDouble().Should().Be(expected); } - [Test] + [TestMethod] public void NextBytes_FillsBuffer() { var mt = new MT19937(42); @@ -92,7 +93,7 @@ public void NextBytes_FillsBuffer() hasNonZero.Should().BeTrue(); } - [Test] + [TestMethod] public void Next_WithRange_StaysInBounds() { var mt = new MT19937(42); @@ -105,7 +106,7 @@ public void Next_WithRange_StaysInBounds() } } - [Test] + [TestMethod] public void NextLong_WithRange_StaysInBounds() { var mt = new MT19937(42); @@ -118,7 +119,7 @@ public void NextLong_WithRange_StaysInBounds() } } - [Test] + [TestMethod] public void NextDouble_IsInRange() { var mt = new MT19937(42); @@ -131,7 +132,7 @@ public void NextDouble_IsInRange() } } - [Test] + [TestMethod] public void SeedByArray_ProducesConsistentSequence() { var mt1 = new MT19937(); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.bernoulli.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.bernoulli.Test.cs index 5b430ce88..7d9ed30ff 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.bernoulli.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.bernoulli.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomBernoulliTests : TestClass { - [Test] + [TestMethod] public void Rand1D() { var rand = np.random.bernoulli(0.5, 5); @@ -17,7 +18,7 @@ public void Rand1D() Assert.IsTrue(rand.size == 5); } - [Test] + [TestMethod] public void Rand2D() { var rand = np.random.bernoulli(0.5, new Shape(5, 5)); @@ -25,7 +26,7 @@ public void Rand2D() Assert.IsTrue(rand.size == 25); } - [Test] + [TestMethod] public void Rand2DByShape() { var rand = np.random.bernoulli(0.5, new Shape(5, 5)); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.beta.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.beta.Test.cs index 2a6911058..619746105 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.beta.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.beta.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomBetaTests : TestClass { - [Test] + [TestMethod] public void Rand1D() { var rand = np.random.beta(1, 2, 5); @@ -17,7 +18,7 @@ public void Rand1D() Assert.IsTrue(rand.size == 5); } - [Test] + [TestMethod] public void Rand2D() { var rand = np.random.beta(1, 2, new Shape(5, 5)); @@ -25,7 +26,7 @@ public void Rand2D() Assert.IsTrue(rand.size == 25); } - [Test] + [TestMethod] public void Rand2DByShape() { var rand = np.random.beta(1, 2, new Shape(5, 5)); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.binomial.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.binomial.Test.cs index c9c8f1e01..3a7ecc47b 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.binomial.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.binomial.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomBinomialTests : TestClass { - [Test] + [TestMethod] public void Rand1D() { var rand = np.random.binomial(5, 0.5, 5); @@ -17,7 +18,7 @@ public void Rand1D() Assert.IsTrue(rand.size == 5); } - [Test] + [TestMethod] public void Rand2D() { var rand = np.random.binomial(5, 0.5, new Shape(5, 5)); @@ -25,7 +26,7 @@ public void Rand2D() Assert.IsTrue(rand.size == 25); } - [Test] + [TestMethod] public void Rand2DByShape() { var rand = np.random.binomial(5, 0.5, new Shape(5, 5)); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.dirichlet.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.dirichlet.Test.cs index 158e59e9a..1ad39d672 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.dirichlet.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.dirichlet.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.RandomSampling /// /// Tests for np.random.dirichlet (Dirichlet distribution) /// + [TestClass] public class NpRandomDirichletTests : TestClass { - [Test] + [TestMethod] public void Dirichlet_SingleSample_ReturnsCorrectShape() { var alpha = new double[] { 1, 2, 3 }; @@ -18,7 +19,7 @@ public void Dirichlet_SingleSample_ReturnsCorrectShape() Assert.AreEqual(3, result.shape[0]); } - [Test] + [TestMethod] public void Dirichlet_MultipleSamples_ReturnsCorrectShape() { var alpha = new double[] { 1, 2, 3 }; @@ -29,7 +30,7 @@ public void Dirichlet_MultipleSamples_ReturnsCorrectShape() Assert.AreEqual(15, result.size); } - [Test] + [TestMethod] public void Dirichlet_2DSize_ReturnsCorrectShape() { var alpha = new double[] { 1, 2, 3 }; @@ -41,7 +42,7 @@ public void Dirichlet_2DSize_ReturnsCorrectShape() Assert.AreEqual(18, result.size); } - [Test] + [TestMethod] public void Dirichlet_ReturnsFloat64() { var alpha = new double[] { 1, 2, 3 }; @@ -49,7 +50,7 @@ public void Dirichlet_ReturnsFloat64() Assert.AreEqual(NPTypeCode.Double, result.typecode); } - [Test] + [TestMethod] public void Dirichlet_EachRowSumsToOne() { var rng = np.random.RandomState(42); @@ -67,7 +68,7 @@ public void Dirichlet_EachRowSumsToOne() } } - [Test] + [TestMethod] public void Dirichlet_AllValuesInZeroOne() { var rng = np.random.RandomState(42); @@ -80,7 +81,7 @@ public void Dirichlet_AllValuesInZeroOne() } } - [Test] + [TestMethod] public void Dirichlet_HasCorrectMean() { // Mean of component i = alpha[i] / sum(alpha) @@ -108,7 +109,7 @@ public void Dirichlet_HasCorrectMean() Assert.IsTrue(Math.Abs(means[2] - 3.0 / alphaSum) < 0.01, $"Mean[2] should be ~0.5, got {means[2]}"); } - [Test] + [TestMethod] public void Dirichlet_UniformAlpha_HasEqualMeans() { // For alpha = [1, 1, 1], all means should be 1/3 @@ -135,7 +136,7 @@ public void Dirichlet_UniformAlpha_HasEqualMeans() } } - [Test] + [TestMethod] public void Dirichlet_SingleCategory_ReturnsAllOnes() { // k=1: only one category, so each sample is [1.0] @@ -152,7 +153,7 @@ public void Dirichlet_SingleCategory_ReturnsAllOnes() } } - [Test] + [TestMethod] public void Dirichlet_SameSeed_ProducesSameResults() { var alpha = new double[] { 1, 2, 3 }; @@ -171,31 +172,31 @@ public void Dirichlet_SameSeed_ProducesSameResults() // ========== Validation Tests ========== - [Test] + [TestMethod] public void Dirichlet_EmptyAlpha_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.dirichlet(new double[0], 5)); } - [Test] + [TestMethod] public void Dirichlet_NullAlpha_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.dirichlet((double[])null, 5)); } - [Test] + [TestMethod] public void Dirichlet_NegativeAlpha_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.dirichlet(new double[] { 1, -1, 2 }, 5)); } - [Test] + [TestMethod] public void Dirichlet_ZeroAlpha_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.dirichlet(new double[] { 0, 1, 2 }, 5)); } - [Test] + [TestMethod] public void Dirichlet_NaNAlpha_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.dirichlet(new double[] { 1, double.NaN, 2 }, 5)); @@ -207,7 +208,7 @@ public void Dirichlet_NaNAlpha_ThrowsArgumentException() /// Migrated from NumPy test_randomstate.py /// Basic smoke test. /// - [Test] + [TestMethod] public void Dirichlet_NumPy_SmokeTest() { var alpha = new double[] { 1.0, 2.0, 3.0 }; @@ -219,7 +220,7 @@ public void Dirichlet_NumPy_SmokeTest() /// /// Migrated from NumPy - verify samples sum to 1. /// - [Test] + [TestMethod] public void Dirichlet_NumPy_SamplesSumToOne() { var rng = np.random.RandomState(12345); @@ -240,7 +241,7 @@ public void Dirichlet_NumPy_SamplesSumToOne() /// /// Test with NDArray input for alpha. /// - [Test] + [TestMethod] public void Dirichlet_NDArrayAlpha_Works() { var alpha = np.array(new double[] { 1, 2, 3 }); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.f.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.f.Test.cs index dd9df5737..addee00bc 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.f.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.f.Test.cs @@ -4,9 +4,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomFTest : TestClass { - [Test] + [TestMethod] public void F_ScalarReturn() { var rng = np.random.RandomState(42); @@ -17,7 +18,7 @@ public void F_ScalarReturn() Assert.IsTrue((double)result > 0); } - [Test] + [TestMethod] public void F_1DArray() { var result = np.random.f(5, 10, 5); @@ -27,7 +28,7 @@ public void F_1DArray() Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void F_2DArray() { var result = np.random.f(5, 10, new Shape(2, 3)); @@ -37,7 +38,7 @@ public void F_2DArray() Assert.AreEqual(3, result.shape[1]); } - [Test] + [TestMethod] public void F_ShapeOverload() { var result = np.random.f(5, 10, new Shape(10, 5)); @@ -46,31 +47,31 @@ public void F_ShapeOverload() Assert.AreEqual(5, result.shape[1]); } - [Test] + [TestMethod] public void F_DfnumZero_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.f(0, 10)); } - [Test] + [TestMethod] public void F_DfdenZero_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.f(5, 0)); } - [Test] + [TestMethod] public void F_DfnumNegative_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.f(-1, 10)); } - [Test] + [TestMethod] public void F_DfdenNegative_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.f(5, -1)); } - [Test] + [TestMethod] public void F_MeanMatchesTheory() { // For F(dfnum, dfden), mean = dfden / (dfden - 2) when dfden > 2 @@ -83,7 +84,7 @@ public void F_MeanMatchesTheory() $"Mean {actualMean} should be close to {expectedMean}"); } - [Test] + [TestMethod] public void F_AllValuesPositive() { var rng = np.random.RandomState(42); @@ -93,7 +94,7 @@ public void F_AllValuesPositive() Assert.IsTrue(val > 0, $"Value {val} should be positive"); } - [Test] + [TestMethod] public void F_DifferentDf_MeanMatchesTheory() { // Test with different df values @@ -106,7 +107,7 @@ public void F_DifferentDf_MeanMatchesTheory() $"Mean {actualMean} should be close to {expectedMean}"); } - [Test] + [TestMethod] public void F_ReturnsFloat64() { var result = np.random.f(5, 10, size: new Shape(5)); @@ -114,7 +115,7 @@ public void F_ReturnsFloat64() Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void F_Reproducible() { var rng1 = np.random.RandomState(123); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.gamma.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.gamma.Test.cs index 9feb73436..c2adf7b63 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.gamma.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.gamma.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomGammmaTests : TestClass { - [Test] + [TestMethod] public void Rand1D() { var rand = np.random.gamma(1, 2, 5); @@ -17,7 +18,7 @@ public void Rand1D() Assert.IsTrue(rand.size == 5); } - [Test] + [TestMethod] public void Rand2D() { var rand = np.random.gamma(1, 2, new Shape(5, 5)); @@ -25,7 +26,7 @@ public void Rand2D() Assert.IsTrue(rand.size == 25); } - [Test] + [TestMethod] public void Rand2DByShape() { var rand = np.random.gamma(1, 2, new Shape(5, 5)); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.gumbel.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.gumbel.Test.cs index 7a1fd025b..2f1b7a621 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.gumbel.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.gumbel.Test.cs @@ -6,12 +6,13 @@ namespace NumSharp.UnitTest.RandomSampling /// /// Tests for np.random.gumbel (Gumbel/extreme value type I distribution) /// + [TestClass] public class NpRandomGumbelTests : TestClass { // Euler-Mascheroni constant private const double EulerGamma = 0.5772156649015329; - [Test] + [TestMethod] public void Gumbel_1D_ReturnsCorrectShape() { var rand = np.random.gumbel(0, 1, 5); @@ -19,7 +20,7 @@ public void Gumbel_1D_ReturnsCorrectShape() Assert.AreEqual(5, rand.size); } - [Test] + [TestMethod] public void Gumbel_2D_ReturnsCorrectShape() { var rand = np.random.gumbel(0, 1, new Shape(5, 5)); @@ -27,7 +28,7 @@ public void Gumbel_2D_ReturnsCorrectShape() Assert.AreEqual(25, rand.size); } - [Test] + [TestMethod] public void Gumbel_2DByShape_ReturnsCorrectShape() { var rand = np.random.gumbel(0, 1, new Shape(5, 5)); @@ -35,7 +36,7 @@ public void Gumbel_2DByShape_ReturnsCorrectShape() Assert.AreEqual(25, rand.size); } - [Test] + [TestMethod] public void Gumbel_DefaultParameters_HasCorrectStatistics() { // Gumbel(0, 1) has mean = γ ≈ 0.5772 (Euler-Mascheroni constant) @@ -52,7 +53,7 @@ public void Gumbel_DefaultParameters_HasCorrectStatistics() Assert.IsTrue(Math.Abs(std - expectedStd) < 0.05, $"Std should be near {expectedStd}, got {std}"); } - [Test] + [TestMethod] public void Gumbel_WithLocScale_TransformsCorrectly() { // Gumbel(loc, scale) has mean = loc + scale * γ @@ -67,13 +68,13 @@ public void Gumbel_WithLocScale_TransformsCorrectly() Assert.IsTrue(Math.Abs(mean - expectedMean) < 0.15, $"Mean should be near {expectedMean}, got {mean}"); } - [Test] + [TestMethod] public void Gumbel_NegativeScale_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.gumbel(0, -1, 5)); } - [Test] + [TestMethod] public void Gumbel_ScaleZero_ReturnsConstantAtLoc() { double loc = 5.0; @@ -85,7 +86,7 @@ public void Gumbel_ScaleZero_ReturnsConstantAtLoc() } } - [Test] + [TestMethod] public void Gumbel_Scalar_ReturnsScalar() { var rng = np.random.RandomState(42); @@ -95,14 +96,14 @@ public void Gumbel_Scalar_ReturnsScalar() Assert.AreEqual(1, result.size); } - [Test] + [TestMethod] public void Gumbel_ReturnsFloat64() { var result = np.random.gumbel(0, 1, 5); Assert.AreEqual(NPTypeCode.Double, result.typecode); } - [Test] + [TestMethod] public void Gumbel_SameSeed_ProducesSameResults() { var rng1 = np.random.RandomState(42); @@ -117,7 +118,7 @@ public void Gumbel_SameSeed_ProducesSameResults() } } - [Test] + [TestMethod] public void Gumbel_DifferentSeeds_ProduceDifferentResults() { var rng1 = np.random.RandomState(42); @@ -138,7 +139,7 @@ public void Gumbel_DifferentSeeds_ProduceDifferentResults() Assert.IsTrue(anyDifferent, "Different seeds should produce different results"); } - [Test] + [TestMethod] public void Gumbel_CanProduceNegativeValues() { // Gumbel distribution can produce negative values (unlike Rayleigh) @@ -163,7 +164,7 @@ public void Gumbel_CanProduceNegativeValues() /// Migrated from NumPy test_random.py test_gumbel_0 /// Tests that scale=0 returns loc (default 0). /// - [Test] + [TestMethod] public void Gumbel_NumPy_ScaleZeroReturnsLoc() { // From NumPy: assert_equal(np.random.gumbel(scale=0), 0) @@ -175,7 +176,7 @@ public void Gumbel_NumPy_ScaleZeroReturnsLoc() /// Migrated from NumPy test_random.py test_gumbel_0 /// Negative scale should raise ValueError. /// - [Test] + [TestMethod] public void Gumbel_NumPy_NegativeScaleRaises() { // From NumPy: assert_raises(ValueError, np.random.gumbel, scale=-0.) @@ -187,7 +188,7 @@ public void Gumbel_NumPy_NegativeScaleRaises() /// Migrated from NumPy test_smoke.py test_gumbel /// Basic smoke test that gumbel produces correct output size. /// - [Test] + [TestMethod] public void Gumbel_NumPy_SmokeTest() { // From NumPy: vals = rg.gumbel(2.0, 2.0, 10); assert_(len(vals) == 10) diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.hypergeometric.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.hypergeometric.Test.cs index 5d6d4a738..f9b326326 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.hypergeometric.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.hypergeometric.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.RandomSampling; /// Samples from hypergeometric distribution without replacement. /// Mean = nsample * ngood / (ngood + nbad) /// +[TestClass] public class RandomHypergeometricTests : TestClass { - [Test] + [TestMethod] public void Hypergeometric_ScalarCall_Returns0dArray() { var rng = np.random.RandomState(42); @@ -21,7 +22,7 @@ public void Hypergeometric_ScalarCall_Returns0dArray() Assert.IsTrue(value >= 0 && value <= 10, $"Result {value} should be in [0, 10]"); } - [Test] + [TestMethod] public void Hypergeometric_ArraySize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -30,7 +31,7 @@ public void Hypergeometric_ArraySize_ReturnsCorrectShape() Assert.AreEqual(typeof(long), result.dtype); } - [Test] + [TestMethod] public void Hypergeometric_MultiDimensionalSize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -38,7 +39,7 @@ public void Hypergeometric_MultiDimensionalSize_ReturnsCorrectShape() result.Should().BeShaped(2, 3); } - [Test] + [TestMethod] public void Hypergeometric_ShapeSize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -46,7 +47,7 @@ public void Hypergeometric_ShapeSize_ReturnsCorrectShape() result.Should().BeShaped(3, 4); } - [Test] + [TestMethod] public void Hypergeometric_AllValuesInRange() { // Result must be in [max(0, nsample-nbad), min(nsample, ngood)] @@ -62,7 +63,7 @@ public void Hypergeometric_AllValuesInRange() } } - [Test] + [TestMethod] public void Hypergeometric_MeanConvergesToExpected() { // Mean = nsample * ngood / (ngood + nbad) @@ -82,7 +83,7 @@ public void Hypergeometric_MeanConvergesToExpected() $"Mean {mean} should be close to 5"); } - [Test] + [TestMethod] public void Hypergeometric_AllGood_ReturnsNsample() { // When nbad=0, result is always nsample (all are good) @@ -96,7 +97,7 @@ public void Hypergeometric_AllGood_ReturnsNsample() } } - [Test] + [TestMethod] public void Hypergeometric_AllBad_ReturnsZero() { // When ngood=0, result is always 0 (none are good) @@ -110,7 +111,7 @@ public void Hypergeometric_AllBad_ReturnsZero() } } - [Test] + [TestMethod] public void Hypergeometric_TakeAll_ReturnsNgood() { // When nsample = ngood + nbad, result is always ngood @@ -124,7 +125,7 @@ public void Hypergeometric_TakeAll_ReturnsNgood() } } - [Test] + [TestMethod] public void Hypergeometric_MostlyGood() { // (100, 2, 10) - should get mostly ~10 good @@ -142,7 +143,7 @@ public void Hypergeometric_MostlyGood() Assert.IsTrue(mean > 9.5, $"Mean {mean} should be close to 10 for mostly good"); } - [Test] + [TestMethod] public void Hypergeometric_MostlyBad() { // (2, 100, 10) - should get mostly ~0 good @@ -160,39 +161,39 @@ public void Hypergeometric_MostlyBad() Assert.IsTrue(mean < 0.5, $"Mean {mean} should be close to 0 for mostly bad"); } - [Test] + [TestMethod] public void Hypergeometric_NegativeNgood_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.hypergeometric(-1, 15, 10, 5L)); } - [Test] + [TestMethod] public void Hypergeometric_NegativeNbad_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.hypergeometric(15, -1, 10, 5L)); } - [Test] + [TestMethod] public void Hypergeometric_ZeroNsample_ThrowsArgumentException() { // NumPy requires nsample >= 1 Assert.ThrowsException(() => np.random.hypergeometric(15, 15, 0, 5L)); } - [Test] + [TestMethod] public void Hypergeometric_NegativeNsample_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.hypergeometric(15, 15, -1, 5L)); } - [Test] + [TestMethod] public void Hypergeometric_NsampleTooLarge_ThrowsArgumentException() { // nsample > ngood + nbad should throw Assert.ThrowsException(() => np.random.hypergeometric(15, 15, 40, 5L)); } - [Test] + [TestMethod] public void Hypergeometric_Reproducibility() { var rng1 = np.random.RandomState(42); @@ -208,7 +209,7 @@ public void Hypergeometric_Reproducibility() } } - [Test] + [TestMethod] public void Hypergeometric_NsampleOne() { // With nsample=1, result is either 0 or 1 diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.laplace.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.laplace.Test.cs index ff4f1878b..0347587eb 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.laplace.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.laplace.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.RandomSampling /// /// Tests for np.random.laplace (Laplace/double exponential distribution) /// + [TestClass] public class NpRandomLaplaceTests : TestClass { - [Test] + [TestMethod] public void Laplace_1D_ReturnsCorrectShape() { var rand = np.random.laplace(0, 1, 5); @@ -16,7 +17,7 @@ public void Laplace_1D_ReturnsCorrectShape() Assert.AreEqual(5, rand.size); } - [Test] + [TestMethod] public void Laplace_2D_ReturnsCorrectShape() { var rand = np.random.laplace(0, 1, new Shape(5, 5)); @@ -24,7 +25,7 @@ public void Laplace_2D_ReturnsCorrectShape() Assert.AreEqual(25, rand.size); } - [Test] + [TestMethod] public void Laplace_2DByShape_ReturnsCorrectShape() { var rand = np.random.laplace(0, 1, new Shape(5, 5)); @@ -32,7 +33,7 @@ public void Laplace_2DByShape_ReturnsCorrectShape() Assert.AreEqual(25, rand.size); } - [Test] + [TestMethod] public void Laplace_DefaultParameters_HasCorrectStatistics() { // Laplace(0, 1) has mean=0 and std=sqrt(2)≈1.414, variance=2 @@ -49,7 +50,7 @@ public void Laplace_DefaultParameters_HasCorrectStatistics() Assert.IsTrue(Math.Abs(variance - 2.0) < 0.1, $"Variance should be near 2, got {variance}"); } - [Test] + [TestMethod] public void Laplace_WithLocScale_TransformsCorrectly() { // Laplace(μ, λ) has mean=μ and variance=2λ² @@ -66,13 +67,13 @@ public void Laplace_WithLocScale_TransformsCorrectly() Assert.IsTrue(Math.Abs(variance - expectedVariance) < 0.5, $"Variance should be near {expectedVariance}, got {variance}"); } - [Test] + [TestMethod] public void Laplace_NegativeScale_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.laplace(0, -1, 5)); } - [Test] + [TestMethod] public void Laplace_ScaleZero_ReturnsConstantAtLoc() { double loc = 5.0; @@ -84,7 +85,7 @@ public void Laplace_ScaleZero_ReturnsConstantAtLoc() } } - [Test] + [TestMethod] public void Laplace_Scalar_ReturnsScalar() { var rng = np.random.RandomState(42); @@ -94,14 +95,14 @@ public void Laplace_Scalar_ReturnsScalar() Assert.AreEqual(1, result.size); } - [Test] + [TestMethod] public void Laplace_ReturnsFloat64() { var result = np.random.laplace(0, 1, 5); Assert.AreEqual(NPTypeCode.Double, result.typecode); } - [Test] + [TestMethod] public void Laplace_DifferentSeeds_ProduceDifferentResults() { var rng1 = np.random.RandomState(42); @@ -122,7 +123,7 @@ public void Laplace_DifferentSeeds_ProduceDifferentResults() Assert.IsTrue(anyDifferent, "Different seeds should produce different results"); } - [Test] + [TestMethod] public void Laplace_SameSeed_ProducesSameResults() { var rng1 = np.random.RandomState(42); @@ -143,7 +144,7 @@ public void Laplace_SameSeed_ProducesSameResults() /// Migrated from NumPy test_random.py test_laplace_0 /// Tests that scale=0 returns loc, and negative scale raises error. /// - [Test] + [TestMethod] public void Laplace_NumPy_ScaleZeroReturnsLoc() { // From NumPy: assert_equal(np.random.laplace(scale=0), 0) @@ -156,7 +157,7 @@ public void Laplace_NumPy_ScaleZeroReturnsLoc() /// Negative zero scale should raise ValueError in NumPy. /// Note: In C#, -0.0 == 0.0, so we test explicit negative values. /// - [Test] + [TestMethod] public void Laplace_NumPy_NegativeScaleRaises() { // From NumPy: assert_raises(ValueError, np.random.laplace, scale=-0.) @@ -169,7 +170,7 @@ public void Laplace_NumPy_NegativeScaleRaises() /// Migrated from NumPy test_smoke.py test_laplace /// Basic smoke test that laplace produces correct output size. /// - [Test] + [TestMethod] public void Laplace_NumPy_SmokeTest() { // From NumPy: vals = rg.laplace(2.0, 2.0, 10); assert_(len(vals) == 10) @@ -180,7 +181,7 @@ public void Laplace_NumPy_SmokeTest() /// /// Test that Laplace can produce both positive and negative values. /// - [Test] + [TestMethod] public void Laplace_ProducesBothPositiveAndNegative() { var rng = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.logistic.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.logistic.Test.cs index beda5cc61..54bbcfdb7 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.logistic.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.logistic.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest.RandomSampling; /// Tests for np.random.logistic following NumPy 2.4.2 behavior. /// Mean = loc, Variance = scale^2 * pi^2 / 3 /// +[TestClass] public class RandomLogisticTests : TestClass { - [Test] + [TestMethod] public void Logistic_DefaultParameters_ReturnsScalar() { var rng = np.random.RandomState(42); @@ -19,7 +20,7 @@ public void Logistic_DefaultParameters_ReturnsScalar() Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void Logistic_ArraySize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -28,7 +29,7 @@ public void Logistic_ArraySize_ReturnsCorrectShape() Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void Logistic_MultiDimensionalSize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -36,7 +37,7 @@ public void Logistic_MultiDimensionalSize_ReturnsCorrectShape() result.Should().BeShaped(2, 3); } - [Test] + [TestMethod] public void Logistic_ShapeSize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -44,7 +45,7 @@ public void Logistic_ShapeSize_ReturnsCorrectShape() result.Should().BeShaped(3, 4); } - [Test] + [TestMethod] public void Logistic_MeanConvergesToLoc() { // Mean of logistic distribution = loc @@ -57,7 +58,7 @@ public void Logistic_MeanConvergesToLoc() $"Mean {mean} should be close to 0 (loc=0)"); } - [Test] + [TestMethod] public void Logistic_StdConvergesToExpected() { // Standard deviation = scale * pi / sqrt(3) ≈ 1.814 for scale=1 @@ -72,7 +73,7 @@ public void Logistic_StdConvergesToExpected() $"Std {std} should be close to {expectedStd}"); } - [Test] + [TestMethod] public void Logistic_WithLocAndScale() { // Mean = loc = 5 @@ -84,7 +85,7 @@ public void Logistic_WithLocAndScale() $"Mean {mean} should be close to 5 (loc=5)"); } - [Test] + [TestMethod] public void Logistic_ScaleZero_ReturnsLoc() { // When scale=0, all values should equal loc @@ -98,19 +99,19 @@ public void Logistic_ScaleZero_ReturnsLoc() } } - [Test] + [TestMethod] public void Logistic_NegativeScale_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.logistic(0, -1, 5)); } - [Test] + [TestMethod] public void Logistic_DefaultScalar_NegativeScale_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.logistic(0, -1)); } - [Test] + [TestMethod] public void Logistic_Reproducibility() { var rng1 = np.random.RandomState(42); @@ -126,7 +127,7 @@ public void Logistic_Reproducibility() } } - [Test] + [TestMethod] public void Logistic_CanProduceNegativeValues() { var rng = np.random.RandomState(42); @@ -145,7 +146,7 @@ public void Logistic_CanProduceNegativeValues() Assert.IsTrue(hasPositive, "Logistic distribution should produce positive values"); } - [Test] + [TestMethod] public void Logistic_LargerScaleProducesLargerVariance() { var rng = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.lognormal.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.lognormal.Test.cs index 31ccdeed0..27a687f1e 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.lognormal.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.lognormal.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomLogNormalTests : TestClass { - [Test] + [TestMethod] public void Rand1D() { var rand = np.random.lognormal(1, 0.5, 5); @@ -17,7 +18,7 @@ public void Rand1D() Assert.IsTrue(rand.size == 5); } - [Test] + [TestMethod] public void Rand2D() { var rand = np.random.lognormal(1, 0.5, new Shape(5, 5)); @@ -25,7 +26,7 @@ public void Rand2D() Assert.IsTrue(rand.size == 25); } - [Test] + [TestMethod] public void Rand2DByShape() { var rand = np.random.lognormal(1, 0.5, new Shape(5, 5)); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.logseries.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.logseries.Test.cs index 2eb0bf2b7..c146afde5 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.logseries.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.logseries.Test.cs @@ -3,7 +3,6 @@ using AwesomeAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.UnitTest.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.RandomSampling { @@ -12,11 +11,12 @@ namespace NumSharp.UnitTest.RandomSampling /// Based on NumPy 2.4.2 behavior. /// + [TestClass] public class np_random_logseries_Tests { #region Basic Functionality - [Test] + [TestMethod] public void Logseries_Scalar_ReturnsNDArray() { var rng = np.random.RandomState(42); @@ -27,7 +27,7 @@ public void Logseries_Scalar_ReturnsNDArray() ((long)result).Should().BeGreaterThanOrEqualTo(1); } - [Test] + [TestMethod] public void Logseries_1D_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -37,7 +37,7 @@ public void Logseries_1D_ReturnsCorrectShape() result.dtype.Should().Be(typeof(long)); } - [Test] + [TestMethod] public void Logseries_2D_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -47,7 +47,7 @@ public void Logseries_2D_ReturnsCorrectShape() result.dtype.Should().Be(typeof(long)); } - [Test] + [TestMethod] public void Logseries_SizeNull_ReturnsScalar() { var rng = np.random.RandomState(42); @@ -56,7 +56,7 @@ public void Logseries_SizeNull_ReturnsScalar() result.ndim.Should().Be(0); } - [Test] + [TestMethod] public void Logseries_3DShape() { var rng = np.random.RandomState(42); @@ -70,7 +70,7 @@ public void Logseries_3DShape() #region Value Verification - [Test] + [TestMethod] public void Logseries_AllValuesAtLeast1() { var rng = np.random.RandomState(42); @@ -83,7 +83,7 @@ public void Logseries_AllValuesAtLeast1() } } - [Test] + [TestMethod] public void Logseries_SmallP_MostlyOnes() { // With small p, values should be mostly 1 @@ -96,7 +96,7 @@ public void Logseries_SmallP_MostlyOnes() countOnes.Should().BeGreaterThan(80); } - [Test] + [TestMethod] public void Logseries_HighP_LargerValues() { // With high p close to 1, values should have more variation @@ -109,7 +109,7 @@ public void Logseries_HighP_LargerValues() maxValue.Should().BeGreaterThan(10); } - [Test] + [TestMethod] public void Logseries_PZero_AllOnes() { // When p=0, all values should be 1 @@ -123,7 +123,7 @@ public void Logseries_PZero_AllOnes() } } - [Test] + [TestMethod] public void Logseries_MeanApproximatesTheoretical() { // Theoretical mean = -p / ((1-p) * ln(1-p)) @@ -143,25 +143,25 @@ public void Logseries_MeanApproximatesTheoretical() #region Validation - [Test] + [TestMethod] public void Logseries_NegativeP_Throws() { Assert.ThrowsException(() => np.random.logseries(-0.1, 10)); } - [Test] + [TestMethod] public void Logseries_PEqualsOne_Throws() { Assert.ThrowsException(() => np.random.logseries(1.0, 10)); } - [Test] + [TestMethod] public void Logseries_PGreaterThanOne_Throws() { Assert.ThrowsException(() => np.random.logseries(1.5, 10)); } - [Test] + [TestMethod] public void Logseries_PIsNaN_Throws() { Assert.ThrowsException(() => np.random.logseries(double.NaN, 10)); @@ -171,7 +171,7 @@ public void Logseries_PIsNaN_Throws() #region Reproducibility - [Test] + [TestMethod] public void Logseries_SameSeed_SameResults() { var rng1 = np.random.RandomState(12345); @@ -189,7 +189,7 @@ public void Logseries_SameSeed_SameResults() } } - [Test] + [TestMethod] public void Logseries_DifferentSeeds_DifferentResults() { var rng1 = np.random.RandomState(111); @@ -218,7 +218,7 @@ public void Logseries_DifferentSeeds_DifferentResults() #region Edge Cases - [Test] + [TestMethod] public void Logseries_VerySmallP() { // Edge case: very small p should still produce valid output @@ -232,7 +232,7 @@ public void Logseries_VerySmallP() } } - [Test] + [TestMethod] public void Logseries_PCloseToOne() { // Edge case: p very close to 1 (but less than 1) @@ -248,7 +248,7 @@ public void Logseries_PCloseToOne() data.Max().Should().BeGreaterThan(1); } - [Test] + [TestMethod] public void Logseries_Size1_ReturnsSingleElementArray() { var rng = np.random.RandomState(42); @@ -258,7 +258,7 @@ public void Logseries_Size1_ReturnsSingleElementArray() result.shape.Should().BeEquivalentTo(new[] { 1 }); } - [Test] + [TestMethod] public void Logseries_VariousP_AllValuesPositive() { var rng = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.multinomial.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.multinomial.Test.cs index 28b68c2e0..c7b7cb306 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.multinomial.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.multinomial.Test.cs @@ -5,11 +5,12 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class MultinomialTests { private static readonly double[] DicePvals = { 1.0 / 6, 1.0 / 6, 1.0 / 6, 1.0 / 6, 1.0 / 6, 1.0 / 6 }; - [Test] + [TestMethod] public void Multinomial_ReturnsSingleSample_WhenNoSize() { var rng = np.random.RandomState(42); @@ -19,7 +20,7 @@ public void Multinomial_ReturnsSingleSample_WhenNoSize() result.dtype.Should().Be(typeof(int)); } - [Test] + [TestMethod] public void Multinomial_SumEqualsN() { var rng = np.random.RandomState(42); @@ -29,7 +30,7 @@ public void Multinomial_SumEqualsN() sum.Should().Be(20); } - [Test] + [TestMethod] public void Multinomial_Returns2DArray_WithSize() { var rng = np.random.RandomState(42); @@ -38,7 +39,7 @@ public void Multinomial_Returns2DArray_WithSize() result.shape.Should().ContainInOrder(5, 6); } - [Test] + [TestMethod] public void Multinomial_Returns3DArray_With2DSize() { var rng = np.random.RandomState(42); @@ -47,7 +48,7 @@ public void Multinomial_Returns3DArray_With2DSize() result.shape.Should().ContainInOrder(2, 3, 6); } - [Test] + [TestMethod] public void Multinomial_AllRowsSumToN() { var rng = np.random.RandomState(42); @@ -64,7 +65,7 @@ public void Multinomial_AllRowsSumToN() } } - [Test] + [TestMethod] public void Multinomial_AllValuesNonNegative() { var rng = np.random.RandomState(42); @@ -76,7 +77,7 @@ public void Multinomial_AllValuesNonNegative() } } - [Test] + [TestMethod] public void Multinomial_BiasedPvals_ProducesMoreInHighProbCategory() { var rng = np.random.RandomState(42); @@ -96,7 +97,7 @@ public void Multinomial_BiasedPvals_ProducesMoreInHighProbCategory() lastCategoryTotal.Should().BeGreaterThan(firstCategoryTotal); } - [Test] + [TestMethod] public void Multinomial_NZero_ReturnsAllZeros() { var rng = np.random.RandomState(42); @@ -108,28 +109,28 @@ public void Multinomial_NZero_ReturnsAllZeros() } } - [Test] + [TestMethod] public void Multinomial_NNegative_ThrowsArgumentException() { Action act = () => np.random.multinomial(-1, DicePvals); act.Should().Throw(); } - [Test] + [TestMethod] public void Multinomial_PvalsNegative_ThrowsArgumentException() { Action act = () => np.random.multinomial(20, new[] { 0.5, -0.1, 0.6 }); act.Should().Throw(); } - [Test] + [TestMethod] public void Multinomial_PvalsSumGreaterThanOne_ThrowsArgumentException() { Action act = () => np.random.multinomial(20, new[] { 0.5, 0.6, 0.1 }); act.Should().Throw(); } - [Test] + [TestMethod] public void Multinomial_ShapeOverload_Works() { var rng = np.random.RandomState(42); @@ -138,7 +139,7 @@ public void Multinomial_ShapeOverload_Works() result.shape.Should().ContainInOrder(3, 4, 6); } - [Test] + [TestMethod] public void Multinomial_Reproducibility_WithSeed() { var rng1 = np.random.RandomState(42); @@ -150,7 +151,7 @@ public void Multinomial_Reproducibility_WithSeed() first.Should().BeEquivalentTo(second); } - [Test] + [TestMethod] public void Multinomial_TwoCategories_IsBinomialLike() { var rng = np.random.RandomState(42); @@ -169,7 +170,7 @@ public void Multinomial_TwoCategories_IsBinomialLike() Math.Abs(avgFirst - 30).Should().BeLessThan(3); } - [Test] + [TestMethod] public void Multinomial_LargeN_Works() { var rng = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.multivariate_normal.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.multivariate_normal.Test.cs index 618bc48b3..4b4690dd4 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.multivariate_normal.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.multivariate_normal.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest.RandomSampling /// Reference: https://numpy.org/doc/stable/reference/random/generated/numpy.random.multivariate_normal.html /// + [TestClass] public class NpRandomMultivariateNormalTests : TestClass { - [Test] + [TestMethod] public void MultivariateNormal_SingleSample_Returns1DArray() { var rng = np.random.RandomState(42); @@ -23,7 +24,7 @@ public void MultivariateNormal_SingleSample_Returns1DArray() Assert.AreEqual(2, result.shape[0]); } - [Test] + [TestMethod] public void MultivariateNormal_MultipleSamples_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -37,7 +38,7 @@ public void MultivariateNormal_MultipleSamples_ReturnsCorrectShape() Assert.AreEqual(2, result.shape[1]); } - [Test] + [TestMethod] public void MultivariateNormal_TupleSize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -52,7 +53,7 @@ public void MultivariateNormal_TupleSize_ReturnsCorrectShape() Assert.AreEqual(2, result.shape[2]); } - [Test] + [TestMethod] public void MultivariateNormal_Samples_HaveCorrectMean() { var rng = np.random.RandomState(42); @@ -74,7 +75,7 @@ public void MultivariateNormal_Samples_HaveCorrectMean() Assert.IsTrue(Math.Abs(sampleMean1 - (-3)) < 0.1, $"Mean[1] should be ~-3, got {sampleMean1}"); } - [Test] + [TestMethod] public void MultivariateNormal_DiagonalCovariance_HasCorrectVariances() { var rng = np.random.RandomState(42); @@ -106,7 +107,7 @@ public void MultivariateNormal_DiagonalCovariance_HasCorrectVariances() Assert.IsTrue(Math.Abs(var1 - 4) < 0.3, $"Variance[1] should be ~4, got {var1}"); } - [Test] + [TestMethod] public void MultivariateNormal_CorrelatedVariables_HaveCorrectCovariance() { var rng = np.random.RandomState(42); @@ -136,7 +137,7 @@ public void MultivariateNormal_CorrelatedVariables_HaveCorrectCovariance() Assert.IsTrue(Math.Abs(cov01 - 0.5) < 0.1, $"Covariance should be ~0.5, got {cov01}"); } - [Test] + [TestMethod] public void MultivariateNormal_ThreeDimensional_Works() { var rng = np.random.RandomState(42); @@ -150,7 +151,7 @@ public void MultivariateNormal_ThreeDimensional_Works() Assert.AreEqual(3, samples.shape[1]); } - [Test] + [TestMethod] public void MultivariateNormal_OneDimensional_Works() { var rng = np.random.RandomState(42); @@ -179,7 +180,7 @@ public void MultivariateNormal_OneDimensional_Works() Assert.IsTrue(Math.Abs(var_ - 4) < 0.3, $"Variance should be ~4, got {var_}"); } - [Test] + [TestMethod] public void MultivariateNormal_IdentityCovariance_ProducesUncorrelatedSamples() { var rng = np.random.RandomState(42); @@ -212,7 +213,7 @@ public void MultivariateNormal_IdentityCovariance_ProducesUncorrelatedSamples() Assert.IsTrue(Math.Abs(correlation) < 0.05, $"Correlation should be ~0, got {correlation}"); } - [Test] + [TestMethod] public void MultivariateNormal_NDArrayInput_Works() { var rng = np.random.RandomState(42); @@ -225,7 +226,7 @@ public void MultivariateNormal_NDArrayInput_Works() Assert.AreEqual(2, result.shape[1]); } - [Test] + [TestMethod] public void MultivariateNormal_DimensionMismatch_Throws() { var mean = new double[] { 0, 0, 0 }; @@ -235,7 +236,7 @@ public void MultivariateNormal_DimensionMismatch_Throws() np.random.multivariate_normal(mean, cov)); } - [Test] + [TestMethod] public void MultivariateNormal_NonSquareCovariance_Throws() { var mean = new double[] { 0, 0 }; @@ -245,7 +246,7 @@ public void MultivariateNormal_NonSquareCovariance_Throws() np.random.multivariate_normal(mean, cov)); } - [Test] + [TestMethod] public void MultivariateNormal_EmptyMean_Throws() { var mean = new double[0]; @@ -255,7 +256,7 @@ public void MultivariateNormal_EmptyMean_Throws() np.random.multivariate_normal(mean, cov)); } - [Test] + [TestMethod] public void MultivariateNormal_NullMean_Throws() { double[] mean = null!; @@ -265,7 +266,7 @@ public void MultivariateNormal_NullMean_Throws() np.random.multivariate_normal(mean, cov)); } - [Test] + [TestMethod] public void MultivariateNormal_NullCovariance_Throws() { var mean = new double[] { 0, 0 }; @@ -275,7 +276,7 @@ public void MultivariateNormal_NullCovariance_Throws() np.random.multivariate_normal(mean, cov)); } - [Test] + [TestMethod] public void MultivariateNormal_InvalidCheckValid_Throws() { var mean = new double[] { 0, 0 }; @@ -285,7 +286,7 @@ public void MultivariateNormal_InvalidCheckValid_Throws() np.random.multivariate_normal(mean, cov, default(Shape), "invalid")); } - [Test] + [TestMethod] public void MultivariateNormal_CheckValidRaise_ThrowsForNonPositiveDefinite() { var mean = new double[] { 0, 0 }; @@ -296,7 +297,7 @@ public void MultivariateNormal_CheckValidRaise_ThrowsForNonPositiveDefinite() np.random.multivariate_normal(mean, cov, null, "raise")); } - [Test] + [TestMethod] public void MultivariateNormal_CheckValidIgnore_ReturnsResultForNonPositiveDefinite() { var rng = np.random.RandomState(42); @@ -311,7 +312,7 @@ public void MultivariateNormal_CheckValidIgnore_ReturnsResultForNonPositiveDefin Assert.AreEqual(2, result.shape[0]); } - [Test] + [TestMethod] public void MultivariateNormal_LargeDimension_Works() { var rng = np.random.RandomState(42); @@ -330,7 +331,7 @@ public void MultivariateNormal_LargeDimension_Works() Assert.AreEqual(n, samples.shape[1]); } - [Test] + [TestMethod] public void MultivariateNormal_ReturnsDtype_Double() { var rng = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.negative_binomial.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.negative_binomial.Test.cs index 8acdfd7dc..afa5b36a8 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.negative_binomial.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.negative_binomial.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling /// Tests for np.random.negative_binomial (negative binomial distribution) /// + [TestClass] public class NpRandomNegativeBinomialTests : TestClass { - [Test] + [TestMethod] public void NegativeBinomial_1D_ReturnsCorrectShape() { var rand = np.random.negative_binomial(10, 0.5, 5L); @@ -17,7 +18,7 @@ public void NegativeBinomial_1D_ReturnsCorrectShape() Assert.AreEqual(5, rand.size); } - [Test] + [TestMethod] public void NegativeBinomial_2D_ReturnsCorrectShape() { var rand = np.random.negative_binomial(10, 0.5, new Shape(5, 5)); @@ -25,7 +26,7 @@ public void NegativeBinomial_2D_ReturnsCorrectShape() Assert.AreEqual(25, rand.size); } - [Test] + [TestMethod] public void NegativeBinomial_2DByShape_ReturnsCorrectShape() { var rand = np.random.negative_binomial(10, 0.5, new Shape(5, 5)); @@ -33,14 +34,14 @@ public void NegativeBinomial_2DByShape_ReturnsCorrectShape() Assert.AreEqual(25, rand.size); } - [Test] + [TestMethod] public void NegativeBinomial_ReturnsInt64() { var result = np.random.negative_binomial(10, 0.5, 5L); Assert.AreEqual(NPTypeCode.Int64, result.typecode); } - [Test] + [TestMethod] public void NegativeBinomial_AllValuesNonNegative() { // Negative binomial produces non-negative integers (number of failures) @@ -53,7 +54,7 @@ public void NegativeBinomial_AllValuesNonNegative() } } - [Test] + [TestMethod] public void NegativeBinomial_HasCorrectMean() { // mean = n * (1-p) / p @@ -70,7 +71,7 @@ public void NegativeBinomial_HasCorrectMean() Assert.IsTrue(Math.Abs(mean - expectedMean) < 0.5, $"Mean should be near {expectedMean}, got {mean}"); } - [Test] + [TestMethod] public void NegativeBinomial_HasCorrectVariance() { // variance = n * (1-p) / p^2 @@ -92,7 +93,7 @@ public void NegativeBinomial_HasCorrectVariance() Assert.IsTrue(Math.Abs(variance - expectedVar) < 2.0, $"Variance should be near {expectedVar}, got {variance}"); } - [Test] + [TestMethod] public void NegativeBinomial_PEqualsOne_ReturnsAllZeros() { // p=1 means immediate success, so 0 failures @@ -104,7 +105,7 @@ public void NegativeBinomial_PEqualsOne_ReturnsAllZeros() } } - [Test] + [TestMethod] public void NegativeBinomial_HighP_FewFailures() { // High p means few failures expected @@ -120,7 +121,7 @@ public void NegativeBinomial_HighP_FewFailures() Assert.IsTrue(mean < 5, $"High p should give low mean, got {mean}"); } - [Test] + [TestMethod] public void NegativeBinomial_LowP_ManyFailures() { // Low p means many failures expected @@ -136,7 +137,7 @@ public void NegativeBinomial_LowP_ManyFailures() Assert.IsTrue(mean > 50, $"Low p should give high mean, got {mean}"); } - [Test] + [TestMethod] public void NegativeBinomial_Scalar_ReturnsScalar() { var rng = np.random.RandomState(42); @@ -146,7 +147,7 @@ public void NegativeBinomial_Scalar_ReturnsScalar() Assert.AreEqual(1, result.size); } - [Test] + [TestMethod] public void NegativeBinomial_SameSeed_ProducesSameResults() { var rng1 = np.random.RandomState(42); @@ -163,37 +164,37 @@ public void NegativeBinomial_SameSeed_ProducesSameResults() // ========== Validation Tests ========== - [Test] + [TestMethod] public void NegativeBinomial_NZero_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.negative_binomial(0, 0.5, 5L)); } - [Test] + [TestMethod] public void NegativeBinomial_NNegative_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.negative_binomial(-1, 0.5, 5L)); } - [Test] + [TestMethod] public void NegativeBinomial_PZero_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.negative_binomial(10, 0, 5L)); } - [Test] + [TestMethod] public void NegativeBinomial_PNegative_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.negative_binomial(10, -0.1, 5L)); } - [Test] + [TestMethod] public void NegativeBinomial_PGreaterThanOne_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.negative_binomial(10, 1.5, 5L)); } - [Test] + [TestMethod] public void NegativeBinomial_PNaN_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.negative_binomial(10, double.NaN, 5L)); @@ -205,7 +206,7 @@ public void NegativeBinomial_PNaN_ThrowsArgumentException() /// Migrated from NumPy test_randomstate.py /// Test that negative binomial accepts floating point arguments. /// - [Test] + [TestMethod] public void NegativeBinomial_NumPy_AcceptsFloatN() { // From NumPy: random_state.negative_binomial(0.5, 0.5) @@ -218,7 +219,7 @@ public void NegativeBinomial_NumPy_AcceptsFloatN() /// Migrated from NumPy test_smoke.py /// Basic smoke test. /// - [Test] + [TestMethod] public void NegativeBinomial_NumPy_SmokeTest() { var vals = np.random.negative_binomial(10, 0.3, 10L); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.noncentral_chisquare.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.noncentral_chisquare.Test.cs index 597a38cbd..9a0e165d6 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.noncentral_chisquare.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.noncentral_chisquare.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.RandomSampling; /// Mean = df + nonc /// + [TestClass] public class RandomNoncentralChisquareTests : TestClass { - [Test] + [TestMethod] public void NoncentralChisquare_ScalarCall_ReturnsDouble() { var rng = np.random.RandomState(42); @@ -19,7 +20,7 @@ public void NoncentralChisquare_ScalarCall_ReturnsDouble() Assert.IsTrue(result >= 0, $"Result {result} should be non-negative"); } - [Test] + [TestMethod] public void NoncentralChisquare_ArraySize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -28,7 +29,7 @@ public void NoncentralChisquare_ArraySize_ReturnsCorrectShape() Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void NoncentralChisquare_MultiDimensionalSize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -36,7 +37,7 @@ public void NoncentralChisquare_MultiDimensionalSize_ReturnsCorrectShape() result.Should().BeShaped(2, 3); } - [Test] + [TestMethod] public void NoncentralChisquare_ShapeSize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -44,7 +45,7 @@ public void NoncentralChisquare_ShapeSize_ReturnsCorrectShape() result.Should().BeShaped(3, 4); } - [Test] + [TestMethod] public void NoncentralChisquare_AllValuesNonNegative() { var rng = np.random.RandomState(12345); @@ -57,7 +58,7 @@ public void NoncentralChisquare_AllValuesNonNegative() } } - [Test] + [TestMethod] public void NoncentralChisquare_MeanConvergesToExpected() { // Mean = df + nonc = 3 + 2 = 5 @@ -69,7 +70,7 @@ public void NoncentralChisquare_MeanConvergesToExpected() $"Mean {mean} should be close to 5 (df + nonc)"); } - [Test] + [TestMethod] public void NoncentralChisquare_ZeroNonc_IsCentralChisquare() { // When nonc=0, it's central chi-square with mean = df @@ -81,7 +82,7 @@ public void NoncentralChisquare_ZeroNonc_IsCentralChisquare() $"Mean {mean} should be close to 3 (df) when nonc=0"); } - [Test] + [TestMethod] public void NoncentralChisquare_SmallDf() { // df <= 1 uses the Poisson method @@ -101,7 +102,7 @@ public void NoncentralChisquare_SmallDf() $"Mean {mean} should be close to 2.5"); } - [Test] + [TestMethod] public void NoncentralChisquare_LargeDf() { // Large df should work correctly @@ -114,7 +115,7 @@ public void NoncentralChisquare_LargeDf() $"Mean {mean} should be close to 15"); } - [Test] + [TestMethod] public void NoncentralChisquare_LargeNonc() { // Large non-centrality @@ -127,37 +128,37 @@ public void NoncentralChisquare_LargeNonc() $"Mean {mean} should be close to 23"); } - [Test] + [TestMethod] public void NoncentralChisquare_ZeroDf_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.noncentral_chisquare(0, 2, 5L)); } - [Test] + [TestMethod] public void NoncentralChisquare_NegativeDf_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.noncentral_chisquare(-1, 2, 5L)); } - [Test] + [TestMethod] public void NoncentralChisquare_NegativeNonc_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.noncentral_chisquare(3, -1, 5L)); } - [Test] + [TestMethod] public void NoncentralChisquare_ScalarZeroDf_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.noncentral_chisquare(0, 2)); } - [Test] + [TestMethod] public void NoncentralChisquare_ScalarNegativeNonc_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.noncentral_chisquare(3, -1)); } - [Test] + [TestMethod] public void NoncentralChisquare_Reproducibility() { var rng1 = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.noncentral_f.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.noncentral_f.Test.cs index e805789e1..ecdf83abf 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.noncentral_f.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.noncentral_f.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NoncentralFTests { - [Test] + [TestMethod] public void NoncentralF_ReturnsScalar_WhenNoSize() { var rng = np.random.RandomState(42); @@ -20,7 +21,7 @@ public void NoncentralF_ReturnsScalar_WhenNoSize() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void NoncentralF_Returns1DArray() { var rng = np.random.RandomState(42); @@ -30,7 +31,7 @@ public void NoncentralF_Returns1DArray() result.size.Should().Be(5); } - [Test] + [TestMethod] public void NoncentralF_Returns2DArray() { var rng = np.random.RandomState(42); @@ -40,7 +41,7 @@ public void NoncentralF_Returns2DArray() result.size.Should().Be(6); } - [Test] + [TestMethod] public void NoncentralF_AllValuesPositive() { var rng = np.random.RandomState(42); @@ -50,7 +51,7 @@ public void NoncentralF_AllValuesPositive() min.Should().BeGreaterThan(0.0); } - [Test] + [TestMethod] public void NoncentralF_NoncZero_IsCentralF() { // When nonc=0, should behave like central F distribution @@ -67,7 +68,7 @@ public void NoncentralF_NoncZero_IsCentralF() Math.Abs(mean - 1.25).Should().BeLessThan(0.1); } - [Test] + [TestMethod] public void NoncentralF_LargeNonc_IncreasesValues() { var rng1 = np.random.RandomState(42); @@ -82,7 +83,7 @@ public void NoncentralF_LargeNonc_IncreasesValues() meanLarge.Should().BeGreaterThan(meanSmall); } - [Test] + [TestMethod] public void NoncentralF_DifferentDf_Works() { var rng = np.random.RandomState(42); @@ -93,42 +94,42 @@ public void NoncentralF_DifferentDf_Works() min.Should().BeGreaterThan(0.0); } - [Test] + [TestMethod] public void NoncentralF_DfnumZero_ThrowsArgumentException() { Action act = () => np.random.noncentral_f(0, 10, 2); act.Should().Throw(); } - [Test] + [TestMethod] public void NoncentralF_DfnumNegative_ThrowsArgumentException() { Action act = () => np.random.noncentral_f(-1, 10, 2); act.Should().Throw(); } - [Test] + [TestMethod] public void NoncentralF_DfdenZero_ThrowsArgumentException() { Action act = () => np.random.noncentral_f(5, 0, 2); act.Should().Throw(); } - [Test] + [TestMethod] public void NoncentralF_DfdenNegative_ThrowsArgumentException() { Action act = () => np.random.noncentral_f(5, -1, 2); act.Should().Throw(); } - [Test] + [TestMethod] public void NoncentralF_NoncNegative_ThrowsArgumentException() { Action act = () => np.random.noncentral_f(5, 10, -1); act.Should().Throw(); } - [Test] + [TestMethod] public void NoncentralF_ShapeOverload_Works() { var rng = np.random.RandomState(42); @@ -137,7 +138,7 @@ public void NoncentralF_ShapeOverload_Works() result.shape.Should().ContainInOrder(3, 4); } - [Test] + [TestMethod] public void NoncentralF_Reproducibility_WithSeed() { var rng1 = np.random.RandomState(42); @@ -149,7 +150,7 @@ public void NoncentralF_Reproducibility_WithSeed() first.Should().BeEquivalentTo(second); } - [Test] + [TestMethod] public void NoncentralF_SmallDf_Works() { // df < 1 uses different algorithm branch in noncentral chisquare diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.normal.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.normal.Test.cs index 960e1400f..1ea8e20b9 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.normal.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.normal.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomNormalTest { - [Test] + [TestMethod] public void NormalDistributionTest() { // https://numpy.org/doc/stable/reference/random/generated/numpy.random.normal.html diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.pareto.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.pareto.Test.cs index 4e9969ffc..0bc26c5f0 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.pareto.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.pareto.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.RandomSampling; /// NumPy's pareto returns samples from Pareto II (Lomax) distribution. /// + [TestClass] public class RandomParetoTests : TestClass { - [Test] + [TestMethod] public void Pareto_ScalarCall_Returns0dArray() { var rng = np.random.RandomState(42); @@ -20,7 +21,7 @@ public void Pareto_ScalarCall_Returns0dArray() Assert.IsTrue(result.GetDouble() >= 0, "Pareto samples should be non-negative"); } - [Test] + [TestMethod] public void Pareto_ArraySize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -29,7 +30,7 @@ public void Pareto_ArraySize_ReturnsCorrectShape() Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void Pareto_MultiDimensionalSize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -37,7 +38,7 @@ public void Pareto_MultiDimensionalSize_ReturnsCorrectShape() result.Should().BeShaped(2, 3); } - [Test] + [TestMethod] public void Pareto_ShapeSize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -45,7 +46,7 @@ public void Pareto_ShapeSize_ReturnsCorrectShape() result.Should().BeShaped(3, 4); } - [Test] + [TestMethod] public void Pareto_AllValuesNonNegative() { var rng = np.random.RandomState(12345); @@ -58,7 +59,7 @@ public void Pareto_AllValuesNonNegative() } } - [Test] + [TestMethod] public void Pareto_MeanConvergesToExpected() { // For Pareto II (Lomax), mean = 1/(a-1) for a > 1 @@ -72,7 +73,7 @@ public void Pareto_MeanConvergesToExpected() $"Mean {mean} should be close to 0.5 for a=3"); } - [Test] + [TestMethod] public void Pareto_DifferentShapeParameters() { // Higher 'a' means heavier tail @@ -88,31 +89,31 @@ public void Pareto_DifferentShapeParameters() $"Mean with a=0.5 ({mean_low}) should be > mean with a=5 ({mean_high})"); } - [Test] + [TestMethod] public void Pareto_ZeroParameter_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.pareto(0.0, 5L)); } - [Test] + [TestMethod] public void Pareto_NegativeParameter_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.pareto(-1.0, 5L)); } - [Test] + [TestMethod] public void Pareto_ScalarZeroParameter_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.pareto(0.0)); } - [Test] + [TestMethod] public void Pareto_ScalarNegativeParameter_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.pareto(-2.0)); } - [Test] + [TestMethod] public void Pareto_SmallA_ProducesLargerValues() { // Small 'a' produces heavier tails (more extreme values) @@ -125,7 +126,7 @@ public void Pareto_SmallA_ProducesLargerValues() $"With a=0.5, max value {max_val} should be > 10"); } - [Test] + [TestMethod] public void Pareto_LargeA_ProducesSmallValues() { // Large 'a' concentrates values near zero @@ -138,7 +139,7 @@ public void Pareto_LargeA_ProducesSmallValues() $"With a=10, max value {max_val} should be < 2"); } - [Test] + [TestMethod] public void Pareto_Reproducibility() { var rng1 = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.poisson.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.poisson.Test.cs index be600bd36..70ba96f98 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.poisson.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.poisson.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomPoissonTests : TestClass { - [Test] + [TestMethod] public void Rand1D() { var rand = np.random.poisson(0.2, 5); @@ -17,7 +18,7 @@ public void Rand1D() Assert.IsTrue(rand.size == 5); } - [Test] + [TestMethod] public void Rand2D() { var rand = np.random.poisson(0.2, new Shape(5, 5)); @@ -25,7 +26,7 @@ public void Rand2D() Assert.IsTrue(rand.size == 25); } - [Test] + [TestMethod] public void Rand2DByShape() { var rand = np.random.poisson(0.2, new Shape(5, 5)); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.power.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.power.Test.cs index 81f9273f0..e0279331f 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.power.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.power.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.RandomSampling; /// Power distribution with PDF: P(x; a) = a * x^(a-1), 0 <= x <= 1, a > 0 /// + [TestClass] public class RandomPowerTests : TestClass { - [Test] + [TestMethod] public void Power_ScalarCall_ReturnsDouble() { var rng = np.random.RandomState(42); @@ -19,7 +20,7 @@ public void Power_ScalarCall_ReturnsDouble() Assert.IsTrue(result >= 0 && result <= 1, $"Result {result} should be in [0, 1]"); } - [Test] + [TestMethod] public void Power_ArraySize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -28,7 +29,7 @@ public void Power_ArraySize_ReturnsCorrectShape() Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void Power_MultiDimensionalSize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -36,7 +37,7 @@ public void Power_MultiDimensionalSize_ReturnsCorrectShape() result.Should().BeShaped(2, 3); } - [Test] + [TestMethod] public void Power_ShapeSize_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -44,7 +45,7 @@ public void Power_ShapeSize_ReturnsCorrectShape() result.Should().BeShaped(3, 4); } - [Test] + [TestMethod] public void Power_AllValuesInRange() { // All values must be in [0, 1] @@ -58,7 +59,7 @@ public void Power_AllValuesInRange() Assert.IsTrue(max <= 1, $"Max {max} should be <= 1"); } - [Test] + [TestMethod] public void Power_HigherA_SkewsTowardOne() { // Higher 'a' skews distribution toward 1 @@ -73,7 +74,7 @@ public void Power_HigherA_SkewsTowardOne() $"Mean with a=5 ({mean_high}) should be > mean with a=0.5 ({mean_low})"); } - [Test] + [TestMethod] public void Power_A1_IsUniform() { // When a=1, PDF = 1 for 0<=x<=1, which is uniform @@ -86,7 +87,7 @@ public void Power_A1_IsUniform() $"Mean {mean} should be close to 0.5 for a=1 (uniform)"); } - [Test] + [TestMethod] public void Power_MeanConvergesToExpected() { // For power distribution, mean = a / (a + 1) @@ -102,31 +103,31 @@ public void Power_MeanConvergesToExpected() $"Mean {mean} should be close to {expectedMean}"); } - [Test] + [TestMethod] public void Power_ZeroParameter_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.power(0.0, 5L)); } - [Test] + [TestMethod] public void Power_NegativeParameter_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.power(-1.0, 5L)); } - [Test] + [TestMethod] public void Power_ScalarZeroParameter_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.power(0.0)); } - [Test] + [TestMethod] public void Power_ScalarNegativeParameter_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.power(-2.0)); } - [Test] + [TestMethod] public void Power_Reproducibility() { var rng1 = np.random.RandomState(42); @@ -142,7 +143,7 @@ public void Power_Reproducibility() } } - [Test] + [TestMethod] public void Power_SmallA_SkewsTowardZero() { // Small 'a' (< 1) skews distribution toward 0 diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.rand.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.rand.Test.cs index 30409b77b..c8fdb17da 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.rand.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.rand.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomRandTests : TestClass { - [Test] + [TestMethod] public void Rand1D() { var rand = np.random.rand(5L); @@ -18,7 +19,7 @@ public void Rand1D() Assert.IsTrue(rand.size == 5); } - [Test] + [TestMethod] public void Rand1DByShape() { var rand = np.random.rand(new Shape(5)); @@ -27,7 +28,7 @@ public void Rand1DByShape() Assert.IsTrue(rand.size == 5); } - [Test] + [TestMethod] public void Rand2D() { var rand = np.random.rand(5L, 5L); @@ -36,7 +37,7 @@ public void Rand2D() Assert.IsTrue(rand.size == 25); } - [Test] + [TestMethod] public void Rand2DByShape() { var rand = np.random.rand(new Shape(5, 5)); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.randint.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.randint.Test.cs index c71645223..9cd42a5aa 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.randint.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.randint.Test.cs @@ -10,9 +10,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomRandintTest { - [Test] + [TestMethod] public void randint() { var a = np.random.RandomState().randint(low: 0, high: 10, size: new Shape(5, 5)); @@ -22,7 +23,7 @@ public void randint() /// /// Based on issue https://github.com/SciSharp/NumSharp/issues/292 /// - [Test] + [TestMethod] public void randint_2() { for (int i = 0; i < 50; i++) diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.rayleigh.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.rayleigh.Test.cs index 15c6138a4..0af0040f6 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.rayleigh.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.rayleigh.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling /// Tests for np.random.rayleigh (Rayleigh distribution) /// + [TestClass] public class NpRandomRayleighTests : TestClass { - [Test] + [TestMethod] public void Rayleigh_1D_ReturnsCorrectShape() { var rand = np.random.rayleigh(1, 5L); @@ -17,7 +18,7 @@ public void Rayleigh_1D_ReturnsCorrectShape() Assert.AreEqual(5, rand.size); } - [Test] + [TestMethod] public void Rayleigh_2D_ReturnsCorrectShape() { var rand = np.random.rayleigh(1, new Shape(5, 5)); @@ -25,7 +26,7 @@ public void Rayleigh_2D_ReturnsCorrectShape() Assert.AreEqual(25, rand.size); } - [Test] + [TestMethod] public void Rayleigh_2DByShape_ReturnsCorrectShape() { var rand = np.random.rayleigh(1, new Shape(5, 5)); @@ -33,7 +34,7 @@ public void Rayleigh_2DByShape_ReturnsCorrectShape() Assert.AreEqual(25, rand.size); } - [Test] + [TestMethod] public void Rayleigh_DefaultParameters_HasCorrectStatistics() { // Rayleigh(scale=1) has mean = sqrt(pi/2) ≈ 1.253 @@ -50,7 +51,7 @@ public void Rayleigh_DefaultParameters_HasCorrectStatistics() Assert.IsTrue(Math.Abs(std - 0.655) < 0.05, $"Std should be near 0.655, got {std}"); } - [Test] + [TestMethod] public void Rayleigh_WithScale_TransformsCorrectly() { // Rayleigh(scale) has mean = scale * sqrt(pi/2) @@ -64,13 +65,13 @@ public void Rayleigh_WithScale_TransformsCorrectly() Assert.IsTrue(Math.Abs(mean - expectedMean) < 0.1, $"Mean should be near {expectedMean}, got {mean}"); } - [Test] + [TestMethod] public void Rayleigh_NegativeScale_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.rayleigh(-1, 5L)); } - [Test] + [TestMethod] public void Rayleigh_ScaleZero_ReturnsAllZeros() { var samples = np.random.rayleigh(0.0, 5L); @@ -81,7 +82,7 @@ public void Rayleigh_ScaleZero_ReturnsAllZeros() } } - [Test] + [TestMethod] public void Rayleigh_Scalar_ReturnsScalar() { var rng = np.random.RandomState(42); @@ -91,14 +92,14 @@ public void Rayleigh_Scalar_ReturnsScalar() Assert.AreEqual(1, result.size); } - [Test] + [TestMethod] public void Rayleigh_ReturnsFloat64() { var result = np.random.rayleigh(1, 5L); Assert.AreEqual(NPTypeCode.Double, result.typecode); } - [Test] + [TestMethod] public void Rayleigh_AllValuesPositive() { // Rayleigh distribution only produces non-negative values @@ -111,7 +112,7 @@ public void Rayleigh_AllValuesPositive() } } - [Test] + [TestMethod] public void Rayleigh_SameSeed_ProducesSameResults() { var rng1 = np.random.RandomState(42); @@ -126,7 +127,7 @@ public void Rayleigh_SameSeed_ProducesSameResults() } } - [Test] + [TestMethod] public void Rayleigh_DifferentSeeds_ProduceDifferentResults() { var rng1 = np.random.RandomState(42); @@ -153,7 +154,7 @@ public void Rayleigh_DifferentSeeds_ProduceDifferentResults() /// Migrated from NumPy test_random.py test_rayleigh_0 /// Tests that scale=0 returns 0. /// - [Test] + [TestMethod] public void Rayleigh_NumPy_ScaleZeroReturnsZero() { // From NumPy: assert_equal(np.random.rayleigh(scale=0), 0) @@ -165,7 +166,7 @@ public void Rayleigh_NumPy_ScaleZeroReturnsZero() /// Migrated from NumPy test_random.py test_rayleigh_0 /// Negative scale should raise ValueError. /// - [Test] + [TestMethod] public void Rayleigh_NumPy_NegativeScaleRaises() { // From NumPy: assert_raises(ValueError, np.random.rayleigh, scale=-0.) @@ -177,7 +178,7 @@ public void Rayleigh_NumPy_NegativeScaleRaises() /// Migrated from NumPy test_smoke.py test_rayleigh /// Basic smoke test that rayleigh produces correct output size. /// - [Test] + [TestMethod] public void Rayleigh_NumPy_SmokeTest() { // From NumPy: vals = rg.rayleigh(0.2, 10); assert_(len(vals) == 10) diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.shuffle.NumPyAligned.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.shuffle.NumPyAligned.Test.cs index b2014cfaf..4b1308d7a 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.shuffle.NumPyAligned.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.shuffle.NumPyAligned.Test.cs @@ -13,9 +13,10 @@ namespace NumSharp.UnitTest.RandomSampling; /// For axis support, use the Generator API (not yet implemented in NumSharp). /// + [TestClass] public class ShuffleNumPyAlignedTests : TestClass { - [Test] + [TestMethod] public void Shuffle_1D_ShufflesElements() { var arr = np.arange(10); @@ -28,7 +29,7 @@ public void Shuffle_1D_ShufflesElements() Assert.AreEqual(originalSum, (int)np.sum(arr)); } - [Test] + [TestMethod] public void Shuffle_2D_ShufflesRowsOnly() { // NumPy: shuffle only shuffles along axis 0 (rows for 2D) @@ -49,7 +50,7 @@ public void Shuffle_2D_ShufflesRowsOnly() CollectionAssert.AreEqual(new[] { 3, 12, 21 }, sums); } - [Test] + [TestMethod] public void Shuffle_3D_ShufflesFirstDimension() { var arr = np.arange(24).reshape(2, 3, 4); @@ -73,7 +74,7 @@ public void Shuffle_3D_ShufflesFirstDimension() CollectionAssert.AreEqual(expectedSums, sums); } - [Test] + [TestMethod] public void Shuffle_SingleElement_NoOp() { var arr = np.array(new[] { 42 }); @@ -81,7 +82,7 @@ public void Shuffle_SingleElement_NoOp() Assert.AreEqual(42, (int)arr[0]); } - [Test] + [TestMethod] public void Shuffle_4D_ShufflesFirstDimension() { var arr = np.arange(120).reshape(2, 3, 4, 5); @@ -104,7 +105,7 @@ public void Shuffle_4D_ShufflesFirstDimension() CollectionAssert.AreEqual(expectedSums, blockSums); } - [Test] + [TestMethod] public void Shuffle_PreservesRowContents() { // Key NumPy behavior: row contents are unchanged, only order changes diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.shuffle.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.shuffle.Test.cs index 44bf7bec4..0231b6b98 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.shuffle.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.shuffle.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomShuffleTest : TestClass { - [Test] + [TestMethod] public void Base1DTest() { // NumPy-aligned: shuffle reorders elements but preserves all values @@ -28,7 +29,7 @@ public void Base1DTest() nd.Shape.Should().BeShaped(10); } - [Test] + [TestMethod] public void Base4DTest() { // NumPy-aligned: shuffle along axis 0 (first dimension) diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.standard_cauchy.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.standard_cauchy.Test.cs index 402de92b1..880aa4c5a 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.standard_cauchy.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.standard_cauchy.Test.cs @@ -5,9 +5,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomStandardCauchyTest : TestClass { - [Test] + [TestMethod] public void StandardCauchy_ScalarReturn() { var rng = np.random.RandomState(42); @@ -17,7 +18,7 @@ public void StandardCauchy_ScalarReturn() Assert.AreEqual(1, result.size); } - [Test] + [TestMethod] public void StandardCauchy_1DArray() { var result = np.random.standard_cauchy(5L); @@ -27,7 +28,7 @@ public void StandardCauchy_1DArray() Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void StandardCauchy_2DArray() { var result = np.random.standard_cauchy(new Shape(2, 3)); @@ -37,7 +38,7 @@ public void StandardCauchy_2DArray() Assert.AreEqual(3, result.shape[1]); } - [Test] + [TestMethod] public void StandardCauchy_ShapeOverload() { var result = np.random.standard_cauchy(new Shape(10, 5)); @@ -46,7 +47,7 @@ public void StandardCauchy_ShapeOverload() Assert.AreEqual(5, result.shape[1]); } - [Test] + [TestMethod] public void StandardCauchy_MedianNearZero() { // Cauchy has no mean/variance, but median = 0 @@ -60,7 +61,7 @@ public void StandardCauchy_MedianNearZero() Assert.IsTrue(Math.Abs(median) < 0.05, $"Median {median} should be close to 0"); } - [Test] + [TestMethod] public void StandardCauchy_InterquartileRange() { // For standard Cauchy, Q1 = -1, Q3 = 1, so IQR = 2 @@ -80,7 +81,7 @@ public void StandardCauchy_InterquartileRange() Assert.IsTrue(Math.Abs(q3 - 1.0) < 0.05, $"Q3 {q3} should be close to 1"); } - [Test] + [TestMethod] public void StandardCauchy_HasHeavyTails() { // Cauchy has heavy tails - should have some extreme values @@ -95,7 +96,7 @@ public void StandardCauchy_HasHeavyTails() $"Should have extreme values (max={max}, min={min})"); } - [Test] + [TestMethod] public void StandardCauchy_ReturnsFloat64() { var result = np.random.standard_cauchy(size: new Shape(5)); @@ -103,7 +104,7 @@ public void StandardCauchy_ReturnsFloat64() Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void StandardCauchy_EmptySize() { var result = np.random.standard_cauchy(0L); @@ -112,7 +113,7 @@ public void StandardCauchy_EmptySize() Assert.AreEqual(0, result.size); } - [Test] + [TestMethod] public void StandardCauchy_Reproducible() { var rng1 = np.random.RandomState(123); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.standard_exponential.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.standard_exponential.Test.cs index e7847ca84..06816931b 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.standard_exponential.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.standard_exponential.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling /// Tests for np.random.standard_exponential (standard exponential distribution) /// + [TestClass] public class NpRandomStandardExponentialTests : TestClass { - [Test] + [TestMethod] public void StandardExponential_1D_ReturnsCorrectShape() { var rand = np.random.standard_exponential(5L); @@ -17,7 +18,7 @@ public void StandardExponential_1D_ReturnsCorrectShape() Assert.AreEqual(5, rand.size); } - [Test] + [TestMethod] public void StandardExponential_2D_ReturnsCorrectShape() { var rand = np.random.standard_exponential(new Shape(5, 5)); @@ -25,7 +26,7 @@ public void StandardExponential_2D_ReturnsCorrectShape() Assert.AreEqual(25, rand.size); } - [Test] + [TestMethod] public void StandardExponential_2DByShape_ReturnsCorrectShape() { var rand = np.random.standard_exponential(new Shape(2, 3)); @@ -33,14 +34,14 @@ public void StandardExponential_2DByShape_ReturnsCorrectShape() Assert.AreEqual(6, rand.size); } - [Test] + [TestMethod] public void StandardExponential_ReturnsFloat64() { var result = np.random.standard_exponential(5L); Assert.AreEqual(NPTypeCode.Double, result.typecode); } - [Test] + [TestMethod] public void StandardExponential_AllValuesPositive() { // Exponential distribution produces strictly positive values @@ -53,7 +54,7 @@ public void StandardExponential_AllValuesPositive() } } - [Test] + [TestMethod] public void StandardExponential_HasCorrectMean() { // mean = 1 for standard exponential @@ -68,7 +69,7 @@ public void StandardExponential_HasCorrectMean() Assert.IsTrue(Math.Abs(mean - 1.0) < 0.05, $"Mean should be near 1.0, got {mean}"); } - [Test] + [TestMethod] public void StandardExponential_HasCorrectVariance() { // variance = 1 for standard exponential @@ -88,7 +89,7 @@ public void StandardExponential_HasCorrectVariance() Assert.IsTrue(Math.Abs(variance - 1.0) < 0.1, $"Variance should be near 1.0, got {variance}"); } - [Test] + [TestMethod] public void StandardExponential_Scalar_ReturnsScalar() { var rng = np.random.RandomState(42); @@ -98,7 +99,7 @@ public void StandardExponential_Scalar_ReturnsScalar() Assert.AreEqual(1, result.size); } - [Test] + [TestMethod] public void StandardExponential_SameSeed_ProducesSameResults() { var rng1 = np.random.RandomState(42); @@ -113,7 +114,7 @@ public void StandardExponential_SameSeed_ProducesSameResults() } } - [Test] + [TestMethod] public void StandardExponential_EquivalentToExponentialScale1() { // standard_exponential() should be equivalent to exponential(scale=1) @@ -129,7 +130,7 @@ public void StandardExponential_EquivalentToExponentialScale1() } } - [Test] + [TestMethod] public void StandardExponential_Size1_ReturnsShape1Array() { var result = np.random.standard_exponential(1L); @@ -137,7 +138,7 @@ public void StandardExponential_Size1_ReturnsShape1Array() Assert.AreEqual(1, result.size); } - [Test] + [TestMethod] public void StandardExponential_LargeSample_NoInfinities() { var rng = np.random.RandomState(42); @@ -156,7 +157,7 @@ public void StandardExponential_LargeSample_NoInfinities() /// Migrated from NumPy test_randomstate.py /// Basic smoke test. /// - [Test] + [TestMethod] public void StandardExponential_NumPy_SmokeTest() { var vals = np.random.standard_exponential(10L); @@ -166,7 +167,7 @@ public void StandardExponential_NumPy_SmokeTest() /// /// Migrated from NumPy - verify output is always positive. /// - [Test] + [TestMethod] public void StandardExponential_NumPy_OutputAlwaysPositive() { var rng = np.random.RandomState(12345); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.standard_gamma.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.standard_gamma.Test.cs index dbc7dc8ea..4317afb57 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.standard_gamma.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.standard_gamma.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class StandardGammaTests { - [Test] + [TestMethod] public void StandardGamma_ReturnsScalar_WhenNoSize() { var rng = np.random.RandomState(42); @@ -20,7 +21,7 @@ public void StandardGamma_ReturnsScalar_WhenNoSize() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void StandardGamma_Returns1DArray() { var rng = np.random.RandomState(42); @@ -30,7 +31,7 @@ public void StandardGamma_Returns1DArray() result.size.Should().Be(5); } - [Test] + [TestMethod] public void StandardGamma_Returns2DArray() { var rng = np.random.RandomState(42); @@ -40,7 +41,7 @@ public void StandardGamma_Returns2DArray() result.size.Should().Be(6); } - [Test] + [TestMethod] public void StandardGamma_AllValuesPositive() { var rng = np.random.RandomState(42); @@ -50,7 +51,7 @@ public void StandardGamma_AllValuesPositive() min.Should().BeGreaterThan(0.0); } - [Test] + [TestMethod] public void StandardGamma_HasExpectedMean_Shape2() { // For standard gamma: mean = shape @@ -61,7 +62,7 @@ public void StandardGamma_HasExpectedMean_Shape2() Math.Abs(mean - 2.0).Should().BeLessThan(0.05); } - [Test] + [TestMethod] public void StandardGamma_HasExpectedStd_Shape2() { // For standard gamma: variance = shape, std = sqrt(shape) @@ -73,7 +74,7 @@ public void StandardGamma_HasExpectedStd_Shape2() Math.Abs(std - expectedStd).Should().BeLessThan(0.05); } - [Test] + [TestMethod] public void StandardGamma_HasExpectedMean_Shape5() { var rng = np.random.RandomState(42); @@ -83,7 +84,7 @@ public void StandardGamma_HasExpectedMean_Shape5() Math.Abs(mean - 5.0).Should().BeLessThan(0.1); } - [Test] + [TestMethod] public void StandardGamma_HasExpectedStd_Shape5() { var rng = np.random.RandomState(42); @@ -94,7 +95,7 @@ public void StandardGamma_HasExpectedStd_Shape5() Math.Abs(std - expectedStd).Should().BeLessThan(0.1); } - [Test] + [TestMethod] public void StandardGamma_ShapeLessThanOne_Works() { // Shape < 1 uses different algorithm branch @@ -112,7 +113,7 @@ public void StandardGamma_ShapeLessThanOne_Works() Math.Abs(mean - 0.5).Should().BeLessThan(0.05); } - [Test] + [TestMethod] public void StandardGamma_ShapeZero_ReturnsZeros() { // Special case: shape=0 returns all zeros (NumPy behavior) @@ -125,14 +126,14 @@ public void StandardGamma_ShapeZero_ReturnsZeros() } } - [Test] + [TestMethod] public void StandardGamma_ShapeNegative_ThrowsArgumentException() { Action act = () => np.random.standard_gamma(-1); act.Should().Throw(); } - [Test] + [TestMethod] public void StandardGamma_ShapeOverload_Works() { var rng = np.random.RandomState(42); @@ -141,7 +142,7 @@ public void StandardGamma_ShapeOverload_Works() result.shape.Should().ContainInOrder(3, 4); } - [Test] + [TestMethod] public void StandardGamma_Reproducibility_WithSeed() { var rng1 = np.random.RandomState(42); @@ -153,7 +154,7 @@ public void StandardGamma_Reproducibility_WithSeed() first.Should().BeEquivalentTo(second); } - [Test] + [TestMethod] public void StandardGamma_FractionalShape_Works() { var rng = np.random.RandomState(42); @@ -165,7 +166,7 @@ public void StandardGamma_FractionalShape_Works() Math.Abs(mean - 2.5).Should().BeLessThan(0.2); } - [Test] + [TestMethod] public void StandardGamma_VerySmallShape_AllPositive() { var rng = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.standard_normal.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.standard_normal.Test.cs index 37b072573..d183bc8f2 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.standard_normal.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.standard_normal.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest.RandomSampling /// Tests for np.random.standard_normal (standard normal distribution with mean=0, std=1). /// NumPy reference: https://numpy.org/doc/stable/reference/random/generated/numpy.random.standard_normal.html /// + [TestClass] public class NpRandomStandardNormalTest : TestClass { - [Test] + [TestMethod] public void StandardNormal_NoArgs_ReturnsScalar() { // Python: np.random.standard_normal() returns a single float @@ -23,7 +24,7 @@ public void StandardNormal_NoArgs_ReturnsScalar() Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void StandardNormal_Size5_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -34,7 +35,7 @@ public void StandardNormal_Size5_ReturnsCorrectShape() Assert.AreEqual(5, result.shape[0]); } - [Test] + [TestMethod] public void StandardNormal_2DShape_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -46,7 +47,7 @@ public void StandardNormal_2DShape_ReturnsCorrectShape() Assert.AreEqual(3, result.shape[1]); } - [Test] + [TestMethod] public void StandardNormal_ShapeOverload_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -58,7 +59,7 @@ public void StandardNormal_ShapeOverload_ReturnsCorrectShape() Assert.AreEqual(20, result.shape[1]); } - [Test] + [TestMethod] public void StandardNormal_EmptySize_ReturnsEmptyArray() { var rng = np.random.RandomState(42); @@ -68,14 +69,14 @@ public void StandardNormal_EmptySize_ReturnsEmptyArray() Assert.AreEqual(0, result.size); } - [Test] + [TestMethod] public void StandardNormal_ReturnsFloat64() { var result = np.random.standard_normal(5); Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void StandardNormal_MeanIsZero() { // Statistical test: mean of standard normal should be close to 0 @@ -86,7 +87,7 @@ public void StandardNormal_MeanIsZero() Assert.IsTrue(Math.Abs(mean) < 0.02, $"Mean {mean} should be close to 0"); } - [Test] + [TestMethod] public void StandardNormal_StdIsOne() { // Statistical test: std of standard normal should be close to 1 @@ -97,7 +98,7 @@ public void StandardNormal_StdIsOne() Assert.IsTrue(Math.Abs(std - 1.0) < 0.02, $"Std {std} should be close to 1"); } - [Test] + [TestMethod] public void StandardNormal_VarianceIsOne() { // Statistical test: variance of standard normal should be close to 1 @@ -108,7 +109,7 @@ public void StandardNormal_VarianceIsOne() Assert.IsTrue(Math.Abs(variance - 1.0) < 0.02, $"Variance {variance} should be close to 1"); } - [Test] + [TestMethod] public void StandardNormal_MatchesRandn() { // standard_normal and randn should produce equivalent statistical properties @@ -130,7 +131,7 @@ public void StandardNormal_MatchesRandn() Assert.IsTrue(Math.Abs(sn_std - 1.0) < 0.1, $"standard_normal std {sn_std} should be near 1"); } - [Test] + [TestMethod] public void StandardNormal_Reproducible() { // Same seed should produce same results @@ -144,7 +145,7 @@ public void StandardNormal_Reproducible() "Same seed should produce identical first values"); } - [Test] + [TestMethod] public void StandardNormal_DifferentSeeds_ProduceDifferentResults() { var rng1 = np.random.RandomState(42); @@ -157,7 +158,7 @@ public void StandardNormal_DifferentSeeds_ProduceDifferentResults() "Different seeds should produce different results"); } - [Test] + [TestMethod] public void StandardNormal_ValuesInReasonableRange() { // Standard normal values should mostly be in [-4, 4] range @@ -172,7 +173,7 @@ public void StandardNormal_ValuesInReasonableRange() } } - [Test] + [TestMethod] public void StandardNormal_3DShape_Works() { var result = np.random.standard_normal(new Shape(2, 3, 4)); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.standard_t.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.standard_t.Test.cs index 3d1d6236a..ef7fa9d7e 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.standard_t.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.standard_t.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class StandardTTests { - [Test] + [TestMethod] public void StandardT_ReturnsScalar_WhenNoSize() { var rng = np.random.RandomState(42); @@ -20,7 +21,7 @@ public void StandardT_ReturnsScalar_WhenNoSize() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void StandardT_Returns1DArray() { var rng = np.random.RandomState(42); @@ -30,7 +31,7 @@ public void StandardT_Returns1DArray() result.size.Should().Be(5); } - [Test] + [TestMethod] public void StandardT_Returns2DArray() { var rng = np.random.RandomState(42); @@ -40,7 +41,7 @@ public void StandardT_Returns2DArray() result.size.Should().Be(6); } - [Test] + [TestMethod] public void StandardT_HasMeanNearZero() { // For t distribution with df > 1: E[X] = 0 @@ -52,7 +53,7 @@ public void StandardT_HasMeanNearZero() Math.Abs(mean).Should().BeLessThan(0.05); } - [Test] + [TestMethod] public void StandardT_HasExpectedStd_df10() { // For t distribution: Var[X] = df/(df-2) for df > 2 @@ -65,7 +66,7 @@ public void StandardT_HasExpectedStd_df10() Math.Abs(std - expectedStd).Should().BeLessThan(0.05); } - [Test] + [TestMethod] public void StandardT_HasExpectedStd_df5() { // df=5: Var = 5/3, Std = sqrt(5/3) ≈ 1.291 @@ -77,7 +78,7 @@ public void StandardT_HasExpectedStd_df5() Math.Abs(std - expectedStd).Should().BeLessThan(0.1); } - [Test] + [TestMethod] public void StandardT_IsSymmetric() { // t distribution is symmetric around 0 @@ -96,7 +97,7 @@ public void StandardT_IsSymmetric() Math.Abs(ratio - 1.0).Should().BeLessThan(0.05); } - [Test] + [TestMethod] public void StandardT_LargeDf_ApproachesNormal() { // As df → ∞, t distribution approaches standard normal @@ -111,7 +112,7 @@ public void StandardT_LargeDf_ApproachesNormal() Math.Abs(std - 1.0).Should().BeLessThan(0.02); } - [Test] + [TestMethod] public void StandardT_SmallDf_HasHeavierTails() { // df=3 should have heavier tails than df=100 @@ -127,21 +128,21 @@ public void StandardT_SmallDf_HasHeavierTails() max3.Should().BeGreaterThan(max100); } - [Test] + [TestMethod] public void StandardT_DfZero_ThrowsArgumentException() { Action act = () => np.random.standard_t(0); act.Should().Throw(); } - [Test] + [TestMethod] public void StandardT_DfNegative_ThrowsArgumentException() { Action act = () => np.random.standard_t(-1); act.Should().Throw(); } - [Test] + [TestMethod] public void StandardT_ShapeOverload_Works() { var rng = np.random.RandomState(42); @@ -150,7 +151,7 @@ public void StandardT_ShapeOverload_Works() result.shape.Should().ContainInOrder(3, 4); } - [Test] + [TestMethod] public void StandardT_Reproducibility_WithSeed() { var rng1 = np.random.RandomState(42); @@ -162,7 +163,7 @@ public void StandardT_Reproducibility_WithSeed() first.Should().BeEquivalentTo(second); } - [Test] + [TestMethod] public void StandardT_FractionalDf_Works() { // df can be fractional diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.triangular.Tests.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.triangular.Tests.cs index 29630bfb3..853a7a9cf 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.triangular.Tests.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.triangular.Tests.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class TriangularTests { - [Test] + [TestMethod] public void Triangular_ReturnsScalar_WhenNoSize() { var rng = np.random.RandomState(42); @@ -20,7 +21,7 @@ public void Triangular_ReturnsScalar_WhenNoSize() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Triangular_Returns1DArray() { var rng = np.random.RandomState(42); @@ -30,7 +31,7 @@ public void Triangular_Returns1DArray() result.size.Should().Be(5); } - [Test] + [TestMethod] public void Triangular_Returns2DArray() { var rng = np.random.RandomState(42); @@ -40,7 +41,7 @@ public void Triangular_Returns2DArray() result.size.Should().Be(6); } - [Test] + [TestMethod] public void Triangular_AllValuesWithinBounds() { var rng = np.random.RandomState(42); @@ -53,7 +54,7 @@ public void Triangular_AllValuesWithinBounds() max.Should().BeLessThanOrEqualTo(1.0); } - [Test] + [TestMethod] public void Triangular_SymmetricMode_HasExpectedMean() { // For triangular(left, mode, right), mean = (left + mode + right) / 3 @@ -66,7 +67,7 @@ public void Triangular_SymmetricMode_HasExpectedMean() Math.Abs(mean - expectedMean).Should().BeLessThan(0.01); } - [Test] + [TestMethod] public void Triangular_LeftSkewed_HasExpectedMean() { // mode=0.1, mean should be (0 + 0.1 + 1) / 3 ≈ 0.3667 @@ -79,7 +80,7 @@ public void Triangular_LeftSkewed_HasExpectedMean() Math.Abs(mean - expectedMean).Should().BeLessThan(0.01); } - [Test] + [TestMethod] public void Triangular_RightSkewed_HasExpectedMean() { // mode=0.9, mean should be (0 + 0.9 + 1) / 3 ≈ 0.6333 @@ -92,7 +93,7 @@ public void Triangular_RightSkewed_HasExpectedMean() Math.Abs(mean - expectedMean).Should().BeLessThan(0.01); } - [Test] + [TestMethod] public void Triangular_ModeAtLeft_StillValid() { var rng = np.random.RandomState(42); @@ -107,7 +108,7 @@ public void Triangular_ModeAtLeft_StillValid() } } - [Test] + [TestMethod] public void Triangular_ModeAtRight_StillValid() { var rng = np.random.RandomState(42); @@ -122,7 +123,7 @@ public void Triangular_ModeAtRight_StillValid() } } - [Test] + [TestMethod] public void Triangular_NegativeRange_Works() { var rng = np.random.RandomState(42); @@ -136,28 +137,28 @@ public void Triangular_NegativeRange_Works() } } - [Test] + [TestMethod] public void Triangular_LeftGreaterThanMode_ThrowsArgumentException() { Action act = () => np.random.triangular(1, 0.5, 2); // left=1, mode=0.5, right=2 act.Should().Throw(); } - [Test] + [TestMethod] public void Triangular_ModeGreaterThanRight_ThrowsArgumentException() { Action act = () => np.random.triangular(0, 1.5, 1); // mode > right act.Should().Throw(); } - [Test] + [TestMethod] public void Triangular_LeftEqualsRight_ThrowsArgumentException() { Action act = () => np.random.triangular(5, 5, 5); // degenerate case not allowed act.Should().Throw(); } - [Test] + [TestMethod] public void Triangular_ShapeOverload_Works() { var rng = np.random.RandomState(42); @@ -166,7 +167,7 @@ public void Triangular_ShapeOverload_Works() result.shape.Should().ContainInOrder(3, 4); } - [Test] + [TestMethod] public void Triangular_Reproducibility_WithSeed() { var rng1 = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.uniform.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.uniform.Test.cs index 28fa8a3ef..3b23a89ac 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.uniform.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.uniform.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomUniformTests : TestClass { - [Test] + [TestMethod] public void UniformByNDArrays() { var low = np.array(1d, 2d, 3d, 4d, 5d); @@ -28,7 +29,7 @@ public void UniformByNDArrays() Assert.IsTrue(uniformed.size == 5); } - [Test] + [TestMethod] public void UniformByIntegers1D() { var low = 1d; @@ -43,7 +44,7 @@ public void UniformByIntegers1D() Assert.IsTrue(data[0] >= 1 && data[0] < 2); } - [Test] + [TestMethod] public void UniformByIntegers2D() { var low = 1d; diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.vonmises.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.vonmises.Test.cs index 9303e11d7..dee5da331 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.vonmises.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.vonmises.Test.cs @@ -10,11 +10,12 @@ namespace NumSharp.UnitTest.RandomSampling /// Based on NumPy 2.4.2 behavior. /// + [TestClass] public class np_random_vonmises_Tests : TestClass { #region Basic Functionality - [Test] + [TestMethod] public void VonMises_Scalar_ReturnsNDArray() { var rng = np.random.RandomState(42); @@ -24,7 +25,7 @@ public void VonMises_Scalar_ReturnsNDArray() result.ndim.Should().Be(0); // Scalar } - [Test] + [TestMethod] public void VonMises_1D_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -34,7 +35,7 @@ public void VonMises_1D_ReturnsCorrectShape() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void VonMises_2D_ReturnsCorrectShape() { var rng = np.random.RandomState(42); @@ -44,7 +45,7 @@ public void VonMises_2D_ReturnsCorrectShape() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void VonMises_SizeNull_ReturnsScalar() { var rng = np.random.RandomState(42); @@ -57,7 +58,7 @@ public void VonMises_SizeNull_ReturnsScalar() #region Range Verification - [Test] + [TestMethod] public void VonMises_ResultsInRange_MinusPiToPi() { // All results should be in [-pi, pi] @@ -72,7 +73,7 @@ public void VonMises_ResultsInRange_MinusPiToPi() } } - [Test] + [TestMethod] public void VonMises_Kappa0_UniformOnCircle() { // kappa=0 gives uniform distribution on [-pi, pi] @@ -94,7 +95,7 @@ public void VonMises_Kappa0_UniformOnCircle() Math.Abs(mean).Should().BeLessThan(0.1); } - [Test] + [TestMethod] public void VonMises_HighKappa_ConcentratedAroundMu() { // High kappa = concentrated around mu @@ -117,7 +118,7 @@ public void VonMises_HighKappa_ConcentratedAroundMu() std.Should().BeLessThan(0.15); } - [Test] + [TestMethod] public void VonMises_HighKappa_ConcentratedAroundMuPiHalf() { // High kappa around mu=pi/2 @@ -137,7 +138,7 @@ public void VonMises_HighKappa_ConcentratedAroundMuPiHalf() #region Kappa Parameter Ranges - [Test] + [TestMethod] public void VonMises_VerySmallKappa_NearUniform() { // kappa < 1e-8 uses uniform distribution @@ -153,7 +154,7 @@ public void VonMises_VerySmallKappa_NearUniform() } } - [Test] + [TestMethod] public void VonMises_VeryHighKappa_WrappedNormalFallback() { // kappa > 1e6 uses wrapped normal approximation @@ -175,7 +176,7 @@ public void VonMises_VeryHighKappa_WrappedNormalFallback() Math.Abs(mean).Should().BeLessThan(0.01); } - [Test] + [TestMethod] public void VonMises_VariousKappaValues_AllInRange() { var rng = np.random.RandomState(42); @@ -196,13 +197,13 @@ public void VonMises_VariousKappaValues_AllInRange() #region Validation - [Test] + [TestMethod] public void VonMises_NegativeKappa_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.vonmises(0, -1)); } - [Test] + [TestMethod] public void VonMises_SmallNegativeKappa_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.vonmises(0, -0.001)); @@ -212,7 +213,7 @@ public void VonMises_SmallNegativeKappa_ThrowsArgumentException() #region Mu Parameter - [Test] + [TestMethod] public void VonMises_DifferentMu_MeanFollowsMu() { var rng = np.random.RandomState(42); @@ -230,7 +231,7 @@ public void VonMises_DifferentMu_MeanFollowsMu() } } - [Test] + [TestMethod] public void VonMises_MuAtPi_WrapsCorrectly() { // mu = pi should wrap around properly @@ -250,7 +251,7 @@ public void VonMises_MuAtPi_WrapsCorrectly() #region Edge Cases - [Test] + [TestMethod] public void VonMises_EmptyShape_ReturnsEmptyArray() { var rng = np.random.RandomState(42); @@ -259,7 +260,7 @@ public void VonMises_EmptyShape_ReturnsEmptyArray() result.size.Should().Be(0); } - [Test] + [TestMethod] public void VonMises_Size1_ReturnsSingleElementArray() { var rng = np.random.RandomState(42); @@ -268,7 +269,7 @@ public void VonMises_Size1_ReturnsSingleElementArray() result.size.Should().Be(1); } - [Test] + [TestMethod] public void VonMises_Reproducibility_SameSeedSameResults() { var rng1 = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.wald.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.wald.Test.cs index 1f051e18e..450eb865f 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.wald.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.wald.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class WaldTests { - [Test] + [TestMethod] public void Wald_ReturnsScalar_WhenNoSize() { var rng = np.random.RandomState(42); @@ -20,7 +21,7 @@ public void Wald_ReturnsScalar_WhenNoSize() result.dtype.Should().Be(typeof(double)); } - [Test] + [TestMethod] public void Wald_Returns1DArray() { var rng = np.random.RandomState(42); @@ -30,7 +31,7 @@ public void Wald_Returns1DArray() result.size.Should().Be(5); } - [Test] + [TestMethod] public void Wald_Returns2DArray() { var rng = np.random.RandomState(42); @@ -40,7 +41,7 @@ public void Wald_Returns2DArray() result.size.Should().Be(6); } - [Test] + [TestMethod] public void Wald_AllValuesPositive() { var rng = np.random.RandomState(42); @@ -50,7 +51,7 @@ public void Wald_AllValuesPositive() min.Should().BeGreaterThan(0.0); } - [Test] + [TestMethod] public void Wald_HasExpectedMean() { // For Wald: E[X] = mean @@ -62,7 +63,7 @@ public void Wald_HasExpectedMean() Math.Abs(mean - 1.0).Should().BeLessThan(0.05); } - [Test] + [TestMethod] public void Wald_HasExpectedVariance() { // For Wald: Var[X] = mean^3 / scale @@ -75,7 +76,7 @@ public void Wald_HasExpectedVariance() Math.Abs(variance - 1.0).Should().BeLessThan(0.1); } - [Test] + [TestMethod] public void Wald_DifferentMean_HasExpectedMean() { // With mean=3, scale=2 @@ -87,7 +88,7 @@ public void Wald_DifferentMean_HasExpectedMean() Math.Abs(mean - 3.0).Should().BeLessThan(0.1); } - [Test] + [TestMethod] public void Wald_DifferentParams_HasExpectedVariance() { // For Wald: Var[X] = mean^3 / scale @@ -100,7 +101,7 @@ public void Wald_DifferentParams_HasExpectedVariance() Math.Abs(variance - 13.5).Should().BeLessThan(1.0); } - [Test] + [TestMethod] public void Wald_SmallParameters_AllPositive() { var rng = np.random.RandomState(42); @@ -112,35 +113,35 @@ public void Wald_SmallParameters_AllPositive() } } - [Test] + [TestMethod] public void Wald_MeanZero_ThrowsArgumentException() { Action act = () => np.random.wald(0, 1); act.Should().Throw(); } - [Test] + [TestMethod] public void Wald_MeanNegative_ThrowsArgumentException() { Action act = () => np.random.wald(-1, 1); act.Should().Throw(); } - [Test] + [TestMethod] public void Wald_ScaleZero_ThrowsArgumentException() { Action act = () => np.random.wald(1, 0); act.Should().Throw(); } - [Test] + [TestMethod] public void Wald_ScaleNegative_ThrowsArgumentException() { Action act = () => np.random.wald(1, -1); act.Should().Throw(); } - [Test] + [TestMethod] public void Wald_ShapeOverload_Works() { var rng = np.random.RandomState(42); @@ -149,7 +150,7 @@ public void Wald_ShapeOverload_Works() result.shape.Should().ContainInOrder(3, 4); } - [Test] + [TestMethod] public void Wald_Reproducibility_WithSeed() { var rng1 = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.weibull.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.weibull.Test.cs index 983b9e188..960281430 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.weibull.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.weibull.Test.cs @@ -5,9 +5,10 @@ namespace NumSharp.UnitTest.RandomSampling { + [TestClass] public class NpRandomWeibullTest : TestClass { - [Test] + [TestMethod] public void Weibull_ScalarReturn() { var rng = np.random.RandomState(42); @@ -18,7 +19,7 @@ public void Weibull_ScalarReturn() Assert.IsTrue((double)result > 0); } - [Test] + [TestMethod] public void Weibull_1DArray() { var result = np.random.weibull(2, new Shape(5)); @@ -28,7 +29,7 @@ public void Weibull_1DArray() Assert.AreEqual(typeof(double), result.dtype); } - [Test] + [TestMethod] public void Weibull_2DArray() { var result = np.random.weibull(2, new Shape(2, 3)); @@ -38,7 +39,7 @@ public void Weibull_2DArray() Assert.AreEqual(3, result.shape[1]); } - [Test] + [TestMethod] public void Weibull_ShapeOverload() { var result = np.random.weibull(1.5, new Shape(10, 5)); @@ -47,13 +48,13 @@ public void Weibull_ShapeOverload() Assert.AreEqual(5, result.shape[1]); } - [Test] + [TestMethod] public void Weibull_NegativeA_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.weibull(-1)); } - [Test] + [TestMethod] public void Weibull_ZeroA_ReturnsZeros() { var result = np.random.weibull(0, 5); @@ -62,7 +63,7 @@ public void Weibull_ZeroA_ReturnsZeros() Assert.AreEqual(0.0, val); } - [Test] + [TestMethod] public void Weibull_A1_IsExponential() { // When a=1, Weibull reduces to exponential distribution with mean=1 @@ -74,7 +75,7 @@ public void Weibull_A1_IsExponential() Assert.IsTrue(Math.Abs(mean - 1.0) < 0.05, $"Mean {mean} should be close to 1.0"); } - [Test] + [TestMethod] public void Weibull_A2_StatisticalProperties() { // For Weibull(a=2), mean = Gamma(1 + 1/a) = Gamma(1.5) ≈ 0.886 @@ -85,7 +86,7 @@ public void Weibull_A2_StatisticalProperties() Assert.IsTrue(Math.Abs(mean - 0.886) < 0.02, $"Mean {mean} should be close to 0.886"); } - [Test] + [TestMethod] public void Weibull_AllValuesNonNegative() { var samples = np.random.weibull(0.5, 1000); @@ -94,7 +95,7 @@ public void Weibull_AllValuesNonNegative() Assert.IsTrue(val >= 0, $"Value {val} should be non-negative"); } - [Test] + [TestMethod] public void Weibull_SmallA_ProducesLargeValues() { // Small a (shape < 1) produces heavy-tailed distribution @@ -106,7 +107,7 @@ public void Weibull_SmallA_ProducesLargeValues() Assert.IsTrue(max > 1.0, $"Max {max} should be > 1 for heavy-tailed distribution"); } - [Test] + [TestMethod] public void Weibull_LargeA_ProducesConcentratedValues() { // Large a produces values concentrated near 1 @@ -120,7 +121,7 @@ public void Weibull_LargeA_ProducesConcentratedValues() Assert.IsTrue(std < 0.2, $"Std {std} should be small for large a"); } - [Test] + [TestMethod] public void Weibull_ReturnsFloat64() { var result = np.random.weibull(2, size: new Shape(5)); diff --git a/test/NumSharp.UnitTest/RandomSampling/np.random.zipf.Test.cs b/test/NumSharp.UnitTest/RandomSampling/np.random.zipf.Test.cs index 8c8abc3f6..dc8ab1ee2 100644 --- a/test/NumSharp.UnitTest/RandomSampling/np.random.zipf.Test.cs +++ b/test/NumSharp.UnitTest/RandomSampling/np.random.zipf.Test.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.RandomSampling /// Tests for np.random.zipf (Zipf/zeta distribution) /// + [TestClass] public class NpRandomZipfTests : TestClass { - [Test] + [TestMethod] public void Zipf_1D_ReturnsCorrectShape() { var rand = np.random.zipf(2, 5); @@ -17,7 +18,7 @@ public void Zipf_1D_ReturnsCorrectShape() Assert.AreEqual(5, rand.size); } - [Test] + [TestMethod] public void Zipf_2D_ReturnsCorrectShape() { var rand = np.random.zipf(2, new Shape(5, 5)); @@ -25,7 +26,7 @@ public void Zipf_2D_ReturnsCorrectShape() Assert.AreEqual(25, rand.size); } - [Test] + [TestMethod] public void Zipf_2DByShape_ReturnsCorrectShape() { var rand = np.random.zipf(2, new Shape(5, 5)); @@ -33,14 +34,14 @@ public void Zipf_2DByShape_ReturnsCorrectShape() Assert.AreEqual(25, rand.size); } - [Test] + [TestMethod] public void Zipf_ReturnsInt64() { var result = np.random.zipf(2, 5); Assert.AreEqual(NPTypeCode.Int64, result.typecode); } - [Test] + [TestMethod] public void Zipf_AllValuesPositive() { // Zipf distribution produces positive integers >= 1 @@ -53,7 +54,7 @@ public void Zipf_AllValuesPositive() } } - [Test] + [TestMethod] public void Zipf_MinValueIsOne() { // Minimum value should be 1 @@ -67,7 +68,7 @@ public void Zipf_MinValueIsOne() Assert.AreEqual(1L, min, "Minimum Zipf value should be 1"); } - [Test] + [TestMethod] public void Zipf_LargeA_ReturnsAllOnes() { // For very large a (>= 1025), NumPy returns 1 @@ -80,7 +81,7 @@ public void Zipf_LargeA_ReturnsAllOnes() } } - [Test] + [TestMethod] public void Zipf_Scalar_ReturnsScalar() { var rng = np.random.RandomState(42); @@ -90,7 +91,7 @@ public void Zipf_Scalar_ReturnsScalar() Assert.AreEqual(1, result.size); } - [Test] + [TestMethod] public void Zipf_SameSeed_ProducesSameResults() { var rng1 = np.random.RandomState(42); @@ -105,7 +106,7 @@ public void Zipf_SameSeed_ProducesSameResults() } } - [Test] + [TestMethod] public void Zipf_DifferentSeeds_ProduceDifferentResults() { var rng1 = np.random.RandomState(42); @@ -128,14 +129,14 @@ public void Zipf_DifferentSeeds_ProduceDifferentResults() // ========== Validation Tests ========== - [Test] + [TestMethod] public void Zipf_AEqualsOne_ThrowsArgumentException() { // a must be > 1 Assert.ThrowsException(() => np.random.zipf(1.0, 5)); } - [Test] + [TestMethod] public void Zipf_ALessThanOne_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.zipf(0.5, 5)); @@ -143,7 +144,7 @@ public void Zipf_ALessThanOne_ThrowsArgumentException() Assert.ThrowsException(() => np.random.zipf(-1, 5)); } - [Test] + [TestMethod] public void Zipf_ANaN_ThrowsArgumentException() { Assert.ThrowsException(() => np.random.zipf(double.NaN, 5)); @@ -155,7 +156,7 @@ public void Zipf_ANaN_ThrowsArgumentException() /// Migrated from NumPy test_smoke.py test_zipf /// Basic smoke test. /// - [Test] + [TestMethod] public void Zipf_NumPy_SmokeTest() { // From NumPy: vals = rg.zipf(10, 10); assert_(len(vals) == 10) @@ -167,7 +168,7 @@ public void Zipf_NumPy_SmokeTest() /// Migrated from NumPy test_generator_mt19937_regressions.py test_zipf_large_parameter /// Large a should return all ones and not hang. /// - [Test] + [TestMethod] public void Zipf_NumPy_LargeParameter() { // From NumPy: sample = mt19937.zipf(10000, size=n); assert_array_equal(sample, np.ones(n, dtype=np.int64)) @@ -183,7 +184,7 @@ public void Zipf_NumPy_LargeParameter() /// Migrated from NumPy test_random.py TestBroadcast test_zipf /// Tests validation of bad a values. /// - [Test] + [TestMethod] public void Zipf_NumPy_BadAThrows() { // From NumPy: assert_raises(ValueError, zipf, bad_a * 3) where bad_a = [0] @@ -195,7 +196,7 @@ public void Zipf_NumPy_BadAThrows() /// Small a = heavy tail (larger values more likely) /// Large a = light tail (mostly 1s) /// - [Test] + [TestMethod] public void Zipf_DifferentA_DifferentDistributions() { var rng1 = np.random.RandomState(42); diff --git a/test/NumSharp.UnitTest/Scripts/water.cs b/test/NumSharp.UnitTest/Scripts/water.cs index eb4f48341..66e618e4f 100644 --- a/test/NumSharp.UnitTest/Scripts/water.cs +++ b/test/NumSharp.UnitTest/Scripts/water.cs @@ -14,7 +14,7 @@ // public double g; // public double dt; -// [Test] +// [TestMethod] // public void Water() // { // int box_size = 1; diff --git a/test/NumSharp.UnitTest/Selection/BooleanIndexing.BattleTests.cs b/test/NumSharp.UnitTest/Selection/BooleanIndexing.BattleTests.cs index 1e3ae6ba8..b5a2d50a2 100644 --- a/test/NumSharp.UnitTest/Selection/BooleanIndexing.BattleTests.cs +++ b/test/NumSharp.UnitTest/Selection/BooleanIndexing.BattleTests.cs @@ -3,7 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using NumSharp.Generic; -using TUnit.Core; namespace NumSharp.UnitTest.Selection; @@ -11,11 +10,12 @@ namespace NumSharp.UnitTest.Selection; /// Comprehensive battle tests for boolean indexing covering all NumPy behaviors. /// These tests are based on actual NumPy 2.4.2 output and verify NumSharp matches exactly. /// +[TestClass] public class BooleanIndexing_BattleTests { #region Case 1: Same-Shape Boolean Mask (Element-wise) - [Test] + [TestMethod] public void Case1_SameShape_1D_BasicMask() { // NumPy: arr = [1, 2, 3, 4, 5], mask = [T, F, T, F, T] → [1, 3, 5] @@ -30,7 +30,7 @@ public void Case1_SameShape_1D_BasicMask() Assert.AreEqual(5, result.GetInt32(2)); } - [Test] + [TestMethod] public void Case1_SameShape_1D_ResultIs1D() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -42,7 +42,7 @@ public void Case1_SameShape_1D_ResultIs1D() Assert.AreEqual(1, result.ndim); } - [Test] + [TestMethod] public void Case1_SameShape_1D_ResultIsCopy() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -59,7 +59,7 @@ public void Case1_SameShape_1D_ResultIsCopy() #region Case 2: 2D Same-Shape Mask - [Test] + [TestMethod] public void Case2_SameShape_2D_ElementWise() { // NumPy: arr2d > 5 selects [6, 7, 8, 9, 10, 11] @@ -77,7 +77,7 @@ public void Case2_SameShape_2D_ElementWise() Assert.AreEqual(11, result.item(5)); } - [Test] + [TestMethod] public void Case2_SameShape_2D_AlwaysReturns1D() { // NumPy: 2D mask on 2D array → always returns 1D @@ -89,7 +89,7 @@ public void Case2_SameShape_2D_AlwaysReturns1D() Assert.AreEqual(1, result.ndim); } - [Test] + [TestMethod] public void Case2_SameShape_2D_PreservesOrder() { // NumPy iterates in C-order (row-major) @@ -110,7 +110,7 @@ public void Case2_SameShape_2D_PreservesOrder() #region Case 3: 1D Mask on Axis-0 (Row Selection) - [Test] + [TestMethod] public void Case3_Axis0_2D_SelectsRows() { // NumPy: arr2d[[T,F,T]] selects rows 0 and 2 @@ -122,7 +122,7 @@ public void Case3_Axis0_2D_SelectsRows() Assert.IsTrue(result.shape.SequenceEqual(new long[] { 2, 4 }), $"Expected shape [2, 4], got [{string.Join(", ", result.shape)}]"); } - [Test] + [TestMethod] public void Case3_Axis0_2D_CorrectValues() { var arr2d = np.arange(12).reshape(3, 4); @@ -143,7 +143,7 @@ public void Case3_Axis0_2D_CorrectValues() Assert.AreEqual(11, result.item(1, 3)); } - [Test] + [TestMethod] public void Case3_Axis0_3D_SelectsAlongAxis0() { // NumPy: 1D mask on 3D array selects along axis 0 @@ -156,7 +156,7 @@ public void Case3_Axis0_3D_SelectsAlongAxis0() Assert.IsTrue(result.shape.SequenceEqual(new long[] { 1, 3, 4 }), $"Expected shape [1, 3, 4], got [{string.Join(", ", result.shape)}]"); } - [Test] + [TestMethod] public void Case3_Axis0_3D_CorrectValues() { var arr3d = np.arange(24).reshape(2, 3, 4); @@ -174,7 +174,7 @@ public void Case3_Axis0_3D_CorrectValues() #region Case 4: Boolean Mask + Additional Index (Combined Indexing) - [Test] + [TestMethod] public void Case4_BooleanPlusInteger_Workaround() { // NumPy: arr2d[mask, 0] - select masked rows, then column 0 @@ -192,7 +192,7 @@ public void Case4_BooleanPlusInteger_Workaround() Assert.AreEqual(8, result.item(1)); } - [Test] + [TestMethod] public void Case4_BooleanPlusSlice_Workaround() { // NumPy: arr2d[mask, 1:3] - select masked rows, then columns 1-2 @@ -215,7 +215,7 @@ public void Case4_BooleanPlusSlice_Workaround() #region Case 5: 3D Array with Masks (ndim variations) - [Test] + [TestMethod] public void Case5_3D_FullShapeMask() { // NumPy: 3D mask on 3D array → 1D result @@ -230,7 +230,7 @@ public void Case5_3D_FullShapeMask() Assert.AreEqual(23, result.item(10)); } - [Test] + [TestMethod] public void Case5_3D_1DMask_PreservesRemainingDims() { var arr3d = np.arange(24).reshape(2, 3, 4); @@ -242,7 +242,7 @@ public void Case5_3D_1DMask_PreservesRemainingDims() Assert.IsTrue(result.shape.SequenceEqual(new long[] { 1, 3, 4 }), $"Expected shape [1, 3, 4], got [{string.Join(", ", result.shape)}]"); } - [Test] + [TestMethod] public void Case5_2DMaskOn3D_PartialShapeMatch() { // NumPy: 2D mask (2,3) on 3D array (2,3,4) → shape (count_true, 4) @@ -279,7 +279,7 @@ public void Case5_2DMaskOn3D_PartialShapeMatch() #region Case 6: Boolean Mask Assignment (Setter) - [Test] + [TestMethod] public void Case6_Assignment_ScalarValue() { // NumPy: arr[mask] = 0 sets all masked elements to 0 @@ -296,7 +296,7 @@ public void Case6_Assignment_ScalarValue() Assert.AreEqual(0, arr.GetInt32(4)); } - [Test] + [TestMethod] public void Case6_Assignment_ArrayValue() { // NumPy: arr[mask] = [10, 20, 30] assigns in order @@ -313,7 +313,7 @@ public void Case6_Assignment_ArrayValue() Assert.AreEqual(30, arr.GetInt32(4)); } - [Test] + [TestMethod] public void Case6_Assignment_2D_SameShapeMask() { // NumPy: arr2d[mask2d] = -1 @@ -328,7 +328,7 @@ public void Case6_Assignment_2D_SameShapeMask() Assert.AreEqual(-1, arr2d.item(2, 3)); // was 11 } - [Test] + [TestMethod] public void Case6_Assignment_2D_RowMask() { // NumPy: arr2d[[T,F,T]] = 99 @@ -344,7 +344,7 @@ public void Case6_Assignment_2D_RowMask() Assert.AreEqual(99, arr2d.item(2, 0)); } - [Test] + [TestMethod] public void Case6_Assignment_BroadcastValue() { // NumPy: arr2d[[T,F,T]] = [[100, 101, 102, 103]] broadcasts @@ -365,7 +365,7 @@ public void Case6_Assignment_BroadcastValue() #region Case 7: Edge Cases - Empty Masks - [Test] + [TestMethod] public void Case7_AllFalse_EmptyResult() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -377,7 +377,7 @@ public void Case7_AllFalse_EmptyResult() Assert.AreEqual(0, result.size); } - [Test] + [TestMethod] public void Case7_AllTrue_AllElements() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -390,7 +390,7 @@ public void Case7_AllTrue_AllElements() Assert.AreEqual(5, result.GetInt32(4)); } - [Test] + [TestMethod] public void Case7_EmptyArray_EmptyMask() { var empty = np.array(new int[0]); @@ -401,7 +401,7 @@ public void Case7_EmptyArray_EmptyMask() Assert.IsTrue(result.shape.SequenceEqual(new long[] { 0 }), $"Expected shape [0], got [{string.Join(", ", result.shape)}]"); } - [Test] + [TestMethod] public void Case7_EmptyResult_PreservesDtype() { var arrFloat = np.array(new[] { 1.5, 2.5, 3.5 }); @@ -417,7 +417,7 @@ public void Case7_EmptyResult_PreservesDtype() #region Case 8: Shape Mismatch Errors - [Test] + [TestMethod] public void Case8_ShapeMismatch_ThrowsError() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -426,7 +426,7 @@ public void Case8_ShapeMismatch_ThrowsError() Assert.ThrowsException(() => arr[badMask]); } - [Test] + [TestMethod] public void Case8_ShapeMismatch_ErrorMessage() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -443,7 +443,7 @@ public void Case8_ShapeMismatch_ErrorMessage() } } - [Test] + [TestMethod] public void Case8_2D_WrongMaskShape() { var arr2d = np.arange(12).reshape(3, 4); @@ -457,7 +457,7 @@ public void Case8_2D_WrongMaskShape() #region Case 9: Boolean Scalar Indexing - [Test] + [TestMethod] public void Case9_BooleanScalar_True() { // NumPy: arr[True] adds a dimension → [[1, 2, 3]] @@ -479,7 +479,7 @@ public void Case9_BooleanScalar_True() } } - [Test] + [TestMethod] public void Case9_BooleanScalar_False() { // NumPy: arr[False] → empty array with extra dimension @@ -503,7 +503,7 @@ public void Case9_BooleanScalar_False() #region Case 10: np.nonzero and np.where equivalence - [Test] + [TestMethod] public void Case10_Nonzero_ReturnsCorrectIndices() { var mask = np.array(new[] { true, false, true, false, true }).MakeGeneric(); @@ -517,7 +517,7 @@ public void Case10_Nonzero_ReturnsCorrectIndices() Assert.AreEqual(4, indices[0].item(2)); } - [Test] + [TestMethod] public void Case10_Nonzero_2D_ReturnsTwoArrays() { var mask2d = np.array(new[,] { { true, false, true }, { false, true, false } }).MakeGeneric(); @@ -538,7 +538,7 @@ public void Case10_Nonzero_2D_ReturnsTwoArrays() Assert.AreEqual(1, indices[1].item(2)); } - [Test] + [TestMethod] public void Case10_BooleanIndex_EqualsNonzeroFancyIndex() { var arr = np.array(new[] { 10, 20, 30, 40, 50 }); @@ -557,7 +557,7 @@ public void Case10_BooleanIndex_EqualsNonzeroFancyIndex() #region Case 11: Order Preservation - [Test] + [TestMethod] public void Case11_OrderPreservation_FollowsMaskPosition() { // NumPy: Order follows the position in the mask, not the order of True values @@ -572,7 +572,7 @@ public void Case11_OrderPreservation_FollowsMaskPosition() Assert.AreEqual(50, result.GetInt32(2)); } - [Test] + [TestMethod] public void Case11_2D_COrderIteration() { // NumPy iterates in C-order (row-major) @@ -591,7 +591,7 @@ public void Case11_2D_COrderIteration() #region Case 12: Non-Contiguous Arrays - [Test] + [TestMethod] public void Case12_SlicedArray_BooleanMask() { // Boolean mask on sliced (non-contiguous) array @@ -611,7 +611,7 @@ public void Case12_SlicedArray_BooleanMask() Assert.AreEqual(14, result.item(2)); } - [Test] + [TestMethod] public void Case12_TransposedArray_BooleanMask() { var arr = np.arange(12).reshape(3, 4); @@ -632,7 +632,7 @@ public void Case12_TransposedArray_BooleanMask() Assert.AreEqual(11, result.item(5)); } - [Test] + [TestMethod] public void Case12_SlicedView_BooleanMask() { var arr = np.arange(20).reshape(4, 5); @@ -652,7 +652,7 @@ public void Case12_SlicedView_BooleanMask() #region Case 13: Broadcast Arrays - [Test] + [TestMethod] public void Case13_BroadcastArray_BooleanMask() { var arr1d = np.array(new[] { 1, 2, 3 }); @@ -676,7 +676,7 @@ public void Case13_BroadcastArray_BooleanMask() #region Case 14: Broadcast Comparison for Mask - [Test] + [TestMethod] public void Case14_BroadcastComparison_CreatesMask() { var arr2d = np.arange(12).reshape(3, 4); @@ -699,7 +699,7 @@ public void Case14_BroadcastComparison_CreatesMask() #region Case 15: Ravel/Flatten with Boolean - [Test] + [TestMethod] public void Case15_RavelThenBoolean() { var arr2d = np.arange(12).reshape(3, 4); @@ -713,7 +713,7 @@ public void Case15_RavelThenBoolean() Assert.AreEqual(11, result.item(5)); } - [Test] + [TestMethod] public void Case15_FlattenThenBoolean() { var arr2d = np.arange(12).reshape(3, 4); @@ -729,7 +729,7 @@ public void Case15_FlattenThenBoolean() #region Case 16: Chained Boolean Indexing - [Test] + [TestMethod] public void Case16_ChainedBooleanIndexing() { var arr = np.arange(20); @@ -754,7 +754,7 @@ public void Case16_ChainedBooleanIndexing() #region Case 17: Result Memory Layout - [Test] + [TestMethod] public void Case17_ResultIsContiguous() { var arr2d = np.arange(12).reshape(3, 4); @@ -766,7 +766,7 @@ public void Case17_ResultIsContiguous() Assert.IsTrue(result.Shape.IsContiguous, "Result should be contiguous"); } - [Test] + [TestMethod] public void Case17_ResultFromNonContiguous_IsContiguous() { var arr = np.arange(20).reshape(4, 5); @@ -785,7 +785,7 @@ public void Case17_ResultFromNonContiguous_IsContiguous() #region Case 18: Different Dtypes - [Test] + [TestMethod] public void Case18_Float64() { var arr = np.array(new[] { 1.5, 2.5, 3.5, 4.5, 5.5 }); @@ -798,7 +798,7 @@ public void Case18_Float64() Assert.AreEqual(3.5, result.GetDouble(0)); } - [Test] + [TestMethod] public void Case18_Float32() { var arr = np.array(new float[] { 1.5f, 2.5f, 3.5f, 4.5f, 5.5f }); @@ -810,7 +810,7 @@ public void Case18_Float32() Assert.AreEqual(3, result.size); } - [Test] + [TestMethod] public void Case18_Int64() { var arr = np.array(new long[] { 1L, 2L, 3L, 4L, 5L }); @@ -821,7 +821,7 @@ public void Case18_Int64() Assert.AreEqual(typeof(long), result.dtype); } - [Test] + [TestMethod] public void Case18_Boolean() { var arr = np.array(new[] { true, false, true, false, true }); @@ -836,7 +836,7 @@ public void Case18_Boolean() Assert.IsTrue(result.GetBoolean(2)); } - [Test] + [TestMethod] public void Case18_Byte() { var arr = np.array(new byte[] { 1, 2, 3, 4, 5 }); @@ -852,7 +852,7 @@ public void Case18_Byte() #region Case 19: Single Element Selection - [Test] + [TestMethod] public void Case19_SingleElementSelected() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -864,7 +864,7 @@ public void Case19_SingleElementSelected() Assert.AreEqual(3, result.GetInt32(0)); } - [Test] + [TestMethod] public void Case19_2D_SingleRow() { var arr2d = np.arange(12).reshape(3, 4); @@ -880,7 +880,7 @@ public void Case19_2D_SingleRow() #region Case 20: Large Arrays - [Test] + [TestMethod] public void Case20_LargeArray_Performance() { var size = 100000; @@ -898,7 +898,7 @@ public void Case20_LargeArray_Performance() #region Case 21: Comparison Operators for Mask Generation - [Test] + [TestMethod] public void Case21_GreaterThan() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -911,7 +911,7 @@ public void Case21_GreaterThan() Assert.AreEqual(5, result.GetInt32(1)); } - [Test] + [TestMethod] public void Case21_LessThan() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -924,7 +924,7 @@ public void Case21_LessThan() Assert.AreEqual(2, result.GetInt32(1)); } - [Test] + [TestMethod] public void Case21_Equal() { var arr = np.array(new[] { 1, 2, 3, 2, 1 }); @@ -937,7 +937,7 @@ public void Case21_Equal() Assert.AreEqual(2, result.GetInt32(1)); } - [Test] + [TestMethod] public void Case21_NotEqual() { var arr = np.array(new[] { 1, 2, 3, 2, 1 }); @@ -951,7 +951,7 @@ public void Case21_NotEqual() Assert.AreEqual(1, result.GetInt32(2)); } - [Test] + [TestMethod] public void Case21_GreaterEqual() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -962,7 +962,7 @@ public void Case21_GreaterEqual() Assert.AreEqual(3, result.size); } - [Test] + [TestMethod] public void Case21_LessEqual() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -977,7 +977,7 @@ public void Case21_LessEqual() #region Case 22: Logical Operations on Masks - [Test] + [TestMethod] public void Case22_LogicalAnd() { var arr = np.array(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); @@ -993,7 +993,7 @@ public void Case22_LogicalAnd() Assert.AreEqual(7, result.GetInt32(3)); } - [Test] + [TestMethod] public void Case22_LogicalOr() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -1009,7 +1009,7 @@ public void Case22_LogicalOr() Assert.AreEqual(5, result.GetInt32(1)); } - [Test] + [TestMethod] public void Case22_LogicalNot() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -1028,7 +1028,7 @@ public void Case22_LogicalNot() #region Case 23: NaN Handling - [Test] + [TestMethod] public void Case23_NaN_Comparison() { var arr = np.array(new[] { 1.0, double.NaN, 3.0, double.NaN, 5.0 }); @@ -1043,7 +1043,7 @@ public void Case23_NaN_Comparison() Assert.AreEqual(5.0, result.GetDouble(1)); } - [Test] + [TestMethod] public void Case23_IsNaN_Mask() { var arr = np.array(new[] { 1.0, double.NaN, 3.0, double.NaN, 5.0 }); @@ -1056,7 +1056,7 @@ public void Case23_IsNaN_Mask() Assert.IsTrue(double.IsNaN(result.GetDouble(1))); } - [Test] + [TestMethod] public void Case23_NotNaN_Mask() { var arr = np.array(new[] { 1.0, double.NaN, 3.0, double.NaN, 5.0 }); @@ -1074,7 +1074,7 @@ public void Case23_NotNaN_Mask() #region Case 24: Infinity Handling - [Test] + [TestMethod] public void Case24_Infinity_Comparison() { var arr = np.array(new[] { 1.0, double.PositiveInfinity, 3.0, double.NegativeInfinity, 5.0 }); @@ -1088,7 +1088,7 @@ public void Case24_Infinity_Comparison() Assert.AreEqual(5.0, result.GetDouble(1)); } - [Test] + [TestMethod] [OpenBugs] // np.isinf is not implemented (returns null) public void Case24_IsInf_Mask() { @@ -1104,7 +1104,7 @@ public void Case24_IsInf_Mask() #region Case 25: Modulo for Mask - [Test] + [TestMethod] public void Case25_Modulo_EvenNumbers() { var arr = np.arange(10); @@ -1118,7 +1118,7 @@ public void Case25_Modulo_EvenNumbers() Assert.AreEqual(8, result.item(4)); } - [Test] + [TestMethod] public void Case25_Modulo_MultipleOf3() { var arr = np.arange(15); @@ -1137,7 +1137,7 @@ public void Case25_Modulo_MultipleOf3() #region Case 26: Complex Mask Expressions - [Test] + [TestMethod] public void Case26_ComplexExpression_Range() { var arr = np.arange(20); @@ -1151,7 +1151,7 @@ public void Case26_ComplexExpression_Range() Assert.AreEqual(14, result.item(9)); } - [Test] + [TestMethod] public void Case26_ComplexExpression_MultipleConditions() { var arr = np.arange(20); @@ -1171,7 +1171,7 @@ public void Case26_ComplexExpression_MultipleConditions() #region Case 27: Assignment Edge Cases - [Test] + [TestMethod] public void Case27_Assignment_EmptyMask_NoChange() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -1187,7 +1187,7 @@ public void Case27_Assignment_EmptyMask_NoChange() } } - [Test] + [TestMethod] public void Case27_Assignment_AllTrue() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -1205,7 +1205,7 @@ public void Case27_Assignment_AllTrue() #region Case 28: Higher Dimensional Arrays - [Test] + [TestMethod] public void Case28_4D_SameShapeMask() { var arr4d = np.arange(24).reshape(2, 3, 2, 2); @@ -1220,7 +1220,7 @@ public void Case28_4D_SameShapeMask() Assert.AreEqual(23, result.item(10)); } - [Test] + [TestMethod] public void Case28_4D_1DMask() { var arr4d = np.arange(48).reshape(2, 3, 4, 2); @@ -1236,7 +1236,7 @@ public void Case28_4D_1DMask() #region Case 29: count_nonzero Relationship - [Test] + [TestMethod] public void Case29_CountNonzero_MatchesResultSize() { var arr = np.array(new[] { 1, 2, 3, 4, 5 }); @@ -1248,7 +1248,7 @@ public void Case29_CountNonzero_MatchesResultSize() Assert.AreEqual(count, result.size); } - [Test] + [TestMethod] public void Case29_CountNonzero_2D() { var arr2d = np.arange(12).reshape(3, 4); diff --git a/test/NumSharp.UnitTest/Selection/BooleanMaskingTests.cs b/test/NumSharp.UnitTest/Selection/BooleanMaskingTests.cs index 975f77029..e83d467e8 100644 --- a/test/NumSharp.UnitTest/Selection/BooleanMaskingTests.cs +++ b/test/NumSharp.UnitTest/Selection/BooleanMaskingTests.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.Selection /// /// Tests for boolean masking based on NumPy 2.4.2 behavior. /// + [TestClass] public class BooleanMaskingTests { - [Test] + [TestMethod] public void ExplicitMask_1D_FiltersCorrectly() { // NumPy: a[mask] where mask = [True, False, True, False, True, False] @@ -23,7 +24,7 @@ public void ExplicitMask_1D_FiltersCorrectly() result.Should().BeOfValues(1, 3, 5).And.BeShaped(3); } - [Test] + [TestMethod] public void Condition_1D_FiltersCorrectly() { // NumPy: a[a % 2 == 1] = [1, 3, 5] @@ -33,7 +34,7 @@ public void Condition_1D_FiltersCorrectly() result.Should().BeOfValues(1, 3, 5).And.BeShaped(3); } - [Test] + [TestMethod] public void ExplicitMask_MatchesCondition() { // Explicit mask and condition should produce same result @@ -47,7 +48,7 @@ public void ExplicitMask_MatchesCondition() condition_result.Should().BeOfValues(1, 3, 5); } - [Test] + [TestMethod] public void AllTrue_ReturnsAll() { // NumPy: a[[T,T,T]] = [1, 2, 3] @@ -58,7 +59,7 @@ public void AllTrue_ReturnsAll() result.Should().BeOfValues(1, 2, 3).And.BeShaped(3); } - [Test] + [TestMethod] public void AllFalse_ReturnsEmpty() { // NumPy: a[[F,F,F]] = [], shape (0,) @@ -70,7 +71,7 @@ public void AllFalse_ReturnsEmpty() Assert.AreEqual(1, result.ndim); // 1D empty array } - [Test] + [TestMethod] public void TwoDimensional_RowSelection() { // NumPy: 2D array with 1D mask selects rows @@ -88,7 +89,7 @@ public void TwoDimensional_RowSelection() result["1"].Should().BeOfValues(7, 8, 9); } - [Test] + [TestMethod] public void TwoDimensional_ElementMask_Flattens() { // NumPy: 2D array with 2D mask of same shape selects elements, flattens @@ -102,7 +103,7 @@ public void TwoDimensional_ElementMask_Flattens() result.Should().BeOfValues(1, 4).And.BeShaped(2); } - [Test] + [TestMethod] public void EmptyResult_PreservesDtype() { // NumPy: Empty result preserves dtype diff --git a/test/NumSharp.UnitTest/Selection/NDArray.AMax.Test.cs b/test/NumSharp.UnitTest/Selection/NDArray.AMax.Test.cs index 5f830a350..4b10cdf33 100644 --- a/test/NumSharp.UnitTest/Selection/NDArray.AMax.Test.cs +++ b/test/NumSharp.UnitTest/Selection/NDArray.AMax.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.Selection { + [TestClass] public class NDArrayAMaxTest { - [Test] + [TestMethod] public void argmax12() { NDArray x = DataSample.Int32D12; @@ -17,35 +18,35 @@ public void argmax12() Assert.AreEqual(y0, 3); } - [Test] + [TestMethod] public void argmax_case1() { var a = np.arange(27).reshape(3, 3, 3); np.argmax(a).Should().Be(26); } - [Test] + [TestMethod] public void argmax_case2() { var a = np.arange(27).reshape(3, 3, 3); np.argmax(a, axis: 1).flat.Cast().Should().AllBeEquivalentTo(2); } - [Test] + [TestMethod] public void argmax_case3() { var a = np.arange(27).reshape(3, 3, 3); np.argmax(a, axis: 0).flat.Cast().Should().AllBeEquivalentTo(2); } - [Test] + [TestMethod] public void argmax_case4() { var a = np.arange(27).reshape(3, 3, 3); np.argmax(a, axis: 2).flat.Cast().Should().AllBeEquivalentTo(2); } - [Test] + [TestMethod] public void argmax_case5() { var a = np.arange(6).reshape(2, 3) + 10; @@ -56,7 +57,7 @@ public void argmax_case5() ret.shape.Should().HaveCount(1).And.ContainInOrder(3); } - [Test] + [TestMethod] public void argmax_case6() { var a = np.arange(6).reshape(2, 3) + 10; @@ -67,7 +68,7 @@ public void argmax_case6() ret.shape.Should().HaveCount(1).And.ContainInOrder(2); } - [Test] + [TestMethod] public void argmin_case5() { var a = np.arange(6).reshape(2, 3) + 10; @@ -78,7 +79,7 @@ public void argmin_case5() ret.shape.Should().HaveCount(1).And.ContainInOrder(3); } - [Test] + [TestMethod] public void argmin_case6() { var a = np.arange(6).reshape(2, 3) + 10; @@ -89,35 +90,35 @@ public void argmin_case6() ret.shape.Should().HaveCount(1).And.ContainInOrder(2); } - [Test] + [TestMethod] public void argmin_case2() { var a = np.arange(27).reshape(3, 3, 3); np.argmin(a, axis: 1).flat.Cast().Should().AllBeEquivalentTo(0); } - [Test] + [TestMethod] public void argmin_case3() { var a = np.arange(27).reshape(3, 3, 3); np.argmin(a, axis: 0).flat.Cast().Should().AllBeEquivalentTo(0); } - [Test] + [TestMethod] public void argmin_case4() { var a = np.arange(27).reshape(3, 3, 3); np.argmin(a, axis: 2).flat.Cast().Should().AllBeEquivalentTo(0); } - [Test] + [TestMethod] public void argmin_case1() { var a = np.arange(27).reshape(3, 3, 3); np.argmin(a).Should().Be(0); } - [Test] + [TestMethod] public void argmax4x3() { NDArray x = DataSample.Int32D4x3; @@ -129,7 +130,7 @@ public void argmax4x3() Assert.IsTrue(Enumerable.SequenceEqual(y1.Data(), new long[] {0, 1, 2, 1})); } - [Test] + [TestMethod] public void amax() { //default type diff --git a/test/NumSharp.UnitTest/Selection/NDArray.AMin.Test.cs b/test/NumSharp.UnitTest/Selection/NDArray.AMin.Test.cs index 8f3f2de90..1f7d76e25 100644 --- a/test/NumSharp.UnitTest/Selection/NDArray.AMin.Test.cs +++ b/test/NumSharp.UnitTest/Selection/NDArray.AMin.Test.cs @@ -6,9 +6,10 @@ namespace NumSharp.UnitTest.Selection { + [TestClass] public class NDArrayAMinTest { - [Test] + [TestMethod] public void amin() { //no axis diff --git a/test/NumSharp.UnitTest/Selection/NDArray.Enumerator.Test.cs b/test/NumSharp.UnitTest/Selection/NDArray.Enumerator.Test.cs index b492ba53d..ac2abdf9d 100644 --- a/test/NumSharp.UnitTest/Selection/NDArray.Enumerator.Test.cs +++ b/test/NumSharp.UnitTest/Selection/NDArray.Enumerator.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest.Selection { + [TestClass] public class EnumeratorTest { - [Test] + [TestMethod] public void Enumerate_1D_YieldsScalars() { // 1D arrays iterate over scalar elements @@ -19,7 +20,7 @@ public void Enumerate_1D_YieldsScalars() values.Should().BeEquivalentTo(new long[] { 0, 1, 2, 3, 4 }); } - [Test] + [TestMethod] public void Enumerate_2D_YieldsRows() { // 2D arrays iterate over rows (1D slices) @@ -31,7 +32,7 @@ public void Enumerate_2D_YieldsRows() rows[1].Should().BeOfValues(3, 4, 5); } - [Test] + [TestMethod] public void Enumerate_3D_Yields2DSlices() { // 3D arrays iterate over 2D slices @@ -43,7 +44,7 @@ public void Enumerate_3D_Yields2DSlices() slices[0].shape.Should().BeEquivalentTo(new long[] { 3, 2 }); } - [Test] + [TestMethod] public void Flat_IteratesAllElements() { // .flat always iterates over all elements as scalars diff --git a/test/NumSharp.UnitTest/Selection/NDArray.Indexing.Test.cs b/test/NumSharp.UnitTest/Selection/NDArray.Indexing.Test.cs index 05e1cb384..9f34eb717 100644 --- a/test/NumSharp.UnitTest/Selection/NDArray.Indexing.Test.cs +++ b/test/NumSharp.UnitTest/Selection/NDArray.Indexing.Test.cs @@ -13,9 +13,10 @@ namespace NumSharp.UnitTest.Selection { + [TestClass] public class IndexingTest : TestClass { - [Test] + [TestMethod] public void IndexAccessorGetter() { var nd = np.arange(12).reshape(3, 4); @@ -24,7 +25,7 @@ public void IndexAccessorGetter() Assert.IsTrue(nd.GetInt64(2, 0) == 8); } - [Test] + [TestMethod] public void NDArrayAccess() { var nd = np.arange(4).reshape(2, 2); @@ -34,7 +35,7 @@ public void NDArrayAccess() Assert.AreEqual(row1[1], 1); } - [Test] + [TestMethod] public void NDArrayAccess3Dim() { NDArray nd = np.arange(1, 19, 1).reshape(3, 3, 2); @@ -47,7 +48,7 @@ public void NDArrayAccess3Dim() Assert.AreEqual(row1[2, 1], 6); } - [Test] + [TestMethod] public void IndexAccessorSetter() { var nd = np.arange(12).reshape(3, 4); @@ -61,7 +62,7 @@ public void IndexAccessorSetter() Assert.IsTrue(nd.GetInt64(1, 3) == 7); } - [Test] + [TestMethod] [OpenBugs] public void MaskSetter() { @@ -74,7 +75,7 @@ public void MaskSetter() nd.Should().BeOfValues(-2, 2, -2, 4, -2, 6); } - [Test] + [TestMethod] [OpenBugs] public void Compare() { @@ -89,7 +90,7 @@ public void Compare() a.Should().BeOfValues(-2, -2, 6); } - [Test] + [TestMethod] public void NDArrayByNDArray() { NDArray x = new double[] { 1, 2, 3, 4, 5, 6 }; @@ -104,7 +105,7 @@ public void NDArrayByNDArray() Assert.IsTrue(Enumerable.SequenceEqual(a, b)); } - [Test] + [TestMethod] public void Filter1D() { var nd = np.array(new int[] { 3, 1, 1, 2, 3, 1 }); @@ -114,7 +115,7 @@ public void Filter1D() AssertAreEqual(new int[] { 3, 1, 1 }, result.ToArray()); } - [Test] + [TestMethod] public void Filter2D() { var nd = np.array(new int[][] { new int[] { 3, 1, 1, 2 }, new int[] { 1, 2, 2, 3 }, new int[] { 2, 1, 1, 3 }, }); @@ -128,7 +129,7 @@ public void Filter2D() x.ravel(); } - [Test] + [TestMethod] public void Slice1() { var x = np.arange(5); @@ -143,7 +144,7 @@ public void Slice1() } - [Test] + [TestMethod] public void Slice2() { //>>> x = np.arange(5) @@ -179,7 +180,7 @@ public void Slice2() AssertAreEqual(y.ToArray(), new long[] { 0, 1, 2, 3, 4 }); } - [Test] + [TestMethod] public void Slice3() { //>>> x = np.arange(6) @@ -207,7 +208,7 @@ public void Slice3() AssertAreEqual(new long[] { 0, 99, 2, 3, 4, 5 }, x.ToArray()); } - [Test] + [TestMethod] public void Slice4() { //>>> x = np.arange(5) @@ -226,7 +227,7 @@ public void Slice4() Assert.AreEqual(99, (int)x[3]); } - [Test] + [TestMethod] public void Slice2x2Mul() { //>>> import numpy as np @@ -247,7 +248,7 @@ public void Slice2x2Mul() z.Should().BeShaped(1, 2).And.BeOfValues(4, 6); } - [Test] + [TestMethod] public void Slice2x2Mul_2() { //>>> import numpy as np @@ -270,7 +271,7 @@ public void Slice2x2Mul_2() //AssertAreEqual(x.ToArray(), new long[] { 0, 1, 4, 6 }); } - [Test] + [TestMethod] public void Slice2x2Mul_3() { var x = np.arange(4).reshape(2, 2); @@ -280,7 +281,7 @@ public void Slice2x2Mul_3() z.Should().BeShaped(2).And.BeOfValues(2, 6); } - [Test] + [TestMethod] public void Slice2x2Mul_4() { var x = np.arange(4).reshape(2, 2); @@ -290,7 +291,7 @@ public void Slice2x2Mul_4() z.Should().BeShaped(2).And.BeOfValues(2, 6); } - [Test] + [TestMethod] public void Slice2x2Mul_5() { var x = np.arange(4).reshape(2, 2); @@ -300,7 +301,7 @@ public void Slice2x2Mul_5() z.Should().BeShaped(2).And.BeOfValues(1, 9); } - [Test] + [TestMethod] public void Slice2x2Mul_6() { var x = np.arange(4).reshape(2, 2); @@ -309,7 +310,7 @@ public void Slice2x2Mul_6() z.Should().BeShaped(2, 2).And.BeOfValues(0, 1, 4, 9); } - [Test] + [TestMethod] [OpenBugs] // This can never work because C# doesn't allow overloading of the assignment operator public void Slice2x2Mul_AssignmentChangesOriginal() { @@ -336,7 +337,7 @@ public void Slice2x2Mul_AssignmentChangesOriginal() AssertAreEqual(x.ToArray(), new int[] { 0, 1, 4, 6 }); // <------- this fails because in C# we can not intercept assignment to a variable } - [Test] + [TestMethod] public void Slice5() { var x = np.arange(6).reshape(3, 2); @@ -350,7 +351,7 @@ public void Slice5() AssertAreEqual(new long[] { 0, 1, 99, 3, 4, 5 }, x.ToArray()); } - [Test] + [TestMethod] public void Slice_Step() { //>>> x = np.arange(5) @@ -370,7 +371,7 @@ public void Slice_Step() AssertAreEqual(y.ToArray(), new long[] { 0, 2, 4 }); } - [Test] + [TestMethod] public void Slice_Step1() { //>>> x = np.arange(6) @@ -408,7 +409,7 @@ public void Slice_Step1() AssertAreEqual(new long[] { 99, 4, 111, 2, 1, 0 }, y.ToArray()); } - [Test] + [TestMethod] public void Slice_Step2() { //>>> x = np.arange(5) @@ -424,7 +425,7 @@ public void Slice_Step2() Assert.AreEqual(4, (int)y[2]); } - [Test] + [TestMethod] public void Slice_Step3() { var x = np.arange(5); @@ -433,7 +434,7 @@ public void Slice_Step3() Assert.AreEqual("[0, 2, 4]", y.ToString()); } - [Test] + [TestMethod] public void Slice_Step_With_Offset() { //>>> x = np.arange(9).astype(np.uint8) @@ -467,7 +468,7 @@ public void Slice_Step_With_Offset() } - [Test] + [TestMethod] public void Slice3x2x2() { //>>> x = np.arange(12).reshape(3, 2, 2) @@ -508,7 +509,7 @@ public void Slice3x2x2() Assert.IsTrue(Enumerable.SequenceEqual(y2.ToArray(), new long[] { 8, 9, 10, 11 })); } - [Test] + [TestMethod] public void AssignGeneric1DSlice1() { //>>> x = np.arange(5) @@ -557,7 +558,7 @@ public void AssignGeneric1DSlice1() AssertAreEqual(new long[] { 0, 10, 11, 12, 4 }, x.ToArray()); } - [Test] + [TestMethod] public void AssignGeneric1DSliceWithStepAndOffset1() { //>>> x = np.arange(9).astype(np.uint16) @@ -592,7 +593,7 @@ public void AssignGeneric1DSliceWithStepAndOffset1() AssertAreEqual(new ushort[] { 10, 10, 2, 11, 11, 5, 12, 12, 8 }, x.ToArray()); } - [Test] + [TestMethod] public void AssignGeneric2DSlice1() { //>>> x = np.arange(9).reshape(3, 3) @@ -650,7 +651,7 @@ public void AssignGeneric2DSlice1() /// /// Based on issue https://github.com/SciSharp/NumSharp/issues/293 /// - [Test] + [TestMethod] public void CastingWhenSettingDifferentType() { NDArray output = np.zeros(5); @@ -664,19 +665,19 @@ public void CastingWhenSettingDifferentType() private static NDArray x = np.arange(10, 1, -1); private static NDArray y = np.arange(35).reshape(5, 7); - [Test] + [TestMethod] public void IndexNDArray_Case1() { x[np.array(new int[] { 3, 3, 1, 8 })].Data().Should().ContainInOrder(7, 7, 9, 2); } - [Test] + [TestMethod] public void IndexNDArray_Case2_NegativeIndex() { x[np.array(new int[] { 3, 3, -3, 8 })].Data().Should().ContainInOrder(7, 7, 4, 2); } - [Test] + [TestMethod] public void IndexNDArray_Case3() { new Action(() => @@ -685,7 +686,7 @@ public void IndexNDArray_Case3() }).Should().Throw(); } - [Test] + [TestMethod] public void IndexNDArray_Case4_Shaped() { var ret = x[np.array(new int[][] { new int[] { 1, 1 }, new int[] { 2, 3 }, })]; @@ -693,7 +694,7 @@ public void IndexNDArray_Case4_Shaped() ret.Shape.Should().BeShaped(2, 2); } - [Test] + [TestMethod] public void IndexNDArray_Case5_Shaped() { var ret = np.arange(0, 10).reshape(2, 5)[np.array(new int[][] { new int[] { 0, 1 }, new int[] { 1, 1 }, })]; @@ -701,7 +702,7 @@ public void IndexNDArray_Case5_Shaped() ret.Should().BeShaped(2, 2, 5).And.BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9); } - [Test] + [TestMethod] public void IndexNDArray_Case6_Shaped() { var ret = np.arange(0, 10).reshape(2, 5)[np.array(new int[] { 0, 1, 1 })]; @@ -709,7 +710,7 @@ public void IndexNDArray_Case6_Shaped() ret.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9).And.BeShaped(3, 5); } - [Test] + [TestMethod] public void IndexNDArray_Case7_Multi() { var ret = y[np.array(new int[] { 0, 2, 4 }), np.array(new int[] { 0, 1, 2 })]; @@ -717,7 +718,7 @@ public void IndexNDArray_Case7_Multi() ret.Shape.Should().BeShaped(3); } - [Test] + [TestMethod] public void IndexNDArray_Case8_Multi() { var a = np.arange(27).reshape(3, 3, 3) + 1; @@ -727,7 +728,7 @@ public void IndexNDArray_Case8_Multi() ret.Shape.Should().BeShaped(9); } - [Test] + [TestMethod] public void IndexNDArray_Case14_Multi_Slice() { var a = np.arange(27 * 2).reshape(2, 3, 3, 3) + 1; @@ -737,7 +738,7 @@ public void IndexNDArray_Case14_Multi_Slice() ret.Shape.Should().BeShaped(9); } - [Test] + [TestMethod] public void IndexNDArray_Case9_Multi() { var a = np.arange(27).reshape(3, 3, 3) + 1; @@ -749,7 +750,7 @@ public void IndexNDArray_Case9_Multi() ret.Shape.Should().BeShaped(3, 3, 2); } - [Test] + [TestMethod] public void IndexNDArray_Case10_Multi() { new Action(() => @@ -759,7 +760,7 @@ public void IndexNDArray_Case10_Multi() } - [Test] + [TestMethod] public void IndexNDArray_Case11_Multi() { var ret = y[np.array(new int[] { 0, 2, 4 })]; @@ -769,7 +770,7 @@ public void IndexNDArray_Case11_Multi() ret[2].Data().Should().ContainInOrder(28, 29, 30, 31, 32, 33, 34); } - [Test] + [TestMethod] public void IndexNDArray_Case12_Multi() { var a = np.arange(16).reshape(2, 2, 2, 2); @@ -780,7 +781,7 @@ public void IndexNDArray_Case12_Multi() ret.GetValue(1, 0, 0).Should().Be(4); } - [Test] + [TestMethod] public void IndexNDArray_Case13_Multi() { var ret = y[np.array(new int[] { 0, 2, 4 })]; @@ -791,7 +792,7 @@ public void IndexNDArray_Case13_Multi() } - [Test] + [TestMethod] public void IndexNDArray_Case14_Multi() { var a = np.arange(16).reshape(2, 2, 1, 2, 2); @@ -805,7 +806,7 @@ public void IndexNDArray_Case14_Multi() //ret[2, 0].Data().Should().ContainInOrder(28, 29, 30, 31, 32, 33, 34); } - [Test] + [TestMethod] public void Slice_TwoMinusOne() { var a = np.arange(1 * 1 * 3).reshape((1, 1, 3)); //0, 1 @@ -817,7 +818,7 @@ public void Slice_TwoMinusOne() b.Should().BeOfValues(2).And.BeShaped(1); } - [Test] + [TestMethod] public void IndexNegativeCoordiantes() { var p = np.arange(6).reshape(2, 3); @@ -826,35 +827,35 @@ public void IndexNegativeCoordiantes() p[-1, 1].Should().BeScalar(4); } - [Test] + [TestMethod] public void MinusOne_Case1() { var a = np.arange(4 * 1 * 10 * 1).reshape((4, 1, 10, 1))[-1]; a.Should().BeOfValues(30, 31, 32, 33, 34, 35, 36, 37, 38, 39); } - [Test] + [TestMethod] public void MinusOne_Case2() { var a = np.arange(4 * 1 * 10 * 1).reshape((4, 1, 10, 1))["-1"]; a.Should().BeOfValues(30, 31, 32, 33, 34, 35, 36, 37, 38, 39); } - [Test] + [TestMethod] public void MinusOne_Case3() { var a = np.arange(4 * 1 * 10 * 1).reshape((4, 1, 10, 1))[-1][-1]; a.Should().BeOfValues(30, 31, 32, 33, 34, 35, 36, 37, 38, 39); } - [Test] + [TestMethod] public void MinusOne_Case4() { var a = np.arange(4 * 1 * 10 * 1).reshape((4, 1, 10, 1))["-1"]["-1"]; a.Should().BeOfValues(30, 31, 32, 33, 34, 35, 36, 37, 38, 39); } - [Test] + [TestMethod] public void Broadcasted_Case1() { var a = np.arange(1 * 1 * 3).reshape((1, 1, 3)); //0, 1 @@ -868,7 +869,7 @@ public void Broadcasted_Case1() d.Should().BeOfValues(2, 2, 2).And.BeShaped(3); } - [Test] + [TestMethod] public void Broadcasted_Case2() { var a = np.arange(1 * 1 * 3).reshape((1, 1, 3)); @@ -882,7 +883,7 @@ public void Broadcasted_Case2() b.Should().BeOfValues(6, 7, 8).And.BeShaped(3); } - [Test] + [TestMethod] public void Broadcasted_Case3() { var a = np.arange(2 * 1 * 3).reshape((2, 1, 3)); @@ -896,7 +897,7 @@ public void Broadcasted_Case3() b.Should().BeOfValues(9, 10, 11, 12, 13, 14, 15, 16, 17).And.BeShaped(3, 3); } - [Test] + [TestMethod] public void Broadcasted_Case4() { var a = np.arange(2 * 10 * 3).reshape((2, 10, 3)); @@ -911,7 +912,7 @@ public void Broadcasted_Case4() b.Should().BeShaped(10, 3); } - [Test] + [TestMethod] public void Broadcasted_Case5() { var a = np.arange(2 * 1 * 3).reshape((2, 1, 3)); //0, 1 @@ -928,7 +929,7 @@ public void Broadcasted_Case5() } - [Test] + [TestMethod] public void Broadcasted_Case6_GetData() { var a = np.arange(3 * 1 * 2 * 2).reshape((3, 1, 2, 2)); @@ -944,7 +945,7 @@ public void Broadcasted_Case6_GetData() ret.Should().BeShaped(2, 2).And.BeOfValues(4, 5, 6, 7); } - [Test] + [TestMethod] public void Broadcasted_Case7_GetData() { var a = np.arange(2 * 3 * 2 * 2).reshape((2, 3, 2, 2)); @@ -958,7 +959,7 @@ public void Broadcasted_Case7_GetData() ret.Should().BeShaped(2, 2).And.BeOfValues(0, 1, 2, 3); } - [Test] + [TestMethod] public void Broadcasted_Case8_GetData() { var a = np.arange(2 * 3 * 2 * 2).reshape((2, 3, 2, 2)); @@ -971,7 +972,7 @@ public void Broadcasted_Case8_GetData() ret.Should().BeShaped(2, 2).And.BeOfValues(4, 5, 6, 7); } - [Test] + [TestMethod] public void Broadcasted_Case9() { var a = np.arange(2 * 3 * 2 * 2).reshape((2, 3, 2, 2)); @@ -986,14 +987,14 @@ public void Broadcasted_Case9() str.Should().Be(np.array(4, 5, 6, 7).reshape(2, 2).ToString(true)); } - [Test] + [TestMethod] public void Slice_MinusOne() { var a = np.arange(4 * 1 * 1 * 1).reshape(4, 1, 1, 1); a["-1, :"].Should().Be(a["3, :"]); } - [Test] + [TestMethod] public void Broadcasted_Case9_Sliced() { var a = np.arange(4 * 1 * 1 * 1).reshape(4, 1, 1, 1)["3, :"]; @@ -1009,7 +1010,7 @@ public void Broadcasted_Case9_Sliced() b.Should().BeOfValues(30, 31, 32, 33, 34, 35, 36, 37, 38, 39); } - [Test] + [TestMethod] public void Broadcasted_Case10_Sliced() { var a = np.arange(2 * 2 * 1 * 3).reshape((2, 2, 1, 3))["0, -1"]; //0, 1 @@ -1023,7 +1024,7 @@ public void Broadcasted_Case10_Sliced() Console.WriteLine(b.ToString()); } - [Test] + [TestMethod] public void SliceEndingWithAll() { var a = np.arange(9).reshape(3, 3); @@ -1033,7 +1034,7 @@ public void SliceEndingWithAll() sliced.Should().BeShaped(3).And.NotBeSliced(); } - [Test] + [TestMethod] public void IndexSelecton_2D_from_1D() { //>>> x = np.arange(10, 1, -1) @@ -1049,7 +1050,7 @@ public void IndexSelecton_2D_from_1D() } - [Test] + [TestMethod] public void IndexSelecton_2D_from_2D() { //>>> y = np.arange(35).reshape(5, 7) @@ -1060,7 +1061,7 @@ public void IndexSelecton_2D_from_2D() y[np.array(0, 2, 4), np.array(0, 1, 2)].Should().BeOfValues(0, 15, 30).And.BeShaped(3); } - [Test] + [TestMethod] public void IndexSelecton_IndexArray_plus_Scalar_from_2D() { //>>> y = np.arange(35).reshape(5, 7) @@ -1071,7 +1072,7 @@ public void IndexSelecton_IndexArray_plus_Scalar_from_2D() y[np.array(0, 2, 4), 1].Should().BeOfValues(1, 15, 29).And.BeShaped(3); } - [Test] + [TestMethod] public void IndexSelecton_1D_from_2D() { //>>> y = np.arange(35).reshape(5, 7) @@ -1083,7 +1084,7 @@ public void IndexSelecton_1D_from_2D() y[np.array(0, 2, 4)].Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 14, 15, 16, 17, 18, 19, 20, 28, 29, 30, 31, 32, 33, 34).And.BeShaped(3, 7); } - [Test] + [TestMethod] public void Masking_2D_over_2D() { //>>> y = np.arange(35).reshape(5, 7) @@ -1094,7 +1095,7 @@ public void Masking_2D_over_2D() y[y > 20].Should().BeOfValues(21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34).And.BeShaped(14); } - [Test] + [TestMethod] public void Masking_1D_over_2D() { //>>> y = np.arange(35).reshape(5, 7) @@ -1108,7 +1109,7 @@ public void Masking_1D_over_2D() y[b[":, 5"]].Should().BeOfValues(21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34).And.BeShaped(2, 7); } - [Test] + [TestMethod] [OpenBugs] public void Masking_2D_over_3D() { @@ -1131,7 +1132,7 @@ public void Masking_2D_over_3D() y[b[":, 5"]].Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29).And.BeShaped(4, 5); } - [Test] + [TestMethod] public void MixedIndexing_NDim() { // slicing with mixed index types @@ -1142,7 +1143,7 @@ public void MixedIndexing_NDim() a[Slice.All, "1:2", 0].Should().BeOfValues(3, 12, 21).And.BeShaped(3, 1); } - [Test] + [TestMethod] [OpenBugs] public void Combining_IndexArrays_with_Slices() { @@ -1156,7 +1157,7 @@ public void Combining_IndexArrays_with_Slices() } - [Test] + [TestMethod] [OpenBugs] public void Combining_MaskArrays_with_Slices() { @@ -1184,7 +1185,7 @@ private NDArray GetIndicesFromSlice(Shape shape, Slice slice, int axis) } - [Test] + [TestMethod] public void IndexNDArray_1d_indexed_by_2d() { var nd = np.arange(12); @@ -1194,7 +1195,7 @@ public void IndexNDArray_1d_indexed_by_2d() ret.Should().BeOfValues(0, 1, 2, 3, 4, 5, 6, 7, 8).And.BeShaped(3, 3); } - [Test] + [TestMethod] public void IndexNDArray_1d_indexed_by_2d_1d() { var nd = np.arange(24).reshape(6, 4); @@ -1204,7 +1205,7 @@ public void IndexNDArray_1d_indexed_by_2d_1d() ret.Should().BeOfValues(1, 5, 9, 13).And.BeShaped(2, 2); } - [Test] + [TestMethod] public void IndexNDArray_2d_indexed_by_1d() { var nd = np.arange(2 * 4).reshape(4, 2); @@ -1214,7 +1215,7 @@ public void IndexNDArray_2d_indexed_by_1d() ret.Should().BeOfValues(0, 1, 4, 5).And.BeShaped(2, 2); } - [Test] + [TestMethod] public void IndexNDArray_2d_indexed_by_1d_1d() { var nd = np.arange(2 * 4).reshape(4, 2); @@ -1224,7 +1225,7 @@ public void IndexNDArray_2d_indexed_by_1d_1d() ret.Should().BeOfValues(0, 5).And.BeShaped(2); } - [Test] + [TestMethod] public void IndexNDArray_2d_and_2dsliced_indexed_by_1dsliced_1dsliced() { Test(np.arange(2 * 4).reshape(4, 2)); @@ -1241,7 +1242,7 @@ void Test(NDArray nd) } } - [Test] + [TestMethod] public void IndexNDArray_sliced2dreshaped_indexed_by_1d_1d() { Test(np.arange(2 * 2 * 4)["::2"].reshape(2, 4)); @@ -1257,7 +1258,7 @@ void Test(NDArray nd) } } - [Test] + [TestMethod] public void IndexNDArray_sliced3dreshaped_indexed_by_1d_1d() { Test(np.arange(2 * 2 * 4 * 2)["::2"].reshape(2, 4, 2)); @@ -1273,7 +1274,7 @@ void Test(NDArray nd) } } - [Test] + [TestMethod] public void GetIndicesFromSlice_Test() { GetIndicesFromSlice((3, 4, 3), new Slice("::2"), 1).Should().BeOfValues(0, 2).And.BeShaped(2); @@ -1282,50 +1283,50 @@ public void GetIndicesFromSlice_Test() // GetCoordinates_Broadcasted test removed - GetCoordinatesFromAbsoluteIndex was dead API - [Test] + [TestMethod] public void IndexNDArray_NewAxis_Case1() { np.arange(8).reshape(2, 2, 2)[0, np.newaxis, 0, np.newaxis, np.newaxis, Slice.All].Should().BeShaped(1, 1, 1, 2).And.BeOfValues(0, 1); } - [Test] + [TestMethod] [OpenBugs] // newaxis indexing returns wrong shape public void IndexNDArray_NewAxis_Case2() { np.arange(2 * 8).reshape(2, 2, 2, 2)[np.array(0), 0, np.newaxis, 0, np.newaxis, np.newaxis, Slice.All].Should().BeShaped(1, 1, 1, 2).And.BeOfValues(0, 1); } - [Test] + [TestMethod] public void IndexNDArray_NewAxis_Case3() { np.arange(4).reshape(2, 2)[np.newaxis, np.arange(2)].Should().BeShaped(1, 2, 2); } - [Test] + [TestMethod] public void IndexNDArray_NewAxis_Ellipsis_Case1() { np.arange(4).reshape(2, 2)["..., newaxis"].Should().BeShaped(2, 2, 1); } - [Test] + [TestMethod] public void IndexNDArray_Ellipsis_Case1() { np.arange(4).reshape(2, 1, 2)[Slice.Ellipsis, 0].Should().BeShaped(2, 1); } - [Test] + [TestMethod] public void IndexNDArray_Ellipsis_Case2() { np.arange(8).reshape(2, 1, 2, 1, 2)[Slice.Ellipsis, 0].Should().BeShaped(2, 1, 2, 1); } - [Test] + [TestMethod] public void IndexNDArray_Ellipsis_Case3() { np.arange(8).reshape(2, 1, 2, 1, 2)[0, Slice.Ellipsis].Should().BeShaped(1, 2, 1, 2); } - [Test] + [TestMethod] public void IndexNDArray_Set_Case1() { var a = np.arange(8).reshape(2,4); @@ -1333,7 +1334,7 @@ public void IndexNDArray_Set_Case1() a.Should().BeShaped(2,4).And.BeOfValues(0,1,2,3,0,1,2,3); } - [Test] + [TestMethod] public void IndexNDArray_Set_Case2() { var a = np.arange(8).reshape(2, 4); @@ -1341,7 +1342,7 @@ public void IndexNDArray_Set_Case2() a.Should().BeShaped(2, 4).And.BeOfValues(0, 1, 2, 3, 0, 1, 2, 3); } - [Test] + [TestMethod] public void IndexNDArray_Set_Case3() { var a = np.arange(8).reshape(2, 4); @@ -1349,7 +1350,7 @@ public void IndexNDArray_Set_Case3() a.Should().BeShaped(2, 4).And.BeOfValues(0, 1, 2, 3, 0, 1, 2, 3); } - [Test] + [TestMethod] public void IndexNDArray_Set_Case4() { var a = np.arange(8).reshape(2, 4); @@ -1357,7 +1358,7 @@ public void IndexNDArray_Set_Case4() a.Should().BeShaped(2, 4).And.BeOfValues(0, 1, 2, 3, 0, 1, 2, 3); } - [Test] + [TestMethod] public void IndexNDArray_Set_Case5() { var a = np.arange(8).reshape(2, 4); @@ -1365,7 +1366,7 @@ public void IndexNDArray_Set_Case5() a.Should().BeShaped(2, 4).And.BeOfValues(0, 1, 2, 3, 0, 1, 2, 3); } - [Test] + [TestMethod] public void IndexNDArray_Set_Case6() { var a = np.arange(8).reshape(2, 4); @@ -1373,7 +1374,7 @@ public void IndexNDArray_Set_Case6() a.Should().BeShaped(2, 4).And.BeOfValues(0, 1, 2, 3, 0, 1, 2, 3); } - [Test] + [TestMethod] public void IndexNDArray_Set_Case7_Boolean() { var a = np.arange(8); @@ -1381,7 +1382,7 @@ public void IndexNDArray_Set_Case7_Boolean() a.Should().BeShaped(8); } - [Test] + [TestMethod] public void IndexNDArray_Set_Case8_Broadcasted() { // Broadcast arrays are read-only (NumPy behavior). @@ -1395,7 +1396,7 @@ public void IndexNDArray_Set_Case8_Broadcasted() }).Should().Throw().WithMessage("assignment destination is read-only"); } - [Test] + [TestMethod] public void IndexNDArray_Get_Case1_Broadcasted() { var a = np.broadcast_to(np.arange(4).reshape(1, 4), (2, 4)); @@ -1403,21 +1404,21 @@ public void IndexNDArray_Get_Case1_Broadcasted() a[1].Should().BeShaped(4).And.BeOfValues(0, 1, 2, 3); } - [Test] + [TestMethod] public void IndexNDArray_Get_Case2_Broadcasted() { var a = np.broadcast_to(np.arange(4).reshape(1, 4), (2, 4)); a["0:1"].Should().BeShaped(1, 4).And.BeOfValues(0, 1, 2, 3); } - [Test] + [TestMethod] public void IndexNDArray_Get_Case3_Broadcasted() { var a = np.broadcast_to(np.arange(4).reshape(1, 4), (2, 4)); a["0:1, :"].Should().BeShaped(1, 4).And.BeOfValues(0, 1, 2, 3); } - [Test] + [TestMethod] public void IndexNDArray_Get_Case4_Broadcasted() { var a = np.broadcast_to(np.arange(4).reshape(1, 4), (2, 4)); @@ -1426,21 +1427,21 @@ public void IndexNDArray_Get_Case4_Broadcasted() } - [Test] + [TestMethod] public void IndexNDArray_Get_Case5_Broadcasted() { var a = np.broadcast_to(np.arange(4).reshape(1, 4), (2, 4)); a[Slice.Index(0)].Should().BeShaped(4).And.BeOfValues(0, 1, 2, 3); } - [Test] + [TestMethod] public void IndexNDArray_Get_Case6_Broadcasted() { var a = np.broadcast_to(np.arange(4).reshape(1, 4), (2, 4)); a[new Slice(0, 1), Slice.All].Should().BeShaped(1, 4).And.BeOfValues(0, 1, 2, 3); } - [Test] + [TestMethod] [OpenBugs] public void IndexNDArray_Get_Case7_Broadcasted() { @@ -1454,7 +1455,7 @@ public void IndexNDArray_Get_Case7_Broadcasted() a[np.arange(1) + 1, Slice.All].Should().BeShaped(1, 4).And.BeOfValues(0, 1, 2, 3); } - [Test] + [TestMethod] [OpenBugs] public void IndexNDArray_Get_Case7() { @@ -1471,7 +1472,7 @@ public void IndexNDArray_Get_Case7() } - [Test] + [TestMethod] [OpenBugs] public void IndexNDArray_Get_Case8_Broadcasted() { diff --git a/test/NumSharp.UnitTest/Sorting/ArgsortInt64Tests.cs b/test/NumSharp.UnitTest/Sorting/ArgsortInt64Tests.cs index 3d30a7db0..cdb86486b 100644 --- a/test/NumSharp.UnitTest/Sorting/ArgsortInt64Tests.cs +++ b/test/NumSharp.UnitTest/Sorting/ArgsortInt64Tests.cs @@ -1,11 +1,7 @@ using System; using System.Linq; -using System.Threading.Tasks; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.Sorting; @@ -13,122 +9,123 @@ namespace NumSharp.UnitTest.Sorting; /// Tests for np.argsort int64 migration. /// Verifies argsort returns long (int64) indices, matching NumPy behavior. /// +[TestClass] public class ArgsortInt64Tests { #region Return Type Tests - [Test] - public async Task Argsort_ReturnsInt64Indices() + [TestMethod] + public void Argsort_ReturnsInt64Indices() { // NumPy: np.argsort([3, 1, 2]).dtype = int64 var a = np.array(new int[] { 3, 1, 2 }); var result = np.argsort(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.typecode.Should().Be(NPTypeCode.Int64); } - [Test] - public async Task Argsort_Float64_ReturnsInt64Indices() + [TestMethod] + public void Argsort_Float64_ReturnsInt64Indices() { var a = np.array(new double[] { 3.0, 1.0, 2.0 }); var result = np.argsort(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.typecode.Should().Be(NPTypeCode.Int64); } - [Test] - public async Task Argsort_Float32_ReturnsInt64Indices() + [TestMethod] + public void Argsort_Float32_ReturnsInt64Indices() { var a = np.array(new float[] { 3.0f, 1.0f, 2.0f }); var result = np.argsort(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.typecode.Should().Be(NPTypeCode.Int64); } - [Test] - public async Task Argsort_Byte_ReturnsInt64Indices() + [TestMethod] + public void Argsort_Byte_ReturnsInt64Indices() { var a = np.array(new byte[] { 3, 1, 2 }); var result = np.argsort(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.typecode.Should().Be(NPTypeCode.Int64); } - [Test] - public async Task Argsort_Int64_ReturnsInt64Indices() + [TestMethod] + public void Argsort_Int64_ReturnsInt64Indices() { var a = np.array(new long[] { 3, 1, 2 }); var result = np.argsort(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.typecode.Should().Be(NPTypeCode.Int64); } #endregion #region Various DType Tests - [Test] - public async Task Argsort_Int16_SortsCorrectly() + [TestMethod] + public void Argsort_Int16_SortsCorrectly() { // NumPy: np.argsort(np.array([30, 10, 20], dtype=np.int16)) = [1, 2, 0] var a = np.array(new short[] { 30, 10, 20 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(2L); + result.GetInt64(2).Should().Be(0L); } - [Test] - public async Task Argsort_UInt16_SortsCorrectly() + [TestMethod] + public void Argsort_UInt16_SortsCorrectly() { var a = np.array(new ushort[] { 30, 10, 20 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(2L); + result.GetInt64(2).Should().Be(0L); } - [Test] - public async Task Argsort_UInt32_SortsCorrectly() + [TestMethod] + public void Argsort_UInt32_SortsCorrectly() { var a = np.array(new uint[] { 30, 10, 20 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(2L); + result.GetInt64(2).Should().Be(0L); } - [Test] - public async Task Argsort_UInt64_SortsCorrectly() + [TestMethod] + public void Argsort_UInt64_SortsCorrectly() { var a = np.array(new ulong[] { 30, 10, 20 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(2L); + result.GetInt64(2).Should().Be(0L); } - [Test] - public async Task Argsort_Decimal_SortsCorrectly() + [TestMethod] + public void Argsort_Decimal_SortsCorrectly() { var a = np.array(new decimal[] { 3.0m, 1.0m, 2.0m }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(2L); + result.GetInt64(2).Should().Be(0L); } #endregion #region Axis Parameter Tests - [Test] - public async Task Argsort_2D_Axis0_SortsColumns() + [TestMethod] + public void Argsort_2D_Axis0_SortsColumns() { // NumPy: // a = np.array([[3, 1], [1, 3], [2, 2]]) @@ -136,23 +133,23 @@ public async Task Argsort_2D_Axis0_SortsColumns() var a = np.array(new int[,] { { 3, 1 }, { 1, 3 }, { 2, 2 } }); var result = np.argsort(a, axis: 0); - await Assert.That(result.shape[0]).IsEqualTo(3); - await Assert.That(result.shape[1]).IsEqualTo(2); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.shape[0].Should().Be(3); + result.shape[1].Should().Be(2); + result.typecode.Should().Be(NPTypeCode.Int64); // First column sorted: values [3,1,2] -> indices [1,2,0] - await Assert.That(result.GetInt64(0, 0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1, 0)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2, 0)).IsEqualTo(0L); + result.GetInt64(0, 0).Should().Be(1L); + result.GetInt64(1, 0).Should().Be(2L); + result.GetInt64(2, 0).Should().Be(0L); // Second column sorted: values [1,3,2] -> indices [0,2,1] - await Assert.That(result.GetInt64(0, 1)).IsEqualTo(0L); - await Assert.That(result.GetInt64(1, 1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2, 1)).IsEqualTo(1L); + result.GetInt64(0, 1).Should().Be(0L); + result.GetInt64(1, 1).Should().Be(2L); + result.GetInt64(2, 1).Should().Be(1L); } - [Test] - public async Task Argsort_2D_Axis1_SortsRows() + [TestMethod] + public void Argsort_2D_Axis1_SortsRows() { // NumPy: // a = np.array([[3, 1, 2], [6, 4, 5]]) @@ -160,62 +157,62 @@ public async Task Argsort_2D_Axis1_SortsRows() var a = np.array(new int[,] { { 3, 1, 2 }, { 6, 4, 5 } }); var result = np.argsort(a, axis: 1); - await Assert.That(result.shape[0]).IsEqualTo(2); - await Assert.That(result.shape[1]).IsEqualTo(3); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.shape[0].Should().Be(2); + result.shape[1].Should().Be(3); + result.typecode.Should().Be(NPTypeCode.Int64); // First row: values [3,1,2] -> indices [1,2,0] - await Assert.That(result.GetInt64(0, 0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(0, 1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(0, 2)).IsEqualTo(0L); + result.GetInt64(0, 0).Should().Be(1L); + result.GetInt64(0, 1).Should().Be(2L); + result.GetInt64(0, 2).Should().Be(0L); // Second row: values [6,4,5] -> indices [1,2,0] - await Assert.That(result.GetInt64(1, 0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1, 1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(1, 2)).IsEqualTo(0L); + result.GetInt64(1, 0).Should().Be(1L); + result.GetInt64(1, 1).Should().Be(2L); + result.GetInt64(1, 2).Should().Be(0L); } - [Test] - public async Task Argsort_2D_AxisMinus1_SortsLastAxis() + [TestMethod] + public void Argsort_2D_AxisMinus1_SortsLastAxis() { // NumPy: axis=-1 is equivalent to the last axis var a = np.array(new int[,] { { 3, 1, 2 }, { 6, 4, 5 } }); var result = np.argsort(a, axis: -1); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.typecode.Should().Be(NPTypeCode.Int64); // Same as axis=1 for 2D - await Assert.That(result.GetInt64(0, 0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(0, 1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(0, 2)).IsEqualTo(0L); + result.GetInt64(0, 0).Should().Be(1L); + result.GetInt64(0, 1).Should().Be(2L); + result.GetInt64(0, 2).Should().Be(0L); } #endregion #region Edge Cases - [Test] - public async Task Argsort_SingleElement_ReturnsZero() + [TestMethod] + public void Argsort_SingleElement_ReturnsZero() { var a = np.array(new int[] { 42 }); var result = np.argsort(a); - await Assert.That(result.size).IsEqualTo(1); - await Assert.That(result.GetInt64(0)).IsEqualTo(0L); + result.size.Should().Be(1); + result.GetInt64(0).Should().Be(0L); } - [Test] - public async Task Argsort_TwoElements_SortsCorrectly() + [TestMethod] + public void Argsort_TwoElements_SortsCorrectly() { var a = np.array(new int[] { 2, 1 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(0L); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(0L); } - [Test] - public async Task Argsort_DuplicateValues_StableSort() + [TestMethod] + public void Argsort_DuplicateValues_StableSort() { // NumPy uses stable sort by default (mergesort) // For equal values, original order is preserved @@ -225,28 +222,28 @@ public async Task Argsort_DuplicateValues_StableSort() // All 1s come first, then all 2s // Original indices of 1s: 0, 2, 4 // Original indices of 2s: 1, 3 - await Assert.That(result.GetInt64(0)).IsEqualTo(0L); - await Assert.That(result.GetInt64(1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2)).IsEqualTo(4L); - await Assert.That(result.GetInt64(3)).IsEqualTo(1L); - await Assert.That(result.GetInt64(4)).IsEqualTo(3L); + result.GetInt64(0).Should().Be(0L); + result.GetInt64(1).Should().Be(2L); + result.GetInt64(2).Should().Be(4L); + result.GetInt64(3).Should().Be(1L); + result.GetInt64(4).Should().Be(3L); } - [Test] - public async Task Argsort_LargerArray_SortsCorrectly() + [TestMethod] + public void Argsort_LargerArray_SortsCorrectly() { // Test with a larger array to ensure no issues with indexing var values = new int[] { 9, 3, 7, 1, 5, 8, 2, 6, 4, 0 }; var a = np.array(values); var result = np.argsort(a); - await Assert.That(result.typecode).IsEqualTo(NPTypeCode.Int64); + result.typecode.Should().Be(NPTypeCode.Int64); // Expected order by value: 0(idx9), 1(idx3), 2(idx6), 3(idx1), 4(idx8), 5(idx4), 6(idx7), 7(idx2), 8(idx5), 9(idx0) var expected = new long[] { 9, 3, 6, 1, 8, 4, 7, 2, 5, 0 }; for (int i = 0; i < expected.Length; i++) { - await Assert.That(result.GetInt64(i)).IsEqualTo(expected[i]); + result.GetInt64(i).Should().Be(expected[i]); } } @@ -254,8 +251,8 @@ public async Task Argsort_LargerArray_SortsCorrectly() #region Using Result as Index - [Test] - public async Task Argsort_CanBeUsedForIndexing() + [TestMethod] + public void Argsort_CanBeUsedForIndexing() { // NumPy pattern: a[np.argsort(a)] gives sorted array var a = np.array(new int[] { 3, 1, 4, 1, 5, 9, 2, 6 }); @@ -268,7 +265,7 @@ public async Task Argsort_CanBeUsedForIndexing() var sortedData = sorted.Data(); for (int i = 1; i < sortedData.Count; i++) { - await Assert.That(sortedData[i]).IsGreaterThanOrEqualTo(sortedData[i - 1]); + sortedData[i].Should().BeGreaterThanOrEqualTo(sortedData[i - 1]); } } diff --git a/test/NumSharp.UnitTest/Sorting/ArgsortNaNTests.cs b/test/NumSharp.UnitTest/Sorting/ArgsortNaNTests.cs index 6da0d08d0..0abfcf51b 100644 --- a/test/NumSharp.UnitTest/Sorting/ArgsortNaNTests.cs +++ b/test/NumSharp.UnitTest/Sorting/ArgsortNaNTests.cs @@ -1,10 +1,6 @@ using System; -using System.Threading.Tasks; using NumSharp; using NumSharp.UnitTest.Utilities; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; -using TUnit.Core; namespace NumSharp.UnitTest.Sorting; @@ -15,150 +11,151 @@ namespace NumSharp.UnitTest.Sorting; /// - -Inf sorts to the beginning /// - +Inf sorts between normal values and NaN /// +[TestClass] public class ArgsortNaNTests { #region NaN Handling - [Test] - public async Task Argsort_NaN_SortsToEnd() + [TestMethod] + public void Argsort_NaN_SortsToEnd() { // NumPy: np.argsort([nan, 1, 2]) = [1, 2, 0] // NaN should be at the end var a = np.array(new double[] { double.NaN, 1.0, 2.0 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(2L); + result.GetInt64(2).Should().Be(0L); } - [Test] - public async Task Argsort_MultipleNaN_SortToEnd() + [TestMethod] + public void Argsort_MultipleNaN_SortToEnd() { // NumPy: np.argsort([nan, 1, nan, 2]) = [1, 3, 0, 2] // All NaN values at the end, maintaining relative order var a = np.array(new double[] { double.NaN, 1.0, double.NaN, 2.0 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); // 1.0 - await Assert.That(result.GetInt64(1)).IsEqualTo(3L); // 2.0 + result.GetInt64(0).Should().Be(1L); // 1.0 + result.GetInt64(1).Should().Be(3L); // 2.0 // NaN values at end - await Assert.That(double.IsNaN(a.GetDouble((int)result.GetInt64(2)))).IsTrue(); - await Assert.That(double.IsNaN(a.GetDouble((int)result.GetInt64(3)))).IsTrue(); + double.IsNaN(a.GetDouble((int)result.GetInt64(2))).Should().BeTrue(); + double.IsNaN(a.GetDouble((int)result.GetInt64(3))).Should().BeTrue(); } #endregion #region Inf Handling - [Test] - public async Task Argsort_Inf_SortsCorrectly() + [TestMethod] + public void Argsort_Inf_SortsCorrectly() { // NumPy: np.argsort([inf, -inf, 0]) = [1, 2, 0] // -inf first, then 0, then inf var a = np.array(new double[] { double.PositiveInfinity, double.NegativeInfinity, 0.0 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); // -inf - await Assert.That(result.GetInt64(1)).IsEqualTo(2L); // 0 - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); // +inf + result.GetInt64(0).Should().Be(1L); // -inf + result.GetInt64(1).Should().Be(2L); // 0 + result.GetInt64(2).Should().Be(0L); // +inf } - [Test] - public async Task Argsort_InfAndNaN_SortsCorrectly() + [TestMethod] + public void Argsort_InfAndNaN_SortsCorrectly() { // NumPy: np.argsort([nan, inf, -inf, 0]) = [2, 3, 1, 0] // Order: -inf, 0, +inf, nan var a = np.array(new double[] { double.NaN, double.PositiveInfinity, double.NegativeInfinity, 0.0 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(2L); // -inf - await Assert.That(result.GetInt64(1)).IsEqualTo(3L); // 0 - await Assert.That(result.GetInt64(2)).IsEqualTo(1L); // +inf - await Assert.That(result.GetInt64(3)).IsEqualTo(0L); // nan + result.GetInt64(0).Should().Be(2L); // -inf + result.GetInt64(1).Should().Be(3L); // 0 + result.GetInt64(2).Should().Be(1L); // +inf + result.GetInt64(3).Should().Be(0L); // nan } #endregion #region Float32 Tests - [Test] - public async Task Argsort_Float32_NaN_SortsToEnd() + [TestMethod] + public void Argsort_Float32_NaN_SortsToEnd() { // Same behavior for float32 var a = np.array(new float[] { float.NaN, 1.0f, 2.0f }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(2L); + result.GetInt64(2).Should().Be(0L); } - [Test] - public async Task Argsort_Float32_InfAndNaN_SortsCorrectly() + [TestMethod] + public void Argsort_Float32_InfAndNaN_SortsCorrectly() { var a = np.array(new float[] { float.NaN, float.PositiveInfinity, float.NegativeInfinity, 0.0f }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(2L); // -inf - await Assert.That(result.GetInt64(1)).IsEqualTo(3L); // 0 - await Assert.That(result.GetInt64(2)).IsEqualTo(1L); // +inf - await Assert.That(result.GetInt64(3)).IsEqualTo(0L); // nan + result.GetInt64(0).Should().Be(2L); // -inf + result.GetInt64(1).Should().Be(3L); // 0 + result.GetInt64(2).Should().Be(1L); // +inf + result.GetInt64(3).Should().Be(0L); // nan } #endregion #region Basic Argsort (No NaN) - [Test] - public async Task Argsort_Normal_SortsCorrectly() + [TestMethod] + public void Argsort_Normal_SortsCorrectly() { // NumPy: np.argsort([3, 1, 2]) = [1, 2, 0] var a = np.array(new double[] { 3.0, 1.0, 2.0 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(2L); + result.GetInt64(2).Should().Be(0L); } - [Test] - public async Task Argsort_AlreadySorted_ReturnsSequentialIndices() + [TestMethod] + public void Argsort_AlreadySorted_ReturnsSequentialIndices() { // NumPy: np.argsort([1, 2, 3]) = [0, 1, 2] var a = np.array(new double[] { 1.0, 2.0, 3.0 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(0L); - await Assert.That(result.GetInt64(1)).IsEqualTo(1L); - await Assert.That(result.GetInt64(2)).IsEqualTo(2L); + result.GetInt64(0).Should().Be(0L); + result.GetInt64(1).Should().Be(1L); + result.GetInt64(2).Should().Be(2L); } - [Test] - public async Task Argsort_ReverseSorted_ReturnsReverseIndices() + [TestMethod] + public void Argsort_ReverseSorted_ReturnsReverseIndices() { // NumPy: np.argsort([3, 2, 1]) = [2, 1, 0] var a = np.array(new double[] { 3.0, 2.0, 1.0 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(2L); - await Assert.That(result.GetInt64(1)).IsEqualTo(1L); - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); + result.GetInt64(0).Should().Be(2L); + result.GetInt64(1).Should().Be(1L); + result.GetInt64(2).Should().Be(0L); } #endregion #region Integer Types (No NaN) - [Test] - public async Task Argsort_Int32_SortsCorrectly() + [TestMethod] + public void Argsort_Int32_SortsCorrectly() { var a = np.array(new int[] { 3, 1, 2 }); var result = np.argsort(a); - await Assert.That(result.GetInt64(0)).IsEqualTo(1L); - await Assert.That(result.GetInt64(1)).IsEqualTo(2L); - await Assert.That(result.GetInt64(2)).IsEqualTo(0L); + result.GetInt64(0).Should().Be(1L); + result.GetInt64(1).Should().Be(2L); + result.GetInt64(2).Should().Be(0L); } #endregion diff --git a/test/NumSharp.UnitTest/Statistics/NDArray.Std.Test.cs b/test/NumSharp.UnitTest/Statistics/NDArray.Std.Test.cs index e50be7108..7cfef4c61 100644 --- a/test/NumSharp.UnitTest/Statistics/NDArray.Std.Test.cs +++ b/test/NumSharp.UnitTest/Statistics/NDArray.Std.Test.cs @@ -4,16 +4,17 @@ namespace NumSharp.UnitTest.Statistics { + [TestClass] public class np_std_tests { - [Test] + [TestMethod] public void Case1() { var nd1 = np.arange(4).reshape(2, 2); nd1.std().Data()[0].Should().BeApproximately(1.118033, 0.0001); } - [Test] + [TestMethod] public void Case2() { var a = np.zeros((2, 4 * 4), dtype: np.float32); @@ -23,7 +24,7 @@ public void Case2() ret.GetValue(0).Should().BeApproximately(0.45f, 0.001f); } - [Test] + [TestMethod] public void Case3() { var nd1 = np.arange(4).reshape(2, 2); @@ -33,7 +34,7 @@ public void Case3() ret.ToArray().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case4() { var nd1 = np.arange(4).reshape(2, 2); @@ -43,7 +44,7 @@ public void Case4() ret.ToArray().Should().AllBeEquivalentTo(0.5d); } - [Test] + [TestMethod] public void Case5() { var nd1 = np.arange(4).reshape(2, 2); @@ -54,7 +55,7 @@ public void Case5() ret.ToArray()[1].Should().BeApproximately(1.41421356, 0.0001d); } - [Test] + [TestMethod] public void Case6() { var nd1 = np.arange(4).reshape(2, 2); @@ -65,7 +66,7 @@ public void Case6() ret.ToArray()[1].Should().BeApproximately(0.70710678, 0.0001d); } - [Test] + [TestMethod] public void Case7() { var nd1 = np.arange(4).reshape(2, 2); diff --git a/test/NumSharp.UnitTest/Statistics/NDArray.Var.Test.cs b/test/NumSharp.UnitTest/Statistics/NDArray.Var.Test.cs index 1a4439bb9..5ba621875 100644 --- a/test/NumSharp.UnitTest/Statistics/NDArray.Var.Test.cs +++ b/test/NumSharp.UnitTest/Statistics/NDArray.Var.Test.cs @@ -4,16 +4,17 @@ namespace NumSharp.UnitTest.Statistics { + [TestClass] public class np_var_tests { - [Test] + [TestMethod] public void Case1() { var nd1 = np.arange(4).reshape(2, 2); nd1.var().Data()[0].Should().BeApproximately(1.25D, 0.0001); } - [Test] + [TestMethod] public void Case2() { var a = np.zeros((2, 4 * 4), dtype: np.float32); @@ -23,7 +24,7 @@ public void Case2() ret.GetValue(0).Should().BeApproximately(0.2025F, 0.001f); } - [Test] + [TestMethod] public void Case3() { var nd1 = np.arange(4).reshape(2, 2); @@ -33,7 +34,7 @@ public void Case3() ret.ToArray().Should().AllBeEquivalentTo(1); } - [Test] + [TestMethod] public void Case4() { var nd1 = np.arange(4).reshape(2, 2); @@ -43,7 +44,7 @@ public void Case4() ret.ToArray().Should().AllBeEquivalentTo(0.5d * 0.5d); } - [Test] + [TestMethod] public void Case5() { var nd1 = np.arange(4).reshape(2, 2); @@ -54,7 +55,7 @@ public void Case5() ret.ToArray()[1].Should().BeApproximately(2, 0.0001d); } - [Test] + [TestMethod] public void Case6() { var nd1 = np.arange(4).reshape(2, 2); @@ -65,7 +66,7 @@ public void Case6() ret.ToArray()[1].Should().BeApproximately(0.5, 0.0001d); } - [Test] + [TestMethod] public void Case7() { var nd1 = np.arange(4).reshape(2, 2); diff --git a/test/NumSharp.UnitTest/Statistics/NdArray.Mean.Test.cs b/test/NumSharp.UnitTest/Statistics/NdArray.Mean.Test.cs index c76afe274..e97b64f98 100644 --- a/test/NumSharp.UnitTest/Statistics/NdArray.Mean.Test.cs +++ b/test/NumSharp.UnitTest/Statistics/NdArray.Mean.Test.cs @@ -5,9 +5,10 @@ namespace NumSharp.UnitTest.Statistics { + [TestClass] public class NdArrayMeanTest { - [Test] + [TestMethod] public void Case1_Elementwise_keepdims() { var np1 = np.array(new double[] { 1, 2, 3, 4, 5, 6 }).reshape(3, 2); @@ -16,7 +17,7 @@ public void Case1_Elementwise_keepdims() mean.GetValue(0, 0).Should().BeEquivalentTo(3.5); } - [Test] + [TestMethod] public void Case0_Scalar() { var np1 = NDArray.Scalar(1d); @@ -25,7 +26,7 @@ public void Case0_Scalar() mean.GetValue(0).Should().BeEquivalentTo(1d); } - [Test] + [TestMethod] public void Case1_Axis0() { var np1 = np.array(new double[] {1, 2, 3, 4}).reshape(2, 2); @@ -33,7 +34,7 @@ public void Case1_Axis0() Assert.IsTrue(Enumerable.SequenceEqual(mean.Data(), new double[] {2, 3})); } - [Test] + [TestMethod] public void Case1_Axis1() { var np1 = np.array(new double[] {1, 2, 3, 4}).reshape(2, 2); @@ -41,7 +42,7 @@ public void Case1_Axis1() Assert.IsTrue(Enumerable.SequenceEqual(mean.Data(), new double[] {1.5, 3.5})); } - [Test] + [TestMethod] public void Case1_Axis_minus1() { var np1 = np.array(new double[] {1, 2, 3, 4}).reshape(2, 2); @@ -50,7 +51,7 @@ public void Case1_Axis_minus1() Assert.IsTrue(Enumerable.SequenceEqual(mean.Data(), new double[] {1.5, 3.5})); } - [Test] + [TestMethod] public void Case1_Elementwise() { var np1 = np.array(new double[] {1, 2, 3, 4, 5, 6}).reshape(3, 2); diff --git a/test/NumSharp.UnitTest/Storage.Test.cs b/test/NumSharp.UnitTest/Storage.Test.cs index c0ca1e955..fd687cea1 100644 --- a/test/NumSharp.UnitTest/Storage.Test.cs +++ b/test/NumSharp.UnitTest/Storage.Test.cs @@ -11,6 +11,7 @@ namespace NumSharp.UnitTest { + [TestClass] public class StorageTester { public UnmanagedStorage strg1D; @@ -32,7 +33,7 @@ public StorageTester() strg2DNonFull.ReplaceData(new float[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); } - [Test] + [TestMethod] public void Creation() { Assert.IsNotNull(strg1D); @@ -40,7 +41,7 @@ public void Creation() Assert.IsNotNull(strg2DNonFull); } - [Test] + [TestMethod] public void InternalArrayCheck() { Assert.IsTrue(strg1D.GetData().Count == 10); @@ -48,7 +49,7 @@ public void InternalArrayCheck() Assert.IsTrue(strg2DNonFull.GetData().Count == 10); } - [Test] + [TestMethod] public void IndexingCheck() { var element1D = strg1D.GetValue(0); @@ -60,7 +61,7 @@ public void IndexingCheck() } } - [Test] + [TestMethod] public unsafe void CloneCheck() { var l = strg1D; @@ -73,7 +74,7 @@ public unsafe void CloneCheck() l.Shape.Should().Be(r.Shape); } - [Test, Skip("Transpose is not implemented")] + [TestMethod, Ignore("Transpose is not implemented")] public void ReshapeLayout2d() { //var x = np.arange(6).MakeGeneric(); @@ -90,7 +91,7 @@ public void ReshapeLayout2d() //Assert.AreEqual(y[1, 0], 3); } - [Test, Skip("Transpose is not implemented")] + [TestMethod, Ignore("Transpose is not implemented")] public void ReshapeLayout3d() { //var x = np.arange(12).MakeGeneric(); @@ -106,7 +107,7 @@ public void ReshapeLayout3d() //Assert.AreEqual(y[0, 1], 4); } - [Test] + [TestMethod] public void CastingViaGet() { new Action(() => @@ -116,8 +117,8 @@ public void CastingViaGet() }).Should().NotThrow(); } - [Skip("Ignored")] - [Test] + [Ignore("Ignored")] + [TestMethod] public void CheckChangeTensorLayout2D() { var strg2DCpy = (UnmanagedStorage)strg2D.Clone(); diff --git a/test/NumSharp.UnitTest/TestCategory.cs b/test/NumSharp.UnitTest/TestCategory.cs index a8db9e29f..2c1c3977b 100644 --- a/test/NumSharp.UnitTest/TestCategory.cs +++ b/test/NumSharp.UnitTest/TestCategory.cs @@ -1,5 +1,6 @@ using System; -using TUnit.Core; +using System.Collections.Generic; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace NumSharp.UnitTest; @@ -8,35 +9,35 @@ namespace NumSharp.UnitTest; /// /// How Categories Work in CI: /// -/// The CI pipeline (.github/workflows/build-and-release.yml) uses TUnit's -/// --treenode-filter to exclude certain categories from test runs: +/// The CI pipeline (.github/workflows/build-and-release.yml) uses MSTest's +/// --filter to exclude certain categories from test runs: /// /// -/// TEST_FILTER: '/*/*/*/*[Category!=OpenBugs]' +/// --filter "TestCategory!=OpenBugs" /// /// -/// This filter excludes all tests marked with [Category("OpenBugs")] from CI runs. +/// This filter excludes all tests marked with [TestCategory("OpenBugs")] from CI runs. /// Tests in other categories (like ) still run and can fail CI. /// /// /// Local Development Filtering: /// /// # Exclude OpenBugs (same as CI) -/// dotnet test -- --treenode-filter "/*/*/*/*[Category!=OpenBugs]" +/// dotnet test --filter "TestCategory!=OpenBugs" /// /// # Run ONLY OpenBugs tests (to verify fixes) -/// dotnet test -- --treenode-filter "/*/*/*/*[Category=OpenBugs]" +/// dotnet test --filter "TestCategory=OpenBugs" /// /// # Run ONLY Misaligned tests -/// dotnet test -- --treenode-filter "/*/*/*/*[Category=Misaligned]" +/// dotnet test --filter "TestCategory=Misaligned" /// /// /// Usage: -/// Apply at individual test level (class-level does not work with treenode filters): +/// Apply at class or method level: /// -/// [Test] -/// [OpenBugs] // or [Category(TestCategory.OpenBugs)] -/// public async Task ReproducesIssue123() { ... } +/// [TestMethod] +/// [OpenBugs] // or [TestCategory(TestCategory.OpenBugs)] +/// public void ReproducesIssue123() { ... } /// /// public static class TestCategory @@ -53,7 +54,7 @@ public static class TestCategory /// /// CI Behavior: /// - /// Excluded from CI runs via --treenode-filter "/*/*/*/*[Category!=OpenBugs]". + /// Excluded from CI runs via --filter "TestCategory!=OpenBugs". /// This prevents known bugs from blocking PRs while keeping them documented. /// /// @@ -99,8 +100,8 @@ public static class TestCategory /// /// Usage: /// - /// [Test] - /// [Category(TestCategory.Misaligned)] + /// [TestMethod] + /// [TestCategory(TestCategory.Misaligned)] /// public void BroadcastSlice_MaterializesInNumSharp() /// { /// // Document: NumSharp copies on slice, NumPy keeps view @@ -131,7 +132,7 @@ public static class TestCategory /// Local Development: /// /// When running tests locally on non-Windows, use the filter: - /// dotnet test -- --treenode-filter "/*/*/*/*[Category!=WindowsOnly]" + /// dotnet test --filter "TestCategory!=WindowsOnly" /// /// /// Note: @@ -171,13 +172,13 @@ public static class TestCategory /// /// CI Behavior: /// - /// Excluded from CI runs via --treenode-filter "/*/*/*/*[Category!=HighMemory]". + /// Excluded from CI runs via --filter "TestCategory!=HighMemory". /// /// /// Local Development: /// /// # Run ONLY HighMemory tests (requires 8GB+ RAM) - /// dotnet test -- --treenode-filter "/*/*/*/*[Category=HighMemory]" + /// dotnet test --filter "TestCategory=HighMemory" /// /// public const string HighMemory = "HighMemory"; @@ -185,27 +186,25 @@ public static class TestCategory /// /// Attribute for tests documenting known bugs that are expected to fail. -/// Shorthand for [Category("OpenBugs")]. -/// -/// NOTE: Must be applied to individual test methods, not classes. -/// Class-level attributes do not work correctly with TUnit's treenode filters. +/// Shorthand for [TestCategory("OpenBugs")]. /// /// See for full documentation. /// /// /// /// // Basic usage -/// [Test] +/// [TestMethod] /// [OpenBugs] -/// public async Task BroadcastArrayWriteThrows() { ... } +/// public void BroadcastArrayWriteThrows() { ... } /// /// // With GitHub issue URL (clickable in IDE) -/// [Test] +/// [TestMethod] /// [OpenBugs(IssueUrl = "https://github.com/SciSharp/NumSharp/issues/396")] -/// public async Task OddWidthBitmapCorruption() { ... } +/// public void OddWidthBitmapCorruption() { ... } /// /// -public class OpenBugsAttribute : CategoryAttribute +[TestClass] +public class OpenBugsAttribute : TestCategoryBaseAttribute { /// /// URL to the GitHub issue tracking this bug. @@ -218,18 +217,18 @@ public class OpenBugsAttribute : CategoryAttribute /// public string? IssueUrl { get; set; } - public OpenBugsAttribute() : base(TestCategory.OpenBugs) { } + public override IList TestCategories => [TestCategory.OpenBugs]; } /// /// Attribute for tests documenting behavioral differences between NumSharp and NumPy. -/// Shorthand for [Category("Misaligned")]. +/// Shorthand for [TestCategory("Misaligned")]. /// /// See for full documentation. /// /// /// -/// [Test] +/// [TestMethod] /// [Misaligned] /// public void SlicingBroadcast_MaterializesData() /// { @@ -239,44 +238,47 @@ public OpenBugsAttribute() : base(TestCategory.OpenBugs) { } /// } /// /// -public class MisalignedAttribute : CategoryAttribute +[TestClass] +public class MisalignedAttribute : TestCategoryBaseAttribute { - public MisalignedAttribute() : base(TestCategory.Misaligned) { } + public override IList TestCategories => [TestCategory.Misaligned]; } /// /// Attribute for tests requiring Windows (GDI+/System.Drawing.Common). -/// Shorthand for [Category("WindowsOnly")]. +/// Shorthand for [TestCategory("WindowsOnly")]. /// /// See for full documentation. /// -public class WindowsOnlyAttribute : CategoryAttribute +[TestClass] +public class WindowsOnlyAttribute : TestCategoryBaseAttribute { - public WindowsOnlyAttribute() : base(TestCategory.WindowsOnly) { } + public override IList TestCategories => [TestCategory.WindowsOnly]; } /// /// Attribute for tests verifying long indexing (> int.MaxValue elements). -/// Shorthand for [Category("LongIndexing")]. +/// Shorthand for [TestCategory("LongIndexing")]. /// /// See for full documentation. /// -public class LongIndexingAttribute : CategoryAttribute +[TestClass] +public class LongIndexingAttribute : TestCategoryBaseAttribute { - public LongIndexingAttribute() : base(TestCategory.LongIndexing) { } + public override IList TestCategories => [TestCategory.LongIndexing]; } /// /// Attribute for tests requiring high memory (8GB+ RAM). -/// Shorthand for [Category("HighMemory")]. +/// Shorthand for [TestCategory("HighMemory")]. /// /// See for full documentation. /// /// /// -/// [Test] +/// [TestMethod] /// [HighMemory] -/// public async Task LargeArraySum() +/// public void LargeArraySum() /// { /// // Allocates ~2.4GB /// using var arr = np.ones<byte>((long)(int.MaxValue * 1.1)); @@ -284,36 +286,31 @@ public LongIndexingAttribute() : base(TestCategory.LongIndexing) { } /// } /// /// -public class HighMemoryAttribute : CategoryAttribute +[TestClass] +public class HighMemoryAttribute : TestCategoryBaseAttribute { - public HighMemoryAttribute() : base(TestCategory.HighMemory) { } + public override IList TestCategories => [TestCategory.HighMemory]; } /// /// Attribute for tests that allocate large amounts of memory and crash CI runners. -/// Inherits from so tests are automatically excluded -/// from CI via the [Category!=OpenBugs] filter. -/// -/// NOTE: Must be applied to individual test methods, not classes. -/// Class-level attributes do not work correctly with TUnit's treenode filters. +/// Combines OpenBugs category so tests are automatically excluded from CI. /// /// Use this instead of [OpenBugs] for memory-intensive tests that aren't actually bugs, /// just too heavy for CI runners. /// /// /// -/// [Test] +/// [TestMethod] /// [LargeMemoryTest] // Auto-excluded from CI -/// public async Task Allocate_4GB() +/// public void Allocate_4GB() /// { /// var arr = np.ones<int>((4L * 1024 * 1024 * 1024 / 4)); // 4GB /// } /// /// -public class LargeMemoryTestAttribute : OpenBugsAttribute +[TestClass] +public class LargeMemoryTestAttribute : TestCategoryBaseAttribute { - public LargeMemoryTestAttribute() - { - // Inherits OpenBugs category for CI exclusion - } + public override IList TestCategories => [TestCategory.OpenBugs, TestCategory.HighMemory]; } diff --git a/test/NumSharp.UnitTest/Utilities/ArraysTests.cs b/test/NumSharp.UnitTest/Utilities/ArraysTests.cs index 01d8aa01e..4c18677a1 100644 --- a/test/NumSharp.UnitTest/Utilities/ArraysTests.cs +++ b/test/NumSharp.UnitTest/Utilities/ArraysTests.cs @@ -9,27 +9,28 @@ namespace NumSharp.UnitTest.Utilities { + [TestClass] public class ArraysTests { - [Test] + [TestMethod] public void Create_1() { Arrays.Create(typeof(int), 1000).Should().BeOfType().Which.Should().HaveCount(1000); } - [Test] + [TestMethod] public void Create_2() { Arrays.Create(typeof(int), new int[] {1000}).Should().BeOfType().Which.Should().HaveCount(1000); } - [Test] + [TestMethod] public void Create_3() { Arrays.Create(NPTypeCode.Int32, 1000).Should().BeOfType().Which.Should().HaveCount(1000); } - [Test] + [TestMethod] public void Insert_0() { int index = 0; @@ -41,7 +42,7 @@ public void Insert_0() Enumerable.SequenceEqual(l, Enumerable.Range(0, 10)).Should().BeTrue(); } - [Test] + [TestMethod] public void Insert_2() { int index = 2; @@ -53,7 +54,7 @@ public void Insert_2() Enumerable.SequenceEqual(l, Enumerable.Range(0, 10)).Should().BeTrue(); } - [Test] + [TestMethod] public void Insert_5() { int index = 5; @@ -65,7 +66,7 @@ public void Insert_5() Enumerable.SequenceEqual(l, Enumerable.Range(0, 10)).Should().BeTrue(); } - [Test] + [TestMethod] public void Insert_9() { int index = 9; @@ -77,7 +78,7 @@ public void Insert_9() Enumerable.SequenceEqual(l, Enumerable.Range(0, 10)).Should().BeTrue(); } - [Test] + [TestMethod] public void Insert_0_Copy() { int index = 0; @@ -89,7 +90,7 @@ public void Insert_0_Copy() Enumerable.SequenceEqual(l, Enumerable.Range(0, 10)).Should().BeTrue(); } - [Test] + [TestMethod] public void Insert_2_Copy() { int index = 2; @@ -101,7 +102,7 @@ public void Insert_2_Copy() Enumerable.SequenceEqual(l, Enumerable.Range(0, 10)).Should().BeTrue(); } - [Test] + [TestMethod] public void Insert_5_Copy() { int index = 5; @@ -113,7 +114,7 @@ public void Insert_5_Copy() Enumerable.SequenceEqual(l, Enumerable.Range(0, 10)).Should().BeTrue(); } - [Test] + [TestMethod] public void Insert_9_Copy() { int index = 9; diff --git a/test/NumSharp.UnitTest/Utilities/FluentExtensionTests.cs b/test/NumSharp.UnitTest/Utilities/FluentExtensionTests.cs index 91b1d02e6..db9d175f1 100644 --- a/test/NumSharp.UnitTest/Utilities/FluentExtensionTests.cs +++ b/test/NumSharp.UnitTest/Utilities/FluentExtensionTests.cs @@ -12,57 +12,58 @@ namespace NumSharp.UnitTest.Utilities /// Verifies that each assertion method produces correct pass/fail behavior /// and that error messages contain meaningful information. /// + [TestClass] public class FluentExtensionTests { #region ShapeAssertions - [Test] + [TestMethod] public void Shape_BeOfSize_Passes_WhenCorrect() { new Shape(3, 4).Should().BeOfSize(12); } - [Test] + [TestMethod] public void Shape_BeOfSize_Fails_WhenWrong() { Action act = () => new Shape(3, 4).Should().BeOfSize(10); act.Should().Throw(); } - [Test] + [TestMethod] public void Shape_NotBeOfSize_Passes_WhenDifferent() { new Shape(3, 4).Should().NotBeOfSize(10); } - [Test] + [TestMethod] public void Shape_NotBeOfSize_Fails_WhenEqual() { Action act = () => new Shape(3, 4).Should().NotBeOfSize(12); act.Should().Throw(); } - [Test] + [TestMethod] public void Shape_BeShaped_Passes_WhenMatch() { new Shape(2, 3, 4).Should().BeShaped(2, 3, 4); } - [Test] + [TestMethod] public void Shape_BeShaped_Fails_WhenMismatch() { Action act = () => new Shape(2, 3, 4).Should().BeShaped(2, 4, 3); act.Should().Throw(); } - [Test] + [TestMethod] public void Shape_Be_Passes_WhenEqual() { var s = new Shape(5, 10); s.Should().Be(new Shape(5, 10)); } - [Test] + [TestMethod] public void Shape_Be_Fails_WhenDifferent() { var s = new Shape(5, 10); @@ -70,33 +71,33 @@ public void Shape_Be_Fails_WhenDifferent() act.Should().Throw(); } - [Test] + [TestMethod] public void Shape_NotBe_Passes_WhenDifferent() { new Shape(5, 10).Should().NotBe(new Shape(10, 5)); } - [Test] + [TestMethod] public void Shape_NotBe_Fails_WhenEqual() { Action act = () => new Shape(5, 10).Should().NotBe(new Shape(5, 10)); act.Should().Throw(); } - [Test] + [TestMethod] public void Shape_HaveNDim_Passes() { new Shape(2, 3, 4).Should().HaveNDim(3); } - [Test] + [TestMethod] public void Shape_HaveNDim_Fails() { Action act = () => new Shape(2, 3, 4).Should().HaveNDim(2); act.Should().Throw(); } - [Test] + [TestMethod] public void Shape_BeNDim_IsAliasForHaveNDim() { // BeNDim delegates to HaveNDim — verify both work identically @@ -104,7 +105,7 @@ public void Shape_BeNDim_IsAliasForHaveNDim() new Shape(3, 4).Should().HaveNDim(2); } - [Test] + [TestMethod] public void Shape_BeSliced_Passes_WhenSliced() { var a = np.arange(10); @@ -112,25 +113,25 @@ public void Shape_BeSliced_Passes_WhenSliced() sliced.Shape.Should().BeSliced(); } - [Test] + [TestMethod] public void Shape_NotBeSliced_Passes_WhenNotSliced() { np.arange(5).Shape.Should().NotBeSliced(); } - [Test] + [TestMethod] public void Shape_BeScalar_Passes() { Shape.NewScalar().Should().BeScalar(); } - [Test] + [TestMethod] public void Shape_NotBeScalar_Passes() { new Shape(3).Should().NotBeScalar(); } - [Test] + [TestMethod] public void Shape_BeBroadcasted_Passes_WhenBroadcasted() { var a = np.array(new int[] { 1, 2, 3 }); @@ -138,19 +139,19 @@ public void Shape_BeBroadcasted_Passes_WhenBroadcasted() b.Shape.Should().BeBroadcasted(); } - [Test] + [TestMethod] public void Shape_NotBeBroadcasted_Passes_WhenNotBroadcasted() { np.arange(6).reshape(2, 3).Shape.Should().NotBeBroadcasted(); } - [Test] + [TestMethod] public void Shape_BeEquivalentTo_Validates_All_Parameters() { new Shape(2, 3).Should().BeEquivalentTo(size: 6, ndim: 2, shape: (2, 3)); } - [Test] + [TestMethod] public void Shape_BeEquivalentTo_Fails_WhenDimensionCountMismatch() { // shape tuple has 3 elements but actual shape has 2 dimensions @@ -158,7 +159,7 @@ public void Shape_BeEquivalentTo_Fails_WhenDimensionCountMismatch() act.Should().Throw(); } - [Test] + [TestMethod] public void Shape_Chaining_Works() { new Shape(2, 3).Should() @@ -173,26 +174,26 @@ public void Shape_Chaining_Works() #region NDArrayAssertions — Shape/Structure - [Test] + [TestMethod] public void NDArray_BeShaped_Passes() { np.arange(6).reshape(2, 3).Should().BeShaped(2, 3); } - [Test] + [TestMethod] public void NDArray_BeShaped_Fails() { Action act = () => np.arange(6).reshape(2, 3).Should().BeShaped(3, 2); act.Should().Throw(); } - [Test] + [TestMethod] public void NDArray_BeShaped_WithSizeNdimTuple() { np.arange(6).reshape(2, 3).Should().BeShaped(size: 6, ndim: 2, shape: (2, 3)); } - [Test] + [TestMethod] public void NDArray_BeShaped_ITuple_FailsOnDimensionCountMismatch() { // Bug 4 fix: should fail cleanly rather than IndexOutOfRangeException @@ -200,87 +201,87 @@ public void NDArray_BeShaped_ITuple_FailsOnDimensionCountMismatch() act.Should().Throw().Which.Should().NotBeOfType(); } - [Test] + [TestMethod] public void NDArray_BeOfSize_Passes() { np.arange(12).Should().BeOfSize(12); } - [Test] + [TestMethod] public void NDArray_HaveNDim_Passes() { np.arange(24).reshape(2, 3, 4).Should().HaveNDim(3); } - [Test] + [TestMethod] public void NDArray_BeNDim_IsAlias() { np.arange(6).reshape(2, 3).Should().BeNDim(2); } - [Test] + [TestMethod] public void NDArray_BeScalar_Passes() { NDArray.Scalar(42).Should().BeScalar(); } - [Test] + [TestMethod] public void NDArray_BeScalar_WithValue_Passes() { NDArray.Scalar(42).Should().BeScalar(42); } - [Test] + [TestMethod] public void NDArray_BeScalar_WithValue_Fails() { Action act = () => NDArray.Scalar(42).Should().BeScalar(99); act.Should().Throw(); } - [Test] + [TestMethod] public void NDArray_NotBeScalar_Passes() { np.arange(3).Should().NotBeScalar(); } - [Test] + [TestMethod] public void NDArray_BeSliced_Passes() { var a = np.arange(10); a["::2"].Should().BeSliced(); // Use step slice (non-contiguous) to test IsSliced } - [Test] + [TestMethod] public void NDArray_NotBeSliced_Passes() { np.arange(5).Should().NotBeSliced(); } - [Test] + [TestMethod] public void NDArray_BeBroadcasted_Passes() { np.broadcast_to(np.array(new[] { 1, 2, 3 }), new Shape(3, 3)).Should().BeBroadcasted(); } - [Test] + [TestMethod] public void NDArray_NotBeBroadcasted_Passes() { np.arange(6).Should().NotBeBroadcasted(); } - [Test] + [TestMethod] public void NDArray_BeOfType_NPTypeCode_Passes() { np.arange(3).Should().BeOfType(NPTypeCode.Int64); } - [Test] + [TestMethod] public void NDArray_BeOfType_SystemType_Passes() { np.arange(3.0).Should().BeOfType(typeof(double)); } - [Test] + [TestMethod] public void NDArray_BeOfType_Generic_Passes() { np.array(new float[] { 1, 2, 3 }).Should().BeOfType(); @@ -290,7 +291,7 @@ public void NDArray_BeOfType_Generic_Passes() #region NDArrayAssertions — Value Assertions - [Test] + [TestMethod] public void NDArray_Be_Passes_WhenEqual() { var a = np.array(new[] { 1, 2, 3 }); @@ -298,7 +299,7 @@ public void NDArray_Be_Passes_WhenEqual() a.Should().Be(b); } - [Test] + [TestMethod] public void NDArray_Be_Fails_WhenDifferent() { var a = np.array(new[] { 1, 2, 3 }); @@ -307,84 +308,84 @@ public void NDArray_Be_Fails_WhenDifferent() act.Should().Throw(); } - [Test] + [TestMethod] public void NDArray_BeOfValues_Int32_Passes() { np.array(new[] { 10, 20, 30 }).Should().BeOfValues(10, 20, 30); } - [Test] + [TestMethod] public void NDArray_BeOfValues_Int32_Fails_OnMismatch() { Action act = () => np.array(new[] { 10, 20, 30 }).Should().BeOfValues(10, 20, 99); act.Should().Throw(); } - [Test] + [TestMethod] public void NDArray_BeOfValues_Double_Passes() { np.array(new[] { 1.5, 2.5, 3.5 }).Should().BeOfValues(1.5, 2.5, 3.5); } - [Test] + [TestMethod] public void NDArray_BeOfValues_Boolean_Passes() { var a = np.array(new[] { true, false, true }); a.Should().BeOfValues(true, false, true); } - [Test] + [TestMethod] public void NDArray_BeOfValues_SizeMismatch_Fails() { Action act = () => np.array(new[] { 1, 2, 3 }).Should().BeOfValues(1, 2); act.Should().Throw(); } - [Test] + [TestMethod] public void NDArray_BeOfValues_Float_Passes() { np.array(new float[] { 1f, 2f, 3f }).Should().BeOfValues(1f, 2f, 3f); } - [Test] + [TestMethod] public void NDArray_BeOfValues_Byte_Passes() { np.array(new byte[] { 0, 127, 255 }).Should().BeOfValues((byte)0, (byte)127, (byte)255); } - [Test] + [TestMethod] public void NDArray_BeOfValues_Int64_Passes() { np.array(new long[] { 100L, 200L, 300L }).Should().BeOfValues(100L, 200L, 300L); } - [Test] + [TestMethod] public void NDArray_AllValuesBe_Passes() { np.full(new Shape(3, 3), 42).Should().AllValuesBe(42); } - [Test] + [TestMethod] public void NDArray_AllValuesBe_Fails() { Action act = () => np.arange(9).Should().AllValuesBe(0); act.Should().Throw(); } - [Test] + [TestMethod] public void NDArray_AllValuesBe_Double_Passes() { np.full(new Shape(2, 2), 3.14).Should().AllValuesBe(3.14); } - [Test] + [TestMethod] public void NDArray_BeOfValuesApproximately_Passes() { np.array(new[] { 1.001, 2.002, 3.003 }).Should() .BeOfValuesApproximately(0.01, 1.0, 2.0, 3.0); } - [Test] + [TestMethod] public void NDArray_BeOfValuesApproximately_Fails_WhenOutOfTolerance() { Action act = () => np.array(new[] { 1.0, 2.0, 3.5 }).Should() @@ -392,7 +393,7 @@ public void NDArray_BeOfValuesApproximately_Fails_WhenOutOfTolerance() act.Should().Throw(); } - [Test] + [TestMethod] public void NDArray_BeOfValuesApproximately_Float_Passes() { np.array(new float[] { 1.001f, 2.002f }).Should() @@ -403,7 +404,7 @@ public void NDArray_BeOfValuesApproximately_Float_Passes() #region NDArrayAssertions — Error Message Quality - [Test] + [TestMethod] public void AllValuesBe_ErrorMessage_ContainsIndex_And_Values() { // Verifies Bug 1 fix: error messages used to show literal "0", "1", "2" @@ -426,7 +427,7 @@ public void AllValuesBe_ErrorMessage_ContainsIndex_And_Values() } } - [Test] + [TestMethod] public void BeOfValues_ErrorMessage_ContainsIndex_And_Values() { var a = np.array(new[] { 10, 20, 30 }); @@ -449,7 +450,7 @@ public void BeOfValues_ErrorMessage_ContainsIndex_And_Values() } } - [Test] + [TestMethod] public void BeOfValuesApproximately_ErrorMessage_ShowsCorrectDtype() { // Verifies Bug 2 fix: all branches used to say "dtype: Boolean" @@ -467,7 +468,7 @@ public void BeOfValuesApproximately_ErrorMessage_ShowsCorrectDtype() } } - [Test] + [TestMethod] public void BeOfValuesApproximately_ErrorMessage_Int32_ShowsCorrectDtype() { var a = np.array(new int[] { 1, 2, 100 }); @@ -484,7 +485,7 @@ public void BeOfValuesApproximately_ErrorMessage_Int32_ShowsCorrectDtype() } } - [Test] + [TestMethod] public void BeOfValuesApproximately_ErrorMessage_Single_ShowsCorrectDtype() { var a = np.array(new float[] { 1f, 2f, 100f }); @@ -505,7 +506,7 @@ public void BeOfValuesApproximately_ErrorMessage_Single_ShowsCorrectDtype() #region NDArrayAssertions — Chaining - [Test] + [TestMethod] public void NDArray_Chaining_Values_And_Shape() { np.arange(6).reshape(2, 3).Should() @@ -516,7 +517,7 @@ public void NDArray_Chaining_Values_And_Shape() .And.BeOfType(NPTypeCode.Int64); } - [Test] + [TestMethod] public void NDArray_Chaining_AllValuesBe_And_Shape() { np.full(new Shape(3, 3), 7).Should() @@ -525,7 +526,7 @@ public void NDArray_Chaining_AllValuesBe_And_Shape() .And.BeOfSize(9); } - [Test] + [TestMethod] public void NDArray_Chaining_Approximate_And_Shape() { np.array(new[] { 1.001, 2.002 }).Should() @@ -538,21 +539,21 @@ public void NDArray_Chaining_Approximate_And_Shape() #region NDArrayAssertions — View/Broadcast Combinations - [Test] + [TestMethod] public void NDArray_SlicedArray_BeOfValues() { var a = np.arange(10); a["::3"].Should().BeOfValues(0, 3, 6, 9).And.BeSliced(); // Use step slice (non-contiguous) } - [Test] + [TestMethod] public void NDArray_BroadcastedArray_AllValuesBe() { var a = np.broadcast_to(np.array(new[] { 5 }), new Shape(3)); a.Should().AllValuesBe(5).And.BeBroadcasted(); } - [Test] + [TestMethod] public void NDArray_2D_BeOfValues_RowMajorOrder() { var a = np.array(new int[,] { { 1, 2 }, { 3, 4 } }); @@ -563,7 +564,7 @@ public void NDArray_2D_BeOfValues_RowMajorOrder() #region UnmanagedStorage — Extension Entry Point - [Test] + [TestMethod] public void UnmanagedStorage_Should_ReturnsNDArrayAssertions() { var a = np.array(new[] { 1, 2, 3 }); @@ -574,19 +575,19 @@ public void UnmanagedStorage_Should_ReturnsNDArrayAssertions() #region Edge Cases - [Test] + [TestMethod] public void NDArray_BeOfValues_SingleElement() { np.array(new[] { 42 }).Should().BeOfValues(42); } - [Test] + [TestMethod] public void NDArray_AllValuesBe_SingleElement() { np.array(new[] { 42 }).Should().AllValuesBe(42); } - [Test] + [TestMethod] public void NDArray_BeOfValues_AllDtypes() { // Verify type switch covers all supported dtypes @@ -604,7 +605,7 @@ public void NDArray_BeOfValues_AllDtypes() np.array(new decimal[] { 1m, 2m }).Should().BeOfValues(1m, 2m); } - [Test] + [TestMethod] public void NDArray_AllValuesBe_AllDtypes() { np.full(new Shape(2), true).Should().AllValuesBe(true); @@ -626,77 +627,77 @@ public void NDArray_AllValuesBe_AllDtypes() #region New Capabilities - [Test] + [TestMethod] public void NDArray_BeContiguous_Passes_ForFreshArray() { np.arange(6).Should().BeContiguous(); } - [Test] + [TestMethod] public void NDArray_NotBeContiguous_Passes_ForSlicedWithStep() { np.arange(10)["::2"].Should().NotBeContiguous(); } - [Test] + [TestMethod] public void Shape_BeContiguous_Passes() { np.arange(6).reshape(2, 3).Shape.Should().BeContiguous(); } - [Test] + [TestMethod] public void Shape_HaveStrides_Passes() { // (2,3) C-order strides are (3,1) np.arange(6).reshape(2, 3).Shape.Should().HaveStrides(3, 1); } - [Test] + [TestMethod] public void Shape_HaveStrides_Fails_WhenWrong() { Action act = () => np.arange(6).reshape(2, 3).Shape.Should().HaveStrides(1, 3); act.Should().Throw(); } - [Test] + [TestMethod] public void NDArray_HaveStrides_Passes() { np.arange(6).reshape(2, 3).Should().HaveStrides(3, 1); } - [Test] + [TestMethod] public void NDArray_BeEmpty_Passes() { new NDArray(NPTypeCode.Int32).Should().BeEmpty(); } - [Test] + [TestMethod] public void NDArray_BeEmpty_Fails_WhenNotEmpty() { Action act = () => np.arange(3).Should().BeEmpty(); act.Should().Throw(); } - [Test] + [TestMethod] public void NDArray_NotBeOfType_Passes() { np.arange(3).Should().NotBeOfType(NPTypeCode.Double); } - [Test] + [TestMethod] public void NDArray_NotBeOfType_Fails_WhenMatch() { Action act = () => np.arange(3).Should().NotBeOfType(NPTypeCode.Int64); act.Should().Throw(); } - [Test] + [TestMethod] public void NDArray_NotBeOfType_Generic_Passes() { np.arange(3).Should().NotBeOfType(); } - [Test] + [TestMethod] public void NDArray_NotBe_Passes_WhenDifferent() { var a = np.array(new[] { 1, 2, 3 }); @@ -704,7 +705,7 @@ public void NDArray_NotBe_Passes_WhenDifferent() a.Should().NotBe(b); } - [Test] + [TestMethod] public void NDArray_NotBe_Fails_WhenEqual() { var a = np.array(new[] { 1, 2, 3 }); @@ -717,7 +718,7 @@ public void NDArray_NotBe_Fails_WhenEqual() #region Correctness — Error Message Fixes - [Test] + [TestMethod] public void Shape_NotBe_ErrorMessage_SaysDidNotExpect() { // Verifies the inverted error message fix @@ -734,7 +735,7 @@ public void Shape_NotBe_ErrorMessage_SaysDidNotExpect() } } - [Test] + [TestMethod] public void NDArray_NotBeShaped_ErrorMessage_SaysDidNotExpect() { var a = np.arange(6).reshape(2, 3); @@ -750,7 +751,7 @@ public void NDArray_NotBeShaped_ErrorMessage_SaysDidNotExpect() } } - [Test] + [TestMethod] public void BeOfValuesApproximately_UInt64_BothDirections() { // Verifies UInt64 overflow fix: 3UL vs 5UL should have distance 2, not wrap around diff --git a/test/NumSharp.UnitTest/Utilities/HashsetLongIndexingTests.cs b/test/NumSharp.UnitTest/Utilities/HashsetLongIndexingTests.cs index 627922b78..64fa4c637 100644 --- a/test/NumSharp.UnitTest/Utilities/HashsetLongIndexingTests.cs +++ b/test/NumSharp.UnitTest/Utilities/HashsetLongIndexingTests.cs @@ -2,7 +2,6 @@ using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp.Utilities; -using TUnit.Core; namespace NumSharp.UnitTest.Utilities { @@ -12,11 +11,12 @@ namespace NumSharp.UnitTest.Utilities /// Verifies that the Hashset supports indexing beyond int.MaxValue /// and uses 33% growth for large collections. /// +[TestClass] public class HashsetLongIndexingTests { #region Basic Functionality Tests - [Test] + [TestMethod] public void Hashset_BasicAddContains() { var set = new Hashset(); @@ -34,7 +34,7 @@ public void Hashset_BasicAddContains() Assert.AreEqual(3L, set.LongCount); } - [Test] + [TestMethod] public void Hashset_Remove() { var set = new Hashset(new[] { 1, 2, 3, 4, 5 }); @@ -47,7 +47,7 @@ public void Hashset_Remove() Assert.AreEqual(4, set.Count); } - [Test] + [TestMethod] public void Hashset_Clear() { var set = new Hashset(new[] { 1, 2, 3, 4, 5 }); @@ -59,7 +59,7 @@ public void Hashset_Clear() Assert.IsFalse(set.Contains(1)); } - [Test] + [TestMethod] public void Hashset_Enumeration() { var set = new Hashset(new[] { 1, 2, 3 }); @@ -73,7 +73,7 @@ public void Hashset_Enumeration() #region Long Index Support Tests - [Test] + [TestMethod] public void Hashset_LongCount_ReturnsSameAsCount_WhenSmall() { var set = new Hashset(); @@ -86,7 +86,7 @@ public void Hashset_LongCount_ReturnsSameAsCount_WhenSmall() Assert.AreEqual(1000L, set.LongCount); } - [Test] + [TestMethod] public void Hashset_LongCapacityConstructor() { // Create with long capacity @@ -100,7 +100,7 @@ public void Hashset_LongCapacityConstructor() Assert.AreEqual(100, set.Count); } - [Test] + [TestMethod] public void Hashset_Slot_UsesLongNext() { // This test verifies that the internal Slot structure uses long for next pointer @@ -129,7 +129,7 @@ public void Hashset_Slot_UsesLongNext() #region HashHelpersLong Tests - [Test] + [TestMethod] public void HashHelpersLong_IsPrime() { // Known primes @@ -152,7 +152,7 @@ public void HashHelpersLong_IsPrime() Assert.IsTrue(HashHelpersLong.IsPrime(4252464407L)); // Valid large prime from extended array } - [Test] + [TestMethod] [OpenBugs] // HashHelpersLong.primes array contains non-prime values public void HashHelpersLong_GetPrime() { @@ -169,7 +169,7 @@ public void HashHelpersLong_GetPrime() Assert.IsTrue(HashHelpersLong.IsPrime(result)); } - [Test] + [TestMethod] public void HashHelpersLong_ExpandPrime_DoublesForSmallSizes() { // For sizes below 1 billion, should approximately double @@ -180,7 +180,7 @@ public void HashHelpersLong_ExpandPrime_DoublesForSmallSizes() Assert.IsTrue(newSize >= 2 * oldSize, $"Expected newSize >= {2 * oldSize}, got {newSize}"); } - [Test] + [TestMethod] public void HashHelpersLong_ExpandPrime_Uses33PercentForLargeSizes() { // For sizes at or above 1 billion, should use 33% growth @@ -198,7 +198,7 @@ public void HashHelpersLong_ExpandPrime_Uses33PercentForLargeSizes() $"Expected newSize < {2 * oldSize} (should use 33% growth, not doubling), got {newSize}"); } - [Test] + [TestMethod] [OpenBugs] // HashHelpersLong.primes array contains non-prime values public void HashHelpersLong_ExpandPrime_ProgressiveGrowthTest() { @@ -233,7 +233,7 @@ public void HashHelpersLong_ExpandPrime_ProgressiveGrowthTest() #region BitHelperLong Tests - [Test] + [TestMethod] public void BitHelperLong_MarkAndCheck() { long[] bitArray = new long[10]; @@ -258,7 +258,7 @@ public void BitHelperLong_MarkAndCheck() Assert.IsFalse(helper.IsMarked(100)); } - [Test] + [TestMethod] public void BitHelperLong_ToLongArrayLength() { // 64 bits per long @@ -277,7 +277,7 @@ public void BitHelperLong_ToLongArrayLength() #region Set Operations Tests - [Test] + [TestMethod] public void Hashset_UnionWith() { var set1 = new Hashset(new[] { 1, 2, 3 }); @@ -289,7 +289,7 @@ public void Hashset_UnionWith() CollectionAssert.AreEquivalent(new[] { 1, 2, 3, 4, 5 }, set1.ToArray()); } - [Test] + [TestMethod] public void Hashset_IntersectWith() { var set1 = new Hashset(new[] { 1, 2, 3, 4 }); @@ -301,7 +301,7 @@ public void Hashset_IntersectWith() CollectionAssert.AreEquivalent(new[] { 2, 3 }, set1.ToArray()); } - [Test] + [TestMethod] public void Hashset_ExceptWith() { var set1 = new Hashset(new[] { 1, 2, 3, 4 }); @@ -313,7 +313,7 @@ public void Hashset_ExceptWith() CollectionAssert.AreEquivalent(new[] { 1, 4 }, set1.ToArray()); } - [Test] + [TestMethod] public void Hashset_SymmetricExceptWith() { var set1 = new Hashset(new[] { 1, 2, 3 }); @@ -329,7 +329,7 @@ public void Hashset_SymmetricExceptWith() #region Stress Tests - [Test] + [TestMethod] public void Hashset_MediumScaleTest() { // Test with 1 million elements to verify correct operation @@ -359,7 +359,7 @@ public void Hashset_MediumScaleTest() } } - [Test] + [TestMethod] public void Hashset_RemoveWhereWithLongReturn() { var set = new Hashset(Enumerable.Range(0, 1000)); @@ -381,7 +381,7 @@ public void Hashset_RemoveWhereWithLongReturn() #region CopyTo Tests - [Test] + [TestMethod] public void Hashset_CopyTo_Array() { var set = new Hashset(new[] { 1, 2, 3, 4, 5 }); @@ -392,7 +392,7 @@ public void Hashset_CopyTo_Array() CollectionAssert.AreEquivalent(new[] { 1, 2, 3, 4, 5 }, array); } - [Test] + [TestMethod] public void Hashset_CopyTo_LongOffsetAndCount() { var set = new Hashset(new[] { 1, 2, 3, 4, 5 }); @@ -414,7 +414,7 @@ public void Hashset_CopyTo_LongOffsetAndCount() #region Edge Cases - [Test] + [TestMethod] public void Hashset_TrimExcess() { var set = new Hashset(1000); @@ -433,7 +433,7 @@ public void Hashset_TrimExcess() } } - [Test] + [TestMethod] public void Hashset_TryGetValue() { var set = new Hashset(new[] { "hello", "world" }); @@ -445,7 +445,7 @@ public void Hashset_TryGetValue() Assert.IsNull(value2); } - [Test] + [TestMethod] public void Hashset_SetEquals() { var set1 = new Hashset(new[] { 1, 2, 3 }); @@ -456,7 +456,7 @@ public void Hashset_SetEquals() Assert.IsFalse(set1.SetEquals(set3)); } - [Test] + [TestMethod] public void Hashset_Overlaps() { var set1 = new Hashset(new[] { 1, 2, 3 }); @@ -465,7 +465,7 @@ public void Hashset_Overlaps() Assert.IsFalse(set1.Overlaps(new[] { 4, 5, 6 })); } - [Test] + [TestMethod] public void Hashset_IsSubsetOf() { var set1 = new Hashset(new[] { 1, 2 }); @@ -476,7 +476,7 @@ public void Hashset_IsSubsetOf() Assert.IsFalse(set1.IsSubsetOf(set3)); } - [Test] + [TestMethod] public void Hashset_IsSupersetOf() { var set1 = new Hashset(new[] { 1, 2, 3 }); diff --git a/test/NumSharp.UnitTest/Utilities/SkipOnNonWindowsAttribute.cs b/test/NumSharp.UnitTest/Utilities/SkipOnNonWindowsAttribute.cs deleted file mode 100644 index 8246045bc..000000000 --- a/test/NumSharp.UnitTest/Utilities/SkipOnNonWindowsAttribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Threading.Tasks; -using TUnit.Core; - -namespace NumSharp.UnitTest.Utilities; - -/// -/// Skips the test on non-Windows platforms (Linux, macOS). -/// Used for tests requiring GDI+/System.Drawing.Common. -/// -/// This is separate from which is a CategoryAttribute -/// for CI filtering. Use both together: -/// -/// [WindowsOnly] // CategoryAttribute for CI filtering -/// [SkipOnNonWindows] // SkipAttribute for runtime skip -/// public class BitmapTests { } -/// -/// -public class SkipOnNonWindowsAttribute : SkipAttribute -{ - public SkipOnNonWindowsAttribute() : base("Requires Windows (GDI+/System.Drawing.Common)") { } - - public override Task ShouldSkip(TestRegisteredContext context) - => Task.FromResult(!OperatingSystem.IsWindows()); -} diff --git a/test/NumSharp.UnitTest/Utilities/StackedMemoryPoolTests.cs b/test/NumSharp.UnitTest/Utilities/StackedMemoryPoolTests.cs index fbe5ab21b..db5408353 100644 --- a/test/NumSharp.UnitTest/Utilities/StackedMemoryPoolTests.cs +++ b/test/NumSharp.UnitTest/Utilities/StackedMemoryPoolTests.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest.Utilities { + [TestClass] public class StackedMemoryPoolTests { - [Test] + [TestMethod] public void TakeExceedStored() { var pool = new StackedMemoryPool(4, 10); diff --git a/test/NumSharp.UnitTest/Utilities/SteppingOverArray.cs b/test/NumSharp.UnitTest/Utilities/SteppingOverArray.cs index 58caea750..1997accba 100644 --- a/test/NumSharp.UnitTest/Utilities/SteppingOverArray.cs +++ b/test/NumSharp.UnitTest/Utilities/SteppingOverArray.cs @@ -7,9 +7,10 @@ namespace NumSharp.UnitTest.Utilities { + [TestClass] public class SteppingOverArray : TestClass { - [Test] + [TestMethod] public void Stepping() { //>>> a =[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] diff --git a/test/NumSharp.UnitTest/View/NDArray.View.Test.cs b/test/NumSharp.UnitTest/View/NDArray.View.Test.cs index d15c0dcf1..79022209d 100644 --- a/test/NumSharp.UnitTest/View/NDArray.View.Test.cs +++ b/test/NumSharp.UnitTest/View/NDArray.View.Test.cs @@ -9,9 +9,10 @@ namespace NumSharp.UnitTest.View { + [TestClass] public class NDArrayViewTest : TestClass { - [Test] + [TestMethod] public void ValueTest() { var x = np.arange(3); @@ -22,7 +23,7 @@ public void ValueTest() Assert.IsTrue((int)x[0] == (int)v[0]); } - [Test] + [TestMethod] public void GetData_1D() { // these slicing operations should be executed with Span internally @@ -47,7 +48,7 @@ public void GetData_1D() AssertAreEqual(new long[] { 2 }, view.ToArray()); } - [Test] + [TestMethod] public void GetData_1D_Stepping() { // these slicing operations should be executed with Stepping internally @@ -65,7 +66,7 @@ public void GetData_1D_Stepping() // negative step! view = data["::-1"]; Assert.AreEqual(new Shape(10), new Shape(view.shape)); - AssertAreEqual(data.ToArray().Reverse().ToArray(), view.ToArray()); + AssertAreEqual((data.ToArray() as IEnumerable).Reverse().ToArray(), view.ToArray()); view = data["::-2"]; Assert.AreEqual(new Shape(5), new Shape(view.shape)); AssertAreEqual(new long[] { 9, 7, 5, 3, 1 }, view.ToArray()); @@ -77,7 +78,7 @@ public void GetData_1D_Stepping() AssertAreEqual(new long[] { 9 }, view.ToArray()); } - [Test] + [TestMethod] public void Indexing_1D() { var data = np.arange(10); @@ -108,7 +109,7 @@ public void Indexing_1D() Assert.AreEqual(2, (int)view[0]); } - [Test] + [TestMethod] public void Indexing_1D_Stepping() { var data = np.arange(10); @@ -146,7 +147,7 @@ public void Indexing_1D_Stepping() Assert.AreEqual(9, (int)view[0]); } - [Test] + [TestMethod] public void Shared_Data_1D() { var data = np.arange(10); @@ -163,7 +164,7 @@ public void Shared_Data_1D() Assert.AreEqual(-1, (int)view[1]); } - [Test] + [TestMethod] public void NestedView_1D() { var data = np.arange(10); @@ -198,7 +199,7 @@ public void NestedView_1D() AssertAreEqual(new long[] { 55, 66, }, view3.ToArray()); } - [Test] + [TestMethod] public void NestedView_1D_Stepping() { var data = np.arange(10); @@ -233,7 +234,7 @@ public void NestedView_1D_Stepping() AssertAreEqual(new long[] { 22, 88 }, view3.ToArray()); } - [Test] + [TestMethod] public void GetData_2D() { //>>> x = np.arange(9).reshape(3, 3) @@ -272,7 +273,7 @@ public void GetData_2D() AssertAreEqual(new long[] { 3, 4, 5, 6, 7, 8 }, view.ToArray()); } - [Test] + [TestMethod] public void GetData_2D_Stepped() { var data = np.arange(9).reshape(3, 3); @@ -333,7 +334,7 @@ public void GetData_2D_Stepped() AssertAreEqual(new long[] { 8, 6, 5, 3, 2, 0 }, view.ToArray()); } - [Test] + [TestMethod] public void NestedView_2D() { var data = np.array(new long[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -389,7 +390,7 @@ public void NestedView_2D() AssertAreEqual(new long[] { 22, 88, 222, 888 }, view3.ToArray()); } - [Test] + [TestMethod] public void Reduce_1D_to_Scalar() { var data = np.arange(10); @@ -400,7 +401,7 @@ public void Reduce_1D_to_Scalar() AssertAreEqual(new long[] { 7 }, view.ToArray()); } - [Test] + [TestMethod] public void Reduce_2D_to_1D_and_0D() { //>>> x = np.arange(9).reshape(3, 3) @@ -428,7 +429,7 @@ public void Reduce_2D_to_1D_and_0D() AssertAreEqual(new long[] { 8 }, view.ToArray()); } - [Test] + [TestMethod] public void Reduce_2D_to_1D_and_0D_Stepping() { //>>> x = np.arange(9).reshape(3, 3) @@ -461,7 +462,7 @@ public void Reduce_2D_to_1D_and_0D_Stepping() AssertAreEqual(new long[] { 8 }, view.ToArray()); } - [Test] + [TestMethod] public void DimensionalityReduction4D_to_1D() { var t = np.arange(15).reshape(1, 1, 3, 5); @@ -475,7 +476,7 @@ public void DimensionalityReduction4D_to_1D() AssertAreEqual(new long[] { 0, 5, 10 }, view.ToArray()); } - [Test] + [TestMethod] public void NestedDimensionalityReduction() { var data = np.arange(9).reshape(3, 3); @@ -491,7 +492,7 @@ public void NestedDimensionalityReduction() AssertAreEqual(new long[] { 6, 7 }, view2.ToArray()); } - [Test] + [TestMethod] public void NestedDimensionalityReduction_Stepped() { var data = np.arange(9).reshape(3, 3); @@ -507,7 +508,7 @@ public void NestedDimensionalityReduction_Stepped() AssertAreEqual(new long[] { 7, 6 }, view2.ToArray()); } - [Test] + [TestMethod] public void SlicingToScalar() { //numpy code: @@ -532,7 +533,7 @@ public void SlicingToScalar() slice.GetValue(0).Should().Be(5); } - [Test] + [TestMethod] public unsafe void SliceSelectsAll() { var lhs = np.full(new Shape(6, 3, 3), 5, NPTypeCode.Int32); @@ -543,7 +544,7 @@ public unsafe void SliceSelectsAll() lhs.Should().Be(sliced); } - [Test] + [TestMethod] public void Multiply_2DSlice_By_1D() { /* @@ -579,7 +580,7 @@ public void Multiply_2DSlice_By_1D() Assert.AreEqual(ret54, ret); } - [Test] + [TestMethod] public void AllSlicesAreIndexes() { var a = np.arange(27).reshape(3, 3, 3); @@ -597,7 +598,7 @@ public void AllSlicesAreIndexes() ret.Should().BeSliced(); //its a a memory slice } - [Test] + [TestMethod] public void SlicingWithNegativeIndex() { var a = np.arange(3 * 1 * 3 * 3).reshape((3, 1, 3, 3)); @@ -610,7 +611,7 @@ public void SlicingWithNegativeIndex() b.Should().BeShaped(1, 3).And.BeOfValues(21, 22, 23); } - [Test] + [TestMethod] public void SlicingWithEllipsis() { var a = np.arange(16).reshape(2, 2, 2, 2); @@ -621,7 +622,7 @@ public void SlicingWithEllipsis() new Action(() => a["..., 0, ..."].flatten()).Should().Throw(); } - [Test] + [TestMethod] public void SlicingWithNewAxis() { var a = np.arange(16).reshape(2, 2, 2, 2); diff --git a/test/NumSharp.UnitTest/View/Shape.IsContiguous.Test.cs b/test/NumSharp.UnitTest/View/Shape.IsContiguous.Test.cs index 0b066413e..b37c4603d 100644 --- a/test/NumSharp.UnitTest/View/Shape.IsContiguous.Test.cs +++ b/test/NumSharp.UnitTest/View/Shape.IsContiguous.Test.cs @@ -17,6 +17,7 @@ namespace NumSharp.UnitTest.View /// PYTHON VERIFICATION (NumPy 2.4.2): /// All expected values and view/copy semantics verified against NumPy. /// + [TestClass] public class ShapeIsContiguousTest { // ================================================================ @@ -26,7 +27,7 @@ public class ShapeIsContiguousTest #region Regression: 1D slices — values - [Test] + [TestMethod] public void Slice1D_Step1_Values() { // np.arange(10)[2:7] = [2, 3, 4, 5, 6] @@ -40,7 +41,7 @@ public void Slice1D_Step1_Values() s.GetInt64(4).Should().Be(6); } - [Test] + [TestMethod] public void Slice1D_Step2_Values() { // np.arange(10)[::2] = [0, 2, 4, 6, 8] @@ -54,7 +55,7 @@ public void Slice1D_Step2_Values() s.GetInt64(4).Should().Be(8); } - [Test] + [TestMethod] public void Slice1D_Reversed_Values() { // np.arange(5)[::-1] = [4, 3, 2, 1, 0] @@ -68,7 +69,7 @@ public void Slice1D_Reversed_Values() s.GetInt64(4).Should().Be(0); } - [Test] + [TestMethod] public void Slice1D_SingleElement_Values() { // np.arange(10)[3:4] = [3] @@ -82,7 +83,7 @@ public void Slice1D_SingleElement_Values() #region Regression: 2D slices — values - [Test] + [TestMethod] public void Slice2D_RowSlice_Values() { // np.arange(12).reshape(3,4)[1:3] = [[4,5,6,7],[8,9,10,11]] @@ -99,7 +100,7 @@ public void Slice2D_RowSlice_Values() s.GetInt64(1, 3).Should().Be(11); } - [Test] + [TestMethod] public void Slice2D_ColumnSlice_Values() { // np.arange(12).reshape(3,4)[:,1:3] = [[1,2],[5,6],[9,10]] @@ -114,7 +115,7 @@ public void Slice2D_ColumnSlice_Values() s.GetInt64(2, 1).Should().Be(10); } - [Test] + [TestMethod] public void Slice2D_SingleRow_Values() { // np.arange(12).reshape(3,4)[1:2] = [[4,5,6,7]] @@ -127,7 +128,7 @@ public void Slice2D_SingleRow_Values() s.GetInt64(0, 3).Should().Be(7); } - [Test] + [TestMethod] public void Slice2D_SingleRowPartialCol_Values() { // np.arange(12).reshape(3,4)[1:2,1:3] = [[5,6]] @@ -142,7 +143,7 @@ public void Slice2D_SingleRowPartialCol_Values() #region Regression: 3D slices — values - [Test] + [TestMethod] public void Slice3D_RowSlice_Values() { // np.arange(24).reshape(2,3,4)[0:1] — shape (1,3,4), values 0..11 @@ -153,7 +154,7 @@ public void Slice3D_RowSlice_Values() s.GetAtIndex(i).Should().Be(i); } - [Test] + [TestMethod] public void Slice3D_SingleRowPartialCol_Values() { // np.arange(24).reshape(2,3,4)[0:1,1:3,:] = [[4..11]] @@ -170,7 +171,7 @@ public void Slice3D_SingleRowPartialCol_Values() s.GetInt64(0, 1, 3).Should().Be(11); } - [Test] + [TestMethod] public void Slice3D_MiddleDim_Values() { // np.arange(24).reshape(2,3,4)[:,1:2,:] — shape (2,1,4) @@ -188,7 +189,7 @@ public void Slice3D_MiddleDim_Values() #region Regression: Slice-of-slice — values - [Test] + [TestMethod] public void SliceOfContiguousSlice_Values() { // np.arange(10)[2:8][1:4] = [3, 4, 5] @@ -201,7 +202,7 @@ public void SliceOfContiguousSlice_Values() s2.GetInt64(2).Should().Be(5); } - [Test] + [TestMethod] public void SliceOfSteppedSlice_SingleElement_Values() { // np.arange(10)[::2][0:1] = [0] @@ -212,7 +213,7 @@ public void SliceOfSteppedSlice_SingleElement_Values() s.GetInt64(0).Should().Be(0); } - [Test] + [TestMethod] public void SliceOfSteppedSlice_Range_Values() { // np.arange(10)[::2][1:3] = [2, 4] @@ -228,7 +229,7 @@ public void SliceOfSteppedSlice_Range_Values() #region Regression: Ravel values (must be correct regardless of view/copy) - [Test] + [TestMethod] public void Ravel_ContiguousSlice1D_Values() { // np.ravel(np.arange(10)[2:7]) = [2,3,4,5,6] @@ -243,7 +244,7 @@ public void Ravel_ContiguousSlice1D_Values() r.GetInt64(4).Should().Be(6); } - [Test] + [TestMethod] public void Ravel_ContiguousRowSlice2D_Values() { // np.ravel(np.arange(12).reshape(3,4)[1:3]) = [4,5,6,7,8,9,10,11] @@ -255,7 +256,7 @@ public void Ravel_ContiguousRowSlice2D_Values() r.GetInt64(i).Should().Be(4 + i); } - [Test] + [TestMethod] public void Ravel_ColumnSlice2D_Values() { // np.ravel(np.arange(12).reshape(3,4)[:,1:3]) = [1,2,5,6,9,10] @@ -271,7 +272,7 @@ public void Ravel_ColumnSlice2D_Values() r.GetInt64(5).Should().Be(10); } - [Test] + [TestMethod] public void Ravel_SteppedSlice_Values() { // np.ravel(np.arange(10)[::2]) = [0,2,4,6,8] @@ -290,7 +291,7 @@ public void Ravel_SteppedSlice_Values() #region Regression: Iterator correctness through slices - [Test] + [TestMethod] public void Iterator_ContiguousSlice1D() { // Iterating through a contiguous slice must produce correct values @@ -301,7 +302,7 @@ public void Iterator_ContiguousSlice1D() s.GetAtIndex(i).Should().Be(expected[i], $"index {i}"); } - [Test] + [TestMethod] public void Iterator_ContiguousRowSlice2D() { var a = np.arange(20).reshape(4, 5); @@ -311,7 +312,7 @@ public void Iterator_ContiguousRowSlice2D() s.GetAtIndex(i).Should().Be(5 + i, $"index {i}"); } - [Test] + [TestMethod] public void Iterator_NonContiguousColumnSlice2D() { var a = np.arange(12).reshape(3, 4); @@ -321,7 +322,7 @@ public void Iterator_NonContiguousColumnSlice2D() s.GetAtIndex(i).Should().Be(expected[i], $"index {i}"); } - [Test] + [TestMethod] public void Iterator_SteppedSlice() { var a = np.arange(10); @@ -336,7 +337,7 @@ public void Iterator_SteppedSlice() #region Regression: np.roll on sliced arrays (uses ravel internally) - [Test] + [TestMethod] public void Roll_OnContiguousSlice() { // np.roll(np.arange(10)[2:7], 2) = [5, 6, 2, 3, 4] @@ -351,7 +352,7 @@ public void Roll_OnContiguousSlice() r.GetInt64(4).Should().Be(4); } - [Test] + [TestMethod] public void Roll_OnRowSlice2D() { // np.roll(np.arange(12).reshape(3,4)[1:3], 1, axis=1) @@ -379,7 +380,7 @@ public void Roll_OnRowSlice2D() #region Fix validation: IsContiguous should be true for contiguous slices - [Test] + [TestMethod] public void IsContiguous_Step1Slice1D() { // NumPy: a[2:7].flags['C_CONTIGUOUS'] = True @@ -389,7 +390,7 @@ public void IsContiguous_Step1Slice1D() "step-1 slice [2:7] is contiguous in memory"); } - [Test] + [TestMethod] public void IsContiguous_RowSlice2D() { // NumPy: a[1:3].flags['C_CONTIGUOUS'] = True @@ -399,7 +400,7 @@ public void IsContiguous_RowSlice2D() "row slice [1:3] of C-contiguous 2D array is contiguous"); } - [Test] + [TestMethod] public void IsContiguous_SingleRow2D() { // NumPy: a[1:2].flags['C_CONTIGUOUS'] = True @@ -409,7 +410,7 @@ public void IsContiguous_SingleRow2D() "single row slice [1:2] is contiguous"); } - [Test] + [TestMethod] public void IsContiguous_SingleRowPartialCol2D() { // NumPy: a[1:2,1:3].flags['C_CONTIGUOUS'] = True @@ -419,7 +420,7 @@ public void IsContiguous_SingleRowPartialCol2D() "single row with partial columns [1:2,1:3] is contiguous"); } - [Test] + [TestMethod] public void IsContiguous_SingleElement1D() { // NumPy: a[3:4].flags['C_CONTIGUOUS'] = True @@ -429,7 +430,7 @@ public void IsContiguous_SingleElement1D() "single element slice [3:4] is contiguous"); } - [Test] + [TestMethod] public void IsContiguous_3D_RowSlice() { // NumPy: a[0:1].flags['C_CONTIGUOUS'] = True @@ -439,7 +440,7 @@ public void IsContiguous_3D_RowSlice() "3D row slice [0:1] is contiguous"); } - [Test] + [TestMethod] public void IsContiguous_3D_SingleRowPartialCol() { // NumPy: a[0:1,1:3,:].flags['C_CONTIGUOUS'] = True @@ -449,7 +450,7 @@ public void IsContiguous_3D_SingleRowPartialCol() "3D single-row partial-col [0:1,1:3,:] is contiguous"); } - [Test] + [TestMethod] public void IsContiguous_SliceOfContiguousSlice() { // np.arange(10)[2:8][1:4] — merged step-1, contiguous @@ -459,7 +460,7 @@ public void IsContiguous_SliceOfContiguousSlice() "slice of a contiguous slice should be contiguous"); } - [Test] + [TestMethod] public void IsContiguous_SliceOfSteppedSlice_SingleElement() { // np.arange(10)[::2][0:1] — merged step=2 but count=1 (contiguous) @@ -473,7 +474,7 @@ public void IsContiguous_SliceOfSteppedSlice_SingleElement() #region Fix validation: IsContiguous should be false for non-contiguous slices - [Test] + [TestMethod] public void IsContiguous_Step2Slice_False() { // NumPy: a[::2].flags['C_CONTIGUOUS'] = False @@ -483,7 +484,7 @@ public void IsContiguous_Step2Slice_False() "step-2 slice has gaps in memory"); } - [Test] + [TestMethod] public void IsContiguous_ReversedSlice_False() { // NumPy: a[::-1].flags['C_CONTIGUOUS'] = False @@ -493,7 +494,7 @@ public void IsContiguous_ReversedSlice_False() "reversed slice is not contiguous"); } - [Test] + [TestMethod] public void IsContiguous_ColumnSlice_False() { // NumPy: a[:,1:3].flags['C_CONTIGUOUS'] = False @@ -503,7 +504,7 @@ public void IsContiguous_ColumnSlice_False() "column slice has gaps between rows"); } - [Test] + [TestMethod] public void IsContiguous_3D_MiddleDim_False() { // NumPy: a[:,1:2,:].flags['C_CONTIGUOUS'] = False @@ -513,7 +514,7 @@ public void IsContiguous_3D_MiddleDim_False() "middle-dim slice of 3D is not contiguous when outer dim > 1"); } - [Test] + [TestMethod] public void IsContiguous_MultiRowPartialCol_False() { // NumPy: a[0:2,1:3].flags['C_CONTIGUOUS'] = False @@ -523,7 +524,7 @@ public void IsContiguous_MultiRowPartialCol_False() "multiple rows with partial columns is not contiguous"); } - [Test] + [TestMethod] public void IsContiguous_SliceOfSteppedSlice_Range_False() { // np.arange(10)[::2][1:3] — merged step=2, count=2 (not contiguous) @@ -533,7 +534,7 @@ public void IsContiguous_SliceOfSteppedSlice_Range_False() "range from stepped slice inherits step>1"); } - [Test] + [TestMethod] public void IsContiguous_Broadcast_False() { // Broadcast is never contiguous @@ -546,7 +547,7 @@ public void IsContiguous_Broadcast_False() #region Fix validation: Contiguous slices should share memory (view semantics) - [Test] + [TestMethod] public void ViewSemantics_Step1Slice1D_MutationPropagates() { // NumPy: s = a[2:7]; s[0] = 999; a[2] == 999 @@ -557,7 +558,7 @@ public void ViewSemantics_Step1Slice1D_MutationPropagates() "contiguous slice should share memory with original"); } - [Test] + [TestMethod] public void ViewSemantics_RowSlice2D_MutationPropagates() { // NumPy: s = a[1:3]; s[0,0] = 999; a[1,0] == 999 @@ -568,7 +569,7 @@ public void ViewSemantics_RowSlice2D_MutationPropagates() "contiguous row slice should share memory with original"); } - [Test] + [TestMethod] public void ViewSemantics_SingleRowPartialCol_MutationPropagates() { // NumPy: s = a[1:2,1:3]; s[0,0] = 999; a[1,1] == 999 @@ -579,7 +580,7 @@ public void ViewSemantics_SingleRowPartialCol_MutationPropagates() "contiguous single-row partial-col slice should share memory"); } - [Test] + [TestMethod] public void ViewSemantics_SliceOfContiguousSlice_MutationPropagates() { // NumPy: s = a[2:8][1:4]; s[0] = 999; a[3] == 999 @@ -594,7 +595,7 @@ public void ViewSemantics_SliceOfContiguousSlice_MutationPropagates() #region Fix validation: Non-contiguous slices should NOT share memory - [Test] + [TestMethod] public void ViewSemantics_SteppedSlice_MutationDoesNotPropagate() { // NumPy: s = np.ravel(a[::2]); s is a copy @@ -606,7 +607,7 @@ public void ViewSemantics_SteppedSlice_MutationDoesNotPropagate() "ravel of stepped slice should be a copy"); } - [Test] + [TestMethod] public void ViewSemantics_ColumnSlice_RavelIsCopy() { var a = np.arange(12).reshape(3, 4); @@ -621,7 +622,7 @@ public void ViewSemantics_ColumnSlice_RavelIsCopy() #region Fix validation: Ravel of contiguous slice should be a view - [Test] + [TestMethod] public void Ravel_ContiguousSlice1D_IsView() { // NumPy: r = np.ravel(a[2:7]); r is a view @@ -633,7 +634,7 @@ public void Ravel_ContiguousSlice1D_IsView() "ravel of contiguous slice should return a view"); } - [Test] + [TestMethod] public void Ravel_ContiguousRowSlice2D_IsView() { // NumPy: r = np.ravel(a[1:3]); r is a view @@ -649,7 +650,7 @@ public void Ravel_ContiguousRowSlice2D_IsView() #region Fix validation: Downstream consumers — copyto, unique - [Test] + [TestMethod] public void Copyto_ContiguousSlice_FastPath() { // np.copyto with contiguous slices should use fast memcpy path @@ -664,7 +665,7 @@ public void Copyto_ContiguousSlice_FastPath() #region Fix validation: Multiple dtypes through contiguous slice path - [Test] + [TestMethod] public void ContiguousSlice_Float64_Values() { var a = np.arange(10.0); // float64 @@ -674,7 +675,7 @@ public void ContiguousSlice_Float64_Values() s.GetDouble(4).Should().Be(6.0); } - [Test] + [TestMethod] public void ContiguousSlice_Float32_Values() { var a = np.arange(10).astype(np.float32); @@ -684,7 +685,7 @@ public void ContiguousSlice_Float32_Values() s.GetSingle(4).Should().Be(6.0f); } - [Test] + [TestMethod] public void ContiguousSlice_Byte_Values() { var a = np.arange(10).astype(np.uint8); @@ -694,7 +695,7 @@ public void ContiguousSlice_Byte_Values() s.GetByte(4).Should().Be(6); } - [Test] + [TestMethod] public void ContiguousSlice_Int64_Values() { var a = np.arange(10).astype(np.int64); @@ -708,7 +709,7 @@ public void ContiguousSlice_Int64_Values() #region Edge cases - [Test] + [TestMethod] public void EmptySlice_Values() { // np.arange(10)[5:5] = [] @@ -717,7 +718,7 @@ public void EmptySlice_Values() s.size.Should().Be(0); } - [Test] + [TestMethod] public void FullSlice_IsContiguous() { // np.arange(10)[:] should be contiguous (it's all elements) @@ -728,7 +729,7 @@ public void FullSlice_IsContiguous() s.size.Should().Be(10); } - [Test] + [TestMethod] public void ContiguousSlice_ThenReshape_Values() { // np.arange(12)[2:10].reshape(2,4) should work and be contiguous diff --git a/test/NumSharp.UnitTest/View/Shape.OffsetParity.Tests.cs b/test/NumSharp.UnitTest/View/Shape.OffsetParity.Tests.cs index 0cc3aa2eb..41dad704d 100644 --- a/test/NumSharp.UnitTest/View/Shape.OffsetParity.Tests.cs +++ b/test/NumSharp.UnitTest/View/Shape.OffsetParity.Tests.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest /// NumPy-aligned offset parity tests: Verify element access uses the formula /// offset + sum(indices * strides) for all shape types (simple, sliced, broadcast). /// + [TestClass] public class ShapeOffsetParityTests { - [Test] + [TestMethod] public void Parity_Vector_AllIndices() { // 1D vector @@ -23,7 +24,7 @@ public void Parity_Vector_AllIndices() } } - [Test] + [TestMethod] public void Parity_Matrix_AllIndices() { // 2D matrix @@ -39,7 +40,7 @@ public void Parity_Matrix_AllIndices() } } - [Test] + [TestMethod] public void Parity_3DArray_AllIndices() { // 3D array @@ -58,7 +59,7 @@ public void Parity_3DArray_AllIndices() } } - [Test] + [TestMethod] public void Parity_4DArray_SampleIndices() { // 4D array (sample indices to keep test fast) @@ -79,7 +80,7 @@ public void Parity_4DArray_SampleIndices() actual.Should().Be(expected); } - [Test] + [TestMethod] public void Parity_Scalar() { // Scalar shape (edge case) @@ -90,7 +91,7 @@ public void Parity_Scalar() } - [Test] + [TestMethod] public void Offset_DefaultsToZero_ForNewShapes() { // Verify offset is 0 for all newly created shapes @@ -102,7 +103,7 @@ public void Offset_DefaultsToZero_ForNewShapes() Shape.Matrix(3, 4).Offset.Should().Be(0); } - [Test] + [TestMethod] public void Offset_PreservedByClone() { var original = new Shape(4, 3); @@ -113,7 +114,7 @@ public void Offset_PreservedByClone() cloned.Offset.Should().Be(original.Offset); } - [Test] + [TestMethod] public void Offset_PreservedByCopyConstructor() { var original = new Shape(4, 3); @@ -121,7 +122,7 @@ public void Offset_PreservedByCopyConstructor() copy.Offset.Should().Be(original.Offset); } - [Test] + [TestMethod] public void Parity_RandomIndices() { // Test with random indices @@ -144,7 +145,7 @@ public void Parity_RandomIndices() } } - [Test] + [TestMethod] public void GetOffsetSimple_Formula_MatchesExpectedCalculation() { // Verify the formula: offset + sum(indices * strides) @@ -165,7 +166,7 @@ public void GetOffsetSimple_Formula_MatchesExpectedCalculation() // Sliced shape tests - offset computed at slice time // ================================================================ - [Test] + [TestMethod] public void Slice_SlicedShape_OffsetComputedAtSliceTime() { // Original shape (4,3) with strides [3, 1] @@ -178,7 +179,7 @@ public void Slice_SlicedShape_OffsetComputedAtSliceTime() sliced.Dimensions.Should().BeEquivalentTo([2, 3]); } - [Test] + [TestMethod] public void Slice_SlicedShape_GetOffsetSimple_Parity() { // np.arange(12).reshape(4,3)[1:3, :] @@ -199,7 +200,7 @@ public void Slice_SlicedShape_GetOffsetSimple_Parity() } } - [Test] + [TestMethod] public void Slice_SlicedVector_OffsetAndParity() { // np.arange(10)[3:7] -> offset=3, strides=[1], dims=[4] @@ -217,7 +218,7 @@ public void Slice_SlicedVector_OffsetAndParity() } } - [Test] + [TestMethod] public void Slice_SlicedWithStep_OffsetAndStrides() { // np.arange(10)[1:7:2] -> starts at 1, takes [1,3,5], dims=[3] @@ -238,7 +239,7 @@ public void Slice_SlicedWithStep_OffsetAndStrides() } } - [Test] + [TestMethod] public void Slice_Sliced2D_ColumnSlice() { // np.arange(12).reshape(4,3)[:, 1] -> column 1 @@ -259,7 +260,7 @@ public void Slice_Sliced2D_ColumnSlice() } } - [Test] + [TestMethod] public void Slice_SlicedScalar_Offset() { // np.arange(12).reshape(4,3)[2, 1] -> scalar at offset 2*3 + 1 = 7 @@ -270,7 +271,7 @@ public void Slice_SlicedScalar_Offset() sliced.Offset.Should().Be(7, because: "[2,1] is at linear offset 7"); } - [Test] + [TestMethod] public void Slice_DoubleSliced_OffsetAccumulates() { // First slice: np.arange(12).reshape(4,3)[1:, :] -> offset=3 @@ -301,7 +302,7 @@ public void Slice_DoubleSliced_OffsetAccumulates() // Broadcast shape tests - offset preserved from source // ================================================================ - [Test] + [TestMethod] public void Broadcast_BroadcastBasic_OffsetPreserved() { // Broadcast a simple shape - offset should stay 0 @@ -315,7 +316,7 @@ public void Broadcast_BroadcastBasic_OffsetPreserved() bRight.Dimensions.Should().BeEquivalentTo([3, 4]); } - [Test] + [TestMethod] public void Broadcast_BroadcastSliced_OffsetPreserved() { // Slice a shape (gains offset), then broadcast @@ -333,7 +334,7 @@ public void Broadcast_BroadcastSliced_OffsetPreserved() bSliced.Dimensions.Should().BeEquivalentTo([2, 3]); } - [Test] + [TestMethod] public void Broadcast_BroadcastScalar_OffsetPreserved() { // Slice to get scalar with offset, then broadcast @@ -351,7 +352,7 @@ public void Broadcast_BroadcastScalar_OffsetPreserved() bScalar.Dimensions.Should().BeEquivalentTo([2, 2]); } - [Test] + [TestMethod] public void Broadcast_BroadcastTo_SlicedArray() { // np.arange(10)[3:7] = [3,4,5,6], offset=3, shape=(4,) @@ -367,7 +368,7 @@ public void Broadcast_BroadcastTo_SlicedArray() broadcasted.Dimensions.Should().BeEquivalentTo([3, 4]); } - [Test] + [TestMethod] public void Broadcast_BroadcastMultiple_OffsetPreserved() { // Test Broadcast(Shape[]) with multiple shapes @@ -385,7 +386,7 @@ public void Broadcast_BroadcastMultiple_OffsetPreserved() results[2].Offset.Should().Be(0); } - [Test] + [TestMethod] public void Broadcast_GetOffsetSimple_BroadcastedSliced() { // End-to-end: slice then broadcast, verify GetOffsetSimple parity @@ -410,7 +411,7 @@ public void Broadcast_GetOffsetSimple_BroadcastedSliced() // NumPy-aligned GetOffset verification // ================================================================ - [Test] + [TestMethod] public void SlicedShape_GetOffset_NumPyAligned() { // GetOffset uses NumPy formula: offset + sum(indices * strides) @@ -430,7 +431,7 @@ public void SlicedShape_GetOffset_NumPyAligned() sliced[1, 2].GetInt64(0).Should().Be(8); } - [Test] + [TestMethod] public void SlicedWithStep_GetOffset_NumPyAligned() { // Slice with step @@ -443,7 +444,7 @@ public void SlicedWithStep_GetOffset_NumPyAligned() sliced[2].GetInt64(0).Should().Be(5); } - [Test] + [TestMethod] public void ColumnSlice_GetOffset_NumPyAligned() { // Column slice (dimension reduction) @@ -457,7 +458,7 @@ public void ColumnSlice_GetOffset_NumPyAligned() col1[3].GetInt64(0).Should().Be(10); } - [Test] + [TestMethod] public void DoubleSliced_GetOffset_NumPyAligned() { // Double slice (slice of slice) @@ -479,7 +480,7 @@ public void DoubleSliced_GetOffset_NumPyAligned() // NumPy purity verification // ================================================================ - [Test] + [TestMethod] public void NumPyPurity_IsSimpleSlice_TrueForNonContiguousSlice() { // Note: Contiguous slices get optimized (IsSliced=false). @@ -492,7 +493,7 @@ public void NumPyPurity_IsSimpleSlice_TrueForNonContiguousSlice() stepSliced.Shape.IsBroadcasted.Should().BeFalse(); } - [Test] + [TestMethod] public void NumPyPurity_IsSimpleSlice_TrueForColumnSlice() { // Column slice is non-contiguous @@ -505,7 +506,7 @@ public void NumPyPurity_IsSimpleSlice_TrueForColumnSlice() colSliced.Shape.Strides.Should().BeEquivalentTo([3]); } - [Test] + [TestMethod] public void NumPyPurity_IsSimpleSlice_FalseForBroadcast() { var arr = np.arange(3); @@ -515,7 +516,7 @@ public void NumPyPurity_IsSimpleSlice_FalseForBroadcast() broadcasted.Shape.IsSimpleSlice.Should().BeFalse(); } - [Test] + [TestMethod] public void NumPyPurity_ContiguousSlice_Optimized() { // Contiguous slices are optimized: no ViewInfo, IsSliced=false @@ -532,7 +533,7 @@ public void NumPyPurity_ContiguousSlice_Optimized() sliced[1, 2].GetInt64(0).Should().Be(8); } - [Test] + [TestMethod] public void NumPyPurity_NonSlicedShape_UsesGetOffsetSimple() { // Verify non-sliced shapes also use the simple offset formula diff --git a/test/NumSharp.UnitTest/View/Shape.Test.cs b/test/NumSharp.UnitTest/View/Shape.Test.cs index fe713cce0..d1cfb5007 100644 --- a/test/NumSharp.UnitTest/View/Shape.Test.cs +++ b/test/NumSharp.UnitTest/View/Shape.Test.cs @@ -12,9 +12,10 @@ namespace NumSharp.UnitTest { + [TestClass] public class ShapeTest { - [Test] + [TestMethod] public void Index() { var shape0 = new Shape(4, 3); @@ -24,7 +25,7 @@ public void Index() Assert.IsTrue(idx0 == 3 * 2 + 1 * 1); } - [Test] + [TestMethod] public void CheckIndexing() { var shape0 = new Shape(4, 3, 2); @@ -61,13 +62,13 @@ public void CheckIndexing() } // Test removed: ChangeTensorLayout was removed (NumSharp is C-order only) - // [Test, Skip("Ignored")] + // [TestMethod, Ignore("Ignored")] // public void CheckColRowSwitch() { ... } /// /// Based on issue https://github.com/SciSharp/NumSharp/issues/306 /// - [Test] + [TestMethod] public void EqualityComparer() { // Shape is now a readonly struct - cannot be null @@ -92,8 +93,8 @@ public void EqualityComparer() } - [Test, TUnit.Core.Timeout(10000)] - public void ExtractShape_FromArray(CancellationToken cancellationToken) + [TestMethod, Timeout(10000)] + public void ExtractShape_FromArray() { // @formatter:off — disable formatter after this line var v = Shape.ExtractShape((Array)new int[][][] @@ -137,7 +138,7 @@ public void ExtractShape_FromArray(CancellationToken cancellationToken) Shape.ExtractShape(new int[5]).Should().ContainInOrder(5); } - [Test] + [TestMethod] public void Create_Vector() { Shape.Vector(10).Should().Be(new Shape(10)); @@ -150,7 +151,7 @@ public void Create_Vector() Shape.Vector(0).strides.Should().ContainInOrder(new Shape(0).strides); } - [Test] + [TestMethod] public void Create_Matrix() { Shape.Matrix(5, 5).Should().Be(new Shape(5, 5)); @@ -169,7 +170,7 @@ public void Create_Matrix() Shape.Matrix(0, 0).strides.Should().ContainInOrder(new Shape(0, 0).strides); } - [Test] + [TestMethod] public void GetAxis() { var baseshape = new Shape(2, 3, 4, 5); @@ -180,7 +181,7 @@ public void GetAxis() Shape.GetAxis(baseshape, -1).Should().ContainInOrder(2, 3, 4); } - [Test] + [TestMethod] public void GetSubshape() { //initialize @@ -294,7 +295,7 @@ public void GetSubshape() retTuple.Shape.Dimensions[1].Should().Be(1); } - [Test] + [TestMethod] public void ShapeSlicing_1D() { // NumPy-pure: test offset and strides instead of ViewInfo @@ -307,7 +308,7 @@ public void ShapeSlicing_1D() new Shape(10).Slice("-7:").Offset.Should().Be(3); } - [Test] + [TestMethod] public void RepeatedSlicing_1D() { // NumPy-pure: double slicing uses parent offset+strides @@ -320,7 +321,7 @@ public void RepeatedSlicing_1D() new Shape(10).Slice(":5").Slice("2:").BufferSize.Should().Be(10); } - [Test] + [TestMethod] public void ShapeSlicing_2D() { // NumPy-pure: test dimensions and offset @@ -331,14 +332,14 @@ public void ShapeSlicing_2D() } - [Test] + [TestMethod] public void GetCoordsFromIndex_2D() { var shape = new Shape(3, 3).Slice(":,1:"); // todo: test get coords from index with sliced shapes } - [Test] + [TestMethod] public void ExpandDim_Case1() { Shape shape = (3, 3, 3); @@ -347,7 +348,7 @@ public void ExpandDim_Case1() shape.GetOffset(2, 0, 0, 2).Should().Be(9 * 2 + 2); } - [Test] + [TestMethod] public void ExpandDim_Case2() { Shape shape = (3, 3, 3); @@ -355,7 +356,7 @@ public void ExpandDim_Case2() shape.GetOffset(0, 2, 0, 2).Should().Be(9 * 2 + 2); } - [Test] + [TestMethod] public void ExpandDim_Case3() { Shape shape = (3, 3, 3); @@ -364,7 +365,7 @@ public void ExpandDim_Case3() shape.GetOffset(2, 0, 0, 2).Should().Be(9 * 2 + 2); } - [Test] + [TestMethod] public void ExpandDim_Case4() { Shape shape = (3, 3, 3); @@ -374,7 +375,7 @@ public void ExpandDim_Case4() } - [Test] + [TestMethod] public void ExpandDim0_Slice() { //>>> a = np.arange(27).reshape(3, 3, 3)[0, :] @@ -403,7 +404,7 @@ public void ExpandDim0_Slice() shape.Should().Be(new Shape(3, 1, 3)); } - [Test] + [TestMethod] public void ExpandDim1_Slice() { //>>> a = np.arange(3 * 2 * 3).reshape(3, 2, 3)[1, :] @@ -426,7 +427,7 @@ public void ExpandDim1_Slice() shape.Should().Be(new Shape(2, 1, 3)); } - //[Test] + //[TestMethod] //public void Strides_Case1() //{ // var a = np.arange(3 * 2 * 2).reshape((3, 2, 2)); @@ -435,7 +436,7 @@ public void ExpandDim1_Slice() // a.Shape.Strides.Should().BeEquivalentTo(new int[] {16, 8, 4}); //} - [Test] + [TestMethod] public void HashcodeComputation() { // With readonly struct, hashcode is computed at construction time @@ -452,7 +453,7 @@ public void HashcodeComputation() a._hashCode.Should().Be(b._hashCode); } - [Test] + [TestMethod] public void HashcodeScalars() { Shape.Scalar.GetHashCode().Should().Be(int.MinValue); diff --git a/test/NumSharp.UnitTest/View/Shape.Unmanaged.Tests.cs b/test/NumSharp.UnitTest/View/Shape.Unmanaged.Tests.cs index cc6354a56..371917453 100644 --- a/test/NumSharp.UnitTest/View/Shape.Unmanaged.Tests.cs +++ b/test/NumSharp.UnitTest/View/Shape.Unmanaged.Tests.cs @@ -12,6 +12,7 @@ namespace NumSharp.UnitTest.View { + [TestClass] public class ShapeUnmanagedTests { private unsafe void TestGetOffset(Shape shape, int[] indices) @@ -24,7 +25,7 @@ private unsafe void TestGetOffset(Shape shape, int[] indices) } } - [Test] + [TestMethod] public void GetOffsetTest_unsliced() { // unsliced shape @@ -37,7 +38,7 @@ public void GetOffsetTest_unsliced() } - [Test] + [TestMethod] public void GetOffsetTest_sliced() { new Shape(10, 10, 10).Slice("2:8, ::-2, 7").Should().Be(new Shape(6, 5)); diff --git a/test/NumSharp.UnitTest/View/Slice.Tests.cs b/test/NumSharp.UnitTest/View/Slice.Tests.cs index baa84bebd..9e17c2bec 100644 --- a/test/NumSharp.UnitTest/View/Slice.Tests.cs +++ b/test/NumSharp.UnitTest/View/Slice.Tests.cs @@ -11,9 +11,10 @@ namespace NumSharp.UnitTest.View { + [TestClass] public class SliceTests { - [Test] + [TestMethod] public void SliceNotation() { // items start through stop-1 @@ -105,14 +106,14 @@ public void SliceNotation() Assert.ThrowsException(() => new Slice("....")); } - [Test] + [TestMethod] public void N_DimensionalSliceNotation() { var s = "1:3,-5:-8,7:8:9,...,1:,999,:,:1,7::9,:7:9,::-1,-5:-8,5:8,..."; Assert.AreEqual(s, Slice.FormatSlices(Slice.ParseSlices(s))); } - [Test] + [TestMethod] public void SliceDef() { // slice sanitation (prerequisite for shape slicing and correct merging!) diff --git a/test/NumSharp.UnitTest/View/UnmanagedStorage.GetView.Tests.cs b/test/NumSharp.UnitTest/View/UnmanagedStorage.GetView.Tests.cs index d44b50486..2bf0cafe9 100644 --- a/test/NumSharp.UnitTest/View/UnmanagedStorage.GetView.Tests.cs +++ b/test/NumSharp.UnitTest/View/UnmanagedStorage.GetView.Tests.cs @@ -10,9 +10,10 @@ namespace NumSharp.UnitTest.View { + [TestClass] public class UnmanagedStorageTest : TestClass { - [Test] + [TestMethod] public void GetData_1D() { var data = new UnmanagedStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -65,7 +66,7 @@ public void GetData_1D() AssertAreEqual(new[] { 9 }, view.ToArray()); } - [Test] + [TestMethod] public void GetData_1D_Negative() { var data = new UnmanagedStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -97,7 +98,7 @@ public void GetData_1D_Negative() AssertAreEqual(new int[] { 8 }, view.ToArray()); } - [Test] + [TestMethod] public void Indexing_1D() { var data = new UnmanagedStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -157,7 +158,7 @@ public void Indexing_1D() Assert.AreEqual(9, view.GetValue(0)); } - [Test] + [TestMethod] public void NestedView_1D() { var data = new UnmanagedStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -193,7 +194,7 @@ public void NestedView_1D() AssertAreEqual(new int[] { 22, 88 }, view3.ToArray()); } - [Test] + [TestMethod] public void GetData_2D() { //>>> x = np.arange(9).reshape(3, 3) @@ -288,7 +289,7 @@ public void GetData_2D() AssertAreEqual(new int[] { 8, 6, 5, 3, 2, 0 }, view.ToArray()); } - [Test] + [TestMethod] public void NestedView_2D() { var data = new UnmanagedStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -344,7 +345,7 @@ public void NestedView_2D() AssertAreEqual(new int[] { 22, 88, 222, 888 }, view3.ToArray()); } - [Test] + [TestMethod] public void Reduce_1D_to_Scalar() { var data = new UnmanagedStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -355,7 +356,7 @@ public void Reduce_1D_to_Scalar() AssertAreEqual(new int[] { 7 }, view.ToArray()); } - [Test] + [TestMethod] public void Reduce_2D_to_1D_and_0D() { //>>> x = np.arange(9).reshape(3, 3) @@ -390,7 +391,7 @@ public void Reduce_2D_to_1D_and_0D() AssertAreEqual(new int[] { 8 }, view.ToArray()); } - [Test] + [TestMethod] public void NestedDimensionalityReduction() { var data = new UnmanagedStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }); @@ -407,14 +408,14 @@ public void NestedDimensionalityReduction() AssertAreEqual(new int[] { 7, 6 }, view2.ToArray()); } - [Test] + [TestMethod] public void Scalar_to_array() { var a = new UnmanagedStorage(17); AssertAreEqual(new int[] { 17 }, a.ToArray()); } - [Test] + [TestMethod] public void DimensionalityReduction4D_to_1D() { var t = new UnmanagedStorage(np.arange(30).GetData(), new Shape(2, 1, 3, 5)); @@ -425,7 +426,7 @@ public void DimensionalityReduction4D_to_1D() AssertAreEqual(new long[] { 0, 5, 10 }, view.ToArray()); } - [Test] + [TestMethod] public void SlicingWithNegativeIndex1() { var a = new UnmanagedStorage(np.arange(10).GetData(), new Shape(10)); @@ -437,7 +438,7 @@ public void SlicingWithNegativeIndex1() a.GetView(":, 1:").GetView("-1, -2").GetValue(0,0).Should().BeEquivalentTo(8L); } - [Test] + [TestMethod] public void SlicingWithNegativeIndex() { var a = new UnmanagedStorage(np.arange(3 * 1 * 3 * 3).GetData(), (3, 1, 3, 3)); diff --git a/test/NumSharp.UnitTest/View/UnmanagedStorage.ReshapeView.Tests.cs b/test/NumSharp.UnitTest/View/UnmanagedStorage.ReshapeView.Tests.cs index d5fcb3b6a..919e98a30 100644 --- a/test/NumSharp.UnitTest/View/UnmanagedStorage.ReshapeView.Tests.cs +++ b/test/NumSharp.UnitTest/View/UnmanagedStorage.ReshapeView.Tests.cs @@ -10,10 +10,11 @@ namespace NumSharp.UnitTest.View { + [TestClass] public class UnmanagedStorageReshapeViewTest : TestClass { - [Test] + [TestMethod] public void ReshapeSlicedArray() { // Reshaping a non-contiguous slice makes a copy (NumPy behavior) @@ -27,7 +28,7 @@ public void ReshapeSlicedArray() new NDArray(view).ToString(flat: true).Should().Be("array([5, 6, 7, 8, 9, 15, 16, 17, 18, 19])"); } - [Test] + [TestMethod] public void ExpandDimensions() { //>>> np.arange(6) @@ -80,7 +81,7 @@ public void ExpandDimensions() nd.ToString(flat: true).Should().Be("array([[[[1], [2]]], [[[4], [5]]]])"); } - [Test] + [TestMethod] public void SliceReshapedSlicedArray() { // Reshaping a non-contiguous slice makes a copy (NumPy behavior) @@ -94,7 +95,7 @@ public void SliceReshapedSlicedArray() new NDArray(v1).ToString(flat: true).Should().Be("array([6, 8, 15, 17, 19])"); } - [Test] + [TestMethod] public void TheUltimateTest______SliceReshapedSlicedReshapedSlicedArray() { // This test demonstrates the copy-on-reshape behavior for non-contiguous arrays. @@ -125,7 +126,7 @@ public void TheUltimateTest______SliceReshapedSlicedReshapedSlicedArray() new NDArray(t).ToString(flat: true).Should().Be("array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])"); } - [Test] + [TestMethod] public void ReshapeSlicedArray1() { //>>> a diff --git a/test/NumSharp.UnitTest/View/ViewStorage.Test.cs b/test/NumSharp.UnitTest/View/ViewStorage.Test.cs index 02ba95f08..1024dfbc2 100644 --- a/test/NumSharp.UnitTest/View/ViewStorage.Test.cs +++ b/test/NumSharp.UnitTest/View/ViewStorage.Test.cs @@ -10,7 +10,7 @@ // [TestClass] // public class ViewStorageTest : TestClass // { -// [Test] +// [TestMethod] // public void GetData_1D() // { // var data = new TypedArrayStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -57,7 +57,7 @@ // AssertAreEqual(new[] { 9 }, view.GetData()); // } -// [Test] +// [TestMethod] // public void Indexing_1D() // { // var data = new TypedArrayStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -117,7 +117,7 @@ // Assert.AreEqual(9, view.GetData(0)); // } -// [Test] +// [TestMethod] // public void NestedView_1D() // { // var data = new TypedArrayStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -152,7 +152,7 @@ // AssertAreEqual(new int[] { 22, 88 }, view3.GetData()); // } -// [Test] +// [TestMethod] // public void GetData_2D() // { // //>>> x = np.arange(9).reshape(3, 3) @@ -246,7 +246,7 @@ // AssertAreEqual(new int[] { 8, 6, 5, 3, 2, 0 }, view.GetData()); // } -// [Test] +// [TestMethod] // public void NestedView_2D() // { // var data = new TypedArrayStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -302,7 +302,7 @@ // AssertAreEqual(new int[] { 22, 88, 222, 888 }, view3.GetData()); // } -// [Test] +// [TestMethod] // public void Reduce_1D_to_Scalar() // { // var data = new TypedArrayStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -313,7 +313,7 @@ // AssertAreEqual(new int[] { 7 }, view.GetData()); // } -// [Test] +// [TestMethod] // public void Reduce_2D_to_1D_and_0D() // { // //>>> x = np.arange(9).reshape(3, 3) @@ -347,7 +347,7 @@ // AssertAreEqual(new int[] { 8 }, view.GetData()); // } -// [Test] +// [TestMethod] // public void NestedDimensionalityReduction() // { // var data = new TypedArrayStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }); @@ -364,7 +364,7 @@ // AssertAreEqual(new int[] { 7, 6 }, view2.GetData()); // } -// [Test] +// [TestMethod] // public void ToStringTest() // { // var data = new TypedArrayStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); @@ -383,7 +383,7 @@ // Assert.AreEqual("[[[0, 1], [2, 3]], [[4, 5], [6, 7]]]", view.ToString(flat: true)); // } -// [Test] +// [TestMethod] // public void ToString_NonFlatTest() // { // var data = new TypedArrayStorage(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); diff --git a/test/NumSharp.UnitTest/View/ViewTests.cs b/test/NumSharp.UnitTest/View/ViewTests.cs index d6838db6d..af8b64d99 100644 --- a/test/NumSharp.UnitTest/View/ViewTests.cs +++ b/test/NumSharp.UnitTest/View/ViewTests.cs @@ -1,6 +1,5 @@ using System; using AwesomeAssertions; -using TUnit.Core; namespace NumSharp.UnitTest.View { @@ -8,11 +7,12 @@ namespace NumSharp.UnitTest.View /// Battle tests for NDArray.view() - NumPy parity verification. /// Tests byte reinterpretation, not value conversion. /// + [TestClass] public class ViewTests { #region Same Type Views - [Test] + [TestMethod] public void View_SameType_SharesMemory() { var arr = np.array(new int[] { 1, 2, 3, 4, 5 }); @@ -24,7 +24,7 @@ public void View_SameType_SharesMemory() view.GetInt32(0).Should().Be(100); } - [Test] + [TestMethod] public void View_SameType_PreservesShape() { var arr = np.arange(12).reshape(3, 4); @@ -37,7 +37,7 @@ public void View_SameType_PreservesShape() #region Byte Reinterpretation (Same Size Types) - [Test] + [TestMethod] public void View_Float64AsInt64_ReinterpretsIEEE754Bits() { // NumPy: np.array([1.0, 2.0]).view(np.int64) @@ -54,7 +54,7 @@ public void View_Float64AsInt64_ReinterpretsIEEE754Bits() view.GetInt64(2).Should().Be(0x4008000000000000L); } - [Test] + [TestMethod] public void View_Float32AsInt32_ReinterpretsIEEE754Bits() { // NumPy: np.array([1.0, 2.0], dtype=np.float32).view(np.int32) @@ -72,7 +72,7 @@ public void View_Float32AsInt32_ReinterpretsIEEE754Bits() view.GetInt32(3).Should().Be(0x40800000); } - [Test] + [TestMethod] public void View_Int64AsFloat64_ReinterpretsToDouble() { // Put IEEE 754 bit pattern for 2.0, should read as 2.0 @@ -86,7 +86,7 @@ public void View_Int64AsFloat64_ReinterpretsToDouble() #region Different Size Types (Shape Changes) - [Test] + [TestMethod] public void View_Float64AsFloat32_DoublesLastDimension() { // NumPy: np.array([1.0, 2.0], dtype=np.float64).view(np.float32) @@ -98,7 +98,7 @@ public void View_Float64AsFloat32_DoublesLastDimension() view.size.Should().Be(4); } - [Test] + [TestMethod] public void View_Float64AsInt8_ExpandsLastDimension() { // NumPy: np.array([1.0, 2.0], dtype=np.float64).view(np.int8) @@ -110,7 +110,7 @@ public void View_Float64AsInt8_ExpandsLastDimension() view.size.Should().Be(16); } - [Test] + [TestMethod] public void View_Int8AsFloat64_ContractsLastDimension() { // int8[16] (16 bytes) -> float64[2] @@ -121,7 +121,7 @@ public void View_Int8AsFloat64_ContractsLastDimension() view.size.Should().Be(2); } - [Test] + [TestMethod] public void View_2D_AdjustsLastDimension() { // NumPy: np.zeros((3, 4), dtype=np.float64).view(np.float32) @@ -136,7 +136,7 @@ public void View_2D_AdjustsLastDimension() #region Memory Sharing - [Test] + [TestMethod] public void View_ModifyThroughView_AffectsOriginal() { var original = np.array(new double[] { 1.0, 2.0 }); @@ -149,7 +149,7 @@ public void View_ModifyThroughView_AffectsOriginal() original.GetDouble(0).Should().Be(3.0); } - [Test] + [TestMethod] public void View_ModifyOriginal_AffectsView() { var original = np.array(new double[] { 1.0, 2.0 }); @@ -165,7 +165,7 @@ public void View_ModifyOriginal_AffectsView() #region Edge Cases - [Test] + [TestMethod] public void View_WithNull_ReturnsSameTypeCopy() { var arr = np.array(new int[] { 1, 2, 3 }); @@ -175,7 +175,7 @@ public void View_WithNull_ReturnsSameTypeCopy() view.shape.Should().BeEquivalentTo(arr.shape); } - [Test] + [TestMethod] public void View_NonContiguous_ThrowsForDifferentSize() { // Non-contiguous arrays can't be viewed as different-sized types @@ -191,7 +191,7 @@ public void View_NonContiguous_ThrowsForDifferentSize() act.Should().Throw(); } - [Test] + [TestMethod] public void View_IncompatibleByteSize_Throws() { // 3 * 8 = 24 bytes, not divisible by sizeof(decimal) = 16 diff --git a/test/NumSharp.UnitTest/np.save_load.Test.cs b/test/NumSharp.UnitTest/np.save_load.Test.cs index a0d490ecf..2fca34675 100644 --- a/test/NumSharp.UnitTest/np.save_load.Test.cs +++ b/test/NumSharp.UnitTest/np.save_load.Test.cs @@ -8,9 +8,10 @@ namespace NumSharp.UnitTest { + [TestClass] public class NumpySaveLoad { - [Test] + [TestMethod] public void Run() { int[] x = {1, 2, 3, 4, 5}; @@ -20,7 +21,7 @@ public void Run() np.Load_Npz(@"test1.npz"); } - [Test] + [TestMethod] public void Float1DimArray() { float[] x = {1.0f, 1.5f, 2.0f, 2.5f, 3.0f}; @@ -30,7 +31,7 @@ public void Float1DimArray() np.Load_Npz(@"test_Float1DimArray.npz"); } - [Test] + [TestMethod] public void Double1DimArray() { double[] x = {1.0, 1.5, 2.0, 2.5, 3.0}; @@ -40,7 +41,7 @@ public void Double1DimArray() np.Load_Npz(@"test_Double1DimArray.npz"); } - [Test] + [TestMethod] public void SaveAndLoadMultiDimArray() { int[,] x = {{1, 2}, {3, 4}}; @@ -51,7 +52,7 @@ public void SaveAndLoadMultiDimArray() } - [Test] + [TestMethod] public void SaveAndLoadWithNpyFileExt() { // float