Repository navigation
implement Axis.chunks & LArray.chunks #505
Copy link
Copy link
Open
Labels
Milestone
Description
this would generalize/deprecate Axis.by
Axis.split(chunks=10, length=None, step=None, before=None, after=None, indices=None)
LArray.split(chunks=10, length=None, step=None, before=None, after=None, indices=None, axis=-1)
>>> age = Axis("0..99", "age")
>>> age.split(5)
(age.i[0:20], age.i[20:40], age.i[40:60], age.i[60:80], age.i[80:100])
>>> age.split(length=20)
(age.i[0:20], age.i[20:40], age.i[40:60], age.i[60:80], age.i[80:100])
>>> age.split(length=10, step=20)
(age.i[0:10], age.i[20:30], age.i[40:50], age.i[60:70], age.i[80:90])
>>> age.split(before=50)
(age.i[0:50], age.i[50:100])
>>> age.split(before=[10, 15, 20, 40])
(age.i[0:10], age.i[10:15], age.i[15:20], age.i[20:40], age.i[40:100])
>>> age.split(indices=50)
(age.i[0:50], age.i[50:100])
>>> age.split(indices=[10, 15, 20, 40])
(age.i[0:10], age.i[10:15], age.i[15:20], age.i[20:40], age.i[40:100])
>>> arr = ndrange(age) * 0.25
>>> arr.split(10, axis='age')
[age 0 1 2 3 4 5 6 7 8 9
0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 2.25,
age 10 11 12 13 14 15 16 17 18 19
2.5 2.75 3.0 3.25 3.5 3.75 4.0 4.25 4.5 4.75,
age 20 21 22 23 24 25 26 27 28 29
5.0 5.25 5.5 5.75 6.0 6.25 6.5 6.75 7.0 7.25,
age 30 31 32 33 34 35 36 37 38 39
7.5 7.75 8.0 8.25 8.5 8.75 9.0 9.25 9.5 9.75,
age 40 41 42 43 44 45 46 47 48 49
10.0 10.25 10.5 10.75 11.0 11.25 11.5 11.75 12.0 12.25,
age 50 51 52 53 54 55 56 57 58 59
12.5 12.75 13.0 13.25 13.5 13.75 14.0 14.25 14.5 14.75,
age 60 61 62 63 64 65 66 67 68 69
15.0 15.25 15.5 15.75 16.0 16.25 16.5 16.75 17.0 17.25,
age 70 71 72 73 74 75 76 77 78 79
17.5 17.75 18.0 18.25 18.5 18.75 19.0 19.25 19.5 19.75,
age 80 81 82 83 84 85 86 87 88 89
20.0 20.25 20.5 20.75 21.0 21.25 21.5 21.75 22.0 22.25,
age 90 91 92 93 94 95 96 97 98 99
22.5 22.75 23.0 23.25 23.5 23.75 24.0 24.25 24.5 24.75]
>>> arr1d.split(10)
idemFWIW: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.split.html
Reactions are currently unavailable
Activity
gdementen commentedon Oct 27, 2017
Oops, Axis.split is already taken for splitting labels. What do we do?
alixdamman commentedon Oct 27, 2017
Certainly not renaming
Axis.split. There is enough FutureWarning for now.Could you add outputs in your example from your first comment, please?
I don't see exactly what you want to do.
gdementen commentedon Oct 27, 2017
I doubt anybody is using Axis.split yet :)
alixdamman commentedon Oct 27, 2017
But
LArray.splityes and we should stay consistent as much as possible.alixdamman commentedon Oct 27, 2017
Take
Axis.chunksgdementen commentedon Oct 27, 2017
FWIW,
LArray.splitdoes not exist (yet).LArray.split_axesdoes.alixdamman commentedon Oct 27, 2017
Indeed sorry. But my mistake make me think that
splitis too close tosplit_axesand may be confusing.alixdamman commentedon Oct 27, 2017
What are the expected outputs?
gdementen commentedon Oct 27, 2017
I updated the description
alixdamman commentedon Oct 27, 2017
Thanks
[-]implement Axis.split & LArray.split[/-][+]implement Axis.chunks & LArray.chunks[/+]