Skip to content

GEOPY-2880: Allow EM receiver orientations to be defined as 2D array (per location) - #171

Open
domfournier wants to merge 2 commits into
developfrom
GEOPY-2880
Open

GEOPY-2880: Allow EM receiver orientations to be defined as 2D array (per location)#171
domfournier wants to merge 2 commits into
developfrom
GEOPY-2880

Conversation

@domfournier

@domfournier domfournier commented Aug 19, 2026

Copy link
Copy Markdown

GEOPY-2880 - Allow EM receiver orientations to be defined as 2D array (per location)

Copilot AI lite review requested due to automatic review settings August 19, 2026 21:16
@github-actions github-actions Bot changed the title GEOPY-2880 GEOPY-2880: Allow EM receiver orientations to be defined as 2D array (per location) Aug 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Enables EM receiver orientations to be provided per-location by extending the validate_direction utility to accept 2D arrays and normalize them row-wise.

Changes:

  • Expand validate_direction to accept either a single direction vector or a per-location matrix of direction vectors.
  • Normalize 2D orientation inputs along the last axis.
Suppressed comments (2)

simpeg/utils/code_utils.py:1225

  • The validate_direction docstring still describes obj/return value as a single (dim,) vector, but the implementation now accepts and returns an (n, dim) array (per-location/per-receiver orientations). Updating the docstring will prevent API confusion.
    obj = validate_ndarray_with_shape(

simpeg/utils/code_utils.py:1234

  • This change alters validate_direction semantics (2D inputs are now valid and should be normalized row-wise). The existing unit tests currently assert that a 2D input like [[1, 2, 3]] raises, and there are no tests covering the new (n, dim) behavior (including normalization and error cases like wrong second dimension). Please update/add tests accordingly to lock in the new contract.
    obj = validate_ndarray_with_shape(
        property_name, obj, shape=[(dim,), ("*", 3)], dtype=float
    )

    # Normalize the orientation
    # do this to make a copy of the input
    if obj.ndim > 1:
        return obj / np.linalg.norm(obj, axis=-1)[:, None]
    else:
        return obj / np.linalg.norm(obj)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread simpeg/utils/code_utils.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

2 participants