I have a fxn that loops through a huge set of data (using dask). The structure of the fxn is something like
def fxn(input 1, input 2, ... input 20):
component_1 = otherclass.fxn_a(input 1, input 2, input 3, input 4)
component_2 = otherclass.fxn_b(input 5, input 6, input 7, input 8, input 9, input 10)
component_3 = otherclass.fxn_c(input 11, input 12, input 13, input 14, input 15)
output_1 = outputclass.fxn_1(component_1, component_2, input 16, input 17, input 18)
output_2 = outputclass.fxn_2(component_3, input 19, input 20)
return output_1 + output_2
I was trying to think through how I should break this up. Should each component be made into its own small class with only the necessary inputs for it?
def fxn(input 16, input 17, input 18, input 19, input 20):
output_1 = outputclass.fxn_1(component1class.get_component(), component2class.get_component(), input 16, input 17, input 18)
output_2 = outputclass.fxn_2(component3class.get_component(), input 19, input 20)
return output_1 + output_2
And then even further:
def fxn():
output = outputclass.get_sum_components()
return output
Would that be the best approach or should I do something else?
Aucun commentaire:
Enregistrer un commentaire