Skip to content

ValueError: Indicators must return (optionally a tuple of) numpy.arrays of same length as data (data shape: (465,); indicator "y_true" shape: (467,) #1280

Closed
@bravegag

Description

@bravegag

Expected behavior

The code that triggers this issue is self.I(lambda x: x['y_true'].values, self._y_pred, name='y_true') where len(self._y_pred) == len(self._y_pred['y_true']) obviously. What I am doing here is showing the plot y with true vs predictions to see the performance of my prediction algos. This was working fine in the previous release so I am reverting back to that for now.

Code sample

self.I(lambda x: x['y_true'].values, self._y_pred, name='y_true')

Actual behavior

I am getting since installing the new 0.6.4 release the following trace:

  File "$ENV_HOME/site-packages/backtesting/backtesting.py", line 162, in I
    raise ValueError(
ValueError: Indicators must return (optionally a tuple of) numpy.arrays of same length as `data` (data shape: (465,); indicator "y_true" shape: (467,), returned value: [ 0.  0.  1.  0.  0.  0.  0.  0. -1.  0.  0.  0.  0.  0.  0.  0.  1.  0.
  1. -1.  1.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. -1.  0.  0.  0.
  0.  0.  1.  1.  0.  1. -1.  0.  1.  0.  0.  0.  0.  0.  0.  0.  1.  0.
 -1.  0.  0.  1.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  1.  0.  1.  0.  0. -1.  0. -1.  0.  0.  0.  0. -1. -1.  1.  0. -1.  0.
  0. -1.  0. -1.  0.  0. -1.  0.  1.  1.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. -1.  0. -1.  0.  0.  0.  0.
  0.  0.  0. -1.  0.  0.  0.  1.  0.  0.  0.  0.  0.  0.  0.  0.  0.  1.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. -1.  0.  0. -1.
  0.  0.  0.  0.  0. -1.  0.  0. -1.  0.  0.  0.  0.  0.  1.  1.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. -1.  0.  0.  0.  0.  0.  0.  0.
  0. -1.  0.  0.  0.  0.  0.  0. -1. -1. -1.  0.  0.  0. -1.  1.  0.  0.
  1.  1.  0.  1. -1.  0.  0.  0.  0.  1.  0.  0.  0.  0.  0.  0. -1.  0.
  1.  0.  0.  0.  0.  0. -1. -1.  1.  1.  0.  0.  0. -1.  0.  0.  0.  0.
  0.  0. -1.  0.  0. -1.  1.  1. -1.  0.  0. -1.  0.  0.  0. -1.  0.  1.
  0.  0.  0.  0.  0.  0.  0.  1.  0.  1.  0.  1.  0.  0.  0.  0.  0. -1.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. -1.  0.  0.  0.  0.  0.  0.  1.
  0. -1.  0. -1.  1.  1.  1.  0.  0.  0.  0.  1.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  1. -1.  0.  0.
  1.  0. -1.  0.  0.  0.  1.  0.  0.  1.  1.  0.  0.  1.  1. -1.  0.  0.
 -1.  0.  0.  0.  0.  0.  0.  0.  0.  1.  0.  0.  0. -1.  0.  1.  0.  0.
  0.  0. -1.  0.  0.  0.  0.  0.  0.  0.  0.  0. -1. -1.  0.  0.  0.  0.
  0.  1. -1.  0.  0. -1.  0.  0. -1. -1.  1.  1.  0.  0.  0.  0.  1.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  1.  1.  0. -1.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  1.  1.  0.  0.  0.])

Additional info, steps to reproduce, full crash traceback, screenshots

No response

Software versions

  • backtesting.__version__: 0.6.4
  • pandas.__version__: 2.2.3
  • numpy.__version__: 2.1.3
  • bokeh.__version__: 3.7.0
  • OS: Linux Thor 6.8.0-60-generic When running GOOG example, no stats table is visible #63~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 22 19:00:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions