Skip to content

Conversation

@pzharrington
Copy link
Collaborator

PhysicsNeMo Pull Request

Description

Move the insolation and zenith angle back to utils from nn. My arg for doing this is that they are not torch functions and are just more general utility functions.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.
  • The CHANGELOG.md is up to date with these changes.
  • An issue is linked to this pull request.

Dependencies

Review Process

All PRs are reviewed by the PhysicsNeMo team before merging.

Depending on which files are changed, GitHub may automatically assign a maintainer for review.

We are also testing AI-based code review tools (e.g., Greptile), which may add automated comments with a confidence score.
This score reflects the AI’s assessment of merge readiness and is not a qualitative judgment of your work, nor is
it an indication that the PR will be accepted / rejected.

AI-generated feedback should be reviewed critically for usefulness.
You are not required to respond to every AI comment, but they are intended to help both authors and reviewers.
Please react to Greptile comments with 👍 or 👎 to provide feedback on their accuracy.

@pzharrington pzharrington self-assigned this Nov 6, 2025
@pzharrington pzharrington changed the title unmigrate the insolation utils Unmigrate the insolation utils Nov 6, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

Moves insolation.py and zenith_angle.py from physicsnemo/nn/ back to physicsnemo/utils/. The rationale is sound - these modules only use numpy/pandas/datetime and have no torch dependencies, making them general utility functions rather than neural network components.

Critical Issues Found:

  • Test file test/nn/test_zenith_angle.py imports from the old physicsnemo.nn.zenith_angle path and will break
  • Compatibility layer in physicsnemo/compat/__init__.py has backwards mappings that need to be reversed to point old nn.* paths to new utils.* paths

Confidence Score: 1/5

  • This PR will break existing tests and has incorrect compatibility mappings
  • The file moves themselves are clean and well-justified, but two critical issues prevent this from being merge-ready: (1) test imports still point to the old location and will fail, and (2) the compatibility layer mappings are backwards and need to be inverted
  • Pay attention to test/nn/test_zenith_angle.py (broken import) and physicsnemo/compat/__init__.py (backwards compat mappings)

Important Files Changed

File Analysis

Filename Score Overview
physicsnemo/utils/insolation.py 5/5 File moved from nn/ to utils/ with no content changes - safe
physicsnemo/utils/zenith_angle.py 5/5 File moved from nn/ to utils/ with no content changes - safe

Sequence Diagram

sequenceDiagram
    participant PR as PR Author
    participant nn as physicsnemo.nn
    participant utils as physicsnemo.utils
    participant compat as physicsnemo.compat
    participant tests as test/nn/test_zenith_angle.py
    
    Note over PR,tests: File Migration (v2.0-refactor)
    
    PR->>nn: Remove insolation.py
    PR->>nn: Remove zenith_angle.py
    PR->>utils: Add insolation.py
    PR->>utils: Add zenith_angle.py
    
    Note over compat: ⚠️ OUTDATED: Still maps utils→nn
    compat-->>nn: Points to OLD location
    
    Note over tests: ⚠️ BROKEN: Imports from old path
    tests-->>nn: Imports from physicsnemo.nn.zenith_angle
Loading

Additional Comments (2)

  1. physicsnemo/utils/zenith_angle.py, line 1 (link)

    logic: the test file at test/nn/test_zenith_angle.py:34 still imports from physicsnemo.nn.zenith_angle and will break after this move

  2. physicsnemo/utils/insolation.py, line 1 (link)

    logic: the compat map at physicsnemo/compat/__init__.py:65-66 has backwards mappings - it maps utils.insolationnn.insolation and utils.zenith_anglenn.zenith_angle, but after this PR the files ARE in utils, so the compat layer should map the OLD nn.* paths to the NEW utils.* paths

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

Reverted the migration of insolation and zenith_angle modules from physicsnemo.nn back to physicsnemo.utils.

  • Removed compatibility mappings in COMPAT_MAP for physicsnemo.utils.insolationphysicsnemo.nn.insolation and physicsnemo.utils.zenith_anglephysicsnemo.nn.zenith_angle
  • Added comprehensive test file test/utils/test_zenith_angle.py that imports directly from physicsnemo.utils.zenith_angle
  • The modules are now located in their original utils/ directory, which is more appropriate since they are general-purpose utility functions rather than neural network components
  • No other code in the codebase imports from the nn locations, ensuring this change is safe

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • Simple, clean refactoring that moves modules back to their logical location. No code imports from the nn paths, and the test file correctly imports from utils. The changes are minimal and well-contained.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
physicsnemo/compat/init.py 5/5 Removed deprecated compatibility mappings for insolation and zenith_angle from nn back to utils
test/utils/test_zenith_angle.py 5/5 Added comprehensive test file for zenith angle utilities with proper imports from physicsnemo.utils.zenith_angle

Sequence Diagram

sequenceDiagram
    participant User as User Code
    participant Utils as physicsnemo.utils
    participant Compat as physicsnemo.compat
    participant NN as physicsnemo.nn
    
    Note over Utils,NN: Before PR: v1 modules migrated to nn/
    User->>NN: import zenith_angle/insolation
    NN-->>User: Module (in nn/)
    User->>Compat: Use old path (utils.zenith_angle)
    Compat->>NN: Redirect to nn.zenith_angle
    NN-->>User: Module
    
    Note over Utils,NN: After PR: Unmigration back to utils/
    User->>Utils: import zenith_angle/insolation
    Utils-->>User: Module (in utils/)
    Note over Compat: Compat mappings removed
    Note over NN: No longer in nn/
Loading

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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