|
40 | 40 | if name.endswith("_functions"):
|
41 | 41 | category = name.replace("_functions", "")
|
42 | 42 | objects = [getattr(mod, name) for name in mod.__all__]
|
43 |
| - assert all(isinstance(o, FunctionType) for o in objects) |
| 43 | + assert all(isinstance(o, FunctionType) for o in objects) # sanity check |
44 | 44 | category_to_funcs[category] = objects
|
45 | 45 |
|
| 46 | +all_funcs = [] |
| 47 | +for funcs in [array_methods, *category_to_funcs.values()]: |
| 48 | + all_funcs.extend(funcs) |
| 49 | +name_to_func: Dict[str, FunctionType] = {f.__name__: f for f in all_funcs} |
| 50 | + |
46 | 51 | EXTENSIONS: str = ["linalg"]
|
47 | 52 | extension_to_funcs: Dict[str, List[FunctionType]] = {}
|
48 | 53 | for ext in EXTENSIONS:
|
49 | 54 | mod = name_to_mod[ext]
|
50 | 55 | objects = [getattr(mod, name) for name in mod.__all__]
|
51 |
| - assert all(isinstance(o, FunctionType) for o in objects) |
52 |
| - extension_to_funcs[ext] = objects |
| 56 | + assert all(isinstance(o, FunctionType) for o in objects) # sanity check |
| 57 | + funcs = [] |
| 58 | + for func in objects: |
| 59 | + if "Alias" in func.__doc__: |
| 60 | + funcs.append(name_to_func[func.__name__]) |
| 61 | + else: |
| 62 | + funcs.append(func) |
| 63 | + extension_to_funcs[ext] = funcs |
53 | 64 |
|
54 |
| -all_funcs = [] |
55 |
| -for funcs in [array_methods, *category_to_funcs.values(), *extension_to_funcs.values()]: |
56 |
| - all_funcs.extend(funcs) |
57 |
| -name_to_func: Dict[str, FunctionType] = {f.__name__: f for f in all_funcs} |
| 65 | +for funcs in extension_to_funcs.values(): |
| 66 | + for func in funcs: |
| 67 | + if func.__name__ not in name_to_func.keys(): |
| 68 | + name_to_func[func.__name__] = func |
0 commit comments