|
11 | 11 | 'annotations', 'anno_ret', 'signature_ex', 'union2tuple', 'argnames', 'with_cast', 'store_attr', 'attrdict',
|
12 | 12 | 'properties', 'camel2words', 'camel2snake', 'snake2camel', 'class2attr', 'getcallable', 'getattrs',
|
13 | 13 | 'hasattrs', 'setattrs', 'try_attrs', 'GetAttrBase', 'GetAttr', 'delegate_attr', 'ShowPrint', 'Int', 'Str',
|
14 |
| - 'Float', 'partition', 'flatten', 'concat', 'strcat', 'detuplify', 'replicate', 'setify', 'merge', 'range_of', |
15 |
| - 'groupby', 'last_index', 'filter_dict', 'filter_keys', 'filter_values', 'cycle', 'zip_cycle', 'sorted_ex', |
16 |
| - 'not_', 'argwhere', 'filter_ex', 'renumerate', 'first', 'last', 'only', 'nested_attr', 'nested_setdefault', |
17 |
| - 'nested_callable', 'nested_idx', 'set_nested_idx', 'val2idx', 'uniqueify', 'loop_first_last', 'loop_first', |
18 |
| - 'loop_last', 'first_match', 'last_match', 'fastuple', 'bind', 'mapt', 'map_ex', 'compose', 'maps', |
19 |
| - 'partialler', 'instantiate', 'using_attr', 'copy_func', 'patch_to', 'patch', 'patch_property', 'compile_re', |
20 |
| - 'ImportEnum', 'StrEnum', 'str_enum', 'ValEnum', 'Stateful', 'NotStr', 'PrettyString', 'even_mults', |
21 |
| - 'num_cpus', 'add_props', 'str2bool', 'str2int', 'str2float', 'str2list', 'str2date', 'to_bool', 'to_int', |
22 |
| - 'to_float', 'to_list', 'to_date', 'typed', 'exec_new', 'exec_import', 'lt', 'gt', 'le', 'ge', 'eq', 'ne', |
23 |
| - 'add', 'sub', 'mul', 'truediv', 'is_', 'is_not', 'mod'] |
| 14 | + 'Float', 'partition', 'partition_dict', 'flatten', 'concat', 'strcat', 'detuplify', 'replicate', 'setify', |
| 15 | + 'merge', 'range_of', 'groupby', 'last_index', 'filter_dict', 'filter_keys', 'filter_values', 'cycle', |
| 16 | + 'zip_cycle', 'sorted_ex', 'not_', 'argwhere', 'filter_ex', 'renumerate', 'first', 'last', 'only', |
| 17 | + 'nested_attr', 'nested_setdefault', 'nested_callable', 'nested_idx', 'set_nested_idx', 'val2idx', |
| 18 | + 'uniqueify', 'loop_first_last', 'loop_first', 'loop_last', 'first_match', 'last_match', 'fastuple', 'bind', |
| 19 | + 'mapt', 'map_ex', 'compose', 'maps', 'partialler', 'instantiate', 'using_attr', 'copy_func', 'patch_to', |
| 20 | + 'patch', 'patch_property', 'compile_re', 'ImportEnum', 'StrEnum', 'str_enum', 'ValEnum', 'Stateful', |
| 21 | + 'NotStr', 'PrettyString', 'even_mults', 'num_cpus', 'add_props', 'str2bool', 'str2int', 'str2float', |
| 22 | + 'str2list', 'str2date', 'to_bool', 'to_int', 'to_float', 'to_list', 'to_date', 'typed', 'exec_new', |
| 23 | + 'exec_import', 'lt', 'gt', 'le', 'ge', 'eq', 'ne', 'add', 'sub', 'mul', 'truediv', 'is_', 'is_not', 'mod'] |
24 | 24 |
|
25 | 25 | # %% ../nbs/01_basics.ipynb
|
26 | 26 | from .imports import *
|
@@ -574,6 +574,13 @@ def partition(coll, f):
|
574 | 574 | ts,fs = typ(ts),typ(fs)
|
575 | 575 | return ts,fs
|
576 | 576 |
|
| 577 | +# %% ../nbs/01_basics.ipynb |
| 578 | +def partition_dict(d, f): |
| 579 | + "Partition a dict by a predicate that takes key/value params" |
| 580 | + ts,fs = {},{} |
| 581 | + for k,v in d.items(): (fs,ts)[f(k,v)][k] = v |
| 582 | + return ts,fs |
| 583 | + |
577 | 584 | # %% ../nbs/01_basics.ipynb
|
578 | 585 | def flatten(o):
|
579 | 586 | "Concatenate all collections and items as a generator"
|
|
0 commit comments