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

View File

@ -2,8 +2,8 @@ import os
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

View File

@ -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

View File

@ -2,8 +2,8 @@ import os
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():

View File

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

View File

@ -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):

View File

@ -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:

View File

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

View File

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

View File

@ -112,7 +112,7 @@ class LinkedDeque(_DoublyLinkedBase):
...
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 @@ class LinkedDeque(_DoublyLinkedBase):
...
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()

View File

@ -17,7 +17,7 @@ class CircularQueue:
>>> 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 @@ class CircularQueue:
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')
"""

View File

@ -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)
[]
"""

View File

@ -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(

View File

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

View File

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

View File

@ -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!"

View File

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