yt.testing.expand_keywords

yt.testing.expand_keywords(keywords, full=False)[source]

expand_keywords is a means for testing all possible keyword arguments in the nosetests. Simply pass it a dictionary of all the keyword arguments and all of the values for these arguments that you want to test.

It will return a list of kwargs dicts containing combinations of the various kwarg values you passed it. These can then be passed to the appropriate function in nosetests.

If full=True, then every possible combination of keywords is produced, otherwise, every keyword option is included at least once in the output list. Be careful, by using full=True, you may be in for an exponentially larger number of tests!

keywords : dict
a dictionary where the keys are the keywords for the function, and the values of each key are the possible values that this key can take in the function
full : bool
if set to True, every possible combination of given keywords is returned
Returns:

array of dicts :

An array of dictionaries to be individually passed to the appropriate function matching these kwargs.

Examples

>>> keywords = {}
>>> keywords['dpi'] = (50, 100, 200)
>>> keywords['cmap'] = ('algae', 'jet')
>>> list_of_kwargs = expand_keywords(keywords)
>>> print list_of_kwargs
array([{‘cmap’: ‘algae’, ‘dpi’: 50},
{‘cmap’: ‘jet’, ‘dpi’: 100}, {‘cmap’: ‘algae’, ‘dpi’: 200}], dtype=object)
>>> list_of_kwargs = expand_keywords(keywords, full=True)
>>> print list_of_kwargs
array([{‘cmap’: ‘algae’, ‘dpi’: 50},
{‘cmap’: ‘algae’, ‘dpi’: 100}, {‘cmap’: ‘algae’, ‘dpi’: 200}, {‘cmap’: ‘jet’, ‘dpi’: 50}, {‘cmap’: ‘jet’, ‘dpi’: 100}, {‘cmap’: ‘jet’, ‘dpi’: 200}], dtype=object)
>>> for kwargs in list_of_kwargs:
...     write_projection(*args, **kwargs)