Skip to content

numpy.linalg.LinAlgError: Matrix is singular to machine precision #1

Description

@bg-aggregator

My python version is 3.12.2

The code I wrote is similar to their test.

    from pybreakpoints.baiperron import breakpoint
    import numpy as np
    import pandas as pd
    
    nile = pd.read_csv("tests/data/nile.csv")
    X = np.ones_like(nile)
    results = breakpoint(X, nile)

But I got errors.

mytest.py", line 9, in <module>
    results = breakpoint(X, nile)
              ^^^^^^^^^^^^^^^^^^^
\pybreakpoints\baiperron.py", line 76, in breakpoint
    ssr = recresid(X_[i:n, :], y_[i:n])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
\pybreakpoints\recresid_.py", line 134, in recresid
    rresid = _recresid(_X, _y, span)[span:]
             ^^^^^^^^^^^^^^^^^^^^^^^

\Python312\Lib\site-packages\numba\np\linalg.py", line 899, in _inv_err_handler
    raise np.linalg.LinAlgError(
numpy.linalg.LinAlgError: Matrix is singular to machine precision.

Since it is the data from the repo the test should at least be able to run. I suspect this is just data format problem but I'm new to python and not sure how to debug.

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