Skip to content

Instantly share code, notes, and snippets.

@Sasszem
Created February 13, 2017 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sasszem/92fff29753838a4943622f3740c9cf80 to your computer and use it in GitHub Desktop.
Save Sasszem/92fff29753838a4943622f3740c9cf80 to your computer and use it in GitHub Desktop.
Thes if v1 vector is the multiple of v2
def test_multiple(v1,v2):
"""Test if the 1st vec is the multiple of the 2nd"""
try:
v=[a/b for a,b in zip(v1,v2) if (not (a==0 and b==0))] #Divide one-by-one, but when dividing 0 by 0, don't do anything(and don1T raise ZDE)
#print(v)
return(len(set(v))<=1) #If there are 0 or 1 types of values(empty list or all the same) then it's true, else it's not
except ZeroDivisionError: #If divide nonzero by zero
return False #Then it's not a multiple of it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment