Created
November 6, 2017 03:48
-
-
Save impiaaa/c5e1fda2e49b7f0a4f1dabfbf6ebf91d 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
import re, random, sys, os | |
def randrepl(matchobj): | |
if "matrix" in s[matchobj.start()-30:matchobj.start()]: return matchobj.group(0) | |
v = float(matchobj.group(2)) | |
v = random.gauss(v, 0.1) | |
return matchobj.group(1)+"%.3f"%v | |
pat = re.compile("([, (])(-?[0-9]+(\.[0-9]+)?)") | |
s = open(sys.argv[1]).read() | |
for i in range(200): | |
s = pat.sub(randrepl, s) | |
open("%s-%03d.svg"%(os.path.splitext(sys.argv[1])[0], i), 'w').write(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment