-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #255 from llllllllll/curried-operator
ENH: Adds curried.operator
- Loading branch information
Showing
4 changed files
with
76 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from __future__ import absolute_import | ||
|
||
import operator | ||
|
||
from toolz import curry | ||
|
||
|
||
# We use a blacklist instead of whitelist because: | ||
# 1. We have more things to include than exclude. | ||
# 2. This gives us access to things like matmul iff we are in Python >=3.5. | ||
no_curry = frozenset(( | ||
'abs', | ||
'index', | ||
'inv', | ||
'invert', | ||
'neg', | ||
'not_', | ||
'pos', | ||
'truth', | ||
)) | ||
|
||
locals().update( | ||
dict((name, curry(f) if name not in no_curry else f) | ||
for name, f in vars(operator).items() if callable(f)), | ||
) | ||
|
||
# Clean up the namespace. | ||
del curry | ||
del no_curry | ||
del operator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters