5eeca7d385178092790e08c1d5ad6cbcff35d3dc,nilmtk/metergroup.py,MeterGroup,load,#MeterGroup#,518

Before Change


                except StopIteration:
                    continue

                if chunk is None:
                    chunk = chunk_from_next_meter
                    timeframe = chunk.timeframe
                elif len(chunk_from_next_meter) > 0:
                    n = len(chunk)
                    timeframe = timeframe.intersect(chunk_from_next_meter.timeframe)
                    chunk += chunk_from_next_meter
                    chunk = chunk.dropna()
                    if len(chunk) < n:
                        warn("Meters are not perfectly aligned.")

            if chunk is None:
                break
            else:
                chunk.timeframe = timeframe

After Change


        // Load each generator and yield the sum
        while True:
            chunk = pd.DataFrame()
            columns_to_average_counter = pd.DataFrame()
            timeframe = TimeFrame()

            // Go through each generator to try sum values together
            for generator in generators:
                try:
                    chunk_from_next_meter = next(generator)
                except StopIteration:
                    continue

                timeframe = timeframe.intersect(chunk_from_next_meter.timeframe)
                chunk = chunk.add(chunk_from_next_meter, fill_value=0, level="physical_quantity")

                if len(chunk) != len(chunk_from_next_meter):
                    warn("Meters are not perfectly aligned.")

                // Update columns_to_average_counter
                physical_quantities = chunk_from_next_meter.columns.get_level_values("physical_quantity")
                columns_to_average = (set(PHYSICAL_QUANTITIES_TO_AVERAGE)
                                      .intersection(physical_quantities))
                counter_increment = pd.DataFrame(1, columns=columns_to_average, 
                                                 index=chunk_from_next_meter.index)
                columns_to_average_counter = columns_to_average_counter.add(
                    counter_increment, fill_value=0)

            if chunk.empty:
                break

            // Divide any columns which need dividing to create mean values
            for column in columns_to_average_counter:
                chunk[column] /= columns_to_average_counter[column]

            chunk.timeframe = timeframe
            yield chunk

    def plot_when_on(self, **load_kwargs):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 9

Instances


Project Name: nilmtk/nilmtk
Commit Name: 5eeca7d385178092790e08c1d5ad6cbcff35d3dc
Time: 2014-12-11
Author: jack-list@xlk.org.uk
File Name: nilmtk/metergroup.py
Class Name: MeterGroup
Method Name: load


Project Name: CellProfiler/CellProfiler
Commit Name: 77bd6e143eaab400f3117519e0178e0a3cba9f7b
Time: 2017-06-03
Author: bethac07@users.noreply.github.com
File Name: cellprofiler/modules/colortogray.py
Class Name: ColorToGray
Method Name: display_split


Project Name: cornellius-gp/gpytorch
Commit Name: 60a342edc8b501802135df44869353cc8604d838
Time: 2018-01-11
Author: gpleiss@gmail.com
File Name: gpytorch/lazy/kronecker_product_lazy_variable.py
Class Name: KroneckerProductLazyVariable
Method Name: _matmul_closure_factory


Project Name: nilmtk/nilmtk
Commit Name: b2cba5c722c3f41244c4c415513ad42fe6325132
Time: 2014-05-07
Author: jack-list@xlk.org.uk
File Name: nilmtk/pipeline/energynode.py
Class Name: EnergyNode
Method Name: process