Created
September 13, 2017 18:36
-
-
Save MattWoodhead/d5b6aabf8521b1162b745ee5a7a4c5d5 to your computer and use it in GitHub Desktop.
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
""" | |
Generator function for creating a range of floating point numbers | |
Numpy linspace is probably better unless you cannot have imports!! | |
""" | |
def frange(start, stop, step, precision=10): | |
""" a range generator that accepts floats """ | |
k = start | |
while k < stop: | |
yield round(k, precision) | |
k += step | |
if __name__ == "__main__": | |
print(list(frange(0.1, 0.9, 0.2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment