Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/toolz/curried/__init__.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

50 statements  

1""" 

2Alternate namespace for toolz such that all functions are curried 

3 

4Currying provides implicit partial evaluation of all functions 

5 

6Example: 

7 

8 Get usually requires two arguments, an index and a collection 

9 >>> from toolz.curried import get 

10 >>> get(0, ('a', 'b')) 

11 'a' 

12 

13 When we use it in higher order functions we often want to pass a partially 

14 evaluated form 

15 >>> data = [(1, 2), (11, 22), (111, 222)] 

16 >>> list(map(lambda seq: get(0, seq), data)) 

17 [1, 11, 111] 

18 

19 The curried version allows simple expression of partial evaluation 

20 >>> list(map(get(0), data)) 

21 [1, 11, 111] 

22 

23See Also: 

24 toolz.functoolz.curry 

25""" 

26import toolz 

27from . import operator 

28from toolz import ( 

29 apply, 

30 comp, 

31 complement, 

32 compose, 

33 compose_left, 

34 concat, 

35 concatv, 

36 count, 

37 curry, 

38 diff, 

39 first, 

40 flip, 

41 frequencies, 

42 identity, 

43 interleave, 

44 isdistinct, 

45 isiterable, 

46 juxt, 

47 last, 

48 memoize, 

49 merge_sorted, 

50 peek, 

51 pipe, 

52 second, 

53 thread_first, 

54 thread_last, 

55) 

56from .exceptions import merge, merge_with 

57 

58accumulate = toolz.curry(toolz.accumulate) 

59assoc = toolz.curry(toolz.assoc) 

60assoc_in = toolz.curry(toolz.assoc_in) 

61cons = toolz.curry(toolz.cons) 

62countby = toolz.curry(toolz.countby) 

63dissoc = toolz.curry(toolz.dissoc) 

64do = toolz.curry(toolz.do) 

65drop = toolz.curry(toolz.drop) 

66excepts = toolz.curry(toolz.excepts) 

67filter = toolz.curry(toolz.filter) 

68get = toolz.curry(toolz.get) 

69get_in = toolz.curry(toolz.get_in) 

70groupby = toolz.curry(toolz.groupby) 

71interpose = toolz.curry(toolz.interpose) 

72itemfilter = toolz.curry(toolz.itemfilter) 

73itemmap = toolz.curry(toolz.itemmap) 

74iterate = toolz.curry(toolz.iterate) 

75join = toolz.curry(toolz.join) 

76keyfilter = toolz.curry(toolz.keyfilter) 

77keymap = toolz.curry(toolz.keymap) 

78map = toolz.curry(toolz.map) 

79mapcat = toolz.curry(toolz.mapcat) 

80nth = toolz.curry(toolz.nth) 

81partial = toolz.curry(toolz.partial) 

82partition = toolz.curry(toolz.partition) 

83partition_all = toolz.curry(toolz.partition_all) 

84partitionby = toolz.curry(toolz.partitionby) 

85peekn = toolz.curry(toolz.peekn) 

86pluck = toolz.curry(toolz.pluck) 

87random_sample = toolz.curry(toolz.random_sample) 

88reduce = toolz.curry(toolz.reduce) 

89reduceby = toolz.curry(toolz.reduceby) 

90remove = toolz.curry(toolz.remove) 

91sliding_window = toolz.curry(toolz.sliding_window) 

92sorted = toolz.curry(toolz.sorted) 

93tail = toolz.curry(toolz.tail) 

94take = toolz.curry(toolz.take) 

95take_nth = toolz.curry(toolz.take_nth) 

96topk = toolz.curry(toolz.topk) 

97unique = toolz.curry(toolz.unique) 

98update_in = toolz.curry(toolz.update_in) 

99valfilter = toolz.curry(toolz.valfilter) 

100valmap = toolz.curry(toolz.valmap) 

101 

102del exceptions 

103del toolz