a1fad60d05352b9bfb9e9ee1a7dc54b1390eb24e,src/sos/Julia/kernel.py,sos_Julia,put_vars,#sos_Julia#Any#Any#,234

Before Change


        if not items:
            return {}

        py_repr = "cat(..py.repr(list({})))".format(",".join("{0}={0}".format(x) for x in items))
        response = self.sos_kernel.get_response(py_repr, ("stream",), name=("stdout",))[0][1]
        expr = response["text"]

        if to_kernel in ("Python2", "Python3"):
            // directly to python3
            return "{}\nglobals().update({})".format("from feather import read_dataframe\n" if "read_dataframe" in expr else "", expr)
        // to sos or any other kernel
        else:
            // irkernel (since the new version) does not produce execute_result, only
            // display_data
            try:
                if "read_dataframe" in expr:
                    // imported to be used by eval
                    from feather import read_dataframe
                    // suppress flakes warning
                    read_dataframe
                // evaluate as raw string to correctly handle \\ etc
                return eval(expr)
            except Exception as e:
                self.sos_kernel.warn("Failed to evaluate {!r}: {}".format(expr, e))
                return None

After Change


    def put_vars(self, items, to_kernel=None):
        // first let us get all variables with names starting with sos
        response = self.sos_kernel.get_response("whos(r"sos")", ("stream",), name=("stdout",), debug=True)[0][1]
        all_vars = [x.strip().split()[0] for x in response["text"].split("\n") if x.strip()]
        items += [x for x in all_vars if x.startswith("sos")]

        if not items:
            return {}

        res = {}
        for item in items:
            py_repr = "__sos__julia_py_repr({})".format(item)
            self.sos_kernel.warn("RXPR for {} is {}".format(item, py_repr))
            response = self.sos_kernel.get_response(py_repr, ("stream",), name=("stdout",), debug=True)[0][1]
            expr = response["text"]

            try:
                if "read_dataframe" in expr:
                    // imported to be used by eval
                    from feather import read_dataframe
                    // suppress flakes warning
                    read_dataframe
                // evaluate as raw string to correctly handle \\ etc
                res[item] = eval(expr)
            except Exception as e:
                self.sos_kernel.warn("Failed to evaluate {!r}: {}".format(expr, e))
                return None
        return res
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: vatlab/SoS
Commit Name: a1fad60d05352b9bfb9e9ee1a7dc54b1390eb24e
Time: 2017-08-21
Author: ml69@rice.edu
File Name: src/sos/Julia/kernel.py
Class Name: sos_Julia
Method Name: put_vars


Project Name: keras-team/keras
Commit Name: bbaa66c5304fad4a45ecbb33445d5c619c1a76e4
Time: 2016-02-22
Author: Nicholas.Eggert@target.com
File Name: tests/keras/layers/test_convolutional.py
Class Name:
Method Name: test_averagepooling_2d


Project Name: vatlab/SoS
Commit Name: 93f4d0776aadf928cc76f04ed810c4e7b44a1d97
Time: 2017-07-19
Author: BPeng1@BCBW31517465254.mdanderson.edu
File Name: src/sos/Matlab/kernel.py
Class Name: sos_Matlab
Method Name: put_vars