Skip to content

Commit c1c30e6

Browse files
committed
Add util.XyzComponents.apply()
1 parent 9240b7f commit c1c30e6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sfs/util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,14 @@ def setter(self, value):
323323
z = make_property(2, doc='z-component (optional).')
324324

325325
del make_property
326+
327+
def apply(self, func, *args, **kwargs):
328+
"""Apply a function to each component.
329+
330+
The function `func` will be called once for each component,
331+
passing the current component as first argument. All further
332+
arguments are passed after that.
333+
The results are returned as a new :class:`XyzComponents` object.
334+
335+
"""
336+
return XyzComponents([func(i, *args, **kwargs) for i in self])

0 commit comments

Comments
 (0)