4
4
Syntax changes
5
5
^^^^^^^^^^^^^^
6
6
7
- * :py:obj:`LArray.as_table()` is deprecated. Please use :py:obj:`LArray.dump()` instead.
8
-
9
7
* :py:obj:`stack()` ``axis`` argument was renamed to ``axes`` to reflect the fact that the function can now stack
10
8
along multiple axes at once (see below).
11
9
10
+ * to accommodate for the "simpler pattern language" now supported for those functions, using a regular expression in
11
+ :py:obj:`Axis.matching()` or :py:obj:`Group.matching()` now requires passing the pattern as an explicit ``regex``
12
+ keyword argument instead of just the first argument of those methods. For example ``my_axis.matching(' test.*' )``
13
+ becomes ``my_axis.matching(regex=' test.*' )``.
12
14
13
- Backward incompatible changes
14
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15
-
16
- * :py:obj:`LArray.equals()` now returns True for arrays even when axes are in a different order or some axes are
17
- missing on either side (but the data is constant over that axis on the other side). To get back the old behavior, use
18
- check_axes=True. Closes :issue:`237`.
19
-
20
- >>> a = Axis(' a=a0,a1' )
21
- >>> arr1 = ndtest(a)
22
- >>> arr1
23
- a a0 a1
24
- 0 1
25
-
26
- Identical arrays are (still) considered equal
27
-
28
- >>> arr2 = arr1.copy()
29
- >>> arr2.equals(arr1)
30
- True
31
-
32
- Arrays with different labels (for the same axes), are (still) not equal
33
-
34
- >>> arr3 = arr1.set_labels(' a' , ' a8,a9' )
35
- >>> arr3
36
- a a8 a9
37
- 0 1
38
- >>> arr3.equals(arr1)
39
- False
15
+ * ``LArray.as_table()`` is deprecated because it duplicated functionality found in :py:obj:`LArray.dump()`.
16
+ Please only use :py:obj:`LArray.dump()` from now on.
40
17
41
- Arrays with the same axes but different data, are (still) not equal
42
-
43
- >>> arr4 = arr1.copy()
44
- >>> arr4['a1'] = 42
45
- >>> arr4
46
- a a0 a1
47
- 0 42
48
- >>> arr4.equals(arr1)
49
- False
50
-
51
- Arrays with extra axes but the same data are now considered equal
52
-
53
- >>> arr5 = arr1.expand(' b=b0..b2' )
54
- >>> arr5
55
- a\b b0 b1 b2
56
- a0 0 0 0
57
- a1 1 1 1
58
- >>> arr5.equals(arr1)
59
- True
60
-
61
- Unless check_axes is True
62
-
63
- >>> arr5.equals(arr1, check_axes=True)
64
- False
65
-
66
- Arrays with axes in a different order (but the same data) are also equal...
67
-
68
- >>> arr6 = arr5.transpose()
69
- >>> arr6
70
- b\a a0 a1
71
- b0 0 1
72
- b1 0 1
73
- b2 0 1
74
- >>> arr6.equals(arr5)
75
- True
18
+ * renamed ``a_min`` and ``a_max`` arguments of :py:obj:`LArray.clip()` to ``minval`` and ``maxval`` respectively
19
+ and made them optional (closes :issue:`747 `).
76
20
77
- Unless check_axes is True
78
21
79
- >>> arr3.equals(arr4, check_axes=True)
80
- False
22
+ Backward incompatible changes
23
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
81
24
82
- * modified the behavior of the ``pattern`` argument of :py:obj:`Session.filter()` to work as the ``pattern``
83
- argument of :py:obj:`Group.matching()`:
25
+ * modified the behavior of the ``pattern`` argument of :py:obj:`Session.filter()` to actually support patterns instead
26
+ of only checking if the object names start with the pattern. Special characters include ``?`` for matching any single
27
+ character and ``*`` for matching any number of characters. Closes :issue:`703`.
84
28
85
- >>> axis = Axis(' a=a0..a2' )
86
- >>> group = axis['a0,a1'] >> 'a01'
87
- >>> test1, zero1 = ndtest((2 , 2 )), zeros((3 , 2 ))
88
- >>> s = Session([(' test1' , test1), (' zero1' , zero1), (' axis' , axis), (' group' , group)])
29
+ .. warning::
89
30
90
- >>> # get all items with names ending with ' 1'
91
- >>> s.filter(pattern=' *1' ).names
92
- [' test1' , ' zero1' ]
31
+ If you were using Session.filter, you must add a ``*`` to your pattern to keep your code working.
32
+ For example, ``my_session.filter(' test' )`` must be changed to ``my_session.filter(' test*' )``.
93
33
94
- >>> # get all items with names starting with letter in range a-k
95
- >>> s.filter(pattern=' [a-k]*' ).names
96
- [' axis' , ' group' ]
34
+ * :py:obj:`LArray.equals()` now returns True for arrays even when axes are in a different order or some axes are
35
+ missing on either side (but the data is constant over that axis on the other side). Closes :issue:`237`.
97
36
98
- Warning: to retrieve the previous behavior, add the character ``*`` to your pattern
99
- (e.g. ``s.filter(' test' )`` becomes ``s.filter(' test*' )``).
37
+ .. warning::
100
38
101
- Closes :issue:`703 `.
39
+ If you were using :py:obj:`LArray.equals()` **and** want to keep the old, stricter, behavior, you must add
40
+ ``check_axes=True``.
102
41
103
42
104
43
New features
105
44
^^^^^^^^^^^^
106
45
46
+ * added :py:obj:`set_options()` and :py:obj:`get_options()` functions to respectively set and get options for larray.
47
+ Available options currently include ``display_precision`` for controlling the number of decimal digits used when
48
+ showing floating point numbers, ``display_maxlines`` to control the maximum number of lines to use when displaying
49
+ an array, etc. :py:obj:`set_options()` can used either like a normal function to set the options globally or within a
50
+ ``with`` block to set them only temporarily. Closes :issue:`274`.
51
+
107
52
* implemented :py:obj:`read_stata()` and :py:obj:`LArray.to_stata()` to read arrays from and write arrays to Stata .dta
108
53
files.
109
54
110
- * added :py:obj:`LArray.isin()` method to check whether each element of an array is contained in a list (or array) of
111
- values.
112
-
113
- * implemented :py:obj:`LArray.keys()`, :py:obj:`LArray.values()` and :py:obj:`LArray.items()`
114
- methods to respectively loop on an array labels, values or (key, value) pairs.
55
+ * implemented :py:obj:`LArray.isin()` method to check whether each value of an array is contained in a list (or array)
56
+ of values.
115
57
116
58
* implemented :py:obj:`LArray.unique()` method to compute unique values (or sub-arrays) for an array,
117
59
optionally along axes.
@@ -123,19 +65,24 @@ New features
123
65
* implemented :py:obj:`LArray.apply_map()` method to apply a transformation mapping to array elements. For example, this
124
66
can be used to transform some numeric codes to labels.
125
67
68
+ * implemented :py:obj:`LArray.reverse()` method to reverse one or several axes of an array (closes :issue:`631 `).
69
+
70
+ * implemented :py:obj:`LArray.roll()` method to roll the cells of an array n-times to the right along an axis. This is
71
+ similar to :py:obj:`LArray.shift()`, except that cells which are pushed "outside of the axis" are reintroduced on the
72
+ opposite side of the axis instead of being dropped.
73
+
126
74
* implemented :py:obj:`Axis.apply()` method to transform an axis labels by a function and return a new Axis.
127
75
128
76
* added :py:obj:`Session.update()` method to add and modify items from an existing session by passing
129
77
either another session or a dict-like object or an iterable object with (key, value) pairs (closes :issue:`754 `).
130
78
79
+ * implemented :py:obj:`AxisCollection.rename()` to rename axes of an AxisCollection, independently of any array.
80
+
131
81
* implemented :py:obj:`wrap_elementwise_array_func()` function to make a function defined in another library work with
132
82
LArray arguments instead of with numpy arrays.
133
83
134
- * implemented :py:obj:`LArray.roll()` to roll the cells of an array n-times to the right along an axis. This is similar
135
- to :py:obj:`LArray.shift()`, except that cells which are pushed "outside of the axis" are reintroduced on the opposite
136
- side of the axis instead of being dropped.
137
-
138
- * implemented :py:obj:`AxisCollection.rename()` to rename axes of an AxisCollection, independently of any array.
84
+ * implemented :py:obj:`LArray.keys()`, :py:obj:`LArray.values()` and :py:obj:`LArray.items()`
85
+ methods to respectively loop on an array labels, values or (key, value) pairs.
139
86
140
87
* implemented :py:obj:`zip_array_values()` and :py:obj:`zip_array_items()` to loop respectively on several arrays values
141
88
or (key, value) pairs.
@@ -147,8 +94,21 @@ New features
147
94
Miscellaneous improvements
148
95
^^^^^^^^^^^^^^^^^^^^^^^^^^
149
96
150
- * implemented the same "simpler pattern language" in :py:obj:`Axis.matching()` and :py:obj:`Group.matching()` than in
151
- :py:obj:`Session.filter()`, in addition to regular expressions (which now require using the ``regexp`` argument).
97
+ * improved speed of :py:obj:`read_hdf()` function when reading a stored LArray object dumped with
98
+ the current and future version of larray. To get benefit of the speedup of reading arrays dumped
99
+ with older versions of larray, please read and re-dump them. Closes :issue:`563`.
100
+
101
+ * allowed to not specify the axes in :py:obj:`LArray.set_labels()` (closes :issue:`634 `):
102
+
103
+ >>> a = ndtest(' nat=BE,FO;sex=M,F' )
104
+ >>> a
105
+ nat\sex M F
106
+ BE 0 1
107
+ FO 2 3
108
+ >>> a.set_labels({' M' : ' Men' , ' BE' : ' Belgian' })
109
+ nat\sex Men F
110
+ Belgian 0 1
111
+ FO 2 3
152
112
153
113
* :py:obj:`LArray.set_labels()` can now take functions to transform axes labels (closes :issue:`536 `).
154
114
@@ -162,6 +122,9 @@ Miscellaneous improvements
162
122
A0 0 1
163
123
A1 2 3
164
124
125
+ * implemented the same "simpler pattern language" in :py:obj:`Axis.matching()` and :py:obj:`Group.matching()` than in
126
+ :py:obj:`Session.filter()`, in addition to regular expressions (which now require using the ``regexp`` argument).
127
+
165
128
* py:obj:`stack()` can now stack along several axes at once (closes :issue:`56 `).
166
129
167
130
>>> country = Axis(' country=BE,FR,DE' )
@@ -186,6 +149,8 @@ Miscellaneous improvements
186
149
object, even on Python < 3.6. This will print a warning though because the ordering of labels is not guaranteed in
187
150
that case.
188
151
152
+ * added password argument to :py:obj:`Workbook.save()` to allow protecting Excel files with a password.
153
+
189
154
* added option ``exact`` to ``join`` argument of :py:obj:`Axis.align()` and :py:obj:`LArray.align()` methods.
190
155
Instead of aligning, passing ``join='exact'`` to the ``align`` method will raise an error when axes are not equal.
191
156
Closes :issue:`338`.
@@ -205,7 +170,7 @@ Miscellaneous improvements
205
170
206
171
Closes :issue:`669`.
207
172
208
- * allowed to specify an axis by its postion when selecting a subset of an array using the string notation:
173
+ * allowed to specify an axis by its position when selecting a subset of an array using the string notation:
209
174
210
175
>>> pop_mouv = ndtest(' geo_from=BE,FR,UK;geo_to=BE,FR,UK' )
211
176
>>> pop_mouv
@@ -230,37 +195,10 @@ Miscellaneous improvements
230
195
231
196
* updated the ``Working With Sessions`` section of the tutorial (closes :issue:`568 `).
232
197
233
- * renamed `a_min` and `a_max` arguments of :py:obj:`LArray.clip()` as `minval` and `maxval` respectively
234
- and made them optional (closes :issue:`747 `).
235
-
236
198
* added dtype argument to LArray to set the type of the array explicitly instead of relying on auto-detection.
237
199
238
200
* added dtype argument to stack to set the type of the resulting array explicitly instead of relying on auto-detection.
239
201
240
- * implemented :py:obj:`LArray.reverse()` method to reverse one or several axes of an array (closes :issue:`631 `).
241
-
242
- * added :py:obj:`set_options` allowing to set options for larray within a ``with`` block or globally:
243
-
244
- The :py:obj:`get_options` function returns a view of the current options as a dictionary:
245
-
246
- Closes :issue:`274`.
247
-
248
- * improved speed of :py:obj:`read_hdf()` function when reading a stored LArray object dumped with
249
- the current and future version of larray. To get benefit of the speedup of reading arrays dumped
250
- with older versions of larray, please read and re-dump them. Closes :issue:`563`.
251
-
252
- * allowed to not specifiy the axes in :py:obj:`LArray.set_labels()` (closes :issue:`634 `):
253
-
254
- >>> a = ndtest(' nat=BE,FO;sex=M,F' )
255
- >>> a
256
- nat\sex M F
257
- BE 0 1
258
- FO 2 3
259
- >>> a.set_labels({' M' : ' Men' , ' BE' : ' Belgian' })
260
- nat\sex Men F
261
- Belgian 0 1
262
- FO 2 3
263
-
264
202
* allowed to pass a single axis or group as ``axes_to_reindex`` argument
265
203
of the :py:obj:`LArray.reindex()` method (closes :issue:`712 `).
266
204
@@ -270,8 +208,6 @@ Miscellaneous improvements
270
208
- light : to output axes labels only when they change instead of repeating them on each line
271
209
- na_repr : to specify how to represent N/A (NaN) values
272
210
273
- * added password argument to :py:obj:`Workbook.save()` to allow protecting Excel files with a password.
274
-
275
211
* substantially improved performance of creating, iterating, and doing a few other operations over larray objects.
276
212
This solves a few pathological cases of slow operations, especially those involving many small-ish arrays but sadly
277
213
the overall performance improvement is negligible over most of the real-world models using larray that we tested these
0 commit comments