Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Crash with numpy version 1.15 and above (function np.product removed) #374

@kvr2007

Description

@kvr2007

Hello!

First of all, great project, really wonderful to have it available as libre and open source code!

I was trying to run some of my scripts from 2022 in python3.12, and apparently numpy developers removed np.product at some point. So I get the following error when computing covariance matrix:

  File "...\site-packages\symfit\core\fit.py", line 574, in execute
    minimizer_ans.covariance_matrix = self.covariance_matrix(
                                      ^^^^^^^^^^^^^^^^^^^^^^^
  File ...\site-packages\symfit\core\fit.py", line 278, in covariance_matrix
    cov_matrix = self._covariance_matrix(best_fit_params,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\site-packages\symfit\core\fit.py", line 256, in _covariance_matrix
    raw_dof = np.sum([np.product(shape) for shape in self.data_shapes[1]])
                      ^^^^^^^^^^
  File "...\site-packages\numpy\__init__.py", line 428, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'product'

If I change np.product to np.prod all works as expected. I think it's the only place in all of symfit, where np.product is used. So I would suggest to change the code. Alternatively, one needs to fix the numpy version.

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