@@ -14,7 +14,7 @@ class ChainConsumer(object):
1414 """ A class for consuming chains produced by an MCMC walk
1515
1616 """
17- __version__ = "0.10.0 "
17+ __version__ = "0.10.1 "
1818
1919 def __init__ (self ):
2020 logging .basicConfig ()
@@ -44,12 +44,14 @@ def add_chain(self, chain, parameters=None, name=None, weights=None, posterior=N
4444 ----------
4545 chain : str|ndarray|dict
4646 The chain to load. Normally a ``numpy.ndarray``. If a string is found, it
47- interprets the string as a filename and attempts to load it in. If a ``dict``
48- is passed in, it assumes the dict has keys of parameter names and values of
49- an array of samples. Notice that using a dictionary puts the order of
50- parameters in the output under the control of the python ``dict.keys()`` function.
47+ interprets the string as a filename and attempts to load it in. If a ``dict``
48+ is passed in, it assumes the dict has keys of parameter names and values of
49+ an array of samples. Notice that using a dictionary puts the order of
50+ parameters in the output under the control of the python ``dict.keys()`` function.
5151 parameters : list[str], optional
52- A list of parameter names, one for each column (dimension) in the chain.
52+ A list of parameter names, one for each column (dimension) in the chain. This parameter
53+ should remain ``None`` if a dictionary is given as ``chain``, as the parameter names
54+ are taken from the dictionary keys.
5355 name : str, optional
5456 The name of the chain. Used when plotting multiple chains at once.
5557 weights : ndarray, optional
@@ -164,6 +166,12 @@ def configure_general(self, bins=None, flip=True, rainbow=None, colours=None,
164166 How much to smooth the marginalised distributions using a gaussian filter.
165167 If ``kde`` is set to true, this parameter is ignored. Setting it to either
166168 ``0``, ``False`` or ``None`` disables smoothing.
169+
170+
171+ Returns
172+ -------
173+ ChainConsumer
174+ Itself, to allow chaining calls.
167175 """
168176 assert rainbow is None or colours is None , \
169177 "You cannot both ask for rainbow colours and then give explicit colours"
@@ -233,6 +241,11 @@ def configure_contour(self, sigmas=None, cloud=None, shade=None,
233241 shade_alpha : float|list[float], optional
234242 Filled contour alpha value override. Default is 1.0. If a list is passed, you can set the
235243 shade opacity for specific chains.
244+
245+ Returns
246+ -------
247+ ChainConsumer
248+ Itself, to allow chaining calls.
236249 """
237250 num_chains = len (self .chains )
238251
@@ -276,13 +289,20 @@ def configure_bar(self, summary=None, shade=None): # pragma: no cover
276289 chain consumer, as the consume changes configuration values depending on
277290 the supplied data.
278291
292+ Parameters
293+ ----------
279294 summary : bool, optional
280295 If overridden, sets whether parameter summaries should be set as axis titles.
281296 Will not work if you have multiple chains
282297 shade : bool|list[bool], optional
283298 If set to true, shades in confidence regions in under histogram. By default
284299 this happens if you less than 3 chains, but is disabled if you are comparing
285300 more chains. You can pass a list if you wish to shade some chains but not others.
301+
302+ Returns
303+ -------
304+ ChainConsumer
305+ Itself, to allow chaining calls.
286306 """
287307 if summary is not None :
288308 summary = summary and len (self .chains ) == 1
@@ -306,6 +326,16 @@ def configure_truth(self, **kwargs): # pragma: no cover
306326 if you want some basic control.
307327
308328 Default is to use an opaque black dashed line.
329+
330+ Parameters
331+ ----------
332+ kwargs : dict
333+ The keyword arguments to unwrap when calling ``axvline`` and ``axhline``.
334+
335+ Returns
336+ -------
337+ ChainConsumer
338+ Itself, to allow chaining calls.
309339 """
310340 if kwargs .get ("ls" ) is None and kwargs .get ("linestyle" ) is None :
311341 kwargs ["ls" ] = "--"
@@ -449,6 +479,11 @@ def get_parameter_text(self, lower, maximum, upper, wrap=False):
449479 The upper bound on the parameter
450480 wrap : bool
451481 Wrap output text in dollar signs for LaTeX
482+
483+ Returns
484+ -------
485+ str
486+ The formatted text given the parameter bounds
452487 """
453488 if lower is None or upper is None :
454489 return ""
@@ -488,7 +523,30 @@ def get_parameter_text(self, lower, maximum, upper, wrap=False):
488523 text = "$%s$" % text
489524 return text
490525
491- def divide_chain (self , i , num_walkers ):
526+ def divide_chain (self , num_walkers , i = 0 ):
527+ """
528+ Returns a ChainConsumer instance containing ``num_walker`` chains,
529+ each formed by splitting the ``i``th chain ``num_walker`` times.
530+
531+ This method might be useful if, for example, your chain was made using
532+ MCMC with 4 walkers. To check the sampling of all 4 walkers agree, you could
533+ call this with ``num_walkers=4`` and plot, and hopefully all four contours
534+ you would see all agree.
535+
536+ Parameters
537+ ----------
538+ num_walkers : int
539+ How many walkers (with equal number of samples) compose
540+ this chain.
541+ i : int,optional
542+ The index of the chain you wish to divide
543+
544+ Returns
545+ -------
546+ ChainConsumer
547+ A new ChainConsumer instance with the same settings as the parent instance, containing
548+ ``num_walker`` chains.
549+ """
492550 cs = np .split (self .chains [i ], num_walkers )
493551 ws = np .split (self .weights [i ], num_walkers )
494552 con = ChainConsumer ()
0 commit comments