sisl.mixing.StepMixer

class sisl.mixing.StepMixer(*yield_funcs)

Bases: BaseMixer

Step between different mixers in a user-defined fashion

This is handy for creating variable mixing schemes that alternates (or differently) between multiple mixers.

Examples

Alternate between two mixers:

>>> mixer = StepMixer(
...        StepMixer.yield_repeat(mix1, 1),
...        StepMixer.yield_repeat(mix2, 1))

One may also create custom based generators which can interact with the mixers in between different mixers:

>>> def gen():
...     yield mix1
...     mix1.history.clear()
...     yield mix1
...     yield mix1
...     yield mix2

A restart mixer for history mixers:

>>> def gen():
...     for _ in range(50):
...         yield mix
...     mix.history.clear()

Methods

next()

Return the current mixer, and step the internal mixer

yield_chain(*yield_funcs)

Returns a function which yields from each of the function arguments in turn

yield_repeat(mixer, n)

Returns a function which repeats mixer n times

mixer

Return the current mixer

__call__(f, df, *args, **kwargs)[source]

Apply the mixing routine

Return type

TypeVar(T)

__init__(*yield_funcs)[source]
property mixer: BaseMixer

Return the current mixer

next()[source]

Return the current mixer, and step the internal mixer

Return type

BaseMixer

classmethod yield_chain(*yield_funcs)[source]

Returns a function which yields from each of the function arguments in turn

Basically equivalent to a function which does this:

>>> for yield_func in yield_funcs:
...     yield from yield_func()
Parameters

*yield_funcs (Callable[[], Iterator[BaseMixer]]) – every function will be yield from

Return type

Callable[[], Iterator[BaseMixer]]

classmethod yield_repeat(mixer, n)[source]

Returns a function which repeats mixer n times

Return type

Callable[[], Iterator[BaseMixer]]