Skip to content

Instantly share code, notes, and snippets.

@wilbefast
Last active January 7, 2017 15:27
Show Gist options
  • Save wilbefast/cfa8e00ddf6da25154926d75f6e3ad70 to your computer and use it in GitHub Desktop.
Save wilbefast/cfa8e00ddf6da25154926d75f6e3ad70 to your computer and use it in GitHub Desktop.
For Alexia
# VARIABLE LIST
midpoint_part1_TX = 0
midpoint_part1_TZ = 0
midpoint_part2_TX = 0
midpoint_part2_TZ = 0
midpoint_part3_TX = 0
midpoint_part3_TZ = 0
length_partl = 0
length_part2 = 0
length_part3 = 0
rotateZ_partl = 0
rotateZ_part2 = 0
rotateZ_part3 = 0
# FIT RANGE
midpoint_part1_TX = fitRange(random.choice(seedList), 1, 0, 0.5, -0.4)
midpoint_part1_TZ = fitRange(random.choice(seedList), 1, 0, 0.2, 0.01)
midpoint_part2_TX = fitRange(random.choice(seedList), 1, 0, 0.5, -0.4)
midpoint_part2_TZ = fitRange(random.choice(seedList), 1, 0, 0.2, 0.01)
midpoint_part3_TX = fitRange(random.choice(seedList), 1, 0, 0.5, -0.4)
midpoint_part3_TZ = fitRange(random.choice(seedList), 1, 0, 0.1, 0.01)
length_partl = fitRange(random.choice(seedList), 1, 0, 0.5, 2.5)
length_part2 = fitRange(random.choice(seedList), 1, 0, 0.1, 2)
length_part3 = fitRange(random.choice(seedList), 1, 0, 0.01, 1)
rotateZ_partl = fitRange(random.choice(seedList), 1, 0, 10, 60)
rotateZ_part2 = fitRange(random.choice(seedList), 1, 0, -45, 0)
rotateZ_part3 = fitRange(random.choice(seedList), 1, 0, 10, 45)
# OPS
op.par.value0 = midpoint_part1_TX
op.par.valuel = midpoint_partl_TZ
op.par.value2 = midpoint_part2_TX
op.par.value3 = midpoint_part2_TZ
op.par.value4 = midpoint_part3_TX
op.par.value5 = midpoint_part3_TZ
op.par.value6 = length_partl
op.par.value7 = length_part2
op.par.value8 = length_part3
op.par.value9 = rotateZ_partl
op.par.value10 = rotateZ_part2
op.par.valuell = rotateZ_part3
def part1( ):
"This one only does the part one stuff "
midpoint_part1_TX = 0
midpoint_part1_TZ = 0
length_partl = 0
rotateZ_partl = 0
midpoint_part1_TX = fitRange(random.choice(seedList), 1, 0, 0.5, -0.4)
midpoint_part1_TZ = fitRange(random.choice(seedList), 1, 0, 0.2, 0.01)
op.par.value0 = midpoint_part1_TX
op.par.valuel = midpoint_partl_TZ
op.par.value6 = length_partl
op.par.value9 = rotateZ_partl
return
def part2( ):
"This one only does the part two stuff "
midpoint_part2_TX = 0
midpoint_part2_TZ = 0
length_part2 = 0
rotateZ_part2 = 0
midpoint_part2_TX = fitRange(random.choice(seedList), 1, 0, 0.5, -0.4)
midpoint_part2_TZ = fitRange(random.choice(seedList), 1, 0, 0.2, 0.01)
op.par.value3 = midpoint_part2_TX
op.par.value4 = midpoint_part2_TZ
op.par.value7 = length_part2
op.par.value10 = rotateZ_part2
return
def part3( ):
"This one only does the part three stuff "
midpoint_part3_TX = 0
midpoint_part3_TZ = 0
length_part3 = 0
rotateZ_part3 = 0
midpoint_part3_TX = fitRange(random.choice(seedList), 1, 0, 0.5, -0.4)
midpoint_part3_TZ = fitRange(random.choice(seedList), 1, 0, 0.2, 0.01)
op.par.value5 = midpoint_part3_TX
op.par.value6 = midpoint_part3_TZ
op.par.value8 = length_part3
op.par.value11 = rotateZ_part3
return
if doPart1:
part1()
if doPart2:
part2()
if doPart3:
part3()
@Bradshaw
Copy link

Bradshaw commented Jan 7, 2017

You can just put bare strings in Python?
What do they do? Just evaluate to a string and continue?

@wilbefast
Copy link
Author

Apparently that's how you do function documentation in Python: https://www.python.org/dev/peps/pep-0257/#what-is-a-docstring

@blobsnfluff
Copy link

Avec les commentaires ^^

#liste des choix possibles
varListNames = ['midpoint_part1_TX', 'midpoint_part1_TZ', 'midpoint_part2_TX', 'midpoint_part2_TZ', 'midpoint_part3_TX', 'midpoint_part3_TZ', 'length_part1',
'length_part2', 'length_part3', 'rotateZ_part1','rotateZ_part2', 'rotateZ_part3']

#evaluation du nombre de choix possibles
listLen = len(varListNames)
print (listLen)
choiceList = list(range(0,listLen))
samplesNum = random.choice(choiceList)

#je prends un nombre compris entre 0 et le nombre de choix
varList = random.sample(set(varListNames), samplesNum)

#et je les execute si jamais ils sont dans la liste
for i in varList:

	if 'midpoint_part1_TX' in i:
		midpoint_part1_TX = fitRange(random.choice(seedList), 1, 0,  0.5, -0.4)
		op.par.value0 = midpoint_part1_TX
		print ('midpoint_part1_TX PROCESSED ')
		
	if 'midpoint_part1_TZ' in i:
		midpoint_part1_TZ = fitRange(random.choice(seedList), 1, 0,  0.5, -0.4)
		op.par.value1 = midpoint_part1_TZ
		print ('midpoint_part1_TZ PROCESSED ')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment