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

Importing from skfda import FDataGrid gives you ValueError #315

Closed
JavierHernandezMontes opened this issue Feb 3, 2021 · 6 comments
Closed
Labels

Comments

@JavierHernandezMontes
Copy link

JavierHernandezMontes commented Feb 3, 2021

Describe the bug
When importing FDataGrid from skfda it will launch the following error:
` ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

`To Reproduce
We are installing scikit-fda==0.3 with the following docker image:

FROM python:3.7-slim-buster

# ------------------------------------------------------------------------------------Basic Linux Packages------------------------------------------------------------------------------------
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
    ca-certificates \
    cmake \
    build-essential \
    gcc \
    g++ \
    git \
    wget \
    curl \
    libffi-dev \
    python-dev \
    unixodbc-dev \
    && rm -rf /var/lib/apt/lists/*

Expected behavior
To be able to import the library
Version information

  • OS: Linux
  • Python version: python:3.7-slim-buster
  • scikit-fda version: 0.3
  • Version of other packages involved [e.g. numpy, scipy, matplotlib, ... ]: numpy==1.16.2 , scipy==1.3.1, matplotlib==3.1.1

Additional context
Add any other context about the problem here.
Since 01/02/2021 we have the issue of not being able to import the library. Before of that date we could import it without problem with the same requirements and environment

Error Thread:

src/hvl/utils/model_utils.py:12: in <module>
    from skfda import FDataGrid
/usr/local/lib/python3.7/site-packages/skfda/__init__.py:36: in <module>
    from . import representation, datasets, preprocessing, exploratory, misc, ml
/bin/bash failed with return code: 1
/usr/local/lib/python3.7/site-packages/skfda/datasets/__init__.py:6: in <module>
return code: 1
    from ._samples_generators import (make_gaussian_process,
/usr/local/lib/python3.7/site-packages/skfda/datasets/_samples_generators.py:8: in <module>
    from ..misc import covariances
/usr/local/lib/python3.7/site-packages/skfda/misc/__init__.py:2: in <module>
    from . import covariances, kernels, metrics
/usr/local/lib/python3.7/site-packages/skfda/misc/covariances.py:9: in <module>
    from ..exploratory.visualization._utils import _create_figure, _figure_to_svg
/usr/local/lib/python3.7/site-packages/skfda/exploratory/__init__.py:4: in <module>
    from . import visualization
/usr/local/lib/python3.7/site-packages/skfda/exploratory/visualization/__init__.py:1: in <module>
    from . import clustering, representation
/usr/local/lib/python3.7/site-packages/skfda/exploratory/visualization/clustering.py:11: in <module>
    from ...ml.clustering.base_kmeans import FuzzyKMeans
/usr/local/lib/python3.7/site-packages/skfda/ml/__init__.py:2: in <module>
    from . import classification, clustering, regression
/usr/local/lib/python3.7/site-packages/skfda/ml/classification/__init__.py:3: in <module>
    from ..._neighbors import (KNeighborsClassifier, RadiusNeighborsClassifier,
/usr/local/lib/python3.7/site-packages/skfda/_neighbors/__init__.py:11: in <module>
    from .unsupervised import NearestNeighbors
>   ???
E   ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

deps/fdasrsf/optimum_reparam.pyx:1: ValueError
@vnmabus
Copy link
Member

vnmabus commented Feb 3, 2021

Hum, the timing is suspiciously similar to the release of numpy version 1.20, the 30th of January. Versions of scikit-fda older than version 0.5 compiled a vendored subset of fdasrsf implemented in C, and I think that could be related (maybe it is trying to compile against a numpy version different to the one installed, although I do not know how).

I would try updating to version 0.5 if you can, as it no longer vendors fdasrsf, but instead depends on it. I hope that you do not need to change much code to update to the newer version. Updating is also recommended nevertheless, as we do not have enough developers to support arbitrarily old versions.

@JavierHernandezMontes
Copy link
Author

JavierHernandezMontes commented Feb 3, 2021

@vnmabus thank you for the quick response. Do you know what version of pandas needs the version 0.5 to work? we are using pandas==0.25.3, and doesn't seem to be compatible. I've seen that it's at least pandas==1.0.0.

Upgrading numpy version to 1.20.0, it solves the issue of importing FDataGrid from skfda with skfda version 0.3.

@vnmabus
Copy link
Member

vnmabus commented Feb 3, 2021

What error did you get with pandas==0.25.3? I think we only use pandas in order to add support for using FDataGrid/FDataBasis as dataframe columns, inheriting from ExtensionArray, which appeared in pandas==0.23.0, but maybe the API changed afterwards and we are depending on that.

@JavierHernandezMontes
Copy link
Author

Hello @vnmabus,

We get the this error, when updating to skfda version 0.5 is the following:

from skfda import FDataGrid
Traceback (most recent call last):
File "", line 1, in
File "/home/jovyan/my-conda-envs/hydro2/lib/python3.7/site-packages/skfda/init.py", line 32, in
from .representation import FData
File "/home/jovyan/my-conda-envs/hydro2/lib/python3.7/site-packages/skfda/representation/init.py", line 1, in
from . import basis
File "/home/jovyan/my-conda-envs/hydro2/lib/python3.7/site-packages/skfda/representation/basis/init.py", line 1, in
from ._basis import Basis
File "/home/jovyan/my-conda-envs/hydro2/lib/python3.7/site-packages/skfda/representation/basis/_basis.py", line 14, in
from ..._utils import _domain_range, _reshape_eval_points, _same_domain
File "/home/jovyan/my-conda-envs/hydro2/lib/python3.7/site-packages/skfda/_utils/init.py", line 2, in
from ._utils import (
File "/home/jovyan/my-conda-envs/hydro2/lib/python3.7/site-packages/skfda/_utils/_utils.py", line 9, in
from pandas.api.indexers import check_array_indexer
ModuleNotFoundError: No module named 'pandas.api.indexers'

The function check_array_indexer from pandas.api.indexers was added in pandas 1.0.0:

https://pandas.pydata.org/docs/reference/api/pandas.api.indexers.check_array_indexer.html

Maybe would be good to specify it like a hard dependency.

Best

@JavierHernandezMontes
Copy link
Author

JavierHernandezMontes commented Feb 3, 2021

Also happening in hdbscan and pygeos

@vnmabus
Copy link
Member

vnmabus commented Nov 1, 2021

Pandas dependency on version 1.0 has been added to setup.py in 7c6f33d, so I guess we can close this issue.

@vnmabus vnmabus closed this as completed Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants