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
This commit is contained in:
Dhruv 2020-09-29 03:11:04 +05:30 committed by GitHub
parent 48357cea5b
commit 9016fe192f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 27 additions and 24 deletions

View File

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

View File

@ -2,8 +2,8 @@ import os
import random import random
import sys import sys
import cryptomath_module as cryptoMath from . import cryptomath_module as cryptoMath
import rabin_miller as rabinMiller from . import rabin_miller as rabinMiller
min_primitive_root = 3 min_primitive_root = 3

View File

@ -1,7 +1,7 @@
import os import os
import sys import sys
import rsa_key_generator as rkg from . import rsa_key_generator as rkg
DEFAULT_BLOCK_SIZE = 128 DEFAULT_BLOCK_SIZE = 128
BYTE_SIZE = 256 BYTE_SIZE = 256

View File

@ -2,8 +2,8 @@ import os
import random import random
import sys import sys
import cryptomath_module as cryptoMath from . import cryptomath_module as cryptoMath
import rabin_miller as rabinMiller from . import rabin_miller as rabinMiller
def main(): def main():

View File

@ -2,7 +2,7 @@ import os
import sys import sys
import time import time
import transposition_cipher as transCipher from . import transposition_cipher as transCipher
def main(): def main():

View File

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

View File

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

View File

@ -1,6 +1,6 @@
from collections import deque from collections import deque
from hash_table import HashTable from .hash_table import HashTable
class HashTableWithLinkedList(HashTable): class HashTableWithLinkedList(HashTable):

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from hash_table import HashTable from .hash_table import HashTable
class QuadraticProbing(HashTable): class QuadraticProbing(HashTable):

View File

@ -112,7 +112,7 @@ class LinkedDeque(_DoublyLinkedBase):
... ...
IndexError: remove_first from empty list IndexError: remove_first from empty list
>>> d.add_first('A') # doctest: +ELLIPSIS >>> 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() >>> d.remove_first()
'A' 'A'
>>> d.is_empty() >>> d.is_empty()
@ -132,7 +132,7 @@ class LinkedDeque(_DoublyLinkedBase):
... ...
IndexError: remove_first from empty list IndexError: remove_first from empty list
>>> d.add_first('A') # doctest: +ELLIPSIS >>> 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() >>> d.remove_last()
'A' 'A'
>>> d.is_empty() >>> d.is_empty()

View File

@ -17,7 +17,7 @@ class CircularQueue:
>>> len(cq) >>> len(cq)
0 0
>>> cq.enqueue("A") # doctest: +ELLIPSIS >>> cq.enqueue("A") # doctest: +ELLIPSIS
<circular_queue.CircularQueue object at ... <data_structures.queue.circular_queue.CircularQueue object at ...
>>> len(cq) >>> len(cq)
1 1
""" """
@ -48,11 +48,11 @@ class CircularQueue:
This function insert an element in the queue using self.rear value as an index This function insert an element in the queue using self.rear value as an index
>>> cq = CircularQueue(5) >>> cq = CircularQueue(5)
>>> cq.enqueue("A") # doctest: +ELLIPSIS >>> cq.enqueue("A") # doctest: +ELLIPSIS
<circular_queue.CircularQueue object at ... <data_structures.queue.circular_queue.CircularQueue object at ...
>>> (cq.size, cq.first()) >>> (cq.size, cq.first())
(1, 'A') (1, 'A')
>>> cq.enqueue("B") # doctest: +ELLIPSIS >>> cq.enqueue("B") # doctest: +ELLIPSIS
<circular_queue.CircularQueue object at ... <data_structures.queue.circular_queue.CircularQueue object at ...
>>> (cq.size, cq.first()) >>> (cq.size, cq.first())
(2, 'A') (2, 'A')
""" """

View File

@ -59,7 +59,7 @@ class FixedPriorityQueue:
>>> fpq.dequeue() >>> fpq.dequeue()
Traceback (most recent call last): 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) >>> print(fpq)
Priority 0: [] Priority 0: []
Priority 1: [] Priority 1: []
@ -141,7 +141,7 @@ class ElementPriorityQueue:
>>> epq.dequeue() >>> epq.dequeue()
Traceback (most recent call last): 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) >>> print(epq)
[] []
""" """

View File

@ -1,6 +1,6 @@
from math import atan, cos, radians, sin, tan from math import atan, cos, radians, sin, tan
from haversine_distance import haversine_distance from .haversine_distance import haversine_distance
def lamberts_ellipsoidal_distance( def lamberts_ellipsoidal_distance(

View File

@ -1,6 +1,6 @@
import unittest import unittest
import greedy_knapsack as kp from . import greedy_knapsack as kp
class TestClass(unittest.TestCase): class TestClass(unittest.TestCase):

View File

@ -8,7 +8,7 @@ This file contains the test-suite for the linear algebra library.
""" """
import unittest import unittest
from lib import Matrix, Vector, axpy, squareZeroMatrix, unitBasisVector, zeroVector from .lib import Matrix, Vector, axpy, squareZeroMatrix, unitBasisVector, zeroVector
class Test(unittest.TestCase): class Test(unittest.TestCase):

View File

@ -1,7 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os 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()) filepaths = list(good_file_paths())
assert filepaths, "good_file_paths() failed!" assert filepaths, "good_file_paths() failed!"

View File

@ -2,7 +2,7 @@
import math import math
import random import random
from hill_climbing import SearchProblem from .hill_climbing import SearchProblem
def simulated_annealing( def simulated_annealing(