fb50688c503567c5db6207e45e2c5e2ee1ad33df,tgen/features.py,,depth,#,41
Before Change
@return: dictionary with one key ("") and the target number as a value
nodes = scope_func(cur_node, incremental=incremental)
if nodes:
return {"": max(node.get_depth() for node in nodes)}
return {"": 0}
def max_children(cur_node, context, scope_func, incremental=False):
After Change
depths = {} // store nodes that we"ve already processed
max_depth = 0
for node_id in xrange(len(tree)):
pos = node_id
depth = 0
// go up to the root / an already processed node
while tree.parents[pos] >= 0 and pos not in depths:
depth += 1
pos = tree.parents[pos]
if pos in depths: // processed node: add its depth
depth += depths[pos]
// store the depth to save computation
depths[node_id] = depth
if depth > max_depth:
max_depth = depth
return {"": max_depth}
def max_children(tree, context):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 7
Instances Project Name: UFAL-DSG/tgen
Commit Name: fb50688c503567c5db6207e45e2c5e2ee1ad33df
Time: 2014-08-25
Author: odusek@ufal.mff.cuni.cz
File Name: tgen/features.py
Class Name:
Method Name: depth
Project Name: geekcomputers/Python
Commit Name: 139259ac8ac83160502cbb896371ce4fa4027361
Time: 2019-10-10
Author: ml.smiley3@gmail.com
File Name: primelib/primelib.py
Class Name:
Method Name: sieveEr
Project Name: scikit-video/scikit-video
Commit Name: c8102caf93b5ef5faa7effbdd581d83c632c0b83
Time: 2016-12-05
Author: tgoodall@utexas.edu
File Name: skvideo/motion/block.py
Class Name:
Method Name: _minCost