Skip to content

Commit f204c8f

Browse files
committed
renamed the LArray class as Array -> random.py
1 parent 5b55be3 commit f204c8f

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

larray/random.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import numpy as np
2727

2828
from larray.core.axis import Axis, AxisCollection
29-
from larray.core.array import LArray, aslarray
29+
from larray.core.array import Array, aslarray
3030
from larray.core.array import raw_broadcastable
3131
import larray as la
3232

@@ -37,7 +37,7 @@
3737
def generic_random(np_func, args, min_axes, meta):
3838
args, res_axes = raw_broadcastable(args, min_axes=min_axes)
3939
res_data = np_func(*args, size=res_axes.shape)
40-
return LArray(res_data, res_axes, meta=meta)
40+
return Array(res_data, res_axes, meta=meta)
4141

4242

4343
# We choose to place the axes argument in place of the numpy size argument, instead of having axes as the first
@@ -70,7 +70,7 @@ def randint(low, high=None, axes=None, dtype='l', meta=None):
7070
7171
Returns
7272
-------
73-
LArray
73+
Array
7474
7575
Examples
7676
--------
@@ -100,7 +100,7 @@ def randint(low, high=None, axes=None, dtype='l', meta=None):
100100
# to do that, uncommenting the following code should be enough:
101101
# return generic_random(np.random.randint, (low, high), axes, meta)
102102
axes = AxisCollection(axes)
103-
return LArray(np.random.randint(low, high, axes.shape, dtype), axes, meta=meta)
103+
return Array(np.random.randint(low, high, axes.shape, dtype), axes, meta=meta)
104104

105105

106106
def normal(loc=0.0, scale=1.0, axes=None, meta=None):
@@ -127,7 +127,7 @@ def normal(loc=0.0, scale=1.0, axes=None, meta=None):
127127
128128
Returns
129129
-------
130-
LArray or scalar
130+
Array or scalar
131131
Drawn samples from the parameterized normal distribution.
132132
133133
Notes
@@ -238,7 +238,7 @@ def uniform(low=0.0, high=1.0, axes=None, meta=None):
238238
239239
Returns
240240
-------
241-
LArray or scalar
241+
Array or scalar
242242
Drawn samples from the parameterized uniform distribution.
243243
244244
See Also
@@ -330,7 +330,7 @@ def permutation(x, axis=0):
330330
331331
Returns
332332
-------
333-
LArray
333+
Array
334334
Permuted sequence or array range.
335335
336336
Examples
@@ -357,7 +357,7 @@ def permutation(x, axis=0):
357357
a2 7 8 6
358358
"""
359359
if isinstance(x, (int, np.integer)):
360-
return LArray(np.random.permutation(x))
360+
return Array(np.random.permutation(x))
361361
else:
362362
x = aslarray(x)
363363
axis = x.axes[axis]
@@ -375,15 +375,15 @@ def choice(choices=None, axes=None, replace=True, p=None, meta=None):
375375
Values to choose from.
376376
If an array, a random sample is generated from its elements.
377377
If an int n, the random sample is generated as if choices was la.sequence(n)
378-
If p is a 1-D LArray, choices are taken from its axis.
378+
If p is a 1-D Array, choices are taken from its axis.
379379
axes : int, tuple of int, str, Axis or tuple/list/AxisCollection of Axis, optional
380380
Axes (or shape) of the resulting array. If ``axes`` is None (the default), a single value is returned.
381381
Otherwise, if the resulting axes have a shape of, e.g., ``(m, n, k)``, then ``m * n * k`` samples are drawn.
382382
replace : boolean, optional
383383
Whether the sample is with or without replacement.
384384
p : array-like, optional
385385
The probabilities associated with each entry in choices.
386-
If p is a 1-D LArray, choices are taken from its axis labels. If p is an N-D LArray, each cell represents the
386+
If p is a 1-D Array, choices are taken from its axis labels. If p is an N-D Array, each cell represents the
387387
probability that the combination of labels will occur.
388388
If not given the sample assumes a uniform distribution over all entries in choices.
389389
meta : list of pairs or dict or OrderedDict or Metadata, optional
@@ -392,7 +392,7 @@ def choice(choices=None, axes=None, replace=True, p=None, meta=None):
392392
393393
Returns
394394
-------
395-
LArray or scalar
395+
Array or scalar
396396
The generated random samples with given ``axes`` (or shape).
397397
398398
Raises
@@ -426,9 +426,9 @@ def choice(choices=None, axes=None, replace=True, p=None, meta=None):
426426
a0 15 10 10
427427
a1 10 5 10
428428
429-
Same as above with labels and probabilities given as a one dimensional LArray
429+
Same as above with labels and probabilities given as a one dimensional Array
430430
431-
>>> proba = LArray([0.3, 0.5, 0.2], Axis([5, 10, 15], 'outcome')) # doctest: +SKIP
431+
>>> proba = Array([0.3, 0.5, 0.2], Axis([5, 10, 15], 'outcome')) # doctest: +SKIP
432432
>>> proba # doctest: +SKIP
433433
outcome 5 10 15
434434
0.3 0.5 0.2
@@ -452,7 +452,7 @@ def choice(choices=None, axes=None, replace=True, p=None, meta=None):
452452
453453
Using an N-dimensional array as probabilities:
454454
455-
>>> proba = LArray([[0.15, 0.25, 0.10],
455+
>>> proba = Array([[0.15, 0.25, 0.10],
456456
... [0.20, 0.10, 0.20]], 'a=a0,a1;b=b0..b2') # doctest: +SKIP
457457
>>> proba # doctest: +SKIP
458458
a\b b0 b1 b2
@@ -468,9 +468,9 @@ def choice(choices=None, axes=None, replace=True, p=None, meta=None):
468468
d5 a0 b1
469469
"""
470470
axes = AxisCollection(axes)
471-
if isinstance(p, LArray):
471+
if isinstance(p, Array):
472472
if choices is not None:
473-
raise ValueError("choices argument cannot be used when p argument is an LArray")
473+
raise ValueError("choices argument cannot be used when p argument is an Array")
474474

475475
if p.ndim > 1:
476476
flat_p = p.data.reshape(-1)
@@ -480,5 +480,5 @@ def choice(choices=None, axes=None, replace=True, p=None, meta=None):
480480
choices = p.axes[0].labels
481481
p = p.data
482482
if choices is None:
483-
raise ValueError("choices argument must be provided unless p is an LArray")
484-
return LArray(np.random.choice(choices, axes.shape, replace, p), axes, meta=meta)
483+
raise ValueError("choices argument must be provided unless p is an Array")
484+
return Array(np.random.choice(choices, axes.shape, replace, p), axes, meta=meta)

0 commit comments

Comments
 (0)