|
350 | 350 | " \"Reindexes collection `coll` with indices `idxs` and optional LRU cache of size `cache`\"\n", |
351 | 351 | " _default='coll'\n", |
352 | 352 | " def __init__(self, coll, idxs=None, cache=None, tfm=noop):\n", |
353 | | - " if idxs is None: idxs = L.range(coll) \n", |
| 353 | + " if idxs is None: idxs = L.range(coll)\n", |
354 | 354 | " store_attr()\n", |
355 | 355 | " if cache is not None: self._get = functools.lru_cache(maxsize=cache)(self._get)\n", |
356 | 356 | "\n", |
|
1401 | 1401 | "#export\n", |
1402 | 1402 | "def _sparkchar(x, mn, incr, empty_zero):\n", |
1403 | 1403 | " if x is None or (empty_zero and not x): return ' '\n", |
| 1404 | + " if incr == 0: return spark_chars[0]\n", |
1404 | 1405 | " res = int((x-mn)/incr-0.5)\n", |
1405 | 1406 | " return spark_chars[res]" |
1406 | 1407 | ] |
|
1415 | 1416 | "def sparkline(data, mn=None, mx=None, empty_zero=False):\n", |
1416 | 1417 | " \"Sparkline for `data`, with `None`s (and zero, if `empty_zero`) shown as empty column\"\n", |
1417 | 1418 | " valid = [o for o in data if o is not None]\n", |
| 1419 | + " if not valid: return ' '\n", |
1418 | 1420 | " mn,mx,n = ifnone(mn,min(valid)),ifnone(mx,max(valid)),len(spark_chars)\n", |
1419 | 1421 | " res = [_sparkchar(o,mn,(mx-mn)/n,empty_zero) for o in data]\n", |
1420 | 1422 | " return ''.join(res)" |
|
1479 | 1481 | " self._reset()\n", |
1480 | 1482 | " self.events +=n\n", |
1481 | 1483 | " self.last = default_timer()\n", |
1482 | | - " \n", |
| 1484 | + "\n", |
1483 | 1485 | " @property\n", |
1484 | 1486 | " def duration(self): return default_timer()-self.start\n", |
1485 | 1487 | " @property\n", |
|
1587 | 1589 | " def __init__(self):\n", |
1588 | 1590 | " self.missing = set()\n", |
1589 | 1591 | " super().__init__()\n", |
1590 | | - " \n", |
| 1592 | + "\n", |
1591 | 1593 | " def get_field(self, nm, args, kwargs):\n", |
1592 | 1594 | " try: return super().get_field(nm, args, kwargs)\n", |
1593 | 1595 | " except KeyError:\n", |
|
0 commit comments