Skip to content

Commit ba7c84c

Browse files
committed
rm
1 parent 536f69a commit ba7c84c

File tree

3 files changed

+9
-66
lines changed

3 files changed

+9
-66
lines changed

fastcore/_nbdev.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@
164164
"spark_chars": "03_xtras.ipynb",
165165
"sparkline": "03_xtras.ipynb",
166166
"autostart": "03_xtras.ipynb",
167-
"time_events": "03_xtras.ipynb",
168167
"EventTimer": "03_xtras.ipynb",
169168
"stringfmt_names": "03_xtras.ipynb",
170169
"PartialFormatter": "03_xtras.ipynb",

fastcore/xtras.py

Lines changed: 3 additions & 10 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', 'untar_dir', 'repo_details', 'run',
5-
'open_file', 'save_pickle', 'load_pickle', 'truncstr', 'spark_chars', 'sparkline', 'autostart',
6-
'time_events', 'EventTimer', 'stringfmt_names', 'PartialFormatter', 'partial_format', 'utc2local',
7-
'local2utc', 'trace', 'round_multiple', 'modified_env', 'ContextManagers', 'str2bool', 'sort_by_run']
5+
'open_file', 'save_pickle', 'load_pickle', 'truncstr', 'spark_chars', 'sparkline', 'autostart', 'EventTimer',
6+
'stringfmt_names', 'PartialFormatter', 'partial_format', 'utc2local', 'local2utc', 'trace', 'round_multiple',
7+
'modified_env', 'ContextManagers', 'str2bool', 'sort_by_run']
88

99
# Cell
1010
from .imports import *
@@ -253,13 +253,6 @@ def f():
253253
return r
254254
return f
255255

256-
# Cell
257-
@autostart
258-
def time_events():
259-
"An event timer implemented as a coroutine"
260-
start,events = default_timer(),0
261-
while True: events += (yield events,events/(default_timer()-start)) or 0
262-
263256
# Cell
264257
class EventTimer:
265258
"An event timer with history of `store` items of time `span`"

nbs/03_xtras.ipynb

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@
618618
{
619619
"data": {
620620
"text/plain": [
621-
"['a', 'e', 'h', 'b', 'g', 'd', 'c', 'f']"
621+
"['a', 'f', 'b', 'g', 'd', 'e', 'h', 'c']"
622622
]
623623
},
624624
"execution_count": null,
@@ -1421,58 +1421,6 @@
14211421
" return f"
14221422
]
14231423
},
1424-
{
1425-
"cell_type": "code",
1426-
"execution_count": null,
1427-
"metadata": {},
1428-
"outputs": [],
1429-
"source": [
1430-
"#export\n",
1431-
"@autostart\n",
1432-
"def time_events():\n",
1433-
" \"An event timer implemented as a coroutine\"\n",
1434-
" start,events = default_timer(),0\n",
1435-
" while True: events += (yield events,events/(default_timer()-start)) or 0"
1436-
]
1437-
},
1438-
{
1439-
"cell_type": "markdown",
1440-
"metadata": {},
1441-
"source": [
1442-
"This is convenient for tracking the frequency of events. Call `send(n)` any time you want to add `n` events to the counter. Pass the object to `next()` to get a tuple of the number of events and the frequency/second."
1443-
]
1444-
},
1445-
{
1446-
"cell_type": "code",
1447-
"execution_count": null,
1448-
"metadata": {},
1449-
"outputs": [],
1450-
"source": [
1451-
"# Random wait function for testing `time_events`\n",
1452-
"def _randwait(): yield from (sleep(random.random()/200) for _ in range(100))"
1453-
]
1454-
},
1455-
{
1456-
"cell_type": "code",
1457-
"execution_count": null,
1458-
"metadata": {},
1459-
"outputs": [
1460-
{
1461-
"name": "stdout",
1462-
"output_type": "stream",
1463-
"text": [
1464-
"# Events: 100, Freq/sec: 396.51\n"
1465-
]
1466-
}
1467-
],
1468-
"source": [
1469-
"c = time_events() # Start timer\n",
1470-
"for o in _randwait(): c.send(1) # Send an event\n",
1471-
"events,freq = next(c) # Return counter values\n",
1472-
"c.close() # Close when done\n",
1473-
"print(f'# Events: {events}, Freq/sec: {freq:.02f}')"
1474-
]
1475-
},
14761424
{
14771425
"cell_type": "code",
14781426
"execution_count": null,
@@ -1544,12 +1492,15 @@
15441492
"name": "stdout",
15451493
"output_type": "stream",
15461494
"text": [
1547-
"Num Events: 5, Freq/sec: 646.7\n",
1548-
"Most recent: ▁▇▃▇▆ 259.5 450.4 362.1 441.0 427.9\n"
1495+
"Num Events: 1, Freq/sec: 225.7\n",
1496+
"Most recent: ▇▁▁▁▁ 346.2 331.6 334.4 332.2 332.9\n"
15491497
]
15501498
}
15511499
],
15521500
"source": [
1501+
"# Random wait function for testing\n",
1502+
"def _randwait(): yield from (sleep(random.random()/200) for _ in range(100))\n",
1503+
"\n",
15531504
"c = EventTimer(store=5, span=0.03)\n",
15541505
"for o in _randwait(): c.add(1)\n",
15551506
"print(f'Num Events: {c.events}, Freq/sec: {c.freq:.01f}')\n",

0 commit comments

Comments
 (0)