Skip to content

ML4SCI/DeepLenseSim/Model-4 ImportError for CDM and ULDM with newer pyHalo versions #108

@Shrishagk

Description

@Shrishagk

While testing Model IV, I encountered ModuleNotFoundError and ImportError for CDM and ULDM imports. This appears to be due to API changes in newer versions of pyHalo. This issue tracks the implementation of version-agnostic factory imports to ensure compatibility.


##Proposed Fix
Replace the original import code with a try and except code block

try:
    from pyHalo.preset_models import preset_model_from_name
    # Use the factory function to get ULDM
    ULDM = preset_model_from_name('ULDM')
except Exception as e:
    # If that also fails, we'll need to see the specific error
    print(f"Failed to load ULDM: {e}")
    raise

Note:

  1. I tested using the latest commits from Fix hardcoded absolute paths in simulation scripts mwt5345/DeepLenseSim#1 (PR branch), since the fixes are not merged into main yet.
  2. Even after resolving imports, the scripts sim_cdm.py and sim_no_sub.py fail with a FileNotFoundError for Galaxy10_DECals.h5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions