Skip to content

Refactoring test.py to support multiple dataset paths and modular transforms#126

Open
BeathovenGala wants to merge 1 commit intoML4SCI:mainfrom
BeathovenGala:main
Open

Refactoring test.py to support multiple dataset paths and modular transforms#126
BeathovenGala wants to merge 1 commit intoML4SCI:mainfrom
BeathovenGala:main

Conversation

@BeathovenGala
Copy link

What this PR does

Refactors DeepLense_Diffusion_Rishi/utils/test.py into a robust, configurable script for visualizing lens .npy data. The original script loaded data from a single hardcoded path, used a fixed index, and had minimal error handling. This PR:

  • Supports multiple dataset paths (e.g., cdm_regress_multi_param, npy_lenses, real_lenses_dataset).
  • Makes the transform pipeline modular via get_transforms().
  • Handles missing files, invalid directories, and constant‑value arrays gracefully.
  • Improves maintainability and reproducibility for the DeepLense Diffusion project.

Changes for Issue #124

  • Use SCRIPT_DIR and DEFAULT_DATA_PATHS to locate datasets relative to the script location:

    DEFAULT_DATA_PATHS = [
        os.path.join(SCRIPT_DIR, "../Data/cdm_regress_multi_param_model_ii/cdm_regress_multi_param/"),
        os.path.join(SCRIPT_DIR, "../Data/npy_lenses-20240731T044737Z-001/npy_lenses/"),
        os.path.join(SCRIPT_DIR, "../Data/real_lenses_dataset/lenses"),
    ]
  • Replaced hardcoded logic with argparse arguments (--data_dirs, --index, --output_dir, --filename).

  • Print selected directory, file path, original shape/range, and transformed tensor shape/range for better debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant