Skip to content

Commit

Permalink
Changed: Fix docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
kayjan committed Sep 29, 2023
1 parent acbd50a commit 534f684
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 96 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Tree Exporter: Relax type hinting using TypeVar for `clone_tree`.
- Tree Helper: Accept Iterable instead of List for custom_style attribute of `yield_tree` and `print_tree`.
- Misc: Fix docstring for better presentation of code vs variable vs normal text.

## [0.12.5] - 2023-09-26
### Added
Expand Down
2 changes: 1 addition & 1 deletion bigtree/binarytree/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def list_to_binarytree(
Args:
heapq_list (List[int]): list containing integer node names, ordered in heapq fashion
node_type (Type[BinaryNode]): node type of tree to be created, defaults to BinaryNode
node_type (Type[BinaryNode]): node type of tree to be created, defaults to ``BinaryNode``
Returns:
(BinaryNode)
Expand Down
6 changes: 3 additions & 3 deletions bigtree/dag/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def list_to_dag(
Args:
relations (List[Tuple[str, str]]): list containing tuple of parent-child names
node_type (Type[DAGNode]): node type of DAG to be created, defaults to DAGNode
node_type (Type[DAGNode]): node type of DAG to be created, defaults to ``DAGNode``
Returns:
(DAGNode)
Expand Down Expand Up @@ -68,7 +68,7 @@ def dict_to_dag(
relation_attrs (Dict[str, Any]): dictionary containing node, node parents, and node attribute information,
key: child name, value: dictionary of parent names, node attribute, and attribute value
parent_key (str): key of dictionary to retrieve list of parents name, defaults to 'parent'
node_type (Type[DAGNode]): node type of DAG to be created, defaults to DAGNode
node_type (Type[DAGNode]): node type of DAG to be created, defaults to ``DAGNode``
Returns:
(DAGNode)
Expand Down Expand Up @@ -133,7 +133,7 @@ def dataframe_to_dag(
if not set, it will take the second column of data
attribute_cols (List[str]): columns of data containing child node attribute information,
if not set, it will take all columns of data except `child_col` and `parent_col`
node_type (Type[DAGNode]): node type of DAG to be created, defaults to DAGNode
node_type (Type[DAGNode]): node type of DAG to be created, defaults to ``DAGNode``
Returns:
(DAGNode)
Expand Down
44 changes: 22 additions & 22 deletions bigtree/tree/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def add_path_to_tree(
"""Add nodes and attributes to existing tree *in-place*, return node of added path.
Adds to existing tree from list of path strings.
Path should contain `Node` name, separated by `sep`.
Path should contain ``Node`` name, separated by `sep`.
- For example: Path string "a/b" refers to Node("b") with parent Node("a").
- Path separator `sep` is for the input `path` and can differ from existing tree.
Expand All @@ -67,7 +67,7 @@ def add_path_to_tree(
tree (Node): existing tree
path (str): path to be added to tree
sep (str): path separator for input `path`
duplicate_name_allowed (bool): indicator if nodes with duplicate `Node` name is allowed, defaults to True
duplicate_name_allowed (bool): indicator if nodes with duplicate ``Node`` name is allowed, defaults to True
node_attrs (Dict[str, Any]): attributes to add to node, key: attribute name, value: attribute value, optional
Returns:
Expand Down Expand Up @@ -122,7 +122,7 @@ def add_dict_to_tree_by_path(
"""Add nodes and attributes to tree *in-place*, return root of tree.
Adds to existing tree from nested dictionary, ``key``: path, ``value``: dict of attribute name and attribute value.
Path should contain `Node` name, separated by `sep`.
Path should contain ``Node`` name, separated by `sep`.
- For example: Path string "a/b" refers to Node("b") with parent Node("a").
- Path separator `sep` is for the input `path` and can differ from existing tree.
Expand Down Expand Up @@ -160,7 +160,7 @@ def add_dict_to_tree_by_path(
path_attrs (Dict[str, Dict[str, Any]]): dictionary containing node path and attribute information,
key: node path, value: dict of node attribute name and attribute value
sep (str): path separator for input `path_attrs`
duplicate_name_allowed (bool): indicator if nodes with duplicate `Node` name is allowed, defaults to True
duplicate_name_allowed (bool): indicator if nodes with duplicate ``Node`` name is allowed, defaults to True
Returns:
(Node)
Expand Down Expand Up @@ -209,7 +209,7 @@ def add_dict_to_tree_by_name(
name_attrs (Dict[str, Dict[str, Any]]): dictionary containing node name and attribute information,
key: node name, value: dict of node attribute name and attribute value
join_type (str): join type with attribute, default of 'left' takes existing tree nodes,
if join_type is set to 'inner' it will only take tree nodes that are in `path_attrs` key and drop others
if join_type is set to 'inner' it will only take tree nodes that are in `name_attrs` key and drop others
Returns:
(Node)
Expand Down Expand Up @@ -238,7 +238,7 @@ def add_dataframe_to_tree_by_path(
`path_col` and `attribute_cols` specify columns for node path and attributes to add to existing tree.
If columns are not specified, `path_col` takes first column and all other columns are `attribute_cols`
Path in path column should contain `Node` name, separated by `sep`.
Path in path column should contain ``Node`` name, separated by `sep`.
- For example: Path string "a/b" refers to Node("b") with parent Node("a").
- Path separator `sep` is for the input `path` and can differ from existing tree.
Expand Down Expand Up @@ -282,7 +282,7 @@ def add_dataframe_to_tree_by_path(
attribute_cols (List[str]): columns of data containing node attribute information,
if not set, it will take all columns of data except `path_col`
sep (str): path separator for input `path_col`
duplicate_name_allowed (bool): indicator if nodes with duplicate `Node` name is allowed, defaults to True
duplicate_name_allowed (bool): indicator if nodes with duplicate ``Node`` name is allowed, defaults to True
Returns:
(Node)
Expand Down Expand Up @@ -368,7 +368,7 @@ def add_dataframe_to_tree_by_name(
name_col (str): column of data containing `name` information,
if not set, it will take the first column of data
attribute_cols (List[str]): column(s) of data containing node attribute information,
if not set, it will take all columns of data except path_col
if not set, it will take all columns of data except `path_col`
join_type (str): join type with attribute, default of 'left' takes existing tree nodes,
if join_type is set to 'inner' it will only take tree nodes with attributes and drop the other nodes
Expand Down Expand Up @@ -450,7 +450,7 @@ def str_to_tree(
tree_string (str): String to construct tree
tree_prefix_list (List[str]): List of prefix to mark the end of tree branch/stem and start of node name, optional.
If not specified, it will infer unicode characters and whitespace as prefix.
node_type (Type[Node]): node type of tree to be created, defaults to Node
node_type (Type[Node]): node type of tree to be created, defaults to ``Node``
Returns:
(Node)
Expand Down Expand Up @@ -502,7 +502,7 @@ def list_to_tree(
) -> Node:
"""Construct tree from list of path strings.
Path should contain `Node` name, separated by `sep`.
Path should contain ``Node`` name, separated by `sep`.
- For example: Path string "a/b" refers to Node("b") with parent Node("a").
Path can start from root node `name`, or start with `sep`.
Expand All @@ -527,8 +527,8 @@ def list_to_tree(
Args:
paths (Iterable[str]): list containing path strings
sep (str): path separator for input `paths` and created tree, defaults to `/`
duplicate_name_allowed (bool): indicator if nodes with duplicate `Node` name is allowed, defaults to True
node_type (Type[Node]): node type of tree to be created, defaults to Node
duplicate_name_allowed (bool): indicator if nodes with duplicate ``Node`` name is allowed, defaults to True
node_type (Type[Node]): node type of tree to be created, defaults to ``Node``
Returns:
(Node)
Expand Down Expand Up @@ -581,7 +581,7 @@ def list_to_tree_by_relation(
relations (Iterable[Tuple[str, str]]): list containing tuple containing parent-child names
allow_duplicates (bool): allow duplicate intermediate nodes such that child node will
be tagged to multiple parent nodes, defaults to False
node_type (Type[Node]): node type of tree to be created, defaults to Node
node_type (Type[Node]): node type of tree to be created, defaults to ``Node``
Returns:
(Node)
Expand Down Expand Up @@ -609,7 +609,7 @@ def dict_to_tree(
"""Construct tree from nested dictionary using path,
``key``: path, ``value``: dict of attribute name and attribute value.
Path should contain `Node` name, separated by `sep`.
Path should contain ``Node`` name, separated by `sep`.
- For example: Path string "a/b" refers to Node("b") with parent Node("a").
Path can start from root node `name`, or start with `sep`.
Expand Down Expand Up @@ -644,8 +644,8 @@ def dict_to_tree(
path_attrs (Dict[str, Any]): dictionary containing path and node attribute information,
key: path, value: dict of tree attribute and attribute value
sep (str): path separator of input `path_attrs` and created tree, defaults to `/`
duplicate_name_allowed (bool): indicator if nodes with duplicate `Node` name is allowed, defaults to True
node_type (Type[Node]): node type of tree to be created, defaults to Node
duplicate_name_allowed (bool): indicator if nodes with duplicate ``Node`` name is allowed, defaults to True
node_type (Type[Node]): node type of tree to be created, defaults to ``Node``
Returns:
(Node)
Expand Down Expand Up @@ -704,7 +704,7 @@ def nested_dict_to_tree(
value of `child_key` (List[Dict[str, Any]]): list of dict containing `name_key` and `child_key` (recursive)
name_key (str): key of node name, value is type str
child_key (str): key of child list, value is type list
node_type (Type[Node]): node type of tree to be created, defaults to Node
node_type (Type[Node]): node type of tree to be created, defaults to ``Node``
Returns:
(Node)
Expand Down Expand Up @@ -747,7 +747,7 @@ def dataframe_to_tree(
Path in path column can start from root node `name`, or start with `sep`.
- For example: Path string can be "/a/b" or "a/b", if sep is "/".
Path in path column should contain `Node` name, separated by `sep`.
Path in path column should contain ``Node`` name, separated by `sep`.
- For example: Path string "a/b" refers to Node("b") with parent Node("a").
All paths should start from the same root node.
Expand Down Expand Up @@ -785,8 +785,8 @@ def dataframe_to_tree(
attribute_cols (List[str]): columns of data containing node attribute information,
if not set, it will take all columns of data except `path_col`
sep (str): path separator of input `path_col` and created tree, defaults to `/`
duplicate_name_allowed (bool): indicator if nodes with duplicate `Node` name is allowed, defaults to True
node_type (Type[Node]): node type of tree to be created, defaults to Node
duplicate_name_allowed (bool): indicator if nodes with duplicate ``Node`` name is allowed, defaults to True
node_type (Type[Node]): node type of tree to be created, defaults to ``Node``
Returns:
(Node)
Expand Down Expand Up @@ -856,7 +856,7 @@ def dataframe_to_tree_by_relation(
This error can be ignored by setting `allow_duplicates` to be True.
`child_col` and `parent_col` specify columns for child name and parent name to construct tree.
`attribute_cols` specify columns for node attribute for child name
`attribute_cols` specify columns for node attribute for child name.
If columns are not specified, `child_col` takes first column, `parent_col` takes second column, and all other
columns are `attribute_cols`.
Expand Down Expand Up @@ -895,7 +895,7 @@ def dataframe_to_tree_by_relation(
if not set, it will take all columns of data except `child_col` and `parent_col`
allow_duplicates (bool): allow duplicate intermediate nodes such that child node will
be tagged to multiple parent nodes, defaults to False
node_type (Type[Node]): node type of tree to be created, defaults to Node
node_type (Type[Node]): node type of tree to be created, defaults to ``Node``
Returns:
(Node)
Expand Down
Loading

0 comments on commit 534f684

Please sign in to comment.