psweep.psweep.pgrid#
- psweep.psweep.pgrid(plists)[source]#
Convenience function for the most common loop: nested loops with
itertools.product:ps.itr2params(itertools.product(a,b,c,...)).- Parameters:
plists (
Sequence[Sequence[dict]]) – List ofplist()results. If more than one, you can also provide plists as args, sopgrid(a,b,c)instead ofpgrid([a,b,c]).- Return type:
Sequence[dict]
Notes
For a single plist arg, you have to use
pgrid([a]).pgrid(a)won’t work. However, this edge case (passing one plist to pgrid) is not super useful, since>>> a=ps.plist("a", [1,2,3]) >>> a [{'a': 1}, {'a': 2}, {'a': 3}] >>> ps.pgrid([a]) [{'a': 1}, {'a': 2}, {'a': 3}]
Examples
>>> a = ps.plist('a', [1,2]) >>> b = ps.plist('b', [77,88]) >>> c = ps.plist('c', ['const']) >>> # same as pgrid([a,b,c]) >>> ps.pgrid(a,b,c) [{'a': 1, 'b': 77, 'c': 'const'}, {'a': 1, 'b': 88, 'c': 'const'}, {'a': 2, 'b': 77, 'c': 'const'}, {'a': 2, 'b': 88, 'c': 'const'}]
>>> ps.pgrid(zip(a,b),c) [{'a': 1, 'b': 77, 'c': 'const'}, {'a': 2, 'b': 88, 'c': 'const'}]