normalize from zero to one for row or table
506543
def zero_to_one(table, option):
    
    if option == 'table':
        m = min(min(table))
        ma = max(max(table))
    t = []
    for row in table:
        t_row = []
        if option != 'table':
            m, ma = min(row), max(row)
        for i in row:
            if ma == m:
                t_row.append(0)
            else:
                t_row.append((i - m)/(ma - m))
        t.append(t_row)
    return t
1251450
def normalize(self):
        """"""
        chrfunc = chr if py3k else HTMLEntity._unichr
        if self.named:
            return chrfunc(htmlentities.name2codepoint[self.value])
        if self.hexadecimal:
            return chrfunc(int(self.value, 16))
        return chrfunc(int(self.value))
714420
function normalizeValues(matrix, vals) {
  reverseUnits.reduce((previous, current) => {
    if (!isUndefined(vals[current])) {
      if (previous) {
        convert(matrix, vals, previous, vals, current);
      }
      return current;
    } else {
      return previous;
    }
  }, null);
}
52192
def normalize_value(value):
	""""""

	value = str(value)
	value = value.casefold()

	value = re.sub(r'\/\s*\d+', '', value)  # Remove "/<totaltracks>" from track number.
	value = re.sub(r'^0+([0-9]+)', r'\1', value)  # Remove leading zero(s) from track number.
	value = re.sub(r'^(\d+)\.+', r'\1', value)  # Remove dots from track number.
	value = re.sub(r'[^\w\s]', '', value)  # Remove leading non-word characters.
	value = re.sub(r'^the\s+', '', value)  # Remove leading "the".
	value = re.sub(r'^\s+', '', value)  # Remove leading spaces.
	value = re.sub(r'\s+$', '', value)  # Remove trailing spaces.
	value = re.sub(r'\s+', ' ', value)  # Reduce multiple spaces to a single space.

	return value
1170081
def normalize_val(self, value=_nothing):
        
        if isinstance(value, basestring):
            value = self.normalize_text(value)
        if self.ignore_empty_slots and self.value_is_empty(value):
            value = _nothing
        return value
1147307
function normalize(tags, ranges) {
  ranges = ranges === undefined || ranges === null ? asterisk : ranges

  return {tags: cast(tags, 'tag'), ranges: cast(ranges, 'range')}
}
1045833
def normalize(data, width):
    """"""
    min_dat = find_min(data)
    # We offset by the minimum if there's a negative.
    off_data = []
    if min_dat < 0:
        min_dat = abs(min_dat)
        for dat in data:
            off_data.append([_d + min_dat for _d in dat])
    else:
        off_data = data
    min_dat = find_min(off_data)
    max_dat = find_max(off_data)

    if max_dat < width:
        # Don't need to normalize if the max value
        # is less than the width we allow.
        return off_data

    # max_dat / width is the value for a single tick. norm_factor is the
    # inverse of this value
    # If you divide a number to the value of single tick, you will find how
    # many ticks it does contain basically.
    norm_factor = width / float(max_dat)
    normal_dat = []
    for dat in off_data:
        normal_dat.append([_v * norm_factor for _v in dat])

    return normal_dat
26543
function normalize(cells, attr) {
  if(attr) {
    var len = cells.length
    var zipped = new Array(len)
    for(var i=0; i<len; ++i) {
      zipped[i] = [cells[i], attr[i]]
    }
    zipped.sort(compareZipped)
    for(var i=0; i<len; ++i) {
      cells[i] = zipped[i][0]
      attr[i] = zipped[i][1]
    }
    return cells
  } else {
    cells.sort(compareCells)
    return cells
  }
}
1260442
def normalize(self):
        ''''''
        error = self.a * self.b
        t0 = self.a - (self.b * (0.5 * error))
        t1 = self.b - (self.a * (0.5 * error))
        t2 = t0 % t1
        self.a = t0 * (1.0 / t0.length())
        self.b = t1 * (1.0 / t1.length())
        self.c = t2 * (1.0 / t2.length())
599422
def normalize(self):
        """"""
        length = self.length()
        if length > 0:
            self.X /= length
            self.Y /= length
        else:
            print "Length 0, cannot normalize."
395786
def _normalize_cursor(self, cursor, orders):
        """"""
        if cursor is None:
            return

        if not orders:
            raise ValueError(_NO_ORDERS_FOR_CURSOR)

        document_fields, before = cursor

        order_keys = [order.field.field_path for order in orders]

        if isinstance(document_fields, document.DocumentSnapshot):
            snapshot = document_fields
            document_fields = snapshot.to_dict()
            document_fields["__name__"] = snapshot.reference

        if isinstance(document_fields, dict):
            # Transform to list using orders
            values = []
            data = document_fields
            for order_key in order_keys:
                try:
                    values.append(field_path_module.get_nested_value(order_key, data))
                except KeyError:
                    msg = _MISSING_ORDER_BY.format(order_key, data)
                    raise ValueError(msg)
            document_fields = values

        if len(document_fields) != len(orders):
            msg = _MISMATCH_CURSOR_W_ORDER_BY.format(document_fields, order_keys)
            raise ValueError(msg)

        _transform_bases = (transforms.Sentinel, transforms._ValueList)

        for index, key_field in enumerate(zip(order_keys, document_fields)):
            key, field = key_field

            if isinstance(field, _transform_bases):
                msg = _INVALID_CURSOR_TRANSFORM
                raise ValueError(msg)

            if key == "__name__" and isinstance(field, six.string_types):
                document_fields[index] = self._parent.document(field)

        return document_fields, before
1298495
def normalize_value(text):
    
    result = text.replace('\n', ' ')
    result = re.subn('[ ]{2,}', ' ', result)[0]
    return result
468358
def normalize(self):
        
        maximum = self.max()
        if maximum:
            self.values = [value / maximum for value in self.values]
1326992
def _reduce_datetimes(row):
    """"""

    row = list(row)

    for i in range(len(row)):
        if hasattr(row[i], 'isoformat'):
            row[i] = row[i].isoformat()
    return tuple(row)
1369064
def normalize(self, email, **kwargs):
        """"""
        emails = super(EmailType, self).normalize(email, **kwargs)
        return [e.lower() for e in emails]
1176407
function normalize(from, to) {
  if (from && (isNaN(from) || from <= 0) || (to && (isNaN(to) || to <= 0))) {
    throw new Error('invalid port range: required > 0');
  }
  if ((from && from > MAX) || (to && to > MAX)) {
    throw new Error(f('invalid port range: required < %d', MAX));
  }
  if (to && to < from) {
    throw new Error('invalid port range: required max >= min');
  }
  if (!from) {
    from = min;
    to = to || max;
  } else {
    to = to || from;
  }
  return {
    from: from,
    to: to
  };
}
272128
def normalise_rows(matrix):
    

    lengths = np.apply_along_axis(np.linalg.norm, 1, matrix)
    if not (lengths > 0).all():
        # raise ValueError('Cannot normalise 0 length vector to length 1')
        # print(matrix)
        lengths[lengths == 0] = 1
    return matrix / lengths[:, np.newaxis]