pydata / pydata/xarray

Bring xr.align objects specification in line with other top-level functions?

Open
#2,779 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

Was wondering if this might be useful given that I ran into this point of confusion. Observing the following argument specifications for various top-level xarray functions:

xarray.align(*objects, join='inner', copy=True, indexes=None, exclude=frozenset())

xarray.concat(objs, dim=None, data_vars='all', coords='different', compat='equals', positions=None, indexers=None, mode=None, concat_over=None)

xarray.concat(objs, dim=None, data_vars='all', coords='different', compat='equals', positions=None, indexers=None, mode=None, concat_over=None)

xarray.merge(objects, compat='no_conflicts', join='outer')

the odd man out here would be xr.align utilizing the *args formulation whereas all the others just take a single objs / objects param, instead. Would it make sense to add functionality to align such that if *args (*objects) is of length 1 and is a list or tuple (or something in this ballpark), you just treat it as the other methods currently operate?

For reference, if you don't notice that align works differently, if you pass an iterable without *args-ifying it, you get this somewhat unhelpful error:

image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the public xarray.align API and comparing its signature and input handling with xarray.concat and xarray.merge. Clarify the intended behavior for a single list or tuple versus the existing argument forms, then verify that the resulting error handling and documented usage match the requested consistency.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.