Skip to content

Create global reference to default registry on import? #7

Closed
@TomNicholas

Description

@TomNicholas

I didn't realise that there are functions for getting and setting a global pint registry (see pint/#880).

For xarray integration, the ideal eventual usage in my opinion would be to enable pint-xarray by default when both pint and xarray are imported, and pint-xarray is installed, so you only need do

import pint
import xarray

ds = open_mfdataset(files).quantify()

Not having to do

ureg = pint.UnitRegistry()
ds = open_mfdataset(files).quantify(unit_registry=ureg)

would be nice I think.

But that would mean initialising the default registry either during quantify, or during the module imports. set_application_registry() means that particular users can still change it after imports, and get_application_registry() can be called from within quantify calls.

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