lanl / SEPIA

Simulation-Enabled Prediction, Inference, and Analysis: physics-informed statistical learning.
Other
33 stars 7 forks source link

Issue arising with current version of scipy #51

Closed sirmurphalot closed 1 year ago

sirmurphalot commented 1 year ago

I think that the current version of scipy is causing issues with loading sepia . From my module loading:

import scipy
import scipy.signal.signaltools
import seaborn as sns
import matplotlib.pyplot as matplt
import numpy as np
import pandas as pd
import math
import random
from sepia import *

Gives the following error:

runcell(0, '/Users/murph/Documents/GP_playtime/GP_sepia.py')
Traceback (most recent call last):

  File "/Users/murph/Documents/GP_playtime/GP_sepia.py", line 31, in <module>
    from sepia import *

  File "/Users/murph/Documents/SEPIA-master/sepia/__init__.py", line 3, in <module>
    from .SepiaModel import ModelContainer

  File "/Users/murph/Documents/SEPIA-master/sepia/SepiaModel.py", line 7, in <module>
    import statsmodels.api as sm

  File "/opt/anaconda3/lib/python3.8/site-packages/statsmodels/api.py", line 27, in <module>
    from .tsa import api as tsa

  File "/opt/anaconda3/lib/python3.8/site-packages/statsmodels/tsa/api.py", line 31, in <module>
    from .filters import api as filters

  File "/opt/anaconda3/lib/python3.8/site-packages/statsmodels/tsa/filters/api.py", line 6, in <module>
    from .filtertools import miso_lfilter, convolution_filter, recursive_filter

  File "/opt/anaconda3/lib/python3.8/site-packages/statsmodels/tsa/filters/filtertools.py", line 18, in <module>
    from scipy.signal.signaltools import _centered as trim_centered

ImportError: cannot import name '_centered' from 'scipy.signal.signaltools' (/opt/anaconda3/lib/python3.8/site-packages/scipy/signal/signaltools.py)

Per the suggestion here, I worked around this by placing:

import  scipy.signal.signaltools

def _centered(arr, newsize):
    # Return the center newsize portion of the array.
    newsize = np.asarray(newsize)
    currsize = np.array(arr.shape)
    startind = (currsize - newsize) // 2
    endind = startind + newsize
    myslice = [slice(startind[k], endind[k]) for k in range(len(endind))]
    return arr[tuple(myslice)]

scipy.signal.signaltools._centered = _centered

before my sepia call. This is all with Python 3.8.8 and Scipy 1.10.1.

luiarthur commented 1 year ago

Hi, I'm not able to replicate the error with the following conda environment on linux. Looks like you're on windows. Don't have access to a windows machine, but tests passed on windows with python 3.8. Can you try again with this environment?

name: issue-51
channels:
  - defaults
dependencies:
  - python=3.8.8
  - tqdm
  - numpy
  - pandas
  - scipy=1.10.1
  - seaborn
  - notebook
  - statsmodels
sirmurphalot commented 1 year ago

Upon further investigation, I think this was an issue with my conda environment having loaded statsmodels.api, which caused the issue with that version of scipy -- not sepia's value at all. Thanks for your attention!