Skip to content

easier way to create arrays #6

@keewis

Description

@keewis

While the idea of using a function to create a nested namespace is neat, it makes creating arrays harder:

import marray
import numpy as np

xp = marray.masked_array(np)

a = xp.asarray(np.arange(10))
a.mask[...] = np.arange(10) % 2 == 0

What I'd like to have (but don't quite know how easy it is to support, nor if it actually is a good idea) is something like this:

import marray
import numpy as np

a = marray.MaskedArray(data=np.arange(10), mask=np.arange(10) % 2 == 0)
xp = a.__array_namespace__()  # nested namespace

Alternatively, this could also work (since the Array API doesn't forbid adding non-standard things to the namespace):

xp = marray.masked_array(np)
a = xp.MaskedArray(data=np.arange(10), mask=np.arange(10) % 2 == 0)

However, I would imagine that this makes creating / composing arrays a bit harder. And since we don't subclass arrays classes anymore, maybe we don't even need the dynamic namespace (and thus the meta-programming)?

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