[Bug]: multipletests import fails in receptive_field.py

Open Beginner friendly
#2,783 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
92/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
data

Research direction

Start at line 37 of allensdk/brain_observatory/receptive_field_analysis/receptive_field.py and compare the failing statsmodels import with the location of multipletests described in the issue. Re-run the reported receptive_field import with statsmodels 0.15.0; done means the module imports successfully without the ImportError.

Written by the indexing model from the issue text.

Description

bug

Describe the bug

receptive_field.py, L37

With statsmodels>=0.15.0, receptive_field.py fails to import multipletests from statsmodels.sandbox.stats.multicomp.

multipletests has been technically importable from sandbox.stats.multicomp for many versions (at least since some version 0.4.x). This is because in sandbox.stats.multicomp, multipletests was imported it globally from statsmodels.stats.multitest. In version 0.15.0, the global import was removed. As a result, the import in the allensdk's receptive_field.py now fails.

To reproduce

With statsmodels>=0.15.0 installed:

from allensdk.brain_observatory.receptive_field_analysis import receptive_field

Expected behavior

Import successful.

Actual behavior

Cell In[1], line 1
----> 1 from allensdk.brain_observatory.receptive_field_analysis import receptive_field

File python3.11/site-packages/allensdk/brain_observatory/receptive_field_analysis/receptive_field.py:37
      1 # Allen Institute Software License - This software license is the 2-clause BSD
      2 # license plus a third clause that prohibits redistribution for commercial
      3 # purposes without further permission.
   (...)     34 # POSSIBILITY OF SUCH DAMAGE.
     35 #
     36 from .eventdetection import detect_events
---> 37 from statsmodels.sandbox.stats.multicomp import multipletests
     38 import numpy as np
     39 from .utilities import get_A, get_A_blur, get_shuffle_matrix, get_components, \
     40     dict_generator

ImportError: cannot import name 'multipletests' from 'statsmodels.sandbox.stats.multicomp' (python3.11/site-packages/statsmodels/sandbox/stats/multicomp.py)

Solution

The function should be imported as:

from statsmodels.stats.multitest import multipletests

That is where it is defined in the current version of statsmodels. And as noted above, as far as I can tell, that is where it has been since one of the 0.4.x versions from 14 years ago. So, I would not expect any backward compatibility problems.

The earliest version I was able to install in my environment was statsmodels==0.13.5 (from around 4 years ago?), and the import worked.

Environment

  • OS and version: Ubuntu 24.04.4 LTS
  • Python version: 3.11
  • AllenSDK version: 2.16.2
  • Install method (pip/conda/source): pip
  • Execution context (local/CI/notebook/cluster): local
  • Any pinned dependencies or unusual environment details: Statsmodels version 0.15.0

Are you willing to submit a fix?

  • Yes, I can work on a PR for this
  • No, but I can help test a proposed fix
Dominant language
Jupyter Notebook
Stars
398
Forks
163
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AllenInstitute/AllenSDK

All issues in AllenInstitute/AllenSDK

Similar issues

More Data Engineering issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.