The Wayback Machine - https://web.archive.org/web/20210831161910/https://github.com/TheAlgorithms/Python/commit/9016fe192fdd3121b6cb20eafeed2dd9154848eb
Skip to content
Permalink
Browse files
Fix imports for all namespace packages (#2506)
* Fix imports as they're namespace packages

* Fix import for scripts/validate_filenames.py

* Fix path in doctest
  • Loading branch information
dhruvmanila committed Sep 28, 2020
1 parent 48357ce commit 9016fe192fdd3121b6cb20eafeed2dd9154848eb
@@ -1,7 +1,7 @@
import random
import sys

import cryptomath_module as cryptomath
from . import cryptomath_module as cryptomath

SYMBOLS = (
r""" !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`"""
@@ -2,8 +2,8 @@
import random
import sys

import cryptomath_module as cryptoMath
import rabin_miller as rabinMiller
from . import cryptomath_module as cryptoMath
from . import rabin_miller as rabinMiller

min_primitive_root = 3

@@ -1,7 +1,7 @@
import os
import sys

import rsa_key_generator as rkg
from . import rsa_key_generator as rkg

DEFAULT_BLOCK_SIZE = 128
BYTE_SIZE = 256
@@ -2,8 +2,8 @@
import random
import sys

import cryptomath_module as cryptoMath
import rabin_miller as rabinMiller
from . import cryptomath_module as cryptoMath
from . import rabin_miller as rabinMiller


def main():
@@ -2,7 +2,7 @@
import sys
import time

import transposition_cipher as transCipher
from . import transposition_cipher as transCipher


def main():
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from hash_table import HashTable
from number_theory.prime_numbers import check_prime, next_prime
from .hash_table import HashTable
from .number_theory.prime_numbers import check_prime, next_prime


class DoubleHash(HashTable):
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from number_theory.prime_numbers import next_prime
from .number_theory.prime_numbers import next_prime


class HashTable:
@@ -1,6 +1,6 @@
from collections import deque

from hash_table import HashTable
from .hash_table import HashTable


class HashTableWithLinkedList(HashTable):
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

from hash_table import HashTable
from .hash_table import HashTable


class QuadraticProbing(HashTable):
@@ -112,7 +112,7 @@ def remove_first(self):
...
IndexError: remove_first from empty list
>>> d.add_first('A') # doctest: +ELLIPSIS
<linked_list.deque_doubly.LinkedDeque object at ...
<data_structures.linked_list.deque_doubly.LinkedDeque object at ...
>>> d.remove_first()
'A'
>>> d.is_empty()
@@ -132,7 +132,7 @@ def remove_last(self):
...
IndexError: remove_first from empty list
>>> d.add_first('A') # doctest: +ELLIPSIS
<linked_list.deque_doubly.LinkedDeque object at ...
<data_structures.linked_list.deque_doubly.LinkedDeque object at ...
>>> d.remove_last()
'A'
>>> d.is_empty()
@@ -17,7 +17,7 @@ def __len__(self) -> int:
>>> len(cq)
0
>>> cq.enqueue("A") # doctest: +ELLIPSIS
<circular_queue.CircularQueue object at ...
<data_structures.queue.circular_queue.CircularQueue object at ...
>>> len(cq)
1
"""
@@ -48,11 +48,11 @@ def enqueue(self, data):
This function insert an element in the queue using self.rear value as an index
>>> cq = CircularQueue(5)
>>> cq.enqueue("A") # doctest: +ELLIPSIS
<circular_queue.CircularQueue object at ...
<data_structures.queue.circular_queue.CircularQueue object at ...
>>> (cq.size, cq.first())
(1, 'A')
>>> cq.enqueue("B") # doctest: +ELLIPSIS
<circular_queue.CircularQueue object at ...
<data_structures.queue.circular_queue.CircularQueue object at ...
>>> (cq.size, cq.first())
(2, 'A')
"""
@@ -59,7 +59,7 @@ class FixedPriorityQueue:
>>> fpq.dequeue()
Traceback (most recent call last):
...
priority_queue_using_list.UnderFlowError: All queues are empty
data_structures.queue.priority_queue_using_list.UnderFlowError: All queues are empty
>>> print(fpq)
Priority 0: []
Priority 1: []
@@ -141,7 +141,7 @@ class ElementPriorityQueue:
>>> epq.dequeue()
Traceback (most recent call last):
...
priority_queue_using_list.UnderFlowError: The queue is empty
data_structures.queue.priority_queue_using_list.UnderFlowError: The queue is empty
>>> print(epq)
[]
"""
@@ -1,6 +1,6 @@
from math import atan, cos, radians, sin, tan

from haversine_distance import haversine_distance
from .haversine_distance import haversine_distance


def lamberts_ellipsoidal_distance(
@@ -1,6 +1,6 @@
import unittest

import greedy_knapsack as kp
from . import greedy_knapsack as kp


class TestClass(unittest.TestCase):
@@ -8,7 +8,7 @@
"""
import unittest

from lib import Matrix, Vector, axpy, squareZeroMatrix, unitBasisVector, zeroVector
from .lib import Matrix, Vector, axpy, squareZeroMatrix, unitBasisVector, zeroVector


class Test(unittest.TestCase):
@@ -1,7 +1,10 @@
#!/usr/bin/env python3
import os

from build_directory_md import good_file_paths
try:
from .build_directory_md import good_file_paths
except ImportError:
from build_directory_md import good_file_paths

filepaths = list(good_file_paths())
assert filepaths, "good_file_paths() failed!"
@@ -2,7 +2,7 @@
import math
import random

from hill_climbing import SearchProblem
from .hill_climbing import SearchProblem


def simulated_annealing(

0 comments on commit 9016fe1

Please sign in to comment.