Skip to content

expose _to_temp_dataset / _from_temp_dataset as semi-public API? #4837

Open
@keewis

Description

@keewis

When writing accessors which behave the same for both Dataset and DataArray, it would be incredibly useful to be able to use DataArray._to_temp_dataset / DataArray._from_temp_dataset to deduplicate code. Is it safe to use those in external packages (like pint-xarray)?

Otherwise I guess it would be possible to use

name = da.name if da.name is None else "__temp"
temp_ds = da.to_dataset(name=name)
new_da = temp_ds[name]
if da.name is None:
    new_da = new_da.rename(da.name)
assert_identical(da, new_da)

but that seems less efficient.

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