You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For reasons related to documentation and showing it in IPython/Jupyter I have some questions/suggestions wrt fully qualified names of object and improvement.
As well as the "inverse" operation: from a str get the object back:
parts = full_qual_name.split('.')
target = parts[0]
for k in parts[1:]:
target = getattr(target, k)
And I have some issues with a few object, the mostly fell in 2 categories:
Object with no module
# full_qual(np.exp) # AttrError , no attribute __module__, (no __qualname__, but have __name__) same with sin, cos...
Could it be possible to add a module to those ?
full_qual(np.memmap) # 'numpy.memmap' is Ok
full_qual(np.memmap.flush) # 'numpy.core.memmap.memmap.flush' is problematic:
target = numpy
for k in ['core', 'memmap', 'memmap', 'flush']:
target = getattr(target, k) # fails with AttributeError: type object 'memmap' has no attribute 'memmap'
For this second one this is due to numpy.core.memmap being ambiguous as core/__init__.py contain from .memmap import memmap so the class shadow the module in which it's defined.
Yes I know I can access .flush via np.memmap.flush it's just one example.
Would it be ok to have a consistent way to go from objects to fully_qualified name and vice versa, and should I open issues when I find such functions/methods/class ?
The text was updated successfully, but these errors were encountered:
I am happy to add a module and/or qualname to ufuncs, we just need to decide on how...
Currently, the name is basically passed to the C creation function. We could do it like Python's static types and just assume everything before the first . is part of the module, that is not ideal (for one some ufuncs couldrequire a __qualname__ technically), but likely "just works" (have to check if pickle is fine with getting __module__ + "."+ __qualname__, but I expect it is).
The other option, is to make __module__ and __qualname__ writeable attribute (or writeable exactly once, with the option of disallowing it when used with future API).
np.memmap thing seems like the @set_module('numpy') decorator can't or doesn't properly set the module of the attributes. I guess the decorator could try to be smart about methods or is there a better solution?
Feature
For reasons related to documentation and showing it in IPython/Jupyter I have some questions/suggestions wrt fully qualified names of object and improvement.
For example if a user does:
I want to be able to say "view online docs at https://numpy.org/doc/stable/reference/generated/{fully_qual}.html".format(full_qual(x))" with roughly:
As well as the "inverse" operation: from a str get the object back:
And I have some issues with a few object, the mostly fell in 2 categories:
Could it be possible to add a module to those ?
For this second one this is due to
numpy.core.memmap
being ambiguous ascore/__init__.py
containfrom .memmap import memmap
so the class shadow the module in which it's defined.Yes I know I can access
.flush
vianp.memmap.flush
it's just one example.Would it be ok to have a consistent way to go from objects to fully_qualified name and vice versa, and should I open issues when I find such functions/methods/class ?
The text was updated successfully, but these errors were encountered: