Showing 1 of 1 files from the diff.

@@ -11,7 +11,7 @@
 11 11 ` pass` 12 12 13 13 14 - `def dsphere(n=100, d=2, r=1, noise=None, ambient=None):` 14 + `def dsphere(n=100, d=2, r=1, noise=None, ambient=None, seed=None):` 15 15 ` """` 16 16 ` Sample `n` data points on a d-sphere.` 17 17
@@ -23,7 +23,10 @@
 23 23 ` Radius of sphere.` 24 24 ` ambient : int, default=None` 25 25 ` Embed the sphere into a space with ambient dimension equal to `ambient`. The sphere is randomly rotated in this high dimensional space.` 26 + ` seed : int, default=None` 27 + ` Seed for random state. ` 26 28 ` """` 29 + ` np.random.seed(seed)` 27 30 ` data = np.random.randn(n, d+1)` 28 31 29 32 ` # Normalize points to the sphere`
@@ -41,7 +44,7 @@
 41 44 ` return data` 42 45 43 46 44 - `def sphere(n=100, r=1, noise=None, ambient=None):` 47 + `def sphere(n=100, r=1, noise=None, ambient=None, seed=None):` 45 48 ` """` 46 49 ` Sample `n` data points on a sphere.` 47 50
@@ -53,8 +56,11 @@
 53 56 ` Radius of sphere.` 54 57 ` ambient : int, default=None` 55 58 ` Embed the sphere into a space with ambient dimension equal to `ambient`. The sphere is randomly rotated in this high dimensional space.` 59 + ` seed : int, default=None` 60 + ` Seed for random state. ` 56 61 ` """` 57 62 63 + ` np.random.seed(seed)` 58 64 ` theta = np.random.random((n,)) * 2.0 * np.pi` 59 65 ` phi = np.random.random((n,)) * np.pi` 60 66 ` rad = np.ones((n,)) * r`
@@ -75,7 +81,7 @@
 75 81 ` return data` 76 82 77 83 78 - `def torus(n=100, c=2, a=1, noise=None, ambient=None):` 84 + `def torus(n=100, c=2, a=1, noise=None, ambient=None, seed=None):` 79 85 ` """` 80 86 ` Sample `n` data points on a torus.` 81 87
@@ -89,10 +95,13 @@
 89 95 ` Radius of tube.` 90 96 ` ambient : int, default=None` 91 97 ` Embed the torus into a space with ambient dimension equal to `ambient`. The torus is randomly rotated in this high dimensional space.` 98 + ` seed : int, default=None` 99 + ` Seed for random state. ` 92 100 ` """` 93 101 94 102 ` assert a <= c, "That's not a torus"` 95 103 104 + ` np.random.seed(seed)` 96 105 ` theta = np.random.random((n,)) * 2.0 * np.pi` 97 106 ` phi = np.random.random((n,)) * 2.0 * np.pi` 98 107
@@ -110,7 +119,7 @@
 110 119 ` return data` 111 120 112 121 113 - `def swiss_roll(n=100, r=10, noise=None, ambient=None):` 122 + `def swiss_roll(n=100, r=10, noise=None, ambient=None, seed=None):` 114 123 ` """Swiss roll implementation` 115 124 116 125 ` Parameters`
@@ -121,12 +130,15 @@
 121 130 ` Length of roll` 122 131 ` ambient : int, default=None` 123 132 ` Embed the swiss roll into a space with ambient dimension equal to `ambient`. The swiss roll is randomly rotated in this high dimensional space.` 133 + ` seed : int, default=None` 134 + ` Seed for random state. ` 124 135 125 136 ` References` 126 137 ` ----------` 127 138 ` Equations mimic [Swiss Roll and SNE by jlmelville](https://jlmelville.github.io/smallvis/swisssne.html)` 128 139 ` """` 129 140 141 + ` np.random.seed(seed)` 130 142 ` phi = (np.random.random((n,)) * 3 + 1.5) * np.pi` 131 143 ` psi = np.random.random((n,)) * r` 132 144
@@ -143,7 +155,7 @@
 143 155 144 156 ` return data` 145 157 146 - `def infty_sign(n=100, noise=None, angle=None):` 158 + `def infty_sign(n=100, noise=None, angle=None, seed=None):` 147 159 ` """Construct a figure 8 or infinity sign with :code:`n` points and noise level with :code:`noise` standard deviation.` 148 160 149 161 ` Parameters`
@@ -155,9 +167,12 @@
 155 167 ` standard deviation of normally distributed noise added to data.` 156 168 ` angle: float` 157 169 ` angle in radians to rotate the infinity sign.` 170 + ` seed : int, default=None` 171 + ` Seed for random state. ` 158 172 ` """` 159 173 160 174 175 + ` np.random.seed(seed)` 161 176 ` t = np.linspace(0, 2*np.pi, n+1)[0:n]` 162 177 ` X = np.zeros((n, 2))` 163 178 ` X[:, 0] = np.cos(t)`
@@ -165,10 +180,8 @@
 165 180 166 181 ` if noise:` 167 182 ` X += noise * np.random.randn(n, 2)` 168 - 169 183 ` if angle is not None:` 170 184 ` assert angle >= -np.pi and angle <= 2*np.pi, "Angle {angle} not in range. Angle should be in the range {min_angle} <= angle <= {max_angle}".format(angle=angle, min_angle="-pi", max_angle="2*pi")` 171 185 172 186 ` X = rotate_2D(X, angle=angle)` 173 - 174 187 ` return X`
Files Coverage
Project Totals (7 files) 90.70%
36.4
```3.6=.6
TRAVIS_OS_NAME=linux
```
36.1
```TRAVIS_OS_NAME=linux
2.7=.7
```
36.3
```3.5=.5
TRAVIS_OS_NAME=linux
```
36.2
```3.4=.4
TRAVIS_OS_NAME=linux
```