Skip to content

50 graphviper changes needed for astroviper demonstrator#55

Merged
Jan-Willem merged 5 commits intomainfrom
50-graphviper-changes-needed-for-astroviper-demonstrator
Mar 19, 2026
Merged

50 graphviper changes needed for astroviper demonstrator#55
Jan-Willem merged 5 commits intomainfrom
50-graphviper-changes-needed-for-astroviper-demonstrator

Conversation

@Jan-Willem
Copy link
Copy Markdown
Member

No description provided.

@Jan-Willem Jan-Willem requested a review from Copilot March 19, 2026 16:57
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 87.15596% with 14 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/graphviper/graph_tools/coordinate_utils.py 87.15% 14 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors interpolate_data_coords_onto_parallel_coords in graphviper to reduce overhead when building task-to-dataset selection mappings for the astroviper demonstrator use case, primarily by reordering loops and adding a faster “nearest” interpolation path.

Changes:

  • Added helper utilities for chunk handling and a np.searchsorted-based nearest-index helper to avoid constructing SciPy interpolator objects in common cases.
  • Reworked the interpolation loop structure to compute per-dimension constants once and avoid redundant work.
  • Minor API/style cleanup around ps_partition and None handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +612 to +616
elif interpolation_method == "nearest":
# Fast path: no interpolator object construction
interp_index = _nearest_interp_indices(coord_values, edges)
else:
# Fallback for non-nearest methods
# We redo this for every partition, because task number will have changed
iter_chunks_indices, parallel_dims = _make_iter_chunks_indices(parallel_coords)
for chunk_indices in iter_chunks_indices:
logger.debug(f"chunk_index: {task_id}, {chunk_indices}")
Comment on lines +654 to 666
# -----------------------------------------------------------------------
# Phase 2 — build node_task_data_mapping
#
# Largely unchanged from v1; parallel_dims is extracted once since it is
# the same for every partition. logger.debug uses %s formatting to skip
# string construction when debug logging is inactive.
# -----------------------------------------------------------------------
node_task_data_mapping = {}

task_id = 0
for partition in partition_map.keys():
# We redo this for every partition, because task number will have changed
iter_chunks_indices, parallel_dims = _make_iter_chunks_indices(parallel_coords)
for chunk_indices in iter_chunks_indices:
Comment on lines +716 to +746
# input_data: Union[Dict, xr.DataTree],
# interpolation_method: {
# "linear",
# "nearest",
# "nearest-up",
# "zero",
# "slinear",
# "quadratic",
# "cubic",
# "previous",
# "next",
# } = "nearest",
# assume_sorted: bool = True,
# ps_partition: Optional[
# list[str]
# ] = None, # Current options are {'field_name', 'spectral_window_name'}
# ) -> Dict:
# """Interpolate data_coords onto parallel_coords to create the ``node_task_data_mapping``. For the case of string coordinates (for example antenna_name), only exact matching is performed.

# Parameters
# ----------
# parallel_coords : Dict
# The parallel coordinates determine the parallelism of the map graph.
# The keys in the parallel coordinates can by any combination of the dimension coordinates in the input data.
# See notes in docstring for structure.
# input_data : Union[Dict, ProcessingSet]
# Can either be a `ProcessingSet <https://github.com/casangi/xradio/blob/main/src/xradio/correlated_data/processing_set.py>`_ or a Dictionary of `xarray.Datasets <https://docs.xarray.dev/en/stable/generated/xarray.Dataset.html>`_. Only coordinates are needed so no actual data is loaded into memory.
# interpolation_method : {"linear", "nearest", "nearest-up", "zero", "slinear", "quadratic", "cubic", "previous", "next",}, optional
# The kind of interpolation method to use as described in `Scipy documentation <https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html>`_ , by default ``nearest``.
# assume_sorted : bool, optional
# Are the data in parallel_coords and input_data monotonically increasing in value, by default True.
)

d = {}
# We loop over the cartersian product of the keys
@Jan-Willem Jan-Willem merged commit 27e755a into main Mar 19, 2026
22 of 23 checks passed
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.

3 participants