248fa57af17b42deec9c818eb83aa71e63d50354,osmnx/io.py,,_convert_edge_attr_types,#Any#Any#,254

Before Change


            pass

        // parse grade attrs to float: should always have only 1 value each
        if "grade" in data:
            data["grade"] = float(data["grade"])
        if "grade_abs" in data:
            data["grade_abs"] = float(data["grade_abs"])

        // these attributes might have a single value, or a list if edge"s
        // topology was simplified
        for attr in [
            "highway",
            "name",
            "bridge",
            "tunnel",
            "lanes",
            "ref",
            "maxspeed",
            "service",
            "access",
            "area",
            "landuse",
            "width",
            "est_width",
        ]:
            // if this edge has this attribute, and it starts with "[" and ends
            // with "]", then it"s a list to be parsed
            if attr in data and data[attr].startswith("[") and data[attr].endswith("]"):
                // try to convert the string list to a list type, else leave as
                // single-value string (and leave as string if error)
                try:
                    data[attr] = ast.literal_eval(data[attr])
                except Exception:
                    pass

        // osmid might have a single value or a list
        if "osmid" in data:
            if data["osmid"].startswith("[") and data["osmid"].endswith("]"):
                // if it"s a list, eval list then convert each element to node_type
                data["osmid"] = [node_type(i) for i in ast.literal_eval(data["osmid"])]
            else:
                // if it"s not a list, convert it to the node_type
                data["osmid"] = node_type(data["osmid"])

        // if geometry attribute exists, load the string as well-known text to
        // shapely LineString
        if "geometry" in data:
            data["geometry"] = wkt.loads(data["geometry"])

    return G

After Change



        // convert to float any possible OSMnx-added edge attributes, which may
        // have multiple values if graph was simplified after they were added
        for attr in ["grade", "grade_abs", "bearing", "speed_kph", "travel_time"]:
            if attr in data:
                if data[attr].startswith("[") and data[attr].endswith("]"):
                    // if it"s a list, eval it then convert each item to float
                    data[attr] = [float(a) for a in ast.literal_eval(data[attr])]
                else:
                    data[attr] = float(data[attr])

        // these attributes might have a single value, or a list if edge"s
        // topology was simplified
        for attr in [
            "highway",
            "name",
            "bridge",
            "tunnel",
            "lanes",
            "ref",
            "maxspeed",
            "service",
            "access",
            "area",
            "landuse",
            "width",
            "est_width",
        ]:
            // if this edge has this attribute, and it starts with "[" and ends
            // with "]", then it"s a list to be parsed
            if attr in data and data[attr].startswith("[") and data[attr].endswith("]"):
                // try to convert the string list to a list type, else leave as
                // single-value string (and leave as string if error)
                try:
                    data[attr] = ast.literal_eval(data[attr])
                except Exception:
                    pass

        // osmid might have a single value or a list
        if "osmid" in data:
            if data["osmid"].startswith("[") and data["osmid"].endswith("]"):
                // if it"s a list, eval list then convert each element to node_type
                data["osmid"] = [node_type(i) for i in ast.literal_eval(data["osmid"])]
            else:
                // if it"s not a list, convert it to the node_type
                data["osmid"] = node_type(data["osmid"])

        // if geometry attribute exists, load the string as well-known text to
        // shapely LineString
        if "geometry" in data:
            data["geometry"] = wkt.loads(data["geometry"])

    return G
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: gboeing/osmnx
Commit Name: 248fa57af17b42deec9c818eb83aa71e63d50354
Time: 2020-06-08
Author: boeing@usc.edu
File Name: osmnx/io.py
Class Name:
Method Name: _convert_edge_attr_types


Project Name: hellohaptik/chatbot_ner
Commit Name: e870ef14c590502fb0dc5ff3199e2602a87ec008
Time: 2019-03-18
Author: jain.chirag925@gmail.com
File Name: ner_v1/detectors/numeral/budget/budget_detection.py
Class Name: BudgetDetector
Method Name: _detect_min_budget


Project Name: hellohaptik/chatbot_ner
Commit Name: e870ef14c590502fb0dc5ff3199e2602a87ec008
Time: 2019-03-18
Author: jain.chirag925@gmail.com
File Name: ner_v1/detectors/numeral/budget/budget_detection.py
Class Name: BudgetDetector
Method Name: _detect_max_budget


Project Name: gboeing/osmnx
Commit Name: 248fa57af17b42deec9c818eb83aa71e63d50354
Time: 2020-06-08
Author: boeing@usc.edu
File Name: osmnx/io.py
Class Name:
Method Name: _convert_edge_attr_types