The tests directory has gotten large over time as we've added new components with their test cases. It's absolutely a good thing to have thorough testing but as a almost-flat directory it's hard to find things and it's cumbersome to view so many files in IDEs. Further there are likely many areas of refactoring that we can do to reduce duplicate code and introduce more helper routines to do common tasks. I would suggest a few things to improve our tests:
TEST_CASES=[]
for arg1 in [2,4]:
for arg2 in [8,16]:
TEST_CASES.append([{"arg1": arg1, "arg2": arg2}, arg1, arg2])
A simple routine for doing product over dictionaries can reduce this code significantly:
def dict_product(**items): # should be put in core utils somewhere
keys=items.keys()
values=items.values()
for pvalues in product(*values):
yield dict(zip(keys, pvalues))
...
TEST_CASES=[[d, d["arg1"], d["arg2"]] for d in dict_product(arg1=[2,4], arg2=[8,16])]
The
testsdirectory has gotten large over time as we've added new components with their test cases. It's absolutely a good thing to have thorough testing but as a almost-flat directory it's hard to find things and it's cumbersome to view so many files in IDEs. Further there are likely many areas of refactoring that we can do to reduce duplicate code and introduce more helper routines to do common tasks. I would suggest a few things to improve our tests:testsinto subdirectories mirroring those in themonaidirectory. Tests for transforms would go undertransforms, those for networks undernetworks, etc. It may be necessary to have more directory structure under these as well but this doesn't need to be overcomplicated.parameterizedin deeply-nested for loops, eg.:A simple routine for doing product over dictionaries can reduce this code significantly: