Merge pull request #477 from ParthS007/patch1

Fixes#476 : Remove Multiple Unused Imports and Variable
This commit is contained in:
Parth Shandilya 2018-10-18 05:36:46 +05:30 committed by GitHub
commit fedb3e70ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 34 additions and 50 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@ __pycache__/
*.so
# Distribution / packaging
.vscode/
.Python
env/
build/

View File

@ -1,3 +0,0 @@
{
"python.pythonPath": "/usr/bin/python3"
}

View File

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

View File

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

View File

@ -1,8 +1,6 @@
from __future__ import print_function
import heapq
import numpy as np
import math
import copy
try:
xrange # Python 2

View File

@ -140,7 +140,7 @@ from collections import deque
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]:

View File

@ -3,7 +3,6 @@ a^2+b^2=c^2
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

View File

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

View File

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

View File

@ -24,7 +24,7 @@ class LinkedList:
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
@ -58,7 +58,7 @@ class LinkedList:
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

View File

@ -19,4 +19,4 @@ class LinkedList:
return item
def is_empty(self):
return self.head == None
return self.head is None

View File

@ -67,3 +67,4 @@ class Linked_List:
current = next_node
# Return prev in order to put the head at the end
Head = prev
return Head

View File

@ -1,5 +1,5 @@
import tensorflow as tf
from random import choice, shuffle
from random import shuffle
from numpy import array

View File

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

View File

@ -28,9 +28,8 @@ Game-Of-Life Rules:
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>'

View File

@ -290,7 +290,7 @@ def goldbach(number):
while (i < lenPN and loop):
j = i+1;
j = i+1
while (j < lenPN and loop):
@ -300,8 +300,7 @@ def goldbach(number):
ans.append(primeNumbers[i])
ans.append(primeNumbers[j])
j += 1;
j += 1
i += 1

View File

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

View File

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

View File

@ -4,7 +4,6 @@
# Sort large text files in a minimum amount of memory
#
import os
import sys
import argparse
class FileSplitter(object):

View File

@ -2,7 +2,6 @@ from __future__ import print_function
from random import randint
from tempfile import TemporaryFile
import numpy as np
import math

View File

@ -11,12 +11,12 @@ class node():
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)

View File

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