Skip to content

Sasmodel not supporting numpy 2.x, re-check when available #100

Open

Description

@bobleesj

Running

        print(load_model_info("ellipsoid"))

provides the following error:

===================================================== ERRORS ======================================================
_______________________________________ ERROR collecting tests/test_sas.py ________________________________________
tests/test_sas.py:66: in <module>
    from sasmodels.core import load_model, load_model_info
/Users/imac/miniconda3/envs/srfit_env/lib/python3.11/site-packages/sasmodels/core.py:22: in <module>
    from . import generate
/Users/imac/miniconda3/envs/srfit_env/lib/python3.11/site-packages/sasmodels/generate.py:173: in <module>
    from .modelinfo import Parameter
/Users/imac/miniconda3/envs/srfit_env/lib/python3.11/site-packages/sasmodels/modelinfo.py:82: in <module>
    def parse_parameter(name, units='', default=np.NaN,
/Users/imac/miniconda3/envs/srfit_env/lib/python3.11/site-packages/numpy/__init__.py:400: in __getattr__
    raise AttributeError(
E   AttributeError: `np.NaN` was removed in the NumPy 2.0 release. Use `np.nan` instead.

How to navigate for now

Reinstall numpy:

    Found existing installation: numpy 2.1.3
    Uninstalling numpy-2.1.3:
      Successfully uninstalled numpy-2.1.3
Successfully installed numpy-1.26.4

======== 2 passed, 2 warnings in 3.74s =========

Reference

There is a pending PR below.

SasView/sasmodels#613

Activity

  1. zmx27 commented on Jul 29, 2025

    @zmx27
    Contributor

    This issue is not relevant anymore. I've done a global search for print(load_model_info("ellipsoid")) and sasmodels.core, and I was not able to find any results. So this issue can be closed.

    But on a side note, it's a bit unclear to me what the tests are trying to import. First, the tests in test_sas.py are being skipped because the has_sas() function is returning false in conftest.py. Inside has_sas(), it tries to import sas.pr.invertor and sas.models, which both fail even when I have sasmodels installed in my conda environment. sasview cannot be installed because it only supports up to python 3.11, and diffpy.srfit supports up to python 3.13. Should it be trying to import sasmodels.models instead? I see that it should exist according to the github repo at this link: https://github.com/SasView/sasmodels/tree/master/sasmodels/models
    I'm not quite sure about sas.pr.invertor though.

  2. sbillinge commented on Jul 29, 2025

    @sbillinge
    Contributor

    that is exactly what this issue is about. We are skipping them because we can't load the sas feature and we can't load it because it is incompatible with our new build environment. So the task is to check that dependency and to see if the maintainers have pushed out a new release of the dependency. At least, that is the first step.

  3. zmx27 commented on Jul 29, 2025

    @zmx27
    Contributor

    Ah, I see. Thanks for the clarification. I think my main roadblock right now is figuring out how the current code is importing sas. Specifically, it issues calls to import sas.models, sas.dataloader, sas.pr, etc, none of which exists in the sasview repo nor the sasmodels repo. I do believe something like sasmodels.core or sasmodels.models as mentioned by Bob in the error traceback above are valid imports, but I don't see them in the source code. Should I work on trying to find replacements for sas.models imports and etc?

    I'd also like to mention that the maintainers of these packages have actually pushed out new releases according to their github repos. Both sasviews and sasmodels had a new release within the recent month or two. I've verified that the imports I mentioned above do not work even after installing both sasmodels and sasview (using the wheel file from their latest release).

  4. sbillinge commented on Jul 30, 2025

    @sbillinge
    Contributor

    ok, nice work. We will have to drill down a bit to look into this. Did you check if sasview/sasmodels support numpy 2.??? now?

  5. zmx27 commented on Jul 30, 2025

    @zmx27
    Contributor

    Yes, sasview supports numpy >= 2.0 now as of this PR: SasView/sasview#3141
    This PR also links additional PRs that separately updates the sasmodels and sasdata packages inside sasviews to use numpy >= 2.0.

  6. sbillinge commented on Jul 30, 2025

    @sbillinge
    Contributor

    OK, great news (and great work @zmx27). Let's try and dig down and figure out why these imports are not working then. During the sasview update process, did these guys change their API? To be honest I think we haven't had this working since 2010 or sthg (maybe more recenlty), so it could have happened a while ago. Basically, the task, which may need help from one of the more scattering-aware group members (realistically only Tina @tinatn29 is likely to know), is to figure out what our test is trying to do (fit some sas data with a model, but which model) and then track down where in the sasview architecture that model is stored and how it is accessed. If their refactor just moved the model and the signature is still the same we won't have to update our test too much (just the import), but if they changed the signature we will have to touch our test.

  7. zmx27 commented on Jul 30, 2025

    @zmx27
    Contributor

    Yes, I believe that the API has changed significantly since we last used it. Since you said that this code is very old (maybe even from 2010), the use of sas.models has been deprecated, and they have converted this feature into the sasmodels subpackage. I will make a PR trying to address these api changes in test_sas.py, and I'll try my best not to update our tests too much.

  8. zmx27 commented on Aug 3, 2025

    @zmx27
    Contributor

    As discussed in #126, let's move this issue to a later release

  9. sbillinge commented on Aug 3, 2025

    @sbillinge
    Contributor

    I think numpy 2x is now supported, but the current issue with having sasview as a dependency is that it is not released for Python above 3.11 (as of version 6.0).

  10. stevenhua0320 commented on Mar 31, 2026

    @stevenhua0320
    Contributor

    @zmx27 @sbillinge Hi guys, so what is the current status of this issue? what should I do for the appropriate testing of code behavior here?

  11. sbillinge commented on Apr 1, 2026

    @sbillinge
    Contributor

    please check if there is a version of sasview available for python 3.12-3.14. If there is, we can unskip these tests and get them passing.

  12. stevenhua0320 commented on Apr 7, 2026

    @stevenhua0320
    Contributor

    @sbillinge I mentioned in the last meeting we mentioned this since currently we did not list sasmodels as a dependency, we might skip this issue to a later version release (Moreover, because of the dependency issue for sasmodel, they could not release their latest version on conda-forge).

  13. modified the milestones: 3.3.0-rc.0, 3.4.0 on Apr 7, 2026
  14. sbillinge commented on Apr 7, 2026

    @sbillinge
    Contributor

    I moved it to 3.4.0 milestone

  15. modified the milestones: 3.4.0, 3.5.0 release on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions