Skip to content

Commit e389b35

Browse files
committed
add ceil
1 parent 80fef4a commit e389b35

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

fastcore/_nbdev.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@
165165
"Path.__repr__": "03_xtras.ipynb",
166166
"truncstr": "03_xtras.ipynb",
167167
"spark_chars": "03_xtras.ipynb",
168-
"ceil": "03_xtras.ipynb",
169168
"sparkline": "03_xtras.ipynb",
170169
"autostart": "03_xtras.ipynb",
171170
"EventTimer": "03_xtras.ipynb",

fastcore/xtras.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
__all__ = ['dict2obj', 'obj2dict', 'repr_dict', 'is_listy', 'shufflish', 'mapped', 'IterLen', 'ReindexCollection',
44
'maybe_open', 'image_size', 'bunzip', 'join_path_file', 'loads', 'loads_multi', 'untar_dir', 'repo_details',
5-
'run', 'open_file', 'save_pickle', 'load_pickle', 'truncstr', 'spark_chars', 'ceil', 'sparkline',
6-
'autostart', 'EventTimer', 'stringfmt_names', 'PartialFormatter', 'partial_format', 'utc2local', 'local2utc',
7-
'trace', 'round_multiple', 'modified_env', 'ContextManagers', 'str2bool', 'sort_by_run']
5+
'run', 'open_file', 'save_pickle', 'load_pickle', 'truncstr', 'spark_chars', 'sparkline', 'autostart',
6+
'EventTimer', 'stringfmt_names', 'PartialFormatter', 'partial_format', 'utc2local', 'local2utc', 'trace',
7+
'round_multiple', 'modified_env', 'ContextManagers', 'str2bool', 'sort_by_run']
88

99
# Cell
1010
from .imports import *
@@ -242,12 +242,12 @@ def truncstr(s:str, maxlen:int, suf:str='…', space='')->str:
242242
spark_chars = '▁▂▃▅▆▇'
243243

244244
# Cell
245-
def ceil(x, lim=None): return x if (not lim or x <= lim) else lim
245+
def _ceil(x, lim=None): return x if (not lim or x <= lim) else lim
246246

247247
def _sparkchar(x, mn, mx, incr, empty_zero):
248248
if x is None or (empty_zero and not x): return ' '
249249
if incr == 0: return spark_chars[0]
250-
res = int((ceil(x,mx)-mn)/incr-0.5)
250+
res = int((_ceil(x,mx)-mn)/incr-0.5)
251251
return spark_chars[res]
252252

253253
# Cell

nbs/03_xtras.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@
618618
{
619619
"data": {
620620
"text/plain": [
621-
"['c', 'g', 'a', 'e', 'b', 'f', 'd', 'h']"
621+
"['g', 'e', 'b', 'd', 'a', 'f', 'h', 'c']"
622622
]
623623
},
624624
"execution_count": null,
@@ -1400,12 +1400,12 @@
14001400
"outputs": [],
14011401
"source": [
14021402
"#export\n",
1403-
"def ceil(x, lim=None): return x if (not lim or x <= lim) else lim\n",
1403+
"def _ceil(x, lim=None): return x if (not lim or x <= lim) else lim\n",
14041404
"\n",
14051405
"def _sparkchar(x, mn, mx, incr, empty_zero):\n",
14061406
" if x is None or (empty_zero and not x): return ' '\n",
14071407
" if incr == 0: return spark_chars[0]\n",
1408-
" res = int((ceil(x,mx)-mn)/incr-0.5)\n",
1408+
" res = int((_ceil(x,mx)-mn)/incr-0.5)\n",
14091409
" return spark_chars[res]"
14101410
]
14111411
},
@@ -1560,8 +1560,8 @@
15601560
"name": "stdout",
15611561
"output_type": "stream",
15621562
"text": [
1563-
"Num Events: 11, Freq/sec: 394.6\n",
1564-
"Most recent: ▇▁▃▁▆ 377.7 299.7 338.0 289.4 361.8\n"
1563+
"Num Events: 7, Freq/sec: 346.2\n",
1564+
"Most recent: ▃▇▆▁▆ 320.1 427.2 389.6 208.7 401.4\n"
15651565
]
15661566
}
15671567
],

0 commit comments

Comments
 (0)