Skip to content

Commit

Permalink
Merge branch 'master' into heaps
Browse files Browse the repository at this point in the history
  • Loading branch information
R. Kaleta committed Jan 21, 2024
2 parents d2c32fa + 3c3754e commit ee4f094
Show file tree
Hide file tree
Showing 41 changed files with 93 additions and 86 deletions.
2 changes: 1 addition & 1 deletion algolib/graphs/graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Structure of basic graph"""
"""Structure of basic graph."""
from abc import ABCMeta, abstractmethod
from typing import Any, Iterable, Union

Expand Down
2 changes: 1 addition & 1 deletion algolib/graphs/multipartite_graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Structure of multipartite graph"""
"""Structure of multipartite graph."""
from typing import Any, Collection, Iterable, Optional, Union

from .edge import Edge
Expand Down
2 changes: 1 addition & 1 deletion algolib/graphs/simple_graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Structure of simple graph"""
"""Structure of simple graph."""
from abc import ABCMeta, abstractmethod
from typing import Any, Iterable, Optional, Union

Expand Down
2 changes: 1 addition & 1 deletion algolib/graphs/tree_graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Structure of tree graph"""
"""Structure of tree graph."""
from typing import Any, Union

from .edge import Edge
Expand Down
2 changes: 1 addition & 1 deletion algolib/graphs/undirected_graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Structure of undirected graph"""
"""Structure of undirected graph."""
from abc import ABCMeta, abstractmethod
from typing import Any, Iterable, Optional

Expand Down
2 changes: 1 addition & 1 deletion algolib/text/edit_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def count_lcs(source: str,
previous_diagonal = previous_above
previous_above = distance[i + 1]
distance[i + 1] = previous_diagonal if element1 == element2 else min(
previous_above + deletion_cost, distance[i] + insertion_cost)
previous_above + deletion_cost, distance[i] + insertion_cost)

return distance[-1]

Expand Down
2 changes: 1 addition & 1 deletion tests/geometry/dim2/test_closets_points.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithm for pair of closest points in 2D"""
"""Tests: Algorithm for pair of closest points in 2D."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/geometry/dim2/test_convex_hull.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithm for convex hull in 2D (monotone chain)"""
"""Tests: Algorithm for convex hull in 2D (monotone chain)."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/geometry/dim2/test_geometry_2d.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for basic geometrical computations in 2D"""
"""Tests: Algorithms for basic geometrical computations in 2D."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/geometry/dim3/test_geometry_3d.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for basic geometrical computations in 3D"""
"""Tests: Algorithms for basic geometrical computations in 3D."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/graphs/algorithms/test_cutting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for graph cutting"""
"""Tests: Algorithms for graph cutting."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/graphs/algorithms/test_lowest_common_ancestor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: lowest common ancestor algorithm"""
"""Tests: lowest common ancestor algorithm."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/graphs/algorithms/test_matching.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Hopcroft-Karp algorithm for matching in bipartite graph"""
"""Tests: Hopcroft-Karp algorithm for matching in bipartite graph."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/graphs/algorithms/test_minimal_spanning_tree.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for minimal spanning tree"""
"""Tests: Algorithms for minimal spanning tree."""
import unittest

from assertpy import assert_that
Expand Down
18 changes: 9 additions & 9 deletions tests/graphs/algorithms/test_searching.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for graph searching"""
"""Tests: Algorithms for graph searching."""
import unittest

from assertpy import assert_that
Expand Down Expand Up @@ -128,8 +128,8 @@ def test__dfs_iterative__when_undirected_graph_and_many_roots__then_all_visited(
strategy = self._TestingStrategy()
# when
result = dfs_iterative(self._undirected_graph, strategy, [
self._undirected_graph.get_vertex(0),
self._undirected_graph.get_vertex(6)])
self._undirected_graph.get_vertex(0),
self._undirected_graph.get_vertex(6)])
# then
assert_that(sorted(result)).is_equal_to(sorted(self._undirected_graph.vertices))
assert_that(sorted(strategy.entries)).is_equal_to(sorted(self._undirected_graph.vertices))
Expand All @@ -156,8 +156,8 @@ def test__dfs_iterative__when_directed_graph_and_many_roots__then_all_visited(se
strategy = self._TestingStrategy()
# when
result = dfs_iterative(self._directed_graph, strategy, [
self._directed_graph.get_vertex(8),
self._directed_graph.get_vertex(6)])
self._directed_graph.get_vertex(8),
self._directed_graph.get_vertex(6)])
# then
assert_that(sorted(result)).is_equal_to(sorted(self._directed_graph.vertices))
assert_that(sorted(strategy.entries)).is_equal_to(sorted(self._undirected_graph.vertices))
Expand All @@ -182,8 +182,8 @@ def test__dfs_recursive__when_undirected_graph_and_many_roots__then_all_visited(
strategy = self._TestingStrategy()
# when
result = dfs_recursive(self._undirected_graph, strategy, [
self._undirected_graph.get_vertex(0),
self._undirected_graph.get_vertex(6)])
self._undirected_graph.get_vertex(0),
self._undirected_graph.get_vertex(6)])
# then
assert_that(sorted(result)).is_equal_to(sorted(self._undirected_graph.vertices))
assert_that(sorted(strategy.entries)).is_equal_to(sorted(self._undirected_graph.vertices))
Expand All @@ -210,8 +210,8 @@ def test__dfs_recursive__when_directed_graph_and_many_roots__then_all_visited(se
strategy = self._TestingStrategy()
# when
result = dfs_recursive(self._directed_graph, strategy, [
self._directed_graph.get_vertex(8),
self._directed_graph.get_vertex(6)])
self._directed_graph.get_vertex(8),
self._directed_graph.get_vertex(6)])
# then
assert_that(sorted(result)).is_equal_to(sorted(self._directed_graph.vertices))
assert_that(sorted(strategy.entries)).is_equal_to(sorted(self._undirected_graph.vertices))
Expand Down
2 changes: 1 addition & 1 deletion tests/graphs/algorithms/test_shortest_paths.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for shortest paths"""
"""Tests: Algorithms for shortest paths."""
import unittest

from assertpy import assert_that
Expand Down
18 changes: 9 additions & 9 deletions tests/graphs/algorithms/test_strongly_connected_components.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Strongly connected components algorithm"""
"""Tests: Strongly connected components algorithm."""
import unittest

from assertpy import assert_that
Expand Down Expand Up @@ -35,14 +35,14 @@ def test__find_scc__when_many_components_then_all_listed():
# then
assert_that(result).is_length(4)
assert_that(result).contains_only({graph.get_vertex(5)}, {graph.get_vertex(2)}, {
graph.get_vertex(0),
graph.get_vertex(1),
graph.get_vertex(3),
graph.get_vertex(4)}, {
graph.get_vertex(6),
graph.get_vertex(7),
graph.get_vertex(8),
graph.get_vertex(9)})
graph.get_vertex(0),
graph.get_vertex(1),
graph.get_vertex(3),
graph.get_vertex(4)}, {
graph.get_vertex(6),
graph.get_vertex(7),
graph.get_vertex(8),
graph.get_vertex(9)})

@staticmethod
def test__find_scc__when_single_component__then_all_vertices():
Expand Down
50 changes: 25 additions & 25 deletions tests/graphs/algorithms/test_topological_sorting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for topological sorting"""
"""Tests: Algorithms for topological sorting."""
import unittest

from assertpy import assert_that
Expand Down Expand Up @@ -93,30 +93,30 @@ def test__dfs_topological_sort__when_acyclic_graph__then_topological_order():
assert_that(result).is_instance_of(list)

assert_that(result).is_in([
graph.get_vertex(5),
graph.get_vertex(3),
graph.get_vertex(1),
graph.get_vertex(0),
graph.get_vertex(4),
graph.get_vertex(2)], [
graph.get_vertex(3),
graph.get_vertex(5),
graph.get_vertex(1),
graph.get_vertex(0),
graph.get_vertex(2),
graph.get_vertex(4)], [
graph.get_vertex(5),
graph.get_vertex(3),
graph.get_vertex(1),
graph.get_vertex(0),
graph.get_vertex(2),
graph.get_vertex(4)], [
graph.get_vertex(3),
graph.get_vertex(5),
graph.get_vertex(1),
graph.get_vertex(0),
graph.get_vertex(4),
graph.get_vertex(2)])
graph.get_vertex(5),
graph.get_vertex(3),
graph.get_vertex(1),
graph.get_vertex(0),
graph.get_vertex(4),
graph.get_vertex(2)], [
graph.get_vertex(3),
graph.get_vertex(5),
graph.get_vertex(1),
graph.get_vertex(0),
graph.get_vertex(2),
graph.get_vertex(4)], [
graph.get_vertex(5),
graph.get_vertex(3),
graph.get_vertex(1),
graph.get_vertex(0),
graph.get_vertex(2),
graph.get_vertex(4)], [
graph.get_vertex(3),
graph.get_vertex(5),
graph.get_vertex(1),
graph.get_vertex(0),
graph.get_vertex(4),
graph.get_vertex(2)])

@staticmethod
def test__dfs_topological_sort__when_cyclic_graph__then_directed_cyclic_graph_error():
Expand Down
2 changes: 1 addition & 1 deletion tests/graphs/test_directed_graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of directed graph"""
"""Tests: Structure of directed graph."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/graphs/test_multipartite_graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of multipartite graph"""
"""Tests: Structure of multipartite graph."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/graphs/test_tree_graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of tree graph """
"""Tests: Structure of tree graph ."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/graphs/test_undirected_graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of undirected graph"""
"""Tests: Structure of undirected graph."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/maths/test_equation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of linear equation"""
"""Tests: Structure of linear equation."""
import unittest

from assertpy import assert_that
Expand Down
9 changes: 5 additions & 4 deletions tests/maths/test_equation_system.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of linear equations system """
"""Tests: Structure of linear equations system ."""
import unittest

from assertpy import assert_that
Expand All @@ -16,9 +16,10 @@ def test__op_repr__then_string_representation():
# when
result = repr(test_object)
# then
assert_that(result).is_equal_to(
"EquationSystem(Equation([2, 3, -2], 15), Equation([7, -1, 0], 4), "
"Equation([-1, 6, 4], 9))")
assert_that(
result
).is_equal_to("EquationSystem(Equation([2, 3, -2], 15), Equation([7, -1, 0], 4), "
"Equation([-1, 6, 4], 9))")

@staticmethod
def test__op_str__then_string_representation():
Expand Down
2 changes: 1 addition & 1 deletion tests/maths/test_fraction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of fraction"""
"""Tests: Structure of fraction."""
from unittest import TestCase

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/maths/test_maths.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for basic mathematics"""
"""Tests: Algorithms for basic mathematics."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/maths/test_primes_searching.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for searching for prime numbers"""
"""Tests: Algorithms for searching for prime numbers."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/maths/test_primes_testing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for testing prime numbers"""
"""Tests: Algorithms for testing prime numbers."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/sequences/test_longest_common_subsequence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithm for longest common subsequence"""
"""Tests: Algorithm for longest common subsequence."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/sequences/test_longest_increasing_subsequence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithm for longest increasing subsequence"""
"""Tests: Algorithm for longest increasing subsequence."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/sequences/test_maximum_subarray.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for maximum subarray"""
"""Tests: Algorithms for maximum subarray."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/sequences/test_sorting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Algorithms for sequence sorting"""
"""Tests: Algorithms for sequence sorting."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/structures/heaps/test_double_heap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of double heap"""
"""Tests: Structure of double heap."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/structures/heaps/test_pairing_heap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of pairing heap"""
"""Tests: Structure of pairing heap."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/structures/test_avl_tree.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of AVL tree"""
"""Tests: Structure of AVL tree."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/structures/test_disjoint_sets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of disjoint sets (union-find)"""
"""Tests: Structure of disjoint sets (union-find)."""
import unittest

from assertpy import assert_that
Expand Down
2 changes: 1 addition & 1 deletion tests/text/test_base_words_dict.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests: Structure of base words dictionary using Karp-Miller-Rosenberg algorithm"""
"""Tests: Structure of base words dictionary using Karp-Miller-Rosenberg algorithm."""
import unittest

from assertpy import assert_that
Expand Down
Loading

0 comments on commit ee4f094

Please sign in to comment.