module documentation

versatile shortcuts for quick typing in an (i)python shell,

or even using from cma.s import * in interactive sessions.

Provides various aliases from within the cma package, to be reached like cma.s....

Do not use this module for stable code developments!

This may not be actively maintained.

Class CMAES Undocumented
Function better_limits l, u are the plt.axis('tight') limits, return new limits.
Function clean Deprecated, renamed to ddir
Function ddir return "public" elements of a list or dict or of object.__dict__.
Function figpolish set better matplotlib figure default values
Function figshow pyplot.show to make a plotted figure show up
Function formated_number return $10^{{-3}}$, $0.01$,...,$1000$, $10^{{4}}$...
Function grid arguments are passed to matplotlib.pyplot.grid
Function log_tick_labels return positions, labels for plt.gca().set_?ticks with log-log plots.
Variable log_tick_labels_candidates candidate tick label positions [times 10^i]
Variable log_tick_labels_number minimal number of tick labels
Function _cdict return public attributes of obj as a dict.
def better_limits(l, u, log='linear', patch=3):

l, u are the plt.axis('tight') limits, return new limits.

This is a quick hack to compute tight-ish plot limits that do not cover up any extreme lines or symbols.

def clean(*args, **kwargs):

Deprecated, renamed to ddir

def ddir(obj, exclude='_'):

return "public" elements of a list or dict or of object.__dict__.

Ignore entries starting with exclude. Return a 'list` when obj is a list or a dict, return a dict otherwise. This is versatile and could change in future.

Typical usage: clean(dir()) or clean(obj) or clean(dir(), '__').

def figpolish(**kwargs):

set better matplotlib figure default values

for scrutinizing data, in particular grid and clip_on.

Set the axis limits, such that regression or grid lines plotted _after_ calling figpolish conveniently do not change the displayed area.

Accepts the following kw-arguments:

axis: str='tight-ish' where 'image', 'scaled' or 'square' are other notable values which all lead to equal scaling, True, 'auto', 'tight' are further alternatives, see help(plt.axis).

clip_on: bool=False do not clip lines outside of the frame, lines after calling figpolish are still clipped

frame: bool=True show frame (default in matplotlib)

grid: dict={'visible': True, 'which': 'both'}

legend: dict={} works for setting a legend title

patch: float=3 is the relative width between data and frame in percent. This is not a matplotlib parameter and ignored when 'axis' is given.

def figshow():

pyplot.show to make a plotted figure show up

def formated_number(n):

return $10^{{-3}}$, $0.01$,...,$1000$, $10^{{4}}$...

def grid(visible=True, which='both', **kwargs):

arguments are passed to matplotlib.pyplot.grid

def log_tick_labels(l, u):

return positions, labels for plt.gca().set_?ticks with log-log plots.

l and u are the axis limits, *plt.?lim(), tick labels are chosen based on log_tick_labels_candidates and log_tick_labels_number.

Example:

if plt.gca().get_xscale() == 'log':
    plt.gca().set_xticks(*log_tick_labels(*plt.xlim()))

Details: (1,2,4,6) leaves three empty lines 7-9, hence (1,2,5,7) seems preferable where also the smallest factors 7/5 and 10/7 are close to sqrt(2) and >=1.4 while 6/4=1.33 is smaller.

log_tick_labels_candidates: list =

candidate tick label positions [times 10^i]

log_tick_labels_number: int =

minimal number of tick labels

def _cdict(obj, exclude='_'):

return public attributes of obj as a dict.

Pass '__' as second argument to see "private" attributes.