-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5db0e8a
Showing
16 changed files
with
1,378 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Smokeshow | ||
|
||
on: | ||
workflow_run: | ||
workflows: [Test] | ||
types: [completed] | ||
|
||
permissions: | ||
statuses: write | ||
|
||
jobs: | ||
smokeshow: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' | ||
|
||
- run: pip install smokeshow | ||
|
||
- uses: dawidd6/[email protected] | ||
with: | ||
workflow: test.yml | ||
commit: ${{ github.event.workflow_run.head_sha }} | ||
|
||
- run: smokeshow upload coverage-html | ||
env: | ||
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage} | ||
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 100 | ||
SMOKESHOW_GITHUB_CONTEXT: coverage | ||
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} | ||
SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
workflow_dispatch: | ||
inputs: | ||
debug_enabled: | ||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' | ||
required: false | ||
default: 'false' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: | ||
- "3.8" | ||
- "3.9" | ||
# - "3.10" | ||
# - "3.11" | ||
# - "3.12" | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
# Allow debugging with tmate | ||
- name: Setup tmate session | ||
uses: mxschmitt/action-tmate@v3 | ||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }} | ||
with: | ||
limit-access-to-actor: true | ||
- uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-v2 | ||
- name: Install poetry | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install "poetry" | ||
python -m poetry self add poetry-version-plugin | ||
- name: Configure poetry | ||
run: python -m poetry config virtualenvs.create false | ||
- name: Install Dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: python -m poetry install | ||
- name: Lint | ||
run: python -m poetry run bash scripts/lint.sh | ||
- run: mkdir coverage | ||
- name: Test | ||
run: python -m poetry run bash scripts/test.sh | ||
env: | ||
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} | ||
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} | ||
- name: Store coverage files | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage | ||
path: coverage | ||
coverage-combine: | ||
needs: | ||
- test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.8' | ||
|
||
- name: Get coverage files | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: coverage | ||
path: coverage | ||
|
||
- run: pip install coverage[toml] | ||
|
||
- run: ls -la coverage | ||
- run: coverage combine coverage | ||
- run: coverage report | ||
- run: coverage html --show-contexts --title "Coverage for ${{ github.sha }}" | ||
|
||
- name: Store coverage HTML | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-html | ||
path: htmlcov | ||
|
||
# https://github.com/marketplace/actions/alls-green#why | ||
alls-green: # This job does nothing and is only used for the branch protection | ||
if: always() | ||
needs: | ||
- coverage-combine | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Decide whether the needed jobs succeeded or failed | ||
uses: re-actors/alls-green@release/v1 | ||
with: | ||
jobs: ${{ toJSON(needs) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea/ | ||
**/__pycache__/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2022 Sebastián Ramírez | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# py-simple-trees | ||
|
||
<p align="center"> | ||
<em>This package is a implementation collection of tree data structures.</em> | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="https://github.com/lpthong90/py-simple-trees/actions?query=workflow%3ATest" target="_blank"> | ||
<img src="https://github.com/lpthong90/py-simple-trees/workflows/Test/badge.svg" alt="Test"> | ||
</a> | ||
<a href="https://github.com/lpthong90/py-simple-trees/actions?query=workflow%3APublish" target="_blank"> | ||
<img src="https://github.com/lpthong90/py-simple-trees/workflows/Publish/badge.svg" alt="Publish"> | ||
</a> | ||
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/lpthong90/py-simple-trees" target="_blank"> | ||
<img src="https://coverage-badge.samuelcolvin.workers.dev/lpthong90/py-simple-trees.svg" alt="Coverage"> | ||
<a href="https://pypi.org/project/py-simple-trees" target="_blank"> | ||
<img src="https://img.shields.io/pypi/v/py-simple-trees?color=%2334D058&label=pypi%20package" alt="Package version"> | ||
</a> | ||
<a href="https://pypi.org/project/py-simple-trees" target="_blank"> | ||
<img alt="Downloads" src="https://img.shields.io/pypi/dm/py-simple-trees?color=%2334D058" /> | ||
</a> | ||
</p> | ||
<p align="center"> | ||
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/py-simple-trees"> | ||
</p> | ||
|
||
|
||
--- | ||
|
||
**Documentation**: <a href="https://lpthong90.dev/py-simple-trees" target="_blank">https://lpthong90.dev/py-simple-trees</a> | ||
|
||
**Source Code**: <a href="https://github.com/lpthong90/py-simple-trees" target="_blank">https://github.com/lpthong90/py-simple-trees</a> | ||
|
||
--- | ||
|
||
This package is a implementation collection of tree data structures. | ||
|
||
## Installation | ||
<div class="termy"> | ||
|
||
```console | ||
$ pip install py-simple-trees | ||
---> 100% | ||
Successfully installed py-simple-trees | ||
``` | ||
|
||
</div> | ||
|
||
## Tree Types | ||
- Binary Tree | ||
- Binary Search Tree (BST) | ||
- AVL Tree | ||
|
||
## Basic Usage | ||
|
||
```Python | ||
import simple_trees import AVLTree | ||
|
||
|
||
if __name__ == "__main__": | ||
tree = AVLTree() | ||
|
||
tree.insert(1, 1) | ||
tree.insert(2, 2) | ||
tree.insert(3, 3) | ||
tree.insert(4, 4) | ||
tree.insert(5, 5) | ||
tree.insert(6, 6) | ||
tree.insert(7, 7) | ||
|
||
tree.print() | ||
``` | ||
|
||
Output | ||
``` | ||
4 --L--> 2 | ||
4 --R--> 6 | ||
2 --L--> 1 | ||
2 --R--> 3 | ||
6 --L--> 5 | ||
6 --R--> 7 | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
## License | ||
|
||
This project is licensed under the terms of the [MIT license](https://github.com/lpthong90/py-simple-trees/blob/main/LICENSE). |
Oops, something went wrong.