psweep.psweep.stargrid#
- psweep.psweep.stargrid(const, vary, vary_labels=None, vary_label_col='_vary', skip_dups=True)[source]#
Helper to create a specific param sampling pattern.
Vary params in a “star” pattern (and not a full pgrid) around constant values (middle of the “star”).
When doing that, duplicate psets can occur. By default try to filter them out (using
filter_params_unique()
) but ignore hash calculation errors and return non-reduced params in that case.- Return type:
Sequence
[dict
]
Examples
>>> import psweep as ps >>> const=dict(a=1, b=77, c=11) >>> a=ps.plist("a", [1,2,3,4]) >>> b=ps.plist("b", [77,88,99]) >>> c=ps.plist("c", [11,22,33,44])
>>> ps.stargrid(const, vary=[a, b]) [{'a': 1, 'b': 77, 'c': 11}, {'a': 2, 'b': 77, 'c': 11}, {'a': 3, 'b': 77, 'c': 11}, {'a': 4, 'b': 77, 'c': 11}, {'a': 1, 'b': 88, 'c': 11}, {'a': 1, 'b': 99, 'c': 11}]
>>> ps.stargrid(const, vary=[a, b], skip_dups=False) [{'a': 1, 'b': 77, 'c': 11}, {'a': 2, 'b': 77, 'c': 11}, {'a': 3, 'b': 77, 'c': 11}, {'a': 4, 'b': 77, 'c': 11}, {'a': 1, 'b': 77, 'c': 11}, {'a': 1, 'b': 88, 'c': 11}, {'a': 1, 'b': 99, 'c': 11}]
>>> ps.stargrid(const, vary=[a, b], vary_labels=["a", "b"]) [{'a': 1, 'b': 77, 'c': 11, '_vary': 'a'}, {'a': 2, 'b': 77, 'c': 11, '_vary': 'a'}, {'a': 3, 'b': 77, 'c': 11, '_vary': 'a'}, {'a': 4, 'b': 77, 'c': 11, '_vary': 'a'}, {'a': 1, 'b': 88, 'c': 11, '_vary': 'b'}, {'a': 1, 'b': 99, 'c': 11, '_vary': 'b'}]
>>> ps.stargrid(const, vary=[ps.itr2params(zip(a,c)),b], vary_labels=["a+c", "b"]) [{'a': 1, 'b': 77, 'c': 11, '_vary': 'a+c'}, {'a': 2, 'b': 77, 'c': 22, '_vary': 'a+c'}, {'a': 3, 'b': 77, 'c': 33, '_vary': 'a+c'}, {'a': 4, 'b': 77, 'c': 44, '_vary': 'a+c'}, {'a': 1, 'b': 88, 'c': 11, '_vary': 'b'}, {'a': 1, 'b': 99, 'c': 11, '_vary': 'b'}]
>>> ps.stargrid(const, vary=[ps.pgrid([zip(a,c)]),b], vary_labels=["a+c", "b"]) [{'a': 1, 'b': 77, 'c': 11, '_vary': 'a+c'}, {'a': 2, 'b': 77, 'c': 22, '_vary': 'a+c'}, {'a': 3, 'b': 77, 'c': 33, '_vary': 'a+c'}, {'a': 4, 'b': 77, 'c': 44, '_vary': 'a+c'}, {'a': 1, 'b': 88, 'c': 11, '_vary': 'b'}, {'a': 1, 'b': 99, 'c': 11, '_vary': 'b'}]