Skip to content

Weird behavior with pint.Quantity + masked array #8908

Closed
@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