Skip to content

Commit

Permalink
Remove Multiple Unused Imports and Variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthS007 committed Oct 17, 2018
1 parent 765a326 commit 0856a61
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 50 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __pycache__/
*.so

# Distribution / packaging
.vscode/
.Python
env/
build/
Expand Down
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

6 changes: 3 additions & 3 deletions ArithmeticAnalysis/LUdecomposition.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math
import numpy

def LUDecompose (table): #table that contains our data
def LUDecompose (table):
#table that contains our data
#table has to be a square array so we need to check first
rows,columns=numpy.shape(table)
L=numpy.zeros((rows,columns))
Expand Down Expand Up @@ -31,4 +31,4 @@ def LUDecompose (table): #table that contains our data
matrix =numpy.array([[2,-2,1],[0,1,2],[5,3,1]])
L,U = LUDecompose(matrix)
print(L)
print(U)
print(U)
4 changes: 1 addition & 3 deletions ArithmeticAnalysis/NewtonRaphsonMethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@

from sympy import diff
from decimal import Decimal
from math import sin, cos, exp

def NewtonRaphson(func, a):
''' Finds root from the point 'a' onwards by Newton-Raphson method '''
while True:
x = a
c = Decimal(a) - ( Decimal(eval(func)) / Decimal(eval(str(diff(func)))) )

x = c
a = c

# This number dictates the accuracy of the answer
if abs(eval(func)) < 10**-15:
return c
Expand Down
2 changes: 0 additions & 2 deletions Multi_Hueristic_Astar.py → Graphs/Multi_Hueristic_Astar.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import print_function
import heapq
import numpy as np
import math
import copy

try:
xrange # Python 2
Expand Down
2 changes: 1 addition & 1 deletion Graphs/basic-graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def dijk(G, s):


def topo(G, ind=None, Q=[1]):
if ind == None:
if ind is None:
ind = [0] * (len(G) + 1) # SInce oth Index is ignored
for u in G:
for v in G[u]:
Expand Down
1 change: 0 additions & 1 deletion Project Euler/Problem 09/sol2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Given N, Check if there exists any Pythagorean triplet for which a+b+c=N
Find maximum possible value of product of a,b,c among all such Pythagorean triplets, If there is no such Pythagorean triplet print -1."""
#!/bin/python3
import sys

product=-1
d=0
Expand Down
2 changes: 1 addition & 1 deletion Project Euler/Problem 15/sol1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import print_function
from math import factorial, ceil
from math import factorial

def lattice_paths(n):
n = 2*n #middle entry of odd rows starting at row 3 is the solution for n = 1, 2, 3,...
Expand Down
4 changes: 2 additions & 2 deletions ciphers/affine_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def getRandomKey():
while True:
keyA = random.randint(2, len(SYMBOLS))
keyB = random.randint(2, len(SYMBOLS))
if cryptoMath.gcd(keyA, len(SYMBOLS)) == 1:
return keyA * len(SYMBOLS) + keyB
if cryptoMath.gcd(keyA, len(SYMBOLS)) == 1:
return keyA * len(SYMBOLS) + keyB

if __name__ == '__main__':
import doctest
Expand Down
4 changes: 2 additions & 2 deletions data_structures/LinkedList/DoublyLinkedList.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def deleteHead(self):
temp = self.head
self.head = self.head.next # oldHead <--> 2ndElement(head)
self.head.previous = None # oldHead --> 2ndElement(head) nothing pointing at it so the old head will be removed
if(self.head == None):
if(self.head is None):
self.tail = None
return temp

Expand Down Expand Up @@ -58,7 +58,7 @@ def delete(self, x):
current.next.previous = current.previous # 1 <--> 3

def isEmpty(self): #Will return True if the list is empty
return(self.head == None)
return(self.head is None)

def display(self): #Prints contents of the list
current = self.head
Expand Down
2 changes: 1 addition & 1 deletion data_structures/LinkedList/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ def remove(self):
return item

def is_empty(self):
return self.head == None
return self.head is None
1 change: 1 addition & 0 deletions data_structures/LinkedList/singly_LinkedList.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ def reverse(Head):
current = next_node
# Return prev in order to put the head at the end
Head = prev
return Head
2 changes: 1 addition & 1 deletion dynamic_programming/k_means_clustering_tensorflow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import tensorflow as tf
from random import choice, shuffle
from random import shuffle
from numpy import array


Expand Down
1 change: 0 additions & 1 deletion machine_learning/linear_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def sum_of_square_error(data_x, data_y, len_data, theta):
:param theta : contains the feature vector
:return : sum of square error computed from given feature's
"""
error = 0.0
prod = np.dot(theta, data_x.transpose())
prod -= data_y.transpose()
sum_elem = np.sum(np.square(prod))
Expand Down
3 changes: 1 addition & 2 deletions other/game_of_life/game_o_life.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
comes a live cell, as if by reproduction.
'''
import numpy as np
import random, time, sys
import random, sys
from matplotlib import pyplot as plt
import matplotlib.animation as animation
from matplotlib.colors import ListedColormap

usage_doc='Usage of script: script_nama <size_of_canvas:int>'
Expand Down
7 changes: 3 additions & 4 deletions other/primelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def goldbach(number):

while (i < lenPN and loop):

j = i+1;
j = i+1


while (j < lenPN and loop):
Expand All @@ -300,9 +300,8 @@ def goldbach(number):
ans.append(primeNumbers[i])
ans.append(primeNumbers[j])

j += 1;


j += 1

i += 1

# precondition
Expand Down
1 change: 0 additions & 1 deletion searches/interpolation_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
This is pure python implementation of interpolation search algorithm
"""
from __future__ import print_function
import bisect

try:
raw_input # Python 2
Expand Down
31 changes: 14 additions & 17 deletions searches/quick_select.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import collections
import sys
import random
import time
import math

"""
A python implementation of the quick select algorithm, which is efficient for calculating the value that would appear in the index of a list if it would be sorted, even if it is not already sorted
https://en.wikipedia.org/wiki/Quickselect
Expand All @@ -25,23 +22,23 @@ def _partition(data, pivot):
equal.append(element)
return less, equal, greater

def quickSelect(list, k):
def quickSelect(list, k):
#k = len(list) // 2 when trying to find the median (index that value would be when list is sorted)
smaller = []
larger = []
pivot = random.randint(0, len(list) - 1)
pivot = list[pivot]
count = 0
smaller, equal, larger =_partition(list, pivot)
count = len(equal)
m = len(smaller)
smaller = []
larger = []
pivot = random.randint(0, len(list) - 1)
pivot = list[pivot]
count = 0
smaller, equal, larger =_partition(list, pivot)
count = len(equal)
m = len(smaller)

#k is the pivot
if m <= k < m + count:
#k is the pivot
if m <= k < m + count:
return pivot
# must be in smaller
elif m > k:
elif m > k:
return quickSelect(smaller, k)
#must be in larger
else:
else:
return quickSelect(larger, k - (m + count))
1 change: 0 additions & 1 deletion sorts/external-sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Sort large text files in a minimum amount of memory
#
import os
import sys
import argparse

class FileSplitter(object):
Expand Down
1 change: 0 additions & 1 deletion sorts/random_normaldistribution_quicksort.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from random import randint
from tempfile import TemporaryFile
import numpy as np
import math



Expand Down
4 changes: 2 additions & 2 deletions sorts/tree_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def __init__(self, val):
def insert(self,val):
if self.val:
if val < self.val:
if self.left == None:
if self.left is None:
self.left = node(val)
else:
self.left.insert(val)
elif val > self.val:
if self.right == None:
if self.right is None:
self.right = node(val)
else:
self.right.insert(val)
Expand Down
1 change: 0 additions & 1 deletion strings/min-cost-string-conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def assemble_transformation(ops, i, j):
return seq

if __name__ == '__main__':
from time import sleep
_, operations = compute_transform_tables('Python', 'Algorithms', -1, 1, 2, 2)

m = len(operations)
Expand Down

0 comments on commit 0856a61

Please sign in to comment.