MCPcopy
hub / github.com/lutzroeder/netron / registerFunction

Method registerFunction

source/python.js:22457–22474  ·  view source on GitHub ↗
(name, value)

Source from the content-addressed store, hash-verified

22455 }
22456
22457 registerFunction(name, value) {
22458 const builtins = this.builtins;
22459 const index = name.lastIndexOf('.');
22460 if (!value) {
22461 value = () => {
22462 throw new python.Error(`'${name}' is not implemented.`);
22463 };
22464 }
22465 value.__class__ = builtins.function;
22466 value.__name__ = index === -1 ? name : name.substring(index + 1);
22467 value.__module__ = index === -1 ? '' : name.substring(0, index);
22468 const module = this.register(value.__module__);
22469 if (module[name]) {
22470 throw new python.Error(`Function '${name}' is already registered.`);
22471 }
22472 module[value.__name__] = value;
22473 return value;
22474 }
22475
22476 registerOperator(name, value) {
22477 this._operators.set(name, value);

Callers 2

constructorMethod · 0.80
constructorMethod · 0.80

Calls 1

registerMethod · 0.45

Tested by

no test coverage detected