Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy versioning issue with clean install via pip #27

Closed
lazear opened this issue Oct 17, 2024 · 1 comment · Fixed by #29
Closed

Numpy versioning issue with clean install via pip #27

lazear opened this issue Oct 17, 2024 · 1 comment · Fixed by #29

Comments

@lazear
Copy link

lazear commented Oct 17, 2024

Steps taken to install

uv venv
source .venv/bin/activate
uv pip install peak-performance

Example code

import pandas
import numpy as np
import arviz as az
from pathlib import Path
from peak_performance import pipeline as pl, models, plots

path = Path(".").absolute() / "example" / "A1t1R1Part2_110_109.9_110.1.npy"
timeseries = np.load(path)


pmodel = models.define_model_skew(
    time=timeseries[0],
    intensity=timeseries[1]
)

idata = pl.sampling(pmodel, tune=6000, draws=2000)

path_result = Path(r"")

plots.plot_posterior(
    identifier="test_plot",
    time=timeseries[0],
    intensity=timeseries[1],
    path=path_result,
    idata=idata,
    discarded=False,
)

Error message

(peak-performance) ➜  peak-performance python p.py
Traceback (most recent call last):
  File "/home/michael/github/peak-performance/p.py", line 5, in <module>
    from peak_performance import pipeline as pl
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/peak_performance/__init__.py", line 3, in <module>
    from . import models, pipeline, plots
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/peak_performance/models.py", line 26, in <module>
    import pymc as pm
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/pymc/__init__.py", line 46, in <module>
    __set_compiler_flags()
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/pymc/__init__.py", line 29, in __set_compiler_flags
    import pytensor
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/pytensor/__init__.py", line 118, in <module>
    from pytensor import scalar, tensor
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/pytensor/tensor/__init__.py", line 103, in <module>
    import pytensor.tensor.rewriting
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/pytensor/tensor/rewriting/__init__.py", line 1, in <module>
    import pytensor.tensor.rewriting.basic
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/pytensor/tensor/rewriting/basic.py", line 43, in <module>
    from pytensor.raise_op import Assert, CheckAndRaise, assert_op
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/pytensor/raise_op.py", line 14, in <module>
    from pytensor.tensor.type import DenseTensorType
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/pytensor/tensor/type.py", line 801, in <module>
    cscalar = TensorType("complex64", ())
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/pytensor/tensor/type.py", line 105, in __init__
    if np.obj2sctype(dtype) is None:
       ^^^^^^^^^^^^^
  File "/home/michael/github/peak-performance/.venv/lib/python3.12/site-packages/numpy/__init__.py", line 400, in __getattr__
    raise AttributeError(
AttributeError: `np.obj2sctype` was removed in the NumPy 2.0 release. Use `np.dtype(obj).type` instead.

Installing numpy==1.26.1 mitigates the issue - not sure if you guys can pin the exact version?

@michaelosthege
Copy link
Member

This is a bug I've seen multiple times this week, with different projects. I suspect the NumPy pins by PyTensor are not strict enough for all install methods.
I couldn't reproduce it this time, but will nevertheless pin numpy <2 and remove it once PyTensor becomes compatible.

Thanks for pointing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants