Created
February 13, 2017 11:00
-
-
Save Sasszem/92fff29753838a4943622f3740c9cf80 to your computer and use it in GitHub Desktop.
Thes if v1 vector is the multiple of v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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