ENH: Adding default_xp context manager for xp_assert functions#747
ENH: Adding default_xp context manager for xp_assert functions#747prady0t wants to merge 1 commit into
default_xp context manager for xp_assert functions#747Conversation
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
default_xp context manager for xp_assert functions
lucascolley
left a comment
There was a problem hiding this comment.
thanks Pradyot! Could you update the SciPy branch to use this branch?
Will have to merge this first right? |
Ah, no! I think the easiest way is to run |
|
We till can't remove these parts from scipy for two reasons:
@lucascolley What do you think? |
Could you explain this in more detail? |
|
Currently, we do not allow for scalar or Python lists as input, but Scipy uses them everywhere. For this reason, we have to convert them to their respective if xp is None:
try:
xp = _default_xp_ctxvar.get()
except LookupError:
xp = array_namespace(desired)Hence, we need this block before we convert to xp.asarray and send it to our xp assert functions. |
| if xp is None: | ||
| try: | ||
| xp = _default_xp_ctxvar.get() | ||
| except LookupError: | ||
| xp = array_namespace(desired) |
There was a problem hiding this comment.
We can remove the default_xp context manager code from scipy and keep it here (and import from here), but we would still do this before converting the inputs to asarrays in scipy. On another thought, we can wrap this around a function and expose it.
No description provided.