Skip to content

Commit 6974950

Browse files
committed
fix(random): fix standard_normal typo and add random() alias
Fixes: - Renamed `stardard_normal` to `standard_normal` (typo fix) - Added backwards-compat alias with [Obsolete] warning - Added `random()` as alias for `random_sample()` (NumPy compat) NumPy random API audit findings: - 19 functions implemented correctly - 1 typo fixed (stardard_normal → standard_normal) - 1 alias added (random → random_sample) - 33 functions still missing (mostly rare distributions) - bernoulli() is NumSharp-specific (not in NumPy, use scipy)
1 parent c594721 commit 6974950

3 files changed

Lines changed: 31 additions & 31 deletions

File tree

bash.exe.stackdump

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/NumSharp.Core/RandomSampling/np.random.rand.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,33 @@ public NDArray random_sample(params int[] size)
4949
/// Return random floats in the half-open interval [0.0, 1.0).
5050
/// Results are from the “continuous uniform” distribution over the stated interval. To sample Unif[a, b), b > a multiply the output of random_sample by (b-a) and add a:
5151
/// </summary>
52-
/// <param name="shape">The shape to randomize</param>
52+
/// <param name=shape>The shape to randomize</param>
5353
/// <returns></returns>
5454
public NDArray random_sample(Shape shape)
5555
{
5656
return rand(shape);
5757
}
58+
59+
/// <summary>
60+
/// Return random floats in the half-open interval [0.0, 1.0).
61+
/// Alias for random_sample (NumPy compatibility).
62+
/// </summary>
63+
/// <param name=”size”>Output shape</param>
64+
/// <returns>Array of random floats</returns>
65+
public NDArray random(params int[] size)
66+
{
67+
return random_sample(size);
68+
}
69+
70+
/// <summary>
71+
/// Return random floats in the half-open interval [0.0, 1.0).
72+
/// Alias for random_sample (NumPy compatibility).
73+
/// </summary>
74+
/// <param name=”shape”>Output shape</param>
75+
/// <returns>Array of random floats</returns>
76+
public NDArray random(Shape shape)
77+
{
78+
return random_sample(shape);
79+
}
5880
}
5981
}

src/NumSharp.Core/RandomSampling/np.random.randn.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public partial class NumPyRandom
1515
/// <returns></returns>
1616
public NDArray randn(params int[] size)
1717
{
18-
return stardard_normal(size);
18+
return standard_normal(size);
1919
}
2020

2121
/// <summary>
@@ -56,9 +56,15 @@ public NDArray normal(double loc, double scale, params int[] dims)
5656
/// </summary>
5757
/// <param name="size"></param>
5858
/// <returns></returns>
59-
public NDArray stardard_normal(params int[] size)
59+
public NDArray standard_normal(params int[] size)
6060
{
6161
return normal(0, 1.0, size);
6262
}
63+
64+
/// <summary>
65+
/// Backwards compatibility alias for standard_normal (typo in older versions).
66+
/// </summary>
67+
[Obsolete("Use standard_normal instead (typo fixed)")]
68+
public NDArray stardard_normal(params int[] size) => standard_normal(size);
6369
}
6470
}

0 commit comments

Comments
 (0)