Skip to content

How to use masked arrays? #5

@alexbovet

Description

@alexbovet

Hi,

I don't understand how to use masked arrays with stl.

import numpy as np
import numpy.ma as ma
from pyloess.mpyloess import stl

y = np.array([1,12,5,3,5,6])
yma = ma.masked_array(y, mask=[0,0,1,0,0,0])

stl(yma)

returns: ValueError: Masked arrays should be filled first!

In the code (mpyloess.py), I see that there is a check:

class stl:
    class _inputs:
        def __init__(self, y):
            self.y = masked_array(y, subok=True, copy=False).ravel()
            self._mask = self.y._mask
            if self._mask.any():
                raise ValueError("Masked arrays should be filled first!")
            self.y_eff = self.y.compressed()

So any masked arrays will raise this error.
If I try with yma.filled() instead, the fit does take the filled values into account, which is not what I want for masked arrays.
Is it possible to use masked arrays, I understood that STL could deal with missing data.

Note that I am using @jcrotinger's fork for Python 3.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions