Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
python -m pip install pytest
python -m pip install pytest-cov
pytest --cov=./ --cov-report=xml
- name: Converage coverage report
- name: Convert coverage report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage.xml
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/conda-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Upload Python Package to Conda

on:
workflow_run:
workflows: ["Upload Python Package to PyPI"]
branches: [master]
types:
- completed
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Conda
run: |
conda install -c conda-forge conda-build conda-verify
- name: Publish to conda
run: |
cd conda
conda config --set anaconda_upload yes
conda build -c conda-forge --output-folder . .
ls
anaconda upload ./noarch/*.tar.bz2
9 changes: 5 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Docs

on:
workflow_run:
workflows: ["Upload Python Package"]
workflows: ["Upload Python Package to PyPI"]
branches: [master]
types:
types:
- completed

permissions:
Expand All @@ -20,8 +20,9 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- name: Install dependencies
run: |
pip install -r docs/requirements.txt
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Upload Python Package
name: Upload Python Package to PyPI

on: workflow_dispatch

Expand All @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.14.3] - 2023-10-31
### Added
- Misc: Publish to conda, enable automated publishing to conda-forge in addition to existing PyPI.
- README: Tree demonstration code for `shift_and_replace_nodes` and `copy_and_replace_nodes_from_tree_to_tree`.

## [0.14.2] - 2023-10-21
### Added
- Misc: RTD integration.
Expand Down Expand Up @@ -370,6 +375,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Utility Iterator: Tree traversal methods.
- Workflow To Do App: Tree use case with to-do list implementation.

[0.14.3]: https://github.com/kayjan/bigtree/compare/0.14.2...0.14.3
[0.14.2]: https://github.com/kayjan/bigtree/compare/0.14.1...0.14.2
[0.14.1]: https://github.com/kayjan/bigtree/compare/0.14.0...0.14.1
[0.14.0]: https://github.com/kayjan/bigtree/compare/0.13.3...0.14.0
Expand Down
58 changes: 53 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Related Links:
- [Issues](https://github.com/kayjan/bigtree/issues)
- [Discussions](https://github.com/kayjan/bigtree/discussions)
- [Contributing](https://bigtree.readthedocs.io/en/latest/others/contributing.html)
- [PyPI](https://pypi.org/project/bigtree/)
- Package
- [PyPI](https://pypi.org/project/bigtree/)
- [Conda](https://anaconda.org/conda-forge/bigtree)
- Articles
- [Python Tree Implementation with BigTree](https://towardsdatascience.com/python-tree-implementation-with-bigtree-13cdabd77adc#245a-94ae81f0b3f1)
- [The Reingold Tilford Algorithm Explained, with Walkthrough](https://towardsdatascience.com/reingold-tilford-algorithm-explained-with-walkthrough-be5810e8ed93?sk=2db8e10398cee76c486c4b06b0b33322)
Expand Down Expand Up @@ -99,6 +101,10 @@ For **Directed Acyclic Graph (DAG)** implementation, there are 4 main components

## Installation

There are two ways to install `bigtree`, with pip (from PyPI) or conda (from conda-forge).

### a) Installation with pip (preferred)

To install `bigtree`, run the following line in command prompt:

```shell
Expand Down Expand Up @@ -127,6 +133,14 @@ Alternatively, install all optional dependencies with the following line in comm
$ pip install 'bigtree[all]'
```

### b) Installation with conda

To install `bigtree` with conda, run the following line in command prompt:

```shell
$ conda install -c conda-forge bigtree
```

----

## Tree Demonstration
Expand Down Expand Up @@ -500,10 +514,10 @@ root.show()

### Modify Tree

Nodes can be shifted or copied from one path to another.
Nodes can be shifted (with or without replacement) or copied from one path to another.

```python
from bigtree import Node, shift_nodes
from bigtree import Node, shift_nodes, shift_and_replace_nodes

root = Node("a")
b = Node("b", parent=root)
Expand All @@ -526,6 +540,17 @@ root.show()
# │ └── c
# └── dummy
# └── d

shift_and_replace_nodes(
tree=root,
from_paths=["a/dummy"],
to_paths=["a/b/c"],
)
root.show()
# a
# └── b
# └── dummy
# └── d
```

```python
Expand Down Expand Up @@ -556,10 +581,10 @@ root.show()
# └── d
```

Nodes can also be copied between two different trees.
Nodes can also be copied (with or without replacement) between two different trees.

```python
from bigtree import Node, copy_nodes_from_tree_to_tree
from bigtree import Node, copy_nodes_from_tree_to_tree, copy_and_replace_nodes_from_tree_to_tree
root = Node("a")
b = Node("b", parent=root)
c = Node("c", parent=root)
Expand All @@ -583,6 +608,28 @@ root_other.show()
# │ └── c
# └── dummy
# └── d

root_other = Node("aa")
b = Node("b", parent=root_other)
c = Node("c", parent=b)
d = Node("d", parent=root_other)
root_other.show()
# aa
# ├── b
# │ └── c
# └── d

copy_and_replace_nodes_from_tree_to_tree(
from_tree=root,
to_tree=root_other,
from_paths=["a/b", "a/c"],
to_paths=["aa/b/c", "aa/d"],
)
root_other.show()
# aa
# ├── b
# │ └── b
# └── c
```

### Tree Search
Expand Down Expand Up @@ -622,6 +669,7 @@ find_attr(root, "age", 40)
```

To find multiple nodes,

```python
from bigtree import Node, findall, find_names, find_relative_path, find_paths, find_attrs
root = Node("a", age=90)
Expand Down
2 changes: 1 addition & 1 deletion bigtree/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.14.2"
__version__ = "0.14.3"

from bigtree.binarytree.construct import list_to_binarytree
from bigtree.dag.construct import dataframe_to_dag, dict_to_dag, list_to_dag
Expand Down
40 changes: 40 additions & 0 deletions bigtree/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% set name = "bigtree" %}
{% set version = "0.14.2" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
url: https://github.com/kayjan/bigtree/archive/{{ version }}.tar.gz
sha256: 21f5c61a48db0c731b00e5e08a66f16e231960accf64e4ae6d80c3fc91eb9c54

build:
noarch: python
script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation
number: 0

requirements:
host:
- python >=3.7
- hatchling
- pip
run:
- python >=3.7

test:
imports:
- bigtree
commands:
- pip check
requires:
- pip

about:
summary: Tree Implementation and Methods for Python, integrated with Python list, dictionary, and pandas DataFrame.
license: MIT
license_file: LICENSE

extra:
recipe-maintainers:
- kay
7 changes: 7 additions & 0 deletions conda/conda-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: conda-env
channels:
- conda-forge
dependencies:
- pip
- pytest
- pytest-cov
6 changes: 6 additions & 0 deletions conda/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
python:
- 3.7
- 3.8
- 3.9
- 3.10
- 3.11
45 changes: 45 additions & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% set name = "bigtree" %}
{% set version = "0.14.2" %}

package:
name: "{{ name|lower }}"
version: "{{ version }}"

source:
url: https://github.com/kayjan/{{ name }}/archive/refs/tags/{{ version }}.tar.gz
sha256: 21f5c61a48db0c731b00e5e08a66f16e231960accf64e4ae6d80c3fc91eb9c54

build:
number: 0
noarch: python
script: "{{ PYTHON }} -m pip install . -vv"

requirements:
host:
- python >=3.7
- hatchling
- pip
run:
- python >=3.8
- pandas
- pydot
- Pillow

test:
imports:
- bigtree
requires:
- pip
- pytest

about:
home: https://github.com/kayjan/bigtree
license: MIT
license_family: MIT
license_file: LICENSE
summary: Tree Implementation and Methods for Python, integrated with Python list, dictionary, and pandas DataFrame.
doc_url: https://bigtree.readthedocs.io/en/latest/

extra:
recipe-maintainers:
- kayjan
8 changes: 8 additions & 0 deletions etc/conda-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: conda-env
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- black=22.10.0
- python=3.11.0