ac6a9dd09a70a41188fd5791a6e69c509c0d3d27,nilmtk/stats/goodsections.py,,get_good_sections,#,89

Before Change


        `end=None`.  If this df starts with an open-ended good section
        then the first TimeFrame will have `start=None`.
    
    index = df.dropna().index
    timedeltas_sec = timedelta64_to_secs(diff(index.values))
    timedeltas_check = timedeltas_sec <= max_sample_period
    timedeltas_check = concatenate(
        [[previous_chunk_ended_with_open_ended_good_section], 
         timedeltas_check])
    transitions = diff(timedeltas_check.astype(np.int))
    good_sect_starts = index[:-1][transitions ==  1]
    good_sect_ends   = index[:-1][transitions == -1]
    good_sect_ends = list(good_sect_ends)
    good_sect_starts = list(good_sect_starts)

    // Use look_ahead to see if we need to append a 
    // good sect start or good sect end.
    look_ahead_valid = look_ahead is not None and not df.look_ahead.empty
    if look_ahead_valid:
        look_ahead_timedelta = df.look_ahead.dropna().index[0] - index[-1]
        look_ahead_gap = look_ahead_timedelta.total_seconds()
    if timedeltas_check[-1]: // current chunk ends with a good section
        if not look_ahead_valid or look_ahead_gap > max_sample_period:
            // current chunk ends with a good section which needs to 
            // be closed because next chunk either does not exist
            // or starts with a sample which is more than max_sample_period
            // away from df.index[-1]
            good_sect_ends += [index[-1]]
    elif look_ahead_valid and look_ahead_gap <= max_sample_period:
        // Current chunk appears to end with a bad section
        // but last sample is the start of a good section
        good_sect_starts += [index[-1]]

    // Work out if this chunk ends with an open ended good section
    if len(good_sect_ends) == 0:
        ends_with_open_ended_good_section = (
            len(good_sect_starts) > 0 or 
            previous_chunk_ended_with_open_ended_good_section)
    elif len(good_sect_starts) > 0:

After Change


        `end=None`.  If this df starts with an open-ended good section
        then the first TimeFrame will have `start=None`.
    
    index = df.dropna().sort_index().index
    timedeltas_sec = timedelta64_to_secs(diff(index.values))
    timedeltas_check = timedeltas_sec <= max_sample_period
    timedeltas_check = concatenate(
        [[previous_chunk_ended_with_open_ended_good_section], 
         timedeltas_check])
    transitions = diff(timedeltas_check.astype(np.int))
    good_sect_starts = index[:-1][transitions ==  1]
    good_sect_ends   = index[:-1][transitions == -1]
    good_sect_ends = list(good_sect_ends)
    good_sect_starts = list(good_sect_starts)

    // Use look_ahead to see if we need to append a 
    // good sect start or good sect end.
    look_ahead_valid = look_ahead is not None and not df.look_ahead.empty
    if look_ahead_valid:
        look_ahead_timedelta = df.look_ahead.dropna().index[0] - index[-1]
        look_ahead_gap = look_ahead_timedelta.total_seconds()
    if timedeltas_check[-1]: // current chunk ends with a good section
        if not look_ahead_valid or look_ahead_gap > max_sample_period:
            // current chunk ends with a good section which needs to 
            // be closed because next chunk either does not exist
            // or starts with a sample which is more than max_sample_period
            // away from df.index[-1]
            good_sect_ends += [index[-1]]
    elif look_ahead_valid and look_ahead_gap <= max_sample_period:
        // Current chunk appears to end with a bad section
        // but last sample is the start of a good section
        good_sect_starts += [index[-1]]

    // Work out if this chunk ends with an open ended good section
    if len(good_sect_ends) == 0:
        ends_with_open_ended_good_section = (
            len(good_sect_starts) > 0 or 
            previous_chunk_ended_with_open_ended_good_section)
    elif len(good_sect_starts) > 0:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 2

Instances


Project Name: nilmtk/nilmtk
Commit Name: ac6a9dd09a70a41188fd5791a6e69c509c0d3d27
Time: 2014-11-04
Author: jack-list@xlk.org.uk
File Name: nilmtk/stats/goodsections.py
Class Name:
Method Name: get_good_sections


Project Name: nilmtk/nilmtk
Commit Name: 62f1dbe2546626f9150ec96e4b238f566627b6ef
Time: 2014-07-10
Author: jack-list@xlk.org.uk
File Name: nilmtk/metergroup.py
Class Name: MeterGroup
Method Name: power_series


Project Name: scikit-learn-contrib/categorical-encoding
Commit Name: 90fadd7f6269bbde2f7b712137f97820a49c6b00
Time: 2018-12-21
Author: jcastaldo08@gmail.com
File Name: category_encoders/leave_one_out.py
Class Name: LeaveOneOutEncoder
Method Name: transform_leave_one_out


Project Name: scikit-learn-contrib/categorical-encoding
Commit Name: 3b1517e09c60dd0268c534328b9b3a6e00ca14b0
Time: 2018-12-21
Author: jcastaldo08@gmail.com
File Name: category_encoders/leave_one_out.py
Class Name: LeaveOneOutEncoder
Method Name: transform_leave_one_out