Skip to content

Commit 71b9483

Browse files
authored
Fix Regression in FNSG (#248)
There was a regression when removing extra nodes in EMME 2024 and 2025. This patch fixes the results to match TMG_Toolbox 1.13.
1 parent c3ae0f4 commit 71b9483

2 files changed

Lines changed: 35 additions & 41 deletions

File tree

TMGToolbox.sln

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26430.13
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.13.35919.96 d17.13
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NewFolder1", "NewFolder1", "{BB827711-D5DA-4966-B23C-F9CF1B385FC8}"
77
ProjectSection(SolutionItems) = preProject
@@ -22,4 +22,7 @@ Global
2222
GlobalSection(SolutionProperties) = preSolution
2323
HideSolutionNode = FALSE
2424
EndGlobalSection
25+
GlobalSection(ExtensibilityGlobals) = postSolution
26+
SolutionGuid = {F01023F6-7353-4BBF-8BDC-968881298B6B}
27+
EndGlobalSection
2528
EndGlobal

TMGToolbox/src/network_editing/remove_extra_nodes.py

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -440,47 +440,38 @@ def _ParseSegmentAggregators(self):
440440
self._segmentAggregators[attName] = funcName
441441
self._nodeAggregators[attName] = funcName
442442

443-
def fix_key_end(dictionary, end_sequency):
444-
to_change = []
445-
for key in six.iterkeys(dictionary):
446-
if key.endswith(end_sequency):
447-
to_change.append(key)
448-
for key in to_change:
449-
newKey = key.replace(end_sequency, "")
450-
val = dictionary.pop(key)
451-
dictionary[newKey] = val
443+
for key in list(six.iterkeys(self._linkAggregators)):
444+
if key.endswith("_l"):
445+
newKey = key.replace("_l", "")
446+
val = self._linkAggregators.pop(key)
447+
self._linkAggregators[newKey] = val
448+
449+
for key in list(six.iterkeys(self._segmentAggregators)):
450+
if key.endswith("_s"):
451+
newKey = key.replace("_s", "")
452+
val = self._segmentAggregators.pop(key)
453+
self._segmentAggregators[newKey] = val
454+
455+
for key in list(six.iterkeys(self._nodeAggregators)):
456+
if key.endswith("_n"):
457+
newKey = key.replace("_n", "")
458+
val = self._nodeAggregators.pop(key)
459+
self._nodeAggregators[newKey] = val
460+
461+
for att, funcName in list(six.iteritems(self._linkAggregators)):
462+
if funcName == 'avg_by_length':
463+
self._linkAggregators[att] = self.AVERAGE_BY_LENGTH_LINKS
464+
else:
465+
self._linkAggregators[att] = _editing.NAMED_AGGREGATORS[funcName]
452466

453-
fix_key_end(self._linkAggregators, "_l")
454-
fix_key_end(self._segmentAggregators, "_s")
455-
fix_key_end(self._nodeAggregators, "_n")
467+
for att, funcName in list(six.iteritems(self._segmentAggregators)):
468+
if funcName == 'avg_by_length':
469+
self._segmentAggregators[att] = self.AVERAGE_BY_LENGTH_SEGMENTS
470+
else:
471+
self._segmentAggregators[att] = _editing.NAMED_AGGREGATORS[funcName]
456472

457-
def assign_function(dictionary, func_name, func_type):
458-
to_change = []
459-
for att, funcName in six.iteritems(dictionary):
460-
if funcName == func_name:
461-
to_change.append((att, func_type))
462-
else:
463-
try:
464-
to_change.append((att, _editing.NAMED_AGGREGATORS[funcName]))
465-
except KeyError as ke:
466-
print("Error assigning function: %s from _editing" %funcName)
467-
print(dictionary)
468-
raise
469-
470-
471-
for key, to_assign in to_change:
472-
try:
473-
dictionary[key] = to_assign
474-
except KeyError as ke:
475-
print("Error assigning function: %s" %key)
476-
print(dictionary)
477-
raise
478-
479-
480-
assign_function(self._linkAggregators, 'avg_by_length', self.AVERAGE_BY_LENGTH_LINKS)
481-
assign_function(self._segmentAggregators, 'avg_by_length', self.AVERAGE_BY_LENGTH_LINKS)
482-
# This one should only set the func type to the _editing.NAMED_AGGREGATORS.
483-
assign_function(self._nodeAggregators, None, None)
473+
for att, funcName in list(six.iteritems(self._nodeAggregators)):
474+
self._nodeAggregators[att] = _editing.NAMED_AGGREGATORS[funcName]
484475

485476
def _GetCandidateNodes(self, network):
486477

0 commit comments

Comments
 (0)