1edd1496383e7ae0374ec5dd8b455d58077e1d62,cnvlib/_merge.py,,_merge_overlapping,#Any#Any#,41
Before Change
def _merge_overlapping(table, combiners):
Merge overlapping regions within a group.
// Short-circuit the simple, common cases
if len(table) == 1:
return table
if table["start"].nunique() == table["end"].nunique() == 1:
return _squash_rows(table, combiners)
// Identify & enumerate (non)overlapping groups of rows
overlap_sizes = table.end.cummax().values[:-1] - table.start.values[1:]
non_overlapping = np.r_[False, (overlap_sizes <= 0)]
// Squash rows within each non-overlapping group
return (table.groupby(non_overlapping * np.arange(len(non_overlapping)),
as_index=False, group_keys=False, sort=False)
After Change
// advantage of the grouping and sorting already done, and don"t repeat
// pandas" traversal and inferences.
// ENH: Find & use a lower-level, 1-pass pandas function
keyed_groups = itertools.izip(_nonoverlapping_groups(table),
table.itertuples(index=False))
merged_rows = [_squash_tuples(row_group, combiners)
for _key, row_group in itertools.groupby(keyed_groups,
lambda x: x[0])]
return pd.DataFrame.from_records(merged_rows, columns=merged_rows[0]._fields)
def _nonoverlapping_groups(table):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 7
Instances
Project Name: etal/cnvkit
Commit Name: 1edd1496383e7ae0374ec5dd8b455d58077e1d62
Time: 2016-10-30
Author: eric.talevich@gmail.com
File Name: cnvlib/_merge.py
Class Name:
Method Name: _merge_overlapping
Project Name: has2k1/plotnine
Commit Name: 44682f54140e61f260878ad2d2703eecba91e1e9
Time: 2015-04-20
Author: has2k1@gmail.com
File Name: ggplot/facets/locate.py
Class Name:
Method Name: locate_wrap
Project Name: has2k1/plotnine
Commit Name: 44682f54140e61f260878ad2d2703eecba91e1e9
Time: 2015-04-20
Author: has2k1@gmail.com
File Name: ggplot/facets/locate.py
Class Name:
Method Name: locate_grid