Skip to content

ImportError in contingency-analysis tutorial: visualization.py imports missing symbols (PBELoss, PQ/PV/REF) #42

@janu000

Description

@janu000

Summary

Running the contingency tutorial notebook fails during imports because gridfm_graphkit.utils.visualization imports symbols that are not available in the current codebase.

Reproduction

  1. Open examples/notebooks/Tutorial_contingency_analisys.ipynb
  2. Run the imports cell containing:
    • from gridfm_graphkit.utils.visualization import (...)
  3. Observe the error.

Actual behavior

Import fails with:

  • ImportError: cannot import name 'PBELoss' from gridfm_graphkit.training.loss
  • (after fixing that) ImportError: cannot import name 'PQ' from gridfm_graphkit.datasets.globals

Expected behavior

The tutorial import cell should run without errors in a clean install of the repository.

Root cause (likely)

visualization.py appears to use outdated imports:

  • PBELoss no longer exists (or was renamed/removed) in training.loss
  • bus type constants are now PQ_H, PV_H, REF_H in datasets.globals

Suggested fix

  • Make PBELoss import optional (or remove hard dependency from module import path)
  • Update constant imports in visualization.py to PQ_H, PV_H, REF_H (or provide backward-compatible aliases)

Environment

  • OS: Linux
  • Python: 3.12
  • Installed from current main checkout

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