Method: read

Parameters:
data - {DOMElement} A gml:featureMember element, a gml:featureMembers
element, or an element containing either of the above at any level.

Returns:
{Array(<OpenLayers.Feature.Vector>)} An array of features.
19128
function(data) {
        if(typeof data == "string") { 
            data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
        }
        if(data && data.nodeType == 9) {
            data = data.documentElement;
        }
        var features = [];
        this.readNode(data, {features: features}, true);
        if(features.length == 0) {
            // look for gml:featureMember elements
            var elements = this.getElementsByTagNameNS(
                data, this.namespaces.gml, "featureMember"
            );
            if(elements.length) {
                for(var i=0, len=elements.length; i<len; ++i) {
                    this.readNode(elements[i], {features: features}, true);
                }
            } else {
                // look for gml:featureMembers elements (this is v3, but does no harm here)
                var elements = this.getElementsByTagNameNS(
                    data, this.namespaces.gml, "featureMembers"
                );
                if(elements.length) {
                    // there can be only one
                    this.readNode(elements[0], {features: features}, true);
                }
            }
        }
        return features;
    }
221134
function (data) {
            var atlas = {};
            var image = data.image;
            var spacing = data.spacing || 0;
            var margin = data.margin || 0;

            var width = image.width;
            var height = image.height;

            // calculate the sprite count (line, col)
            var spritecount = me.pool.pull("me.Vector2d",
                ~~((width - margin + spacing) / (data.framewidth + spacing)),
                ~~((height - margin + spacing) / (data.frameheight + spacing))
            );

            // verifying the texture size
            if ((width % (data.framewidth + spacing)) !== 0 ||
                (height % (data.frameheight + spacing)) !== 0) {
                // "truncate size"
                width = spritecount.x * (data.framewidth + spacing);
                height = spritecount.y * (data.frameheight + spacing);
                // warning message
                console.warn(
                    "Spritesheet Texture for image: " + image.src +
                    " is not divisible by " + (data.framewidth + spacing) +
                    "x" + (data.frameheight + spacing) +
                    ", truncating effective size to " + width + "x" + height
                );
            }

            // build the local atlas
            for (var frame = 0, count = spritecount.x * spritecount.y; frame < count; frame++) {
                var name = "" + frame;
                atlas[name] = {
                    name        : name,
                    texture     : "default", // the source texture
                    offset      : new me.Vector2d(
                        margin + (spacing + data.framewidth) * (frame % spritecount.x),
                        margin + (spacing + data.frameheight) * ~~(frame / spritecount.x)
                    ),
                    anchorPoint : (data.anchorPoint || null),
                    trimmed     : false,
                    width       : data.framewidth,
                    height      : data.frameheight,
                    angle       : 0
                };
                this.addUvsMap(atlas, name, width, height);
            }

            me.pool.push(spritecount);

            return atlas;
        }
1011041
public static Dataset<String, String> readSVMLightFormat(String filename, Index<String> featureIndex, Index<String> labelIndex, List<String> lines) {
    Dataset<String, String> dataset;
    try {
      dataset = new Dataset<String, String>(10, featureIndex, labelIndex);
      for (String line : ObjectBank.getLineIterator(new File(filename))) {
        if(lines != null)
          lines.add(line);
        dataset.add(svmLightLineToDatum(line));
      }

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return dataset;
  }
1006959
def _get_data(self, id_list, format='MLDataset'):
        """"""

        format = format.lower()

        features = list()  # returning a dict would be better if AutoMKL() can handle it
        for modality, data in self._modalities.items():
            if format in ('ndarray', 'data_matrix'):
                # turning dict of arrays into a data matrix
                # this is arguably worse, as labels are difficult to pass
                subset = np.array(itemgetter(*id_list)(data))
            elif format in ('mldataset', 'pyradigm'):
                # getting container with fake data
                subset = self._dataset.get_subset(id_list)
                # injecting actual features
                subset.data = { id_: data[id_] for id_ in id_list }
            else:
                raise ValueError('Invalid output format - choose only one of '
                                 'MLDataset or data_matrix')

            features.append(subset)

        return features
623988
function(doc) {
        if (typeof doc == "string") { 
            doc = OpenLayers.Format.XML.prototype.read.apply(this, [doc]);
        }

        var nodes = this.getNodes(doc);
        var ways = this.getWays(doc);
        
        // Geoms will contain at least ways.length entries.
        var feat_list = new Array(ways.length);
        
        for (var i = 0; i < ways.length; i++) {
            // We know the minimal of this one ahead of time. (Could be -1
            // due to areas/polygons)
            var point_list = new Array(ways[i].nodes.length);
            
            var poly = this.isWayArea(ways[i]) ? 1 : 0; 
            for (var j = 0; j < ways[i].nodes.length; j++) {
               var node = nodes[ways[i].nodes[j]];
               
               var point = new OpenLayers.Geometry.Point(node.lon, node.lat);
               
               // Since OSM is topological, we stash the node ID internally. 
               point.osm_id = parseInt(ways[i].nodes[j]);
               point_list[j] = point;
               
               // We don't display nodes if they're used inside other 
               // elements.
               node.used = true; 
            }
            var geometry = null;
            if (poly) { 
                geometry = new OpenLayers.Geometry.Polygon(
                    new OpenLayers.Geometry.LinearRing(point_list));
            } else {    
                geometry = new OpenLayers.Geometry.LineString(point_list);
            }
            if (this.internalProjection && this.externalProjection) {
                geometry.transform(this.externalProjection, 
                    this.internalProjection);
            }        
            var feat = new OpenLayers.Feature.Vector(geometry,
                ways[i].tags);
            feat.osm_id = parseInt(ways[i].id);
            feat.fid = "way." + feat.osm_id;
            feat_list[i] = feat;
        } 
        for (var node_id in nodes) {
            var node = nodes[node_id];
            if (!node.used || this.checkTags) {
                var tags = null;
                
                if (this.checkTags) {
                    var result = this.getTags(node.node, true);
                    if (node.used && !result[1]) {
                        continue;
                    }
                    tags = result[0];
                } else { 
                    tags = this.getTags(node.node);
                }    
                
                var feat = new OpenLayers.Feature.Vector(
                    new OpenLayers.Geometry.Point(node['lon'], node['lat']),
                    tags);
                if (this.internalProjection && this.externalProjection) {
                    feat.geometry.transform(this.externalProjection, 
                        this.internalProjection);
                }        
                feat.osm_id = parseInt(node_id); 
                feat.fid = "node." + feat.osm_id;
                feat_list.push(feat);
            }   
            // Memory cleanup
            node.node = null;
        }        
        return feat_list;
    }
860292
function readObject(data, replaceIds) {
        var element = null,
            id,
            name,
            obj,
            val,
            _replaceIdMap;

        function _replaceRef(item) {
            var newId = _replaceIdMap[item.$ref];
            if (newId) {
                item.$ref = newId;
            }
        }

        function _resolveRef(item) {
            return _idMap[item.$ref];
        }

        if (data) {
            if (_.isString(data)) {
                data = JSON.parse(data);
            }
            var reader = new Core.Reader({data: data}, _global.type);
            element = reader.readObj("data");

            // Replace all ids
            if (replaceIds) {

                // Map.<oldId, newId>
                _replaceIdMap = {};

                // Assign new ids
                for (id in reader.idMap) {
                    if (reader.idMap.hasOwnProperty(id)) {
                        var newId = IdGenerator.generateGuid();
                        obj = reader.idMap[id];
                        _replaceIdMap[obj._id] = newId;
                        delete reader.idMap[obj._id];
                        obj._id = newId;
                        reader.idMap[newId] = obj;
                    }
                }

                // Fix all refs to refer to new ids
                for (id in reader.idMap) {
                    if (reader.idMap.hasOwnProperty(id)) {
                        obj = reader.idMap[id];
                        for (name in obj) {
                            if (obj.hasOwnProperty(name)) {
                                val = obj[name];
                                // when val is reference
                                if (val && val.$ref) {
                                    _replaceRef(val);
                                // when val is non-empty array of reference
                                } else if (_.isArray(val) && val.length > 0 && val[0].$ref) {
                                    _.each(val, _replaceRef);
                                }
                            }
                        }

                    }
                }
            }

            // Resolve all references
            _.extend(_idMap, reader.idMap);
            for (id in reader.idMap) {
                if (reader.idMap.hasOwnProperty(id)) {
                    obj = _idMap[id];
                    for (name in obj) {
                        if (obj.hasOwnProperty(name)) {
                            val = obj[name];
                            // when val is reference
                            if (val && val.$ref) {
                                obj[name] = _idMap[val.$ref];
                            // when val is non-empty array of reference
                            } else if (_.isArray(val) && val.length > 0 && val[0].$ref) {
                                var resolvedRefs = _.map(val, _resolveRef);
                                obj[name] = resolvedRefs;
                            }
                        }
                    }
                    _addRefsOf(obj);
                }
            }

            // Fix problems in the file
            // TODO: Remove this enough time after
            for (id in reader.idMap) {
                if (reader.idMap.hasOwnProperty(id)) {
                    obj = _idMap[id];

                    // Fix _parent of Image owned by Stereotype
                    if (obj instanceof type.UMLStereotype && obj.icon instanceof type.UMLImage) {
                        obj.icon._parent = obj;
                    }

                    // Fix: remove disconnected UndirectedRelationships
                    if (obj instanceof type.UndirectedRelationship) {
                        if (!(obj.end1 instanceof type.RelationshipEnd &&
                              obj.end1.reference instanceof type.Model &&
                              obj.end2 instanceof type.RelationshipEnd &&
                              obj.end2.reference instanceof type.Model)) {
                            if (obj._parent && obj.getParentField()) {
                                obj._parent[obj.getParentField()].remove(obj);
                                obj._parent = null;
                                obj.end1.reference = null;
                                obj.end2.reference = null;
                                delete reader.idMap[obj._id];
                            }
                        }
                    }

                    // Fix: remove disconnected DirectedRelationships
                    if (obj instanceof type.DirectedRelationship) {
                        if (!(obj.source instanceof type.Model &&
                              obj.target instanceof type.Model)) {
                            if (obj._parent && obj.getParentField()) {
                                obj._parent[obj.getParentField()].remove(obj);
                                obj._parent = null;
                                obj.source = null;
                                obj.target = null;
                                delete reader.idMap[obj._id];
                            }
                        }
                    }

                    // Fix: Clear too large distance values
                    if (obj instanceof type.ParasiticView) {
                        if (obj.distance > 5000) {
                            obj.distance = 10;
                        }
                    }

                    // Fix: problems in diagram
                    if (obj instanceof type.Diagram) {
                        var diagram = obj;

                        // 1) Communication Diagram에서 hostEdge가 null인 UMLCommMessageView를 모두 지움.
                        if (diagram instanceof type.UMLCommunicationDiagram) {
                            _.each(diagram.ownedViews, function (v) {
                                if (v instanceof type.UMLCommMessageView && v.hostEdge === null) {
                                    diagram.removeOwnedView(v);
                                    delete reader.idMap[v._id];
                                }
                            });
                        }

                        for (var vi = 0, vlen = diagram.ownedViews.length; vi < vlen; vi++) {
                            var v = diagram.ownedViews[vi];

                            if (!v) { continue; }

                            // 1) model이 없는 UMLGeneralNodeView, UMLGeneralEdgeView를 모두 삭제.
                            if (!v.model && v instanceof type.UMLGeneralNodeView) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }
                            if (!v.model && v instanceof type.UMLGeneralEdgeView) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }

                            // 2) _parent가 없는 View들 모두 삭제
                            if (!v._parent) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }

                            // 3) head or tail이 없는 EdgeView는 삭제
                            if (v instanceof type.EdgeView) {
                                if (!v.head || !v.tail) {
                                    diagram.removeOwnedView(v);
                                    delete reader.idMap[v._id];
                                }
                            }

                            // 4) end1.reference or end2.reference가 없는 UndirectedRelationship을 모두 삭제.
                            if (v.model instanceof type.UndirectedRelationship) {
                                if (!v.model.end1.reference || !v.model.end2.reference) {
                                    var pf1 = v.model.getParentField();
                                    if (v.model._parent && pf1) {
                                        v.model._parent[pf1].remove(v.model);
                                    }
                                    diagram.removeOwnedView(v);
                                    delete reader.idMap[v._id];
                                }
                            }

                            // 5) source or target이 없는 DirectedRelationship을 모두 삭제.
                            if (v.model instanceof type.DirectedRelationship) {
                                if (!v.model.source || !v.model.target) {
                                    var pf2 = v.model.getParentField();
                                    if (v.model._parent && pf2) {
                                        v.model._parent[pf2].remove(v.model);
                                    }
                                    diagram.removeOwnedView(v);
                                    delete reader.idMap[v._id];
                                }
                            }

                            // 5) nameLabel, stereotypeLabel, propertyLabel, RoleNameLabel, MultiplicityLabel, PropertyLabel, QualifiersCompartment
                            if (v.nameLabel && !reader.idMap[v.nameLabel._id]) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }
                            if (v.stereotypeLabel && !reader.idMap[v.stereotypeLabel._id]) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }
                            if (v.propertyLabel && !reader.idMap[v.propertyLabel._id]) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }
                            if (v.tailRoleNameLabel && !reader.idMap[v.tailRoleNameLabel._id]) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }
                            if (v.tailPropertyLabel && !reader.idMap[v.tailPropertyLabel._id]) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }
                            if (v.tailMultiplicityLabel && !reader.idMap[v.tailMultiplicityLabel._id]) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }
                            if (v.tailQualifiersCompartment && !reader.idMap[v.tailQualifiersCompartment._id]) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }
                            if (v.headRoleNameLabel && !reader.idMap[v.headRoleNameLabel._id]) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }
                            if (v.headPropertyLabel && !reader.idMap[v.headPropertyLabel._id]) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }
                            if (v.headMultiplicityLabel && !reader.idMap[v.headMultiplicityLabel._id]) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }
                            if (v.headQualifiersCompartment && !reader.idMap[v.headQualifiersCompartment._id]) {
                                diagram.removeOwnedView(v);
                                delete reader.idMap[v._id];
                            }

                        }

                    }

                }
            }
        }
        return element;
    }
920645
def _read_node_data(subnw, current_node, node_type, matcher, formatcode):
    

    if node_type == "leaf" or node_type == "single":
        if node_type == "leaf":
            node = current_node.add_child()
        else:
            node = current_node
    else:
        node = current_node

    subnw = subnw.strip()
    
    if not subnw and node_type == 'leaf' and formatcode != 100:
        raise NewickError('Empty leaf node found')
    elif not subnw:
        return

    container1, container2, converterFn1, converterFn2, compiled_matcher = matcher[node_type]
    data = re.match(compiled_matcher, subnw)
    if data:
        data = data.groups()
        # This prevents ignoring errors even in flexible nodes:
        if subnw and data[0] is None and data[1] is None and data[2] is None:
            raise NewickError("Unexpected newick format '%s'" %subnw)

        if data[0] is not None and data[0] != '':
            node.add_feature(container1, converterFn1(data[0].strip()))

        if data[1] is not None and data[1] != '':
            node.add_feature(container2, converterFn2(data[1][1:].strip()))

        if data[2] is not None \
                and data[2].startswith("[&&NHX"):
            _parse_extra_features(node, data[2])
    else:
        raise NewickError("Unexpected newick format '%s' " %subnw[0:50])
    return
713029
def read(self, frame, data):
        ""
        seq = []
        while data:
            elem, data = self.spec.read(frame, data)
            seq.append(elem)
        return seq, data
1367095
function( data ) {
   
            
            var read_buffer = read_buffers_by_connection[tcp_connection];
            read_buffer += data;

            //split by new lines, 
            var messages = read_buffer.split('\n');
            
            //last element is either a partial message, or ''            
            read_buffer = messages.pop();
        
            for ( var i = 0; i < messages.length; i++ ) {
                
                //TODO error handling
                var message = messages[i];
                var components = message.split( ' ' );
                var path = components[0];
                var value = components[1];
                var timestamp = components[2];
                
                that.emit(  path, value, timestamp );                
            }            
        }
1248416
function getData(element, name) {
  if (isObject(element[name])) {
    return element[name];
  } else if (element.dataset) {
    return element.dataset[name];
  }

  return element.getAttribute('data-' + hyphenate(name));
}
280662
function(node) {
        // we need to use the old Format.GML parser since we do not know the 
        // geometry name
        if (!this.gmlFormat) {
            this.gmlFormat = new OpenLayers.Format.GML();
        }
        var feature = this.gmlFormat.parseFeature(node);
        var geometry, bounds = null;
        if (feature) {
            geometry = feature.geometry && feature.geometry.clone();
            bounds = feature.bounds && feature.bounds.clone();
            feature.destroy();
        }
        return {geometry: geometry, bounds: bounds};
    }
92761
public static double[][] toFeatureVector(Iterable<? extends MLRecord> data,
            List<MLFeatureModifier> featureModifiers) {
        final List<double[]> trainingInstances = new ArrayList<>();
        for (MLRecord record : data) {
            final double[] features = generateFeatureValues(record, featureModifiers);
            trainingInstances.add(features);
        }
        final double[][] x = trainingInstances.toArray(new double[trainingInstances.size()][]);
        return x;
    }
1171792
function(object, data) {
            var props = getProps(object),
                values = [], descs, i = 0,
                data = {
                    handlers: createMap(),
                    frozen: O.isFrozen ? O.isFrozen(object) : false,
                    extensible: O.isExtensible ? O.isExtensible(object) : true,
                    proto: getPrototype && getPrototype(object),
                    properties: props,
                    values: values,
                    notifier: retrieveNotifier(object, data)
                };

            if (getDescriptor) {
                descs = data.descriptors = [];
                while (i < props.length) {
                    descs[i] = getDescriptor(object, props[i]);
                    values[i] = object[props[i++]];
                }
            } else while (i < props.length)
                values[i] = object[props[i++]];

            observed.set(object, data);

            return data;
        }
770903
function(data) {
            var paramArray = [],
                key, value;
        // TODO: use `object` module
            for (key in data) {
                value = data[key];
                key = ENCODE_URI_COMPONENT(key);
                paramArray.push((value === null) ? key : (key + '=' + ENCODE_URI_COMPONENT(value)));
            }
            console.log(NAME, '_toQueryString --> '+paramArray.join('&'));
            return paramArray.join('&');
        }
785202
function(geometry) {
            var gml = this.createElementNS(this.gmlns, "gml:MultiPoint");
            var points = geometry.components;
            var pointMember, pointGeom;
            for(var i=0; i<points.length; i++) { 
                pointMember = this.createElementNS(this.gmlns,
                                                   "gml:pointMember");
                pointGeom = this.buildGeometry.point.apply(this,
                                                               [points[i]]);
                pointMember.appendChild(pointGeom);
                gml.appendChild(pointMember);
            }
            return gml;            
        }
210105
def read_geojson(filename):
    
    json_file = open(filename)
    data = json.load(json_file)
    json_file.close()
    times = data["properties"]["times"]
    main_data = dict(timesteps=[], masks=[], x=[], y=[], i=[], j=[])
    attribute_data = dict()
    for feature in data["features"]:
        for main_name in main_data.keys():
            main_data[main_name].append(np.array(feature["properties"][main_name]))
        for k, v in feature["properties"]["attributes"].items():
            if k not in attribute_data.keys():
                attribute_data[k] = [np.array(v)]
            else:
                attribute_data[k].append(np.array(v))
    kwargs = {}
    for kw in ["dx", "step", "u", "v"]:
        if kw in data["properties"].keys():
            kwargs[kw] = data["properties"][kw]
    sto = STObject(main_data["timesteps"], main_data["masks"], main_data["x"], main_data["y"],
                   main_data["i"], main_data["j"], times[0], times[-1], **kwargs)
    for k, v in attribute_data.items():
        sto.attributes[k] = v
    return sto
566390
function(features) {
            if (!(features instanceof Array)) {
                features = [features];
            }
            var result = this.toTriangles().map(function(triPoly) {
                    return triPoly.getTetraFeatures(features);
                })
                .reduce(function(pv, v) {
                    return v.map(function(feat, i) {
                        return feat + (pv === 0 ? 0 : pv[i]);
                    });
                }, 0);
            return (result.length == 1) ? result[0] : result;
        }