Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Commit

Permalink
Organize sorting and searching in separate directories & misc cleanup (
Browse files Browse the repository at this point in the history
…#135)

* Organize sorting and searching in separate directories

* Dropping 3.2 support
  • Loading branch information
Amit Kumar committed Aug 21, 2017
1 parent fd81165 commit a69d1f6
Show file tree
Hide file tree
Showing 33 changed files with 38 additions and 77 deletions.
38 changes: 0 additions & 38 deletions .coafile

This file was deleted.

4 changes: 1 addition & 3 deletions .travis.yml
@@ -1,14 +1,12 @@
language: python
python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"

# command to install dependencies
install: pip install -U pytest
install: pip install -U autopep8
install: "pip install -r requirements-dev.txt"

# command to run tests
script: py.test
22 changes: 7 additions & 15 deletions pydsa/__init__.py
@@ -1,19 +1,11 @@
from .bst import BSTNode
from .selection_sort import selection_sort
from .bubble_sort import bubble_sort
from .insertion_sort import insertion_sort
from .merge_sort import merge_sort
from .quick_sort import quick_sort
from .sleep_sort import sleep_sort
from pydsa.searching.binary_search import binary_search
from pydsa.sorting.bubble_sort import bubble_sort
from pydsa.sorting.heap_sort import heap_sort
from .bfs import bfs
from .heap_sort import heap_sort
from .binary_search import binary_search
from .linear_search import linear_search
from .queue import queue
from .counting_sort import counting_sort
from .stack import Stack
from .radix_sort import radix_sort
from .binary_tree import BTNode
from .bst import BSTNode
from .euclid import gcd, extended_euclid
from .gnome_sort import gnome_sort
from .mod_inverse import mod_inverse
from .euclid import gcd, extended_euclid
from .queue import queue
from .stack import Stack
Empty file added pydsa/searching/__init__.py
Empty file.
File renamed without changes.
@@ -1,7 +1,7 @@
def linear_search(List, item):
"""
Find the element in list using linear search
>>> from pydsa import linear_search
>>> from pydsa.searching.linear_search import linear_search
>>> List = [3, 4, 6, 8, 12, 15, 26]
>>> item = 6
>>> linear_search(List, item)
Expand Down
Empty file added pydsa/sorting/__init__.py
Empty file.
File renamed without changes.
2 changes: 1 addition & 1 deletion pydsa/counting_sort.py → pydsa/sorting/counting_sort.py
Expand Up @@ -7,7 +7,7 @@ def counting_sort(array, maxval):
"""
Sorts the list 'array' using counting sort
>>> from pydsa import counting_sort
>>> from pydsa.sorting.counting_sort import counting_sort
>>> a = [5, 6, 1, 9, 3]
>>> counting_sort(a, 9)
[1, 3, 5, 6, 9]
Expand Down
File renamed without changes.
Expand Up @@ -2,7 +2,7 @@ def insertion_sort(a):
"""
Sorts the list 'a' using insertion sort algorithm
>>> from pydsa import insertion_sort
>>> from pydsa.sorting.insertion_sort import insertion_sort
>>> a = [3, 4, 2, 1, 12, 9]
>>> insertion_sort(a)
[1, 2, 3, 4, 9, 12]
Expand Down
2 changes: 1 addition & 1 deletion pydsa/merge_sort.py → pydsa/sorting/merge_sort.py
Expand Up @@ -22,7 +22,7 @@ def merge_sort(a):
"""
Sorts the list 'a' using Merge sort algorithm
>>> from pydsa import merge_sort
>>> from pydsa.sorting.merge_sort import merge_sort
>>> a = [3, 4, 2, 1, 12, 9]
>>> merge_sort(a)
[1, 2, 3, 4, 9, 12]
Expand Down
2 changes: 1 addition & 1 deletion pydsa/quick_sort.py → pydsa/sorting/quick_sort.py
Expand Up @@ -6,7 +6,7 @@ def quick_sort(a, start=0, end=None):
"""
Sorts the list 'a' using Quick sort algorithm
>>> from pydsa import quick_sort
>>> from pydsa.sorting.quick_sort import quick_sort
>>> a = [3, 4, 2, 1, 12, 9]
>>> quick_sort(a)
[1, 2, 3, 4, 9, 12]
Expand Down
2 changes: 1 addition & 1 deletion pydsa/radix_sort.py → pydsa/sorting/radix_sort.py
Expand Up @@ -15,7 +15,7 @@ def radix_sort(a):
representing numbers. This implementation is for decimal system i.e. base
is taken to be 10.
>>> from pydsa import radix_sort
>>> from pydsa.sorting.radix_sort import radix_sort
>>> a = [708, 4567, 3, 45, 911, 123, 57, 37]
>>> radix_sort(a)
[3, 37, 45, 57, 123, 708, 911, 4567]
Expand Down
Expand Up @@ -6,7 +6,7 @@ def selection_sort(a):
"""
Sorts the list 'a' using Selection sort algorithm
>>> from pydsa import selection_sort
>>> from pydsa.sorting.selection_sort import selection_sort
>>> a = [3, 4, 2, 1, 12, 9]
>>> selection_sort(a)
[1, 2, 3, 4, 9, 12]
Expand Down
2 changes: 1 addition & 1 deletion pydsa/sleep_sort.py → pydsa/sorting/sleep_sort.py
Expand Up @@ -10,7 +10,7 @@ def sleep_sort(a):
"""
Sorts the list 'a' using Sleep sort algorithm
>>> from pydsa import sleep_sort
>>> from pydsa.sorting.sleep_sort import sleep_sort
>>> a = [3, 4, 2]
>>> sleep_sort(a)
[2, 3, 4]
Expand Down
Empty file.
@@ -1,6 +1,7 @@
from pydsa.binary_search import binary_search
from random import randint

from pydsa.searching.binary_search import binary_search


def test_binary_search():
a = [randint(1, 10) for i in range(10)]
Expand Down
@@ -1,4 +1,4 @@
from pydsa.linear_search import linear_search
from pydsa.searching.linear_search import linear_search


def test_linear_search():
Expand Down
Empty file added pydsa/tests/sorting/__init__.py
Empty file.
File renamed without changes.
@@ -1,6 +1,7 @@
from pydsa.counting_sort import counting_sort
from random import randint

from pydsa.sorting.counting_sort import counting_sort


def test_counting_sort():
a = b = [randint(1, 100) for i in range(100)]
Expand Down
File renamed without changes.
@@ -1,6 +1,8 @@
from pydsa.heap_sort import heap_sort
from random import randint

from pydsa.sorting.heap_sort import heap_sort


def test_heap_sort():
a = [randint(1, 10) for i in range(10)]
b = sorted(a)
Expand Down
@@ -1,6 +1,7 @@
from pydsa.insertion_sort import insertion_sort
from random import randint

from pydsa.sorting.insertion_sort import insertion_sort


def test_insertion_sort():
a = b = [randint(1, 100) for i in range(100)]
Expand Down
@@ -1,6 +1,7 @@
from pydsa.merge_sort import merge_sort
from random import randint

from pydsa.sorting.merge_sort import merge_sort


def test_merge_sort():
a = [randint(1, 100) for i in range(100)]
Expand Down
@@ -1,6 +1,7 @@
from pydsa.quick_sort import quick_sort
from random import randint

from pydsa.sorting.quick_sort import quick_sort


def test_quick_sort():
a = b = [randint(1, 100) for i in range(100)]
Expand Down
@@ -1,6 +1,7 @@
from pydsa.radix_sort import radix_sort
from random import randint

from pydsa.sorting.radix_sort import radix_sort


def test_radix_sort():
"""Tests Radix Sort for a randomly generated list of integers"""
Expand Down
@@ -1,6 +1,7 @@
from pydsa.selection_sort import selection_sort
from random import randint

from pydsa.sorting.selection_sort import selection_sort


def test_selection_sort():
a = b = [randint(1, 100) for i in range(100)]
Expand Down
@@ -1,6 +1,7 @@
from pydsa.sleep_sort import sleep_sort
from random import randint

from pydsa.sorting.sleep_sort import sleep_sort


def test_sleep_sort():
a = b = [randint(1, 3) for i in range(3)]
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
@@ -0,0 +1 @@
pytest==3.0.5
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -9,4 +9,4 @@
packages=['pydsa'],
zip_safe=False,
install_requires=[],
)
)

0 comments on commit a69d1f6

Please sign in to comment.