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

Method setDebugName

source/python.js:13184–13221  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

13182 return this._unique_name && this._unique_name.length > 0;
13183 }
13184 setDebugName(name) {
13185 if (!this.isValidName(name)) {
13186 throw new python.Error(`Invalid name '${name}'.`);
13187 }
13188 const names = this.node().owningGraph()._unique_names;
13189 if (this.hasDebugName()) {
13190 names.delete(this._unique_name);
13191 this._unique_name = '';
13192 }
13193 if (!name) {
13194 return this;
13195 }
13196 const old_owner_of_name = names.get(name);
13197 if (old_owner_of_name) {
13198 let suffix = 1;
13199 let name_base = name;
13200 const last_dot_pos = name.lastIndexOf('.');
13201 if (last_dot_pos !== -1) {
13202 if (/^\d+$/.test(name.substring(last_dot_pos + 1))) {
13203 suffix = Number(name.substring(last_dot_pos + 1));
13204 name_base = name.substring(0, last_dot_pos);
13205 }
13206 }
13207 const names_suffixes = this.node().owningGraph()._name_base_suffix;
13208 if (names_suffixes.has(name_base)) {
13209 suffix = Math.max(suffix, names_suffixes.get(name_base));
13210 }
13211 let replacement_name = null;
13212 do {
13213 replacement_name = `${name_base}.${suffix++}`;
13214 } while (names.has(replacement_name));
13215 names_suffixes.set(name_base, suffix);
13216 old_owner_of_name.setDebugName(replacement_name);
13217 }
13218 names.set(name, this);
13219 this._unique_name = name;
13220 return this;
13221 }
13222 debugName() {
13223 if (this.hasDebugName()) {
13224 return this._unique_name;

Callers 9

createGetAttrMethod · 0.80
freeValueMethod · 0.80
addInputMethod · 0.80
copyMetadataMethod · 0.80
insertLoadMethod · 0.80
setSugaredVarMethod · 0.80
constructorMethod · 0.80
emitFormalArgumentsMethod · 0.80
addNodeOutputMethod · 0.80

Calls 8

isValidNameMethod · 0.80
owningGraphMethod · 0.80
hasDebugNameMethod · 0.80
nodeMethod · 0.45
deleteMethod · 0.45
getMethod · 0.45
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected