Skip to content

Commit 3d68c53

Browse files
committed
faster Axis.apply
1 parent cd29b25 commit 3d68c53

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

doc/source/changes/version_0_30.rst.inc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ New features
138138

139139
* implemented :py:obj:`Axis.apply()` method to transform an axis labels by a function and return a new Axis.
140140

141-
>>> sex = Axis('sex=MALE,FEMALE')
142-
>>> sex.apply(str.capitalize)
143-
Axis(['Male', 'Female'], 'sex')
144-
145141
* added :py:obj:`Session.update()` method to add and modify items from an existing session by passing
146142
either another session or a dict-like object or an iterable object with (key, value) pairs (closes :issue:`754`).
147143

larray/core/axis.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
renamed_to, common_type, LHDFStore, lazy_attribute, _isnoneslice, unique_multi, Product)
2020

2121

22+
np_frompyfunc = np.frompyfunc
23+
24+
2225
class Axis(ABCAxis):
2326
"""
2427
Represents an axis. It consists of a name and a list of labels.
@@ -1105,7 +1108,7 @@ def apply(self, func):
11051108
>>> sex.apply(str.capitalize)
11061109
Axis(['Male', 'Female'], 'sex')
11071110
"""
1108-
return Axis(map(func, self.labels), self.name)
1111+
return Axis(np_frompyfunc(func, 1, 1)(self.labels), self.name)
11091112

11101113
# XXX: rename to named like Group?
11111114
def rename(self, name):

0 commit comments

Comments
 (0)