Skip to content
New: Star-import, signal unraveling, Python 3.12 support, and more

# combining module

Functions for combining arrays.

Combine functions combine two or more NumPy arrays using a custom function. The emphasis here is done upon stacking the results into one NumPy array - since vectorbt is all about brute-forcing large spaces of hyper-parameters, concatenating the results of each hyper-parameter combination into a single DataFrame is important. All functions are available in both Python and Numba-compiled form.

## apply_and_concat function

    apply_and_concat(
        ntimes,
        apply_func,
        *args,
        n_outputs=None,
        jitted_loop=False,
        jitted_warmup=False,
        execute_kwargs=None,
        **kwargs
    )

Run `apply_func` function a number of times and concatenate the results depending upon how many array-like objects it generates.

`apply_func` must accept arguments `i`, `*args`, and `**kwargs`.

Set `jitted_loop` to True to use the JIT-compiled version.

All jitted iteration functions are resolved using JITRegistry.resolve().

Note

`n_outputs` must be set when `jitted_loop` is True.

Numba doesn't support variable keyword arguments.

## apply_and_concat_each function

    apply_and_concat_each(
        funcs_args,
        n_outputs=None,
        execute_kwargs=None
    )

Apply each function on its own set of positional and keyword arguments.

Executes the function using execute().

## apply_and_concat_multiple_nb function

    apply_and_concat_multiple_nb(
        ntimes,
        apply_func_nb,
        *args
    )

Run `apply_func_nb` that returns multiple arrays number of times.

Uses custom_apply_and_concat_multiple_nb().

## apply_and_concat_none_nb function

    apply_and_concat_none_nb(
        ntimes,
        apply_func_nb,
        *args
    )

Run `apply_func_nb` that returns nothing number of times.

Uses custom_apply_and_concat_none_nb().

## apply_and_concat_one_nb function

    apply_and_concat_one_nb(
        ntimes,
        apply_func_nb,
        *args
    )

Run `apply_func_nb` that returns one array number of times.

Uses custom_apply_and_concat_one_nb().

## combine_and_concat function

    combine_and_concat(
        obj,
        others,
        combine_func,
        *args,
        jitted_loop=False,
        **kwargs
    )

Combine `obj` with each in `others` using `combine_func` and concatenate.

select_and_combine_nb() is resolved using JITRegistry.resolve().

## combine_and_concat_nb function

    combine_and_concat_nb(
        obj,
        others,
        combine_func_nb,
        *args
    )

Numba-compiled version of combine_and_concat().

## combine_multiple function

    combine_multiple(
        objs,
        combine_func,
        *args,
        jitted_loop=False,
        **kwargs
    )

Combine `objs` pairwise into a single object.

Set `jitted_loop` to True to use the JIT-compiled version.

combine_multiple_nb() is resolved using JITRegistry.resolve().

Note

Numba doesn't support variable keyword arguments.

## combine_multiple_nb function

    combine_multiple_nb(
        objs,
        combine_func_nb,
        *args
    )

Numba-compiled version of combine_multiple().

## custom_apply_and_concat_multiple_nb function

    custom_apply_and_concat_multiple_nb(
        indices,
        apply_func_nb,
        *args
    )

Run `apply_func_nb` that returns multiple arrays for each index.

## custom_apply_and_concat_none_nb function

    custom_apply_and_concat_none_nb(
        indices,
        apply_func_nb,
        *args
    )

Run `apply_func_nb` that returns nothing for each index.

Meant for in-place outputs.

## custom_apply_and_concat_one_nb function

    custom_apply_and_concat_one_nb(
        indices,
        apply_func_nb,
        *args
    )

Run `apply_func_nb` that returns one array for each index.

## select_and_combine function

    select_and_combine(
        i,
        obj,
        others,
        combine_func,
        *args,
        **kwargs
    )

Combine `obj` with an array at position `i` in `others` using `combine_func`.

## select_and_combine_nb function

    select_and_combine_nb(
        i,
        obj,
        others,
        combine_func_nb,
        *args
    )

Numba-compiled version of select_and_combine().

## to_2d_multiple_nb function

    to_2d_multiple_nb(
        a
    )

Expand the dimensions of each array in `a` along axis 1.

## to_2d_one_nb function

    to_2d_one_nb(
        a
    )

Expand the dimensions of the array along the axis 1.

#### Cookie consent

We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.

- Google Analytics
- GitHub

Manage settings