Skip to content

Commit

Permalink
Minor docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mar10 committed Nov 1, 2024
1 parent 5c39c23 commit f7516ad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
23 changes: 13 additions & 10 deletions docs/jupyter/take_the_tour.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,14 @@
"source": [
"### Control the `data_id`\n",
"\n",
"If the object instances have a natural attribute that identifies them, we can use\n",
"it instead of the default `hash()`. <br>\n",
"This improves readability and helps to (de)serialize:"
"If the object instances have an attribute that naturally identifies them, \n",
"we can use it instead of the default `hash()`. <br>\n",
"This improves readability and may be more appropriate for serialization:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -309,16 +309,18 @@
],
"source": [
"tree_2 = Tree(\"Organization\", calc_data_id=lambda tree, data: str(data.guid))\n",
"\n",
"dep_node_2 = tree_2.add(development_dep)\n",
"dep_node_2.add(bob)\n",
"\n",
"tree_2.print(repr=\"{node}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"now we could also search by the guid, for example"
"now we could also search by the GUID, for example:"
]
},
{
Expand Down Expand Up @@ -352,7 +354,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -365,7 +367,7 @@
],
"source": [
"res = []\n",
"for node in tree: # depth-first, pre-orde traversal\n",
"for node in tree: # depth-first, pre-order traversal\n",
" res.append(node.data.name)\n",
"print(res)"
]
Expand Down Expand Up @@ -394,7 +396,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -501,7 +503,7 @@
"source": [
"## Mutation\n",
"\n",
"We can add, copy, move, remove, sort, etc.\n",
"We can add, copy, move, remove, sort, &hellip; nodes.\n",
"\n",
"For example:"
]
Expand Down Expand Up @@ -541,7 +543,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Read the user guide for more."
"Read the [user guide](https://nutree.readthedocs.io/en/latest/ug_mutation.html) \n",
"for more ways to modify a tree."
]
},
{
Expand Down
17 changes: 10 additions & 7 deletions docs/sphinx/take_the_tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,17 @@ tree.find_all(match=lambda node: "i" in node.data.name)

### Control the `data_id`

If the object instances have a natural attribute that identifies them, we can use
it instead of the default `hash()`. <br>
This improves readability and helps to (de)serialize:
If the object instances have an attribute that naturally identifies them,
we can use it instead of the default `hash()`. <br>
This improves readability and may be more appropriate for serialization:


```python
tree_2 = Tree("Organization", calc_data_id=lambda tree, data: str(data.guid))

dep_node_2 = tree_2.add(development_dep)
dep_node_2.add(bob)

tree_2.print(repr="{node}")
```

Expand All @@ -183,7 +185,7 @@ tree_2.print(repr="{node}")
╰── Node<'Person<Bob (35)>', data_id=ad20de1f-34c4-40cc-a102-51c28fb6ec5b>


now we could also search by the guid, for example
now we could also search by the GUID, for example:


```python
Expand All @@ -204,7 +206,7 @@ There are multiple methods to iterate the tree.

```python
res = []
for node in tree: # depth-first, pre-orde traversal
for node in tree: # depth-first, pre-order traversal
res.append(node.data.name)
print(res)
```
Expand Down Expand Up @@ -278,7 +280,7 @@ tree_copy.print(repr="{node}")

## Mutation

We can add, copy, move, remove, sort, etc.
We can add, copy, move, remove, sort, &hellip; nodes.

For example:

Expand All @@ -304,7 +306,8 @@ tree.print(repr="{node.data}")
╰── Person<Alice (25)>


Read the user guide for more.
Read the [user guide](https://nutree.readthedocs.io/en/latest/ug_mutation.html)
for more ways to modify a tree.

## Data IDs and Clones

Expand Down

0 comments on commit f7516ad

Please sign in to comment.