93a71bd6c3f3c731473bc0ddd9b894a252738d01,src/backends/cgpm_backend.py,CGPM_Backend,json_ready_models,#CGPM_Backend#Any#Any#,926

Before Change



        import operator, itertools
        // Sort (name, code, value) list by variable name
        sorted_cats = sorted(cursor, key=operator.itemgetter(0))
        // Group triples by variable name -> list? of (name, group)
        groups = itertools.groupby(sorted_cats, key=operator.itemgetter(0))

        return {"column-statistical-types": stattypes,
                "categories": {name: {triple[1]:triple[2] for triple in group} for name, group in groups},
                "models": []}

    def _unique_rowid(self, rowids):
        if len(set(rowids)) != 1:
            raise ValueError("Multiple-row query: %r" % (list(set(rowids)),))

After Change


                     """, (generator_id, population_id))}

        raw_categories = \
            sorted(bdb.sql_execute("""
                       SELECT colno, code, value FROM bayesdb_cgpm_category
                       WHERE generator_id = ?
                   """, (generator_id,)))
        assert len(raw_categories) > 0

        // compare core.bayesdb_variable_name
        cat_variables = {colno: name for (colno, name) in
                         bdb.sql_execute("""
                             SELECT colno, name FROM bayesdb_variable
                             WHERE (generator_id IS NULL OR generator_id = ?)
                             AND population_id = ?
                         """, (generator_id, population_id))}
        assert len(cat_variables) > 0

        // Doing the join in python because i can"t figure out how to
        // do it in sqlite SQL
        import operator, itertools
        groups = \
            {colno: group for (colno, group) in 
                itertools.groupby(raw_categories, key=operator.itemgetter(0))}
        assert len(groups) > 0
        assert cat_variables[groups.keys()[0]]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: probcomp/bayeslite
Commit Name: 93a71bd6c3f3c731473bc0ddd9b894a252738d01
Time: 2019-12-06
Author: jar23@mumble.net
File Name: src/backends/cgpm_backend.py
Class Name: CGPM_Backend
Method Name: json_ready_models


Project Name: pantsbuild/pants
Commit Name: e41fecf5d55a9b26316ea12ef6caa187fee921fb
Time: 2019-11-04
Author: wisechengyi@gmail.com
File Name: src/python/pants/option/options_fingerprinter.py
Class Name: OptionsFingerprinter
Method Name: _fingerprint_dict_with_files


Project Name: snipsco/snips-nlu
Commit Name: 875b2af240cbd6ba5ec512ea6e1cce89e4d0db67
Time: 2019-01-08
Author: clement.doumouro@gmail.com
File Name: snips_nlu/entity_parser/custom_entity_parser.py
Class Name:
Method Name: _stem_entity_utterances