create marker ids corresponding to known marker textures
191882
function marker(markers, group, options) {
        var activation = group.activation; // reset marker elements

        activation.forEach(function (buffer) {
          return buffer && buffer.destroy && buffer.destroy();
        });
        activation.length = 0; // single sdf marker

        if (!markers || typeof markers[0] === 'number') {
          var id = _this3.addMarker(markers);

          activation[id] = true;
        } // per-point markers use mask buffers to enable markers in vert shader
        else {
            var markerMasks = [];

            for (var _i = 0, l = Math.min(markers.length, group.count); _i < l; _i++) {
              var _id = _this3.addMarker(markers[_i]);

              if (!markerMasks[_id]) markerMasks[_id] = new Uint8Array(group.count); // enable marker by default

              markerMasks[_id][_i] = 1;
            }

            for (var _id2 = 0; _id2 < markerMasks.length; _id2++) {
              if (!markerMasks[_id2]) continue;
              var opts = {
                data: markerMasks[_id2],
                type: 'uint8',
                usage: 'static'
              };

              if (!activation[_id2]) {
                activation[_id2] = regl.buffer(opts);
              } else {
                activation[_id2](opts);
              }

              activation[_id2].data = markerMasks[_id2];
            }
          }

        return markers;
      }
304844
def get_map(self):
        """"""
        if self._cache['map']:
            return self._cache['map']
        map_id = self._header.scenario.game_settings.map_id
        instructions = self._header.scenario.messages.instructions
        size = mgz.const.MAP_SIZES.get(self._header.map_info.size_x)
        dimension = self._header.map_info.size_x
        custom = True
        name = 'Unknown'
        language = None
        encoding = 'unknown'

        # detect encoding and language
        for pair in ENCODING_MARKERS:
            marker = pair[0]
            test_encoding = pair[1]
            e_m = marker.encode(test_encoding)
            for line in instructions.split(b'\n'):
                pos = line.find(e_m)
                if pos > -1:
                    encoding = test_encoding
                    name = line[pos+len(e_m):].decode(encoding)
                    language = pair[2]
                    break

        # disambiguate certain languages
        if not language:
            language = 'unknown'
            for pair in LANGUAGE_MARKERS:
                if instructions.find(pair[0].encode(pair[1])) > -1:
                    language = pair[2]
                    break
        self._cache['encoding'] = encoding
        self._cache['language'] = language

        # lookup base game map if applicable
        if map_id != 44:
            if map_id not in mgz.const.MAP_NAMES:
                raise ValueError('unspecified builtin map')
            name = mgz.const.MAP_NAMES[map_id]
            custom = False

        # extract map seed
        match = re.search(b'\x00.*? (\-?[0-9]+)\x00.*?\.rms', instructions)
        seed = None
        if match:
            seed = int(match.group(1))

        # extract userpatch modes
        has_modes = name.find(': !')
        mode_string = ''
        if has_modes > -1:
            mode_string = name[has_modes + 3:]
            name = name[:has_modes]
        modes = {
            'direct_placement': 'P' in mode_string,
            'effect_quantity': 'C' in mode_string,
            'guard_state': 'G' in mode_string,
            'fixed_positions': 'F' in mode_string
        }

        self._cache['map'] = {
            'id': map_id if not custom else None,
            'name': name.strip(),
            'size': size,
            'dimension': dimension,
            'seed': seed,
            'modes': modes,
            'custom': custom,
            'zr': name.startswith('ZR@')
        }
        return self._cache['map']
813770
def _get_cmaps(names):
    """"""
    import matplotlib.pyplot as plt
    available_cmaps = list(
        chain(plt.cm.cmap_d, _cmapnames, rcParams['colors.cmaps']))
    names = list(names)
    wrongs = []
    for arg in (arg for arg in names if (not isinstance(arg, Colormap) and
                                         arg not in available_cmaps)):
        if isinstance(arg, str):
            similarkeys = get_close_matches(arg, available_cmaps)
        if similarkeys != []:
            warn("Colormap %s not found in standard colormaps.\n"
                 "Similar colormaps are %s." % (arg, ', '.join(similarkeys)))
        else:
            warn("Colormap %s not found in standard colormaps.\n"
                 "Run function without arguments to see all colormaps" % arg)
        names.remove(arg)
        wrongs.append(arg)
    if not names and not wrongs:
        names = sorted(m for m in available_cmaps if not m.endswith("_r"))
    return names
974132
def _init_trace(self, n,  color, style,
                    linewidth=2.5, zorder=None, marker=None, markersize=6):
        
        while n >= len(self.traces):
            self.traces.append(LineProperties())
        line = self.traces[n]
        label = "trace %i" % (n+1)
        line.label = label
        line.drawstyle = 'default'
        if zorder     is None:
            zorder = 5 * (n+1)
        line.zorder = zorder
        if color      is not None: line.color = color
        if style      is not None: line.style = style
        if linewidth  is not None: line.linewidth = linewidth
        if marker     is not None: line.marker = marker
        if markersize is not None: line.markersize = markersize
        self.traces[n] = line
897425
def _read_current_marker(self):
        """"""
        return self._geno_values[
            np.frombuffer(self._bed.read(self._nb_bytes), dtype=np.uint8)
        ].flatten(order="C")[:self._nb_samples]
105992
def create_colormap(palette):
    """"""
    from trollimage.colormap import Colormap
    fname = palette.get('filename', None)
    if fname:
        data = np.load(fname)
        cmap = []
        num = 1.0 * data.shape[0]
        for i in range(int(num)):
            cmap.append((i / num, (data[i, 0] / 255., data[i, 1] / 255.,
                                   data[i, 2] / 255.)))
        return Colormap(*cmap)

    colors = palette.get('colors', None)
    if isinstance(colors, list):
        cmap = []
        values = palette.get('values', None)
        for idx, color in enumerate(colors):
            if values:
                value = values[idx]
            else:
                value = idx / float(len(colors) - 1)
            cmap.append((value, tuple(color)))
        return Colormap(*cmap)

    if isinstance(colors, str):
        from trollimage import colormap
        import copy
        return copy.copy(getattr(colormap, colors))

    return None
1089218
function (options) {
		var ret,
			series = this.series,
			pointArrayMap = series.pointArrayMap || ['y'],
			valueCount = pointArrayMap.length,
			firstItemType,
			i = 0,
			j = 0;

		if (typeof options === 'number' || options === null) {
			ret = { y: options };

		} else if (isArray(options)) {
			ret = {};
			// with leading x value
			if (options.length > valueCount) {
				firstItemType = typeof options[0];
				if (firstItemType === 'string') {
					ret.name = options[0];
				} else if (firstItemType === 'number') {
					ret.x = options[0];
				}
				i++;
			}
			while (j < valueCount) {
				ret[pointArrayMap[j++]] = options[i++];
			}			
		} else if (typeof options === 'object') {
			ret = options;

			// This is the fastest way to detect if there are individual point dataLabels that need 
			// to be considered in drawDataLabels. These can only occur in object configs.
			if (options.dataLabels) {
				series._hasPointLabels = true;
			}

			// Same approach as above for markers
			if (options.marker) {
				series._hasPointMarkers = true;
			}
		}
		return ret;
	}
956030
def _get_texture(arr, default, n_items, from_bounds):
    
    if not hasattr(default, '__len__'):  # pragma: no cover
        default = [default]
    n_cols = len(default)
    if arr is None:  # pragma: no cover
        arr = np.tile(default, (n_items, 1))
    assert arr.shape == (n_items, n_cols)
    # Convert to 3D texture.
    arr = arr[np.newaxis, ...].astype(np.float64)
    assert arr.shape == (1, n_items, n_cols)
    # NOTE: we need to cast the texture to [0., 1.] (float texture).
    # This is easy as soon as we assume that the signal bounds are in
    # [-1, 1].
    assert len(from_bounds) == 2
    m, M = map(float, from_bounds)
    assert np.all(arr >= m)
    assert np.all(arr <= M)
    arr = (arr - m) / (M - m)
    assert np.all(arr >= 0)
    assert np.all(arr <= 1.)
    return arr
606988
function identicon($str,$size=64,$blocks=4) {
		$sprites=[
			[.5,1,1,0,1,1],
			[.5,0,1,0,.5,1,0,1],
			[.5,0,1,0,1,1,.5,1,1,.5],
			[0,.5,.5,0,1,.5,.5,1,.5,.5],
			[0,.5,1,0,1,1,0,1,1,.5],
			[1,0,1,1,.5,1,1,.5,.5,.5],
			[0,0,1,0,1,.5,0,0,.5,1,0,1],
			[0,0,.5,0,1,.5,.5,1,0,1,.5,.5],
			[.5,0,.5,.5,1,.5,1,1,.5,1,.5,.5,0,.5],
			[0,0,1,0,.5,.5,1,.5,.5,1,.5,.5,0,1],
			[0,.5,.5,1,1,.5,.5,0,1,0,1,1,0,1],
			[.5,0,1,0,1,1,.5,1,1,.75,.5,.5,1,.25],
			[0,.5,.5,0,.5,.5,1,0,1,.5,.5,1,.5,.5,0,1],
			[0,0,1,0,1,1,0,1,1,.5,.5,.25,.5,.75,0,.5,.5,.25],
			[0,.5,.5,.5,.5,0,1,0,.5,.5,1,.5,.5,1,.5,.5,0,1],
			[0,0,1,0,.5,.5,.5,0,0,.5,1,.5,.5,1,.5,.5,0,1]
		];
		$hash=sha1($str);
		$this->data=imagecreatetruecolor($size,$size);
		list($r,$g,$b)=$this->rgb(hexdec(substr($hash,-3)));
		$fg=imagecolorallocate($this->data,$r,$g,$b);
		imagefill($this->data,0,0,IMG_COLOR_TRANSPARENT);
		$ctr=count($sprites);
		$dim=$blocks*floor($size/$blocks)*2/$blocks;
		for ($j=0,$y=ceil($blocks/2);$j<$y;$j++)
			for ($i=$j,$x=$blocks-1-$j;$i<$x;$i++) {
				$sprite=imagecreatetruecolor($dim,$dim);
				imagefill($sprite,0,0,IMG_COLOR_TRANSPARENT);
				$block=$sprites[hexdec($hash[($j*$blocks+$i)*2])%$ctr];
				for ($k=0,$pts=count($block);$k<$pts;$k++)
					$block[$k]*=$dim;
				imagefilledpolygon($sprite,$block,$pts/2,$fg);
				for ($k=0;$k<4;$k++) {
					imagecopyresampled($this->data,$sprite,
						$i*$dim/2,$j*$dim/2,0,0,$dim/2,$dim/2,$dim,$dim);
					$this->data=imagerotate($this->data,90,
						imagecolorallocatealpha($this->data,0,0,0,127));
				}
				imagedestroy($sprite);
			}
		imagesavealpha($this->data,TRUE);
		return $this->save();
	}
869239
function( smooth, mipmap, miplinear ){
    var gl = this.gl;
    var filter = getFilter( !!smooth, !!mipmap, !!miplinear);
    gl.texParameteri( T2D, gl.TEXTURE_MAG_FILTER, getFilter( !!smooth, false, false ) );
    gl.texParameteri( T2D, gl.TEXTURE_MIN_FILTER, filter );
  }
763735
function makeRowIds(numRows, maxLines) {
  var printVec = jd.seq(numRows)._toTruncatedPrintVector(maxLines);
  return printVec.map(function(str) {
    return str === _SKIP_MARKER ? str : str + _ROW_ID_SUFFIX;
  });
}
1237254
def store_markerformat(rgbFore, rgbBack, marker, grbit, icvFore, icvBack, miSize)# :nodoc:
    record  = 0x1009     # Record identifier.
    length  = 0x0014     # Number of bytes to follow.
    # rgbFore            # Foreground RGB color.
    # rgbBack            # Background RGB color.
    # marker             # Type of marker.
    # grbit              # Format flags.
    # icvFore            # Color index marker border.
    # icvBack            # Color index marker fill.
    # miSize             # Size of line markers.

    header = [record, length].pack('vv')
    data  = [rgbFore].pack('V')
    data += [rgbBack].pack('V')
    data += [marker].pack('v')
    data += [grbit].pack('v')
    data += [icvFore].pack('v')
    data += [icvBack].pack('v')
    data += [miSize].pack('V')

    append(header, data)
  end
693885
def create(self):
        """ ------ MARKERS ------ """
        tab0 = QTableWidget()
        self.idx_marker = tab0

        tab0.setColumnCount(3)
        tab0.horizontalHeader().setStretchLastSection(True)
        tab0.setSelectionBehavior(QAbstractItemView.SelectRows)
        tab0.setEditTriggers(QAbstractItemView.NoEditTriggers)
        go_to_marker = lambda r, c: self.go_to_marker(r, c, 'dataset')
        tab0.cellDoubleClicked.connect(go_to_marker)
        tab0.setHorizontalHeaderLabels(['Start', 'Duration', 'Text'])

        """ ------ SUMMARY ------ """
        tab1 = QWidget()
        self.idx_eventtype = QComboBox(self)
        self.idx_stage = QComboBox(self)
        self.idx_stage.activated.connect(self.get_sleepstage)
        self.idx_quality = QComboBox(self)
        self.idx_quality.activated.connect(self.get_quality)

        self.idx_annotations = QPushButton('Load Annotation File...')
        self.idx_annotations.clicked.connect(self.load_annot)
        self.idx_rater = QLabel('')

        b0 = QGroupBox('Info')
        form = QFormLayout()
        b0.setLayout(form)

        form.addRow('File:', self.idx_annotations)
        form.addRow('Rater:', self.idx_rater)

        b1 = QGroupBox('Staging')
        b2 = QGroupBox('Signal quality')

        layout = QVBoxLayout()
        layout.addWidget(b0)
        layout.addWidget(b1)
        layout.addWidget(b2)
        self.idx_summary = layout

        tab1.setLayout(layout)

        """ ------ ANNOTATIONS ------ """
        tab2 = QWidget()
        tab_annot = QTableWidget()
        self.idx_annot_list = tab_annot
        delete_row = QPushButton('Delete')
        delete_row.clicked.connect(self.delete_row)

        scroll = QScrollArea(tab2)
        scroll.setWidgetResizable(True)

        evttype_group = QGroupBox('Event Types')
        scroll.setWidget(evttype_group)
        self.idx_eventtype_scroll = scroll

        tab_annot.setColumnCount(5)
        tab_annot.setHorizontalHeaderLabels(['Start', 'Duration', 'Text',
                                             'Type', 'Channel'])
        tab_annot.horizontalHeader().setStretchLastSection(True)
        tab_annot.setSelectionBehavior(QAbstractItemView.SelectRows)
        tab_annot.setEditTriggers(QAbstractItemView.NoEditTriggers)
        go_to_annot = lambda r, c: self.go_to_marker(r, c, 'annot')
        tab_annot.cellDoubleClicked.connect(go_to_annot)
        tab_annot.cellDoubleClicked.connect(self.reset_current_row)

        layout = QVBoxLayout()
        layout.addWidget(self.idx_eventtype_scroll, stretch=1)
        layout.addWidget(self.idx_annot_list)
        layout.addWidget(delete_row)
        tab2.setLayout(layout)

        """ ------ TABS ------ """
        self.addTab(tab0, 'Markers')
        self.addTab(tab1, 'Summary')  # disable
        self.addTab(tab2, 'Annotations')
1088909
def _get_line_styles(marker_str):
    
    def _extract_marker_value(marker_str, code_dict):
        """Extracts the marker value from a given marker string.

        Looks up the `code_dict` and returns the corresponding marker for a
        specific code.

        For example if `marker_str` is 'g-o' then the method extracts
        - 'green' if the code_dict is color_codes,
        - 'circle' if the code_dict is marker_codes etc.
        """
        val = None
        for code in code_dict:
            if code in marker_str:
                val = code_dict[code]
                break
        return val

    return [_extract_marker_value(marker_str, code_dict) for
            code_dict in [LINE_STYLE_CODES, COLOR_CODES, MARKER_CODES]]
868625
function doTidyUp(l) {
    var d = parseInt(Date.now()/1000);
    for (var m in markers) {
        if ((l && (l == markers[m].lay)) || typeof markers[m].ts != "undefined") {
            if ((l && (l == markers[m].lay)) || (markers[m].hasOwnProperty("ts") && (Number(markers[m].ts) < d) && (markers[m].lay !== "_drawing"))) {
                //console.log("STALE :",m);
                layers[markers[m].lay].removeLayer(markers[m]);
                if (typeof polygons[m] != "undefined") {
                    layers[markers[m].lay].removeLayer(polygons[m]);
                    delete polygons[m];
                }
                if (typeof polygons[m+"_"] != "undefined") {
                    layers[polygons[m+"_"].lay].removeLayer(polygons[m+"_"]);
                    delete polygons[m+"_"];
                }
                delete markers[m];
            }
        }
    }
    if (l) {
        if (layers[l]) { map.removeLayer(layers[l]); layercontrol.removeLayer(layers[l]); delete layers[l]; }
        if (overlays[l]) { map.removeLayer(overlays[l]); layercontrol.removeLayer(overlays[l]); delete overlays[l]; }
    }
}
356292
def _make_marker_token(self, type_):
        """"""
        tok = Token(type_,
                    '',
                    self.line,
                    self.line_num,
                    self.start,
                    self.start)
        return tok
1186389
def markers():
    ''' 
    '''
    print("Available markers: \n\n - " + "\n - ".join(list(MarkerType)))
    print()
    print("Shortcuts: \n\n" + "\n".join(" %r: %s" % item for item in _MARKER_SHORTCUTS.items()))