Skip to content

Weird behavior with pint.Quantity + masked array #8908

@dopplershift

Description

@dopplershift

From my SciPy 2017 talk, the combination of pint.Quantity for unit support with masked arrays produces problems not seen with either individually:

%matplotlib inline

import matplotlib.pyplot as plt
import numpy as np
import pint

units = pint.UnitRegistry()

data = np.random.randn(30,)
data_units = data * units.meters
data_masked = np.ma.array(data, mask=data<0.)
data_masked_units = data_masked * units.meters

fig, axes = plt.subplots(1, 3, sharex=True, sharey=True, figsize=(8, 4))
axes[0].plot(data_units)
axes[1].plot(data_masked)
axes[2].plot(data_masked_units)

produces:

bug

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy