Get a global function by name Parameters ---------- name : str The name of the global function allow_missing : bool Whether allow missing function or raise an error. Returns ------- func : dgl.Function The function to be returned, None if functi
(name, allow_missing=False)
| 207 | |
| 208 | |
| 209 | def get_global_func(name, allow_missing=False): |
| 210 | """Get a global function by name |
| 211 | |
| 212 | Parameters |
| 213 | ---------- |
| 214 | name : str |
| 215 | The name of the global function |
| 216 | |
| 217 | allow_missing : bool |
| 218 | Whether allow missing function or raise an error. |
| 219 | |
| 220 | Returns |
| 221 | ------- |
| 222 | func : dgl.Function |
| 223 | The function to be returned, None if function is missing. |
| 224 | """ |
| 225 | handle = FunctionHandle() |
| 226 | check_call(_LIB.DGLFuncGetGlobal(c_str(name), ctypes.byref(handle))) |
| 227 | if handle.value: |
| 228 | return Function(handle, False) |
| 229 | else: |
| 230 | if allow_missing: |
| 231 | return None |
| 232 | else: |
| 233 | raise ValueError("Cannot find global function %s" % name) |
| 234 | |
| 235 | |
| 236 | def list_global_func_names(): |
no test coverage detected