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
40
-
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...
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.
67
17
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.
@@ -189,19 +131,24 @@ New features
189
131
* implemented :py:obj:`LArray.apply_map()` method to apply a transformation mapping to array elements. For example, this
190
132
can be used to transform some numeric codes to labels.
191
133
134
+ * implemented :py:obj:`LArray.reverse()` method to reverse one or several axes of an array (closes :issue:`631 `).
135
+
136
+ * implemented :py:obj:`LArray.roll()` method to roll the cells of an array n-times to the right along an axis. This is
137
+ similar to :py:obj:`LArray.shift()`, except that cells which are pushed "outside of the axis" are reintroduced on the
138
+ opposite side of the axis instead of being dropped.
139
+
192
140
* implemented :py:obj:`Axis.apply()` method to transform an axis labels by a function and return a new Axis.
193
141
194
142
* added :py:obj:`Session.update()` method to add and modify items from an existing session by passing
195
143
either another session or a dict-like object or an iterable object with (key, value) pairs (closes :issue:`754 `).
196
144
145
+ * implemented :py:obj:`AxisCollection.rename()` to rename axes of an AxisCollection, independently of any array.
146
+
197
147
* implemented :py:obj:`wrap_elementwise_array_func()` function to make a function defined in another library work with
198
148
LArray arguments instead of with numpy arrays.
199
149
200
- * implemented :py:obj:`LArray.roll()` to roll the cells of an array n-times to the right along an axis. This is similar
201
- to :py:obj:`LArray.shift()`, except that cells which are pushed "outside of the axis" are reintroduced on the opposite
202
- side of the axis instead of being dropped.
203
-
204
- * implemented :py:obj:`AxisCollection.rename()` to rename axes of an AxisCollection, independently of any array.
150
+ * implemented :py:obj:`LArray.keys()`, :py:obj:`LArray.values()` and :py:obj:`LArray.items()`
151
+ methods to respectively loop on an array labels, values or (key, value) pairs.
205
152
206
153
* implemented :py:obj:`zip_array_values()` and :py:obj:`zip_array_items()` to loop respectively on several arrays values
207
154
or (key, value) pairs.
@@ -213,9 +160,37 @@ New features
213
160
Miscellaneous improvements
214
161
^^^^^^^^^^^^^^^^^^^^^^^^^^
215
162
216
- * implemented a simpler pattern language in :py:obj:`Axis.matching()` and :py:obj:`Group.matching()`. In addition to
217
- regular expressions (which now require using the ``regexp`` argument), the two methods support the following simpler
218
- patterns:
163
+ * improved speed of :py:obj:`read_hdf()` function when reading a stored LArray object dumped with
164
+ the current and future version of larray. To get benefit of the speedup of reading arrays dumped
165
+ with older versions of larray, please read and re-dump them. Closes :issue:`563`.
166
+
167
+ * allowed to not specify the axes in :py:obj:`LArray.set_labels()` (closes :issue:`634 `):
168
+
169
+ >>> a = ndtest(' nat=BE,FO;sex=M,F' )
170
+ >>> a
171
+ nat\sex M F
172
+ BE 0 1
173
+ FO 2 3
174
+ >>> a.set_labels({' M' : ' Men' , ' BE' : ' Belgian' })
175
+ nat\sex Men F
176
+ Belgian 0 1
177
+ FO 2 3
178
+
179
+ * :py:obj:`LArray.set_labels()` can now take functions to transform axes labels (closes :issue:`536 `).
180
+
181
+ >>> arr = ndtest((2 , 2 ))
182
+ >>> arr
183
+ a\b b0 b1
184
+ a0 0 1
185
+ a1 2 3
186
+ >>> arr.set_labels(' a' , str.upper)
187
+ a\b b0 b1
188
+ A0 0 1
189
+ A1 2 3
190
+
191
+ * implemented the same "simpler pattern language" in :py:obj:`Axis.matching()` and :py:obj:`Group.matching()` than in
192
+ :py:obj:`Session.filter()`. In addition to regular expressions (which now require using the ``regexp`` argument),
193
+ the two methods support the following simpler patterns:
219
194
220
195
* `?` matches any single character
221
196
* `*` matches any number of characters
@@ -246,18 +221,6 @@ Miscellaneous improvements
246
221
>>> people.matching(pattern=' [AB]*' )
247
222
people['Bruce Wayne', 'Bruce Willis', 'Arthur Dent']
248
223
249
- * :py:obj:`LArray.set_labels()` can now take functions to transform axes labels (closes :issue:`536 `).
250
-
251
- >>> arr = ndtest((2 , 2 ))
252
- >>> arr
253
- a\b b0 b1
254
- a0 0 1
255
- a1 2 3
256
- >>> arr.set_labels(' a' , str.upper)
257
- a\b b0 b1
258
- A0 0 1
259
- A1 2 3
260
-
261
224
* py:obj:`stack()` can now stack along several axes at once (closes :issue:`56 `).
262
225
263
226
>>> country = Axis(' country=BE,FR,DE' )
@@ -282,6 +245,8 @@ Miscellaneous improvements
282
245
object, even on Python < 3.6. This will print a warning though because the ordering of labels is not guaranteed in
283
246
that case.
284
247
248
+ * added password argument to :py:obj:`Workbook.save()` to allow protecting Excel files with a password.
249
+
285
250
* added option ``exact`` to ``join`` argument of :py:obj:`Axis.align()` and :py:obj:`LArray.align()` methods.
286
251
Instead of aligning, passing ``join='exact'`` to the ``align`` method will raise an error when axes are not equal.
287
252
Closes :issue:`338`.
@@ -301,7 +266,7 @@ Miscellaneous improvements
301
266
302
267
Closes :issue:`669`.
303
268
304
- * allowed to specify an axis by its postion when selecting a subset of an array using the string notation:
269
+ * allowed to specify an axis by its position when selecting a subset of an array using the string notation:
305
270
306
271
>>> pop_mouv = ndtest(' geo_from=BE,FR,UK;geo_to=BE,FR,UK' )
307
272
>>> pop_mouv
@@ -326,37 +291,10 @@ Miscellaneous improvements
326
291
327
292
* updated the ``Working With Sessions`` section of the tutorial (closes :issue:`568 `).
328
293
329
- * renamed `a_min` and `a_max` arguments of :py:obj:`LArray.clip()` as `minval` and `maxval` respectively
330
- and made them optional (closes :issue:`747 `).
331
-
332
294
* added dtype argument to LArray to set the type of the array explicitly instead of relying on auto-detection.
333
295
334
296
* added dtype argument to stack to set the type of the resulting array explicitly instead of relying on auto-detection.
335
297
336
- * implemented :py:obj:`LArray.reverse()` method to reverse one or several axes of an array (closes :issue:`631 `).
337
-
338
- * added :py:obj:`set_options` allowing to set options for larray within a ``with`` block or globally:
339
-
340
- The :py:obj:`get_options` function returns a view of the current options as a dictionary:
341
-
342
- Closes :issue:`274`.
343
-
344
- * improved speed of :py:obj:`read_hdf()` function when reading a stored LArray object dumped with
345
- the current and future version of larray. To get benefit of the speedup of reading arrays dumped
346
- with older versions of larray, please read and re-dump them. Closes :issue:`563`.
347
-
348
- * allowed to not specifiy the axes in :py:obj:`LArray.set_labels()` (closes :issue:`634 `):
349
-
350
- >>> a = ndtest(' nat=BE,FO;sex=M,F' )
351
- >>> a
352
- nat\sex M F
353
- BE 0 1
354
- FO 2 3
355
- >>> a.set_labels({' M' : ' Men' , ' BE' : ' Belgian' })
356
- nat\sex Men F
357
- Belgian 0 1
358
- FO 2 3
359
-
360
298
* allowed to pass a single axis or group as ``axes_to_reindex`` argument
361
299
of the :py:obj:`LArray.reindex()` method (closes :issue:`712 `).
362
300
@@ -366,8 +304,6 @@ Miscellaneous improvements
366
304
- light : to output axes labels only when they change instead of repeating them on each line
367
305
- na_repr : to specify how to represent N/A (NaN) values
368
306
369
- * added password argument to :py:obj:`Workbook.save()` to allow protecting Excel files with a password.
370
-
371
307
* substantially improved performance of creating, iterating, and doing a few other operations over larray objects.
372
308
This solves a few pathological cases of slow operations, especially those involving many small-ish arrays but sadly
373
309
the overall performance improvement is negligible over most of the real-world models using larray that we tested these
0 commit comments