From 360f015ce869d084fd129ef9a91d1680bcff9d3c Mon Sep 17 00:00:00 2001 From: joncrall Date: Sat, 4 Nov 2023 17:03:34 -0400 Subject: [PATCH] Update usefulness --- README.rst | 183 ++++++++++++------------- dev/maintain/count_usage_freq.py | 7 +- dev/maintain/gen_api_for_docs.py | 2 +- docs/source/function_usefulness.rst | 198 ++++++++++++++-------------- 4 files changed, 199 insertions(+), 191 deletions(-) mode change 100644 => 100755 dev/maintain/gen_api_for_docs.py diff --git a/README.rst b/README.rst index 3e3e1e4c..494d58b9 100644 --- a/README.rst +++ b/README.rst @@ -128,8 +128,8 @@ Ubelt is small. Its top-level API is defined using roughly 40 lines: from ubelt.util_indexable import (IndexableWalker, indexable_allclose,) from ubelt.util_memoize import (memoize, memoize_method, memoize_property,) from ubelt.util_mixins import (NiceRepr,) - from ubelt.util_path import (Path, TempDir, augpath, ensuredir, expandpath, - shrinkuser, userhome,) + from ubelt.util_path import (ChDir, Path, TempDir, augpath, ensuredir, + expandpath, shrinkuser, userhome,) from ubelt.util_platform import (DARWIN, LINUX, POSIX, WIN32, find_exe, find_path, platform_cache_dir, platform_config_dir, platform_data_dir,) @@ -141,6 +141,7 @@ Ubelt is small. Its top-level API is defined using roughly 40 lines: from ubelt.progiter import (ProgIter,) + Installation: ============= @@ -187,102 +188,105 @@ project. Note: this measure is biased towards older functions. ================================================================================================================================================ ================ Function name Usefulness ================================================================================================================================================ ================ -`ubelt.urepr `__ 2893 -`ubelt.Path `__ 992 -`ubelt.ProgIter `__ 544 -`ubelt.paragraph `__ 482 -`ubelt.take `__ 387 -`ubelt.codeblock `__ 358 -`ubelt.expandpath `__ 331 -`ubelt.cmd `__ 302 -`ubelt.udict `__ 271 -`ubelt.ensuredir `__ 256 -`ubelt.odict `__ 253 -`ubelt.iterable `__ 252 -`ubelt.ddict `__ 238 -`ubelt.NiceRepr `__ 221 -`ubelt.NoParam `__ 216 -`ubelt.map_vals `__ 215 -`ubelt.flatten `__ 214 -`ubelt.dzip `__ 200 -`ubelt.oset `__ 198 -`ubelt.peek `__ 196 -`ubelt.argflag `__ 177 -`ubelt.group_items `__ 171 -`ubelt.hash_data `__ 165 -`ubelt.grabdata `__ 131 -`ubelt.argval `__ 125 -`ubelt.Timer `__ 120 -`ubelt.dict_isect `__ 113 -`ubelt.dict_hist `__ 111 -`ubelt.augpath `__ 106 -`ubelt.identity `__ 106 -`ubelt.ensure_app_cache_dir `__ 105 -`ubelt.allsame `__ 102 -`ubelt.memoize `__ 99 -`ubelt.color_text `__ 98 -`ubelt.dict_diff `__ 95 -`ubelt.delete `__ 89 -`ubelt.hzcat `__ 88 -`ubelt.schedule_deprecation `__ 87 -`ubelt.named_product `__ 85 -`ubelt.compress `__ 85 -`ubelt.IndexableWalker `__ 74 -`ubelt.indent `__ 68 -`ubelt.JobPool `__ 67 -`ubelt.unique `__ 63 -`ubelt.dict_union `__ 57 -`ubelt.map_keys `__ 49 -`ubelt.invert_dict `__ 48 -`ubelt.iter_window `__ 46 -`ubelt.timestamp `__ 46 -`ubelt.argsort `__ 44 -`ubelt.Cacher `__ 43 -`ubelt.find_exe `__ 41 -`ubelt.symlink `__ 41 -`ubelt.dict_subset `__ 41 -`ubelt.writeto `__ 40 -`ubelt.find_duplicates `__ 39 -`ubelt.chunks `__ 38 -`ubelt.hash_file `__ 37 -`ubelt.modname_to_modpath `__ 37 -`ubelt.ensure_unicode `__ 33 -`ubelt.memoize_property `__ 33 -`ubelt.highlight_code `__ 33 -`ubelt.sorted_vals `__ 32 -`ubelt.CacheStamp `__ 30 -`ubelt.WIN32 `__ 28 -`ubelt.import_module_from_name `__ 27 -`ubelt.argmax `__ 27 +`ubelt.urepr `__ 4327 +`ubelt.Path `__ 2125 +`ubelt.paragraph `__ 1349 +`ubelt.ProgIter `__ 747 +`ubelt.cmd `__ 657 +`ubelt.codeblock `__ 611 +`ubelt.udict `__ 603 +`ubelt.expandpath `__ 508 +`ubelt.take `__ 462 +`ubelt.oset `__ 342 +`ubelt.ddict `__ 341 +`ubelt.iterable `__ 313 +`ubelt.flatten `__ 303 +`ubelt.group_items `__ 287 +`ubelt.NiceRepr `__ 270 +`ubelt.ensuredir `__ 267 +`ubelt.map_vals `__ 265 +`ubelt.peek `__ 262 +`ubelt.NoParam `__ 248 +`ubelt.dzip `__ 239 +`ubelt.odict `__ 236 +`ubelt.hash_data `__ 200 +`ubelt.argflag `__ 184 +`ubelt.grabdata `__ 161 +`ubelt.dict_hist `__ 156 +`ubelt.identity `__ 156 +`ubelt.dict_isect `__ 152 +`ubelt.Timer `__ 145 +`ubelt.memoize `__ 142 +`ubelt.argval `__ 134 +`ubelt.allsame `__ 133 +`ubelt.color_text `__ 129 +`ubelt.schedule_deprecation `__ 123 +`ubelt.augpath `__ 120 +`ubelt.dict_diff `__ 117 +`ubelt.IndexableWalker `__ 116 +`ubelt.compress `__ 116 +`ubelt.JobPool `__ 107 +`ubelt.named_product `__ 104 +`ubelt.hzcat `__ 90 +`ubelt.delete `__ 88 +`ubelt.unique `__ 84 +`ubelt.WIN32 `__ 78 +`ubelt.dict_union `__ 76 +`ubelt.symlink `__ 76 +`ubelt.indent `__ 69 +`ubelt.ensure_app_cache_dir `__ 67 +`ubelt.iter_window `__ 62 +`ubelt.invert_dict `__ 58 +`ubelt.memoize_property `__ 57 +`ubelt.import_module_from_name `__ 56 +`ubelt.argsort `__ 55 +`ubelt.timestamp `__ 54 +`ubelt.modname_to_modpath `__ 53 +`ubelt.find_duplicates `__ 53 +`ubelt.hash_file `__ 51 +`ubelt.find_exe `__ 50 +`ubelt.map_keys `__ 50 +`ubelt.dict_subset `__ 50 +`ubelt.Cacher `__ 49 +`ubelt.chunks `__ 47 +`ubelt.sorted_vals `__ 40 +`ubelt.CacheStamp `__ 38 +`ubelt.highlight_code `__ 37 +`ubelt.argmax `__ 36 +`ubelt.writeto `__ 36 +`ubelt.ensure_unicode `__ 32 +`ubelt.sorted_keys `__ 30 +`ubelt.memoize_method `__ 29 +`ubelt.compatible `__ 24 +`ubelt.import_module_from_path `__ 24 +`ubelt.Executor `__ 23 `ubelt.readfrom `__ 23 -`ubelt.import_module_from_path `__ 22 -`ubelt.compatible `__ 17 +`ubelt.modpath_to_modname `__ 17 +`ubelt.AutoDict `__ 17 `ubelt.touch `__ 17 -`ubelt.Executor `__ 16 -`ubelt.memoize_method `__ 16 -`ubelt.sorted_keys `__ 14 -`ubelt.AutoDict `__ 11 +`ubelt.inject_method `__ 14 +`ubelt.timeparse `__ 13 +`ubelt.ChDir `__ 11 `ubelt.shrinkuser `__ 11 -`ubelt.inject_method `__ 10 +`ubelt.argmin `__ 10 `ubelt.varied_values `__ 9 `ubelt.split_modpath `__ 8 -`ubelt.modpath_to_modname `__ 8 -`ubelt.get_app_cache_dir `__ 8 -`ubelt.zopen `__ 7 -`ubelt.LINUX `__ 7 +`ubelt.LINUX `__ 8 +`ubelt.download `__ 7 +`ubelt.NO_COLOR `__ 7 +`ubelt.OrderedSet `__ 6 +`ubelt.zopen `__ 6 `ubelt.CaptureStdout `__ 6 -`ubelt.download `__ 5 -`ubelt.timeparse `__ 5 `ubelt.DARWIN `__ 5 -`ubelt.argmin `__ 5 +`ubelt.boolmask `__ 4 `ubelt.find_path `__ 4 -`ubelt.indexable_allclose `__ 4 -`ubelt.boolmask `__ 3 -`ubelt.map_values `__ 2 +`ubelt.get_app_cache_dir `__ 4 +`ubelt.indexable_allclose `__ 3 +`ubelt.UDict `__ 3 +`ubelt.SetDict `__ 2 `ubelt.AutoOrderedDict `__ 2 `ubelt.argunique `__ 2 -`ubelt.NO_COLOR `__ 2 -`ubelt.UDict `__ 1 +`ubelt.map_values `__ 1 `ubelt.unique_flags `__ 1 `ubelt.userhome `__ 0 `ubelt.split_archive `__ 0 @@ -297,15 +301,14 @@ project. Note: this measure is biased towards older functions. `ubelt.ensure_app_config_dir `__ 0 `ubelt.TempDir `__ 0 `ubelt.TeeStringIO `__ 0 -`ubelt.SetDict `__ 0 `ubelt.ReprExtensions `__ 0 `ubelt.POSIX `__ 0 -`ubelt.OrderedSet `__ 0 `ubelt.DownloadManager `__ 0 `ubelt.CaptureStream `__ 0 ================================================================================================================================================ ================ + Examples ======== diff --git a/dev/maintain/count_usage_freq.py b/dev/maintain/count_usage_freq.py index 0ead0636..6c3c76df 100755 --- a/dev/maintain/count_usage_freq.py +++ b/dev/maintain/count_usage_freq.py @@ -1,4 +1,4 @@ - +#!/usr/bin/env python import scriptconfig as scfg @@ -19,11 +19,14 @@ def count_ubelt_usage(): import glob from os.path import join names = [ - 'xdoctest', 'netharn', 'xdev', 'xinspect', 'ndsampler', + 'xdoctest', 'netharn', 'xdev', 'xinspect', 'xcookie', 'ndsampler', 'kwarray', 'kwimage', 'kwplot', 'kwcoco', 'scriptconfig', 'vimtk', 'mkinit', 'futures_actors', 'graphid', + 'kwutil', 'git_well', 'line_profiler', 'delayed_image', 'simple_dvc', + 'pypogo', + 'ibeis', 'plottool_ibeis', 'guitool_ibeis', 'utool', 'dtool_ibeis', 'vtool_ibeis', 'hesaff', 'torch_liberator', 'liberator', ] + config['extra_modnames'] diff --git a/dev/maintain/gen_api_for_docs.py b/dev/maintain/gen_api_for_docs.py old mode 100644 new mode 100755 index 5dd382cc..8714deb7 --- a/dev/maintain/gen_api_for_docs.py +++ b/dev/maintain/gen_api_for_docs.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python def count_ubelt_usage(): """ @@ -12,7 +13,6 @@ def count_ubelt_usage(): # Reorgnaize data to contain more information rows = [] unseen = usage.copy() - import ubelt as ub for attrname in ub.__all__: member = getattr(ub, attrname) submembers = getattr(member, '__all__', None) diff --git a/docs/source/function_usefulness.rst b/docs/source/function_usefulness.rst index 58cfb880..79762a14 100644 --- a/docs/source/function_usefulness.rst +++ b/docs/source/function_usefulness.rst @@ -1,7 +1,7 @@ The API by usefulness ===================== -.. to help generate python ~/code/ubelt/dev/gen_api_for_docs.py --extra_modname=bioharn,watch --remove_zeros=False +.. to help generate python ~/code/ubelt/dev/maintain/gen_api_for_docs.py --extra_modname=bioharn,watch --remove_zeros=False Perhaps the most useful way to learn this API is to sort by "usefulness". I measure usefulness as the number of times I've used a particular function in @@ -11,102 +11,105 @@ my own code (excluding ubelt itself). ================================================================================= ================ Function name Usefulness ================================================================================= ================ -:func:`ubelt.urepr` 2893 -:func:`ubelt.Path` 992 -:func:`ubelt.ProgIter` 544 -:func:`ubelt.paragraph` 482 -:func:`ubelt.take` 387 -:func:`ubelt.codeblock` 358 -:func:`ubelt.expandpath` 331 -:func:`ubelt.cmd` 302 -:func:`ubelt.udict` 271 -:func:`ubelt.ensuredir` 256 -:func:`ubelt.odict` 253 -:func:`ubelt.iterable` 252 -:func:`ubelt.ddict` 238 -:func:`ubelt.NiceRepr` 221 -:func:`ubelt.NoParam` 216 -:func:`ubelt.map_vals` 215 -:func:`ubelt.flatten` 214 -:func:`ubelt.dzip` 200 -:func:`ubelt.oset` 198 -:func:`ubelt.peek` 196 -:func:`ubelt.argflag` 177 -:func:`ubelt.group_items` 171 -:func:`ubelt.hash_data` 165 -:func:`ubelt.grabdata` 131 -:func:`ubelt.argval` 125 -:func:`ubelt.Timer` 120 -:func:`ubelt.dict_isect` 113 -:func:`ubelt.dict_hist` 111 -:func:`ubelt.augpath` 106 -:func:`ubelt.identity` 106 -:func:`ubelt.ensure_app_cache_dir` 105 -:func:`ubelt.allsame` 102 -:func:`ubelt.memoize` 99 -:func:`ubelt.color_text` 98 -:func:`ubelt.dict_diff` 95 -:func:`ubelt.delete` 89 -:func:`ubelt.hzcat` 88 -:func:`ubelt.schedule_deprecation` 87 -:func:`ubelt.named_product` 85 -:func:`ubelt.compress` 85 -:func:`ubelt.IndexableWalker` 74 -:func:`ubelt.indent` 68 -:func:`ubelt.JobPool` 67 -:func:`ubelt.unique` 63 -:func:`ubelt.dict_union` 57 -:func:`ubelt.map_keys` 49 -:func:`ubelt.invert_dict` 48 -:func:`ubelt.iter_window` 46 -:func:`ubelt.timestamp` 46 -:func:`ubelt.argsort` 44 -:func:`ubelt.Cacher` 43 -:func:`ubelt.find_exe` 41 -:func:`ubelt.symlink` 41 -:func:`ubelt.dict_subset` 41 -:func:`ubelt.writeto` 40 -:func:`ubelt.find_duplicates` 39 -:func:`ubelt.chunks` 38 -:func:`ubelt.hash_file` 37 -:func:`ubelt.modname_to_modpath` 37 -:func:`ubelt.ensure_unicode` 33 -:func:`ubelt.memoize_property` 33 -:func:`ubelt.highlight_code` 33 -:func:`ubelt.sorted_vals` 32 -:func:`ubelt.CacheStamp` 30 -:func:`ubelt.WIN32` 28 -:func:`ubelt.import_module_from_name` 27 -:func:`ubelt.argmax` 27 +:func:`ubelt.urepr` 4327 +:func:`ubelt.Path` 2125 +:func:`ubelt.paragraph` 1349 +:func:`ubelt.ProgIter` 747 +:func:`ubelt.cmd` 657 +:func:`ubelt.codeblock` 611 +:func:`ubelt.udict` 603 +:func:`ubelt.expandpath` 508 +:func:`ubelt.take` 462 +:func:`ubelt.oset` 342 +:func:`ubelt.ddict` 341 +:func:`ubelt.iterable` 313 +:func:`ubelt.flatten` 303 +:func:`ubelt.group_items` 287 +:func:`ubelt.NiceRepr` 270 +:func:`ubelt.ensuredir` 267 +:func:`ubelt.map_vals` 265 +:func:`ubelt.peek` 262 +:func:`ubelt.NoParam` 248 +:func:`ubelt.dzip` 239 +:func:`ubelt.odict` 236 +:func:`ubelt.hash_data` 200 +:func:`ubelt.argflag` 184 +:func:`ubelt.grabdata` 161 +:func:`ubelt.dict_hist` 156 +:func:`ubelt.identity` 156 +:func:`ubelt.dict_isect` 152 +:func:`ubelt.Timer` 145 +:func:`ubelt.memoize` 142 +:func:`ubelt.argval` 134 +:func:`ubelt.allsame` 133 +:func:`ubelt.color_text` 129 +:func:`ubelt.schedule_deprecation` 123 +:func:`ubelt.augpath` 120 +:func:`ubelt.dict_diff` 117 +:func:`ubelt.IndexableWalker` 116 +:func:`ubelt.compress` 116 +:func:`ubelt.JobPool` 107 +:func:`ubelt.named_product` 104 +:func:`ubelt.hzcat` 90 +:func:`ubelt.delete` 88 +:func:`ubelt.unique` 84 +:func:`ubelt.WIN32` 78 +:func:`ubelt.dict_union` 76 +:func:`ubelt.symlink` 76 +:func:`ubelt.indent` 69 +:func:`ubelt.ensure_app_cache_dir` 67 +:func:`ubelt.iter_window` 62 +:func:`ubelt.invert_dict` 58 +:func:`ubelt.memoize_property` 57 +:func:`ubelt.import_module_from_name` 56 +:func:`ubelt.argsort` 55 +:func:`ubelt.timestamp` 54 +:func:`ubelt.modname_to_modpath` 53 +:func:`ubelt.find_duplicates` 53 +:func:`ubelt.hash_file` 51 +:func:`ubelt.find_exe` 50 +:func:`ubelt.map_keys` 50 +:func:`ubelt.dict_subset` 50 +:func:`ubelt.Cacher` 49 +:func:`ubelt.chunks` 47 +:func:`ubelt.sorted_vals` 40 +:func:`ubelt.CacheStamp` 38 +:func:`ubelt.highlight_code` 37 +:func:`ubelt.argmax` 36 +:func:`ubelt.writeto` 36 +:func:`ubelt.ensure_unicode` 32 +:func:`ubelt.sorted_keys` 30 +:func:`ubelt.memoize_method` 29 +:func:`ubelt.compatible` 24 +:func:`ubelt.import_module_from_path` 24 +:func:`ubelt.Executor` 23 :func:`ubelt.readfrom` 23 -:func:`ubelt.import_module_from_path` 22 -:func:`ubelt.compatible` 17 +:func:`ubelt.modpath_to_modname` 17 +:func:`ubelt.AutoDict` 17 :func:`ubelt.touch` 17 -:func:`ubelt.Executor` 16 -:func:`ubelt.memoize_method` 16 -:func:`ubelt.sorted_keys` 14 -:func:`ubelt.AutoDict` 11 +:func:`ubelt.inject_method` 14 +:func:`ubelt.timeparse` 13 +:func:`ubelt.ChDir` 11 :func:`ubelt.shrinkuser` 11 -:func:`ubelt.inject_method` 10 +:func:`ubelt.argmin` 10 :func:`ubelt.varied_values` 9 :func:`ubelt.split_modpath` 8 -:func:`ubelt.modpath_to_modname` 8 -:func:`ubelt.get_app_cache_dir` 8 -:func:`ubelt.zopen` 7 -:func:`ubelt.LINUX` 7 +:func:`ubelt.LINUX` 8 +:func:`ubelt.download` 7 +:func:`ubelt.NO_COLOR` 7 +:func:`ubelt.OrderedSet` 6 +:func:`ubelt.zopen` 6 :func:`ubelt.CaptureStdout` 6 -:func:`ubelt.download` 5 -:func:`ubelt.timeparse` 5 :func:`ubelt.DARWIN` 5 -:func:`ubelt.argmin` 5 +:func:`ubelt.boolmask` 4 :func:`ubelt.find_path` 4 -:func:`ubelt.indexable_allclose` 4 -:func:`ubelt.boolmask` 3 -:func:`ubelt.map_values` 2 +:func:`ubelt.get_app_cache_dir` 4 +:func:`ubelt.indexable_allclose` 3 +:func:`ubelt.UDict` 3 +:func:`ubelt.SetDict` 2 :func:`ubelt.AutoOrderedDict` 2 :func:`ubelt.argunique` 2 -:func:`ubelt.NO_COLOR` 2 -:func:`ubelt.UDict` 1 +:func:`ubelt.map_values` 1 :func:`ubelt.unique_flags` 1 :func:`ubelt.userhome` 0 :func:`ubelt.split_archive` 0 @@ -121,10 +124,8 @@ my own code (excluding ubelt itself). :func:`ubelt.ensure_app_config_dir` 0 :func:`ubelt.TempDir` 0 :func:`ubelt.TeeStringIO` 0 -:func:`ubelt.SetDict` 0 :func:`ubelt.ReprExtensions` 0 :func:`ubelt.POSIX` 0 -:func:`ubelt.OrderedSet` 0 :func:`ubelt.DownloadManager` 0 :func:`ubelt.CaptureStream` 0 ================================================================================= ================ @@ -132,16 +133,16 @@ my own code (excluding ubelt itself). .. code:: python usage stats = { - 'mean': 109.39655, - 'std': 292.5527, + 'mean': 164.10257, + 'std': 467.12064, 'min': 0.0, - 'max': 2893.0, - 'q_0.25': 5.0, - 'q_0.50': 37.0, - 'q_0.75': 106.0, - 'med': 37.0, - 'sum': 12690, - 'shape': (116,), + 'max': 4327.0, + 'q_0.25': 6.0, + 'q_0.50': 50.0, + 'q_0.75': 134.0, + 'med': 50.0, + 'sum': 19200, + 'shape': (117,), } :mod:`ubelt.orderedset` @@ -301,6 +302,7 @@ my own code (excluding ubelt itself). :func:`` :func:`` :func:`` +:func:`` :mod:`ubelt.util_platform` --------------------------