On Thu, May 23, 2019 at 3:02 AM Marten van Kerkwijk < m.h.vankerkw...@gmail.com> wrote:
> > If we want to keep an "off" switch we might want to add some sort of API >> for exposing whether NumPy is using __array_function__ or not. Maybe >> numpy.__experimental_array_function_enabled__ = True, so you can just test >> `hasattr(numpy, '__experimental_array_function_enabled__')`? This is >> assuming that we are OK with adding an underscore attribute to NumPy's >> namespace semi-indefinitely. >> > I don't think we want to add or document anything publicly. That only adds to the configuration problem, and indeed makes it harder to rely on the issue. All I was suggested was keeping some (private) safety switch in the code base for a while in case of real issues as a workaround. > Might this be overthinking it? I might use this myself on supercomputer > runs were I know that I'm using arrays only. Though one should not > extrapolate from oneself! > > That said, it is not difficult as is. For instance, we could explain in > the docs that one can tell from: > ``` > enabled = hasattr(np.core, 'overrides') and > np.core.overrides.ENABLE_ARRAY_FUNCTION > ``` > One could even allow for eventual removal by explaining it should be, > ``` > enabled = hasattr(np.core, 'overrides') and getattr(np.core.overrides, > 'ENABLE_ARRAY_FUNCTION', True) > ``` > (If I understand correctly, one cannot tell from the presence of > `ndarray.__array_function__`, correct?) > I think a hasattr check for __array_function__ is right. Ralf > -- Marten > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@python.org > https://mail.python.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion