Skip to content

Commit

Permalink
__repr__ updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rlayers committed Jul 27, 2023
1 parent 35c62f8 commit c06c258
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/4. Arborform.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@ Itorators are callable objects[^callable_object] are are invoked using simple fu
>>> s = 'Hello, world!'
>>> i = Ito(s)
>>> i # Starting ito has no .desc
Ito('Hello, world!', 0, 13, None)
Ito(span=(0, 13), desc='', substr='Hello, world!')
>>> itor_desc = arborform.Desc('changed') # Desc itorator: changes .desc property
>>> next(itor_desc(i)) # Invoke itorator and get first item from pipeline
Ito('Hello, world!', 0, 13, 'changed')
Ito(span=(0, 13), desc='changed', substr='Hello, world!')
```

When invoked, an itorator clones the input Ito, which guarrantees that it is unaltered by the pipeline:

```python
>>> i # Original remains unmodified
Ito('Hello, world!', 0, 13, None)
Ito(span=(0, 13), desc='', substr='Hello, world!')
```

Transformations are performed in the ``._transform`` method, which is abstract for the base class ``Itorator``. The ``._transform`` method is not intended to be called directly, rather, it is available for you to override in derived classes. Several concrete itorators with implementations for ``._transform`` are available:
Expand Down Expand Up @@ -138,15 +138,15 @@ Note that if you use a ``return`` statement with a single Ito, the *ito itself*
>>> from pawpaw.arborform import Itorator
>>> i = Itorator.wrap(lambda i: [i.clone()]) # ok: returns a list with 1 ito
>>> [*i(Ito('abc'))]
[Ito('abc', 0, 3, None)]
[Ito(span=(0, 3), desc='', substr='abc')]

>>> i = Itorator.wrap(lambda i: (i.clone(),)) # ok: returns a tuple with 1 ito
>>> [*i(Ito('abc'))]
[Ito('abc', 0, 3, None)]
[Ito(span=(0, 3), desc='', substr='abc')]

>>> i = Itorator.wrap(lambda i: i.clone()) # warning: returns an Ito...
>>> [*i(Ito('abc'))] # ...which is also a 3-Ito sequence
[Ito('abc', 0, 1, None), Ito('abc', 1, 2, None), Ito('abc', 2, 3, None)]
[Ito(span=(0, 1), desc='', substr='a'), Ito(span=(1, 2), desc='', substr='b'), Ito(span=(2, 3), desc='', substr='c')]
```

``Itorator`` also features a ``.tag`` property, which is a convenience field that allows you to assign arbitrary labels in order to assist in the development and testing of your pipelines.
Expand Down

0 comments on commit c06c258

Please sign in to comment.