Skip to content

Commit

Permalink
Overhaul for 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joowani committed May 11, 2018
1 parent 8119d0d commit b9d4fbf
Show file tree
Hide file tree
Showing 16 changed files with 706 additions and 584 deletions.
15 changes: 6 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ python:
- 3.5
- 3.6
install:
- pip install coverage
- pip install pytest
- pip install pytest-cov
- pip install python-coveralls
- pip install flake8
- python setup.py install
- pip install flake8 mock pytest pytest-cov python-coveralls sphinx sphinx_rtd_theme
- pip install .
script:
- python -m flake8 binarytree/__init__.py
- python -m doctest binarytree/__init__.py
- py.test tests.py --cov=binarytree
- python -m flake8
- python -m sphinx -b doctest docs docs/_build
- python -m sphinx -b html -W docs docs/_build
- py.test -s -v --cov=binarytree
after_success:
- coveralls
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include README.rst LICENSE
prune tests
34 changes: 12 additions & 22 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,22 @@ Are you studying binary trees for your next exam, assignment or technical interv

**Binarytree** is a Python library which provides a simple API to generate,
visualize, inspect and manipulate binary trees. It allows you to skip the
tedious work of setting up test data, and dive straight into practising
your algorithms! Heaps and BSTs (binary search trees) are also supported.
tedious work of setting up test data, and dive straight into practising your
algorithms. Heaps and BSTs (binary search trees) are also supported.

Announcements
=============

* **Binarytree** has been completely overhauled in version `3.0`_!
* **Binarytree** version `4.0`_ is now out!
* Please see the releases_ page for details on the latest updates.

.. _3.0: https://github.com/joowani/binarytree/releases/tag/3.0.0
.. _4.0: https://github.com/joowani/binarytree/releases/tag/4.0.0
.. _releases: https://github.com/joowani/binarytree/releases

Requirements
============

- Python 2.7, 3.4, 3.5 or 3.6
- Pip_ installer

.. _Pip: https://pip.pypa.io

Installation
============
Expand All @@ -66,19 +63,17 @@ To install a stable version from PyPi_:
~$ pip install binarytree
To install the latest version directly from GitHub_:

.. code-block:: bash
~$ pip install -e [email protected]:joowani/binarytree.git@master#egg=binarytree
You may need to use ``sudo`` depending on your environment setup.
You may need to use ``sudo`` depending on your environment.

.. _PyPi: https://pypi.python.org/pypi/binarytree
.. _GitHub: https://github.com/joowani/binarytree


Getting Started
===============

Expand All @@ -93,7 +88,6 @@ By default, **binarytree** uses the following class to represent a node:
self.left = left # Left child
self.right = right # Right child
Generate and pretty-print various types of binary trees:

.. code-block:: python
Expand Down Expand Up @@ -164,7 +158,6 @@ Use the `binarytree.Node`_ class to build your own trees:
# 4
#
Inspect tree properties:

.. code-block:: python
Expand Down Expand Up @@ -296,7 +289,6 @@ Use `level-order (breadth-first)`_ indexes to manipulate nodes:
# \
# 2-3
Traverse the trees using different algorithms:

.. code-block:: python
Expand Down Expand Up @@ -329,19 +321,20 @@ Traverse the trees using different algorithms:
>>> root.levelorder
[Node(1), Node(2), Node(3), Node(4), Node(5)]
>>> list(root) # Equivalent to root.levelorder
[Node(1), Node(2), Node(3), Node(4), Node(5)]
`List representations`_ are also supported:

.. _List representations:
https://en.wikipedia.org/wiki/Binary_tree#Arrays

.. _List representations: https://en.wikipedia.org/wiki/Binary_tree#Arrays

.. code-block:: python
>>> from binarytree import build
>>>
>>> # Build a tree from list representation
>>> root = build([7, 3, 2, 6, 9, None, 1, 5, 8])
>>> values = [7, 3, 2, 6, 9, None, 1, 5, 8]
>>> root = build(values)
>>> print(root)
#
# __7
Expand All @@ -353,19 +346,16 @@ Traverse the trees using different algorithms:
# 5 8
#
>>> # Convert the tree back to list representation
>>> list(root)
>>> root.values
[7, 3, 2, 6, 9, None, 1, 5, 8]
Check out the documentation_ for more details!

.. _documentation: http://binarytree.readthedocs.io/en/latest/index.html


Contributing
============

Please have a look at this page_ before submitting a pull request. Thanks!

.. _page: http://binarytree.readthedocs.io/en/latest/contributing.html
.. _page: http://binarytree.readthedocs.io/en/latest/contributing.html
Loading

0 comments on commit b9d4fbf

Please sign in to comment.