Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quality tests for public API #255

Merged
merged 3 commits into from
Apr 20, 2020
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
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ parallel = True
source = pydatastructs
omit =
*/tests/*
*/setup.py

[report]
exclude_lines =
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ install:
- pip install -r requirements.txt

script:
- python -m pytest --doctest-modules --cov=./ --cov-report=xml
- python -m pytest --doctest-modules --cov=./ --cov-report=xml -s

after_success:
- codecov
6 changes: 6 additions & 0 deletions pydatastructs/graphs/adjacency_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ def __new__(cls, *vertices):
obj.edge_weights = dict()
return obj

@classmethod
def methods(self):
return ['is_adjacent', 'neighbors',
'add_vertex', 'remove_vertex', 'add_edge',
'get_edge', 'remove_edge', '__new__']

def is_adjacent(self, node1, node2):
node1 = self.__getattribute__(node1)
return hasattr(node1, node2)
Expand Down
6 changes: 6 additions & 0 deletions pydatastructs/graphs/adjacency_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ def __new__(cls, *vertices):
obj.edge_weights = dict()
return obj

@classmethod
def methods(self):
return ['is_adjacent', 'neighbors',
'add_edge', 'get_edge', 'remove_edge',
'__new__']

def is_adjacent(self, node1, node2):
node1, node2 = str(node1), str(node2)
row = self.matrix.get(node1, dict())
Expand Down
12 changes: 12 additions & 0 deletions pydatastructs/linear_data_structures/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def __new__(cls, dtype=NoneType, *args, **kwargs):

return obj

@classmethod
def methods(cls):
return ['__new__', '__getitem__',
'__setitem__', 'fill', '__len__',
'__str__']

def __getitem__(self, i):
if i >= self._size or i < 0:
raise IndexError("Index out of range.")
Expand Down Expand Up @@ -215,6 +221,12 @@ def __new__(cls, dtype=NoneType, *args, **kwargs):
obj._last_pos_filled = obj._num - 1
return obj

@classmethod
def methods(cls):
return ['__new__', '_modify',
'append', 'delete', 'size',
'__str__', '__reversed__']

def _modify(self, force=False):
"""
Contracts the array if Num(T)/Size(T) falls
Expand Down
Loading