|
3119 | 3119 | "text/markdown": [ |
3120 | 3120 | "---\n", |
3121 | 3121 | "\n", |
3122 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L525){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 3122 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L542){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
3123 | 3123 | "\n", |
3124 | 3124 | "#### GetAttr\n", |
3125 | 3125 | "\n", |
|
3128 | 3128 | "*Inherit from this to have all attr accesses in `self._xtra` passed down to `self.default`*" |
3129 | 3129 | ], |
3130 | 3130 | "text/plain": [ |
3131 | | - "---\n", |
3132 | | - "\n", |
3133 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L525){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
3134 | | - "\n", |
3135 | | - "#### GetAttr\n", |
3136 | | - "\n", |
3137 | 3131 | "> GetAttr ()\n", |
3138 | 3132 | "\n", |
3139 | 3133 | "*Inherit from this to have all attr accesses in `self._xtra` passed down to `self.default`*" |
|
5054 | 5048 | "text/markdown": [ |
5055 | 5049 | "---\n", |
5056 | 5050 | "\n", |
5057 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L861){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 5051 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L878){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
5058 | 5052 | "\n", |
5059 | 5053 | "#### fastuple\n", |
5060 | 5054 | "\n", |
|
5063 | 5057 | "*A `tuple` with elementwise ops and more friendly __init__ behavior*" |
5064 | 5058 | ], |
5065 | 5059 | "text/plain": [ |
5066 | | - "---\n", |
5067 | | - "\n", |
5068 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L861){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
5069 | | - "\n", |
5070 | | - "#### fastuple\n", |
5071 | | - "\n", |
5072 | 5060 | "> fastuple (x=None, *rest)\n", |
5073 | 5061 | "\n", |
5074 | 5062 | "*A `tuple` with elementwise ops and more friendly __init__ behavior*" |
|
5144 | 5132 | "text/markdown": [ |
5145 | 5133 | "---\n", |
5146 | 5134 | "\n", |
5147 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L880){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 5135 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L897){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
5148 | 5136 | "\n", |
5149 | 5137 | "##### fastuple.add\n", |
5150 | 5138 | "\n", |
|
5153 | 5141 | "*`+` is already defined in `tuple` for concat, so use `add` instead*" |
5154 | 5142 | ], |
5155 | 5143 | "text/plain": [ |
5156 | | - "---\n", |
5157 | | - "\n", |
5158 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L880){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
5159 | | - "\n", |
5160 | | - "##### fastuple.add\n", |
5161 | | - "\n", |
5162 | 5144 | "> fastuple.add (*args)\n", |
5163 | 5145 | "\n", |
5164 | 5146 | "*`+` is already defined in `tuple` for concat, so use `add` instead*" |
|
5196 | 5178 | "text/markdown": [ |
5197 | 5179 | "---\n", |
5198 | 5180 | "\n", |
5199 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L876){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 5181 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L893){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
5200 | 5182 | "\n", |
5201 | 5183 | "##### fastuple.mul\n", |
5202 | 5184 | "\n", |
|
5205 | 5187 | "*`*` is already defined in `tuple` for replicating, so use `mul` instead*" |
5206 | 5188 | ], |
5207 | 5189 | "text/plain": [ |
5208 | | - "---\n", |
5209 | | - "\n", |
5210 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L876){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
5211 | | - "\n", |
5212 | | - "##### fastuple.mul\n", |
5213 | | - "\n", |
5214 | 5190 | "> fastuple.mul (*args)\n", |
5215 | 5191 | "\n", |
5216 | 5192 | "*`*` is already defined in `tuple` for replicating, so use `mul` instead*" |
|
5369 | 5345 | "text/markdown": [ |
5370 | 5346 | "---\n", |
5371 | 5347 | "\n", |
5372 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L907){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 5348 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L924){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
5373 | 5349 | "\n", |
5374 | 5350 | "### bind\n", |
5375 | 5351 | "\n", |
|
5378 | 5354 | "*Same as `partial`, except you can use `arg0` `arg1` etc param placeholders*" |
5379 | 5355 | ], |
5380 | 5356 | "text/plain": [ |
5381 | | - "---\n", |
5382 | | - "\n", |
5383 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L907){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
5384 | | - "\n", |
5385 | | - "### bind\n", |
5386 | | - "\n", |
5387 | 5357 | "> bind (func, *pargs, **pkwargs)\n", |
5388 | 5358 | "\n", |
5389 | 5359 | "*Same as `partial`, except you can use `arg0` `arg1` etc param placeholders*" |
|
6478 | 6448 | "text/markdown": [ |
6479 | 6449 | "---\n", |
6480 | 6450 | "\n", |
6481 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L1080){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 6451 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L1097){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
6482 | 6452 | "\n", |
6483 | 6453 | "#### ImportEnum\n", |
6484 | 6454 | "\n", |
6485 | | - "> ImportEnum (value, names=None, module=None, qualname=None, type=None,\n", |
| 6455 | + "> ImportEnum (new_class_name, names, module=None, qualname=None, type=None,\n", |
6486 | 6456 | "> start=1, boundary=None)\n", |
6487 | 6457 | "\n", |
6488 | 6458 | "*An `Enum` that can have its values imported*" |
6489 | 6459 | ], |
6490 | 6460 | "text/plain": [ |
6491 | | - "---\n", |
6492 | | - "\n", |
6493 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L1080){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
6494 | | - "\n", |
6495 | | - "#### ImportEnum\n", |
6496 | | - "\n", |
6497 | | - "> ImportEnum (value, names=None, module=None, qualname=None, type=None,\n", |
| 6461 | + "> ImportEnum (new_class_name, names, module=None, qualname=None, type=None,\n", |
6498 | 6462 | "> start=1, boundary=None)\n", |
6499 | 6463 | "\n", |
6500 | 6464 | "*An `Enum` that can have its values imported*" |
|
6546 | 6510 | "text/markdown": [ |
6547 | 6511 | "---\n", |
6548 | 6512 | "\n", |
6549 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L1088){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 6513 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L1105){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
6550 | 6514 | "\n", |
6551 | 6515 | "#### StrEnum\n", |
6552 | 6516 | "\n", |
6553 | | - "> StrEnum (value, names=None, module=None, qualname=None, type=None,\n", |
| 6517 | + "> StrEnum (new_class_name, names, module=None, qualname=None, type=None,\n", |
6554 | 6518 | "> start=1, boundary=None)\n", |
6555 | 6519 | "\n", |
6556 | 6520 | "*An `ImportEnum` that behaves like a `str`*" |
6557 | 6521 | ], |
6558 | 6522 | "text/plain": [ |
6559 | | - "---\n", |
6560 | | - "\n", |
6561 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L1088){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
6562 | | - "\n", |
6563 | | - "#### StrEnum\n", |
6564 | | - "\n", |
6565 | | - "> StrEnum (value, names=None, module=None, qualname=None, type=None,\n", |
| 6523 | + "> StrEnum (new_class_name, names, module=None, qualname=None, type=None,\n", |
6566 | 6524 | "> start=1, boundary=None)\n", |
6567 | 6525 | "\n", |
6568 | 6526 | "*An `ImportEnum` that behaves like a `str`*" |
|
6614 | 6572 | "text/markdown": [ |
6615 | 6573 | "---\n", |
6616 | 6574 | "\n", |
6617 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L1098){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 6575 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L1115){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
6618 | 6576 | "\n", |
6619 | 6577 | "#### ValEnum\n", |
6620 | 6578 | "\n", |
6621 | | - "> ValEnum (value, names=None, module=None, qualname=None, type=None,\n", |
| 6579 | + "> ValEnum (new_class_name, names, module=None, qualname=None, type=None,\n", |
6622 | 6580 | "> start=1, boundary=None)\n", |
6623 | 6581 | "\n", |
6624 | 6582 | "*An `ImportEnum` that stringifies using values*" |
6625 | 6583 | ], |
6626 | 6584 | "text/plain": [ |
6627 | | - "---\n", |
6628 | | - "\n", |
6629 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L1098){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
6630 | | - "\n", |
6631 | | - "#### ValEnum\n", |
6632 | | - "\n", |
6633 | | - "> ValEnum (value, names=None, module=None, qualname=None, type=None,\n", |
| 6585 | + "> ValEnum (new_class_name, names, module=None, qualname=None, type=None,\n", |
6634 | 6586 | "> start=1, boundary=None)\n", |
6635 | 6587 | "\n", |
6636 | 6588 | "*An `ImportEnum` that stringifies using values*" |
|
6706 | 6658 | "text/markdown": [ |
6707 | 6659 | "---\n", |
6708 | 6660 | "\n", |
6709 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L1103){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 6661 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L1120){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
6710 | 6662 | "\n", |
6711 | 6663 | "#### Stateful\n", |
6712 | 6664 | "\n", |
|
6715 | 6667 | "*A base class/mixin for objects that should not serialize all their state*" |
6716 | 6668 | ], |
6717 | 6669 | "text/plain": [ |
6718 | | - "---\n", |
6719 | | - "\n", |
6720 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/basics.py#L1103){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
6721 | | - "\n", |
6722 | | - "#### Stateful\n", |
6723 | | - "\n", |
6724 | 6670 | "> Stateful (*args, **kwargs)\n", |
6725 | 6671 | "\n", |
6726 | 6672 | "*A base class/mixin for objects that should not serialize all their state*" |
|
6816 | 6762 | { |
6817 | 6763 | "cell_type": "code", |
6818 | 6764 | "execution_count": null, |
6819 | | - "id": "8b4b2755", |
| 6765 | + "id": "5094ae23", |
6820 | 6766 | "metadata": {}, |
6821 | 6767 | "outputs": [], |
6822 | 6768 | "source": [ |
|
6835 | 6781 | " def __hash__(self): return hash(self.s)\n", |
6836 | 6782 | " def __bool__(self): return bool(self.s)\n", |
6837 | 6783 | " def __contains__(self, b): return b in self.s\n", |
6838 | | - " def __iter__(self): return iter(self.s)" |
| 6784 | + " def __iter__(self): return iter(self.s)\n", |
| 6785 | + " def __getitem__(self, i): return NotStr(self.s[i])" |
6839 | 6786 | ] |
6840 | 6787 | }, |
6841 | 6788 | { |
6842 | 6789 | "cell_type": "code", |
6843 | 6790 | "execution_count": null, |
6844 | | - "id": "1c296d2b", |
| 6791 | + "id": "cff43774", |
6845 | 6792 | "metadata": {}, |
6846 | 6793 | "outputs": [], |
6847 | 6794 | "source": [ |
6848 | 6795 | "s = NotStr(\"hello\")\n", |
6849 | 6796 | "assert not isinstance(s, str)\n", |
6850 | 6797 | "test_eq(s, 'hello')\n", |
6851 | 6798 | "test_eq(s*2, 'hellohello')\n", |
6852 | | - "test_eq(len(s), 5)" |
| 6799 | + "test_eq(len(s), 5)\n", |
| 6800 | + "test_eq(s[:2], \"he\")\n", |
| 6801 | + "test_eq(s[2], \"l\")" |
6853 | 6802 | ] |
6854 | 6803 | }, |
6855 | 6804 | { |
|
0 commit comments