Clips (limits) the values in an array.
778244
def clip(attrs, inputs, proto_obj):
    """"""
    new_attrs = translation_utils._fix_attribute_names(attrs, {'min' : 'a_min',
                                                               'max' : 'a_max'})
    if 'a_max' not in new_attrs:
        new_attrs = translation_utils._add_extra_attributes(new_attrs, {'a_max' : np.inf})
    if 'a_min' not in new_attrs:
        new_attrs = translation_utils._add_extra_attributes(new_attrs, {'a_min' : -np.inf})
    return 'clip', new_attrs, inputs
441832
function arraySample (array, number) {
  var result = arrayShuffle(array)
  if (arguments.length <= 1) {
    return result[0]
  }
  if (number < result.length) {
    result.length = number || 0
  }
  return result
}
1334291
function(start_index, values, names) {

		if (start_index >= this._count) Lava.t("Index is out of range");

		var i = 0,
			count = values.length,
			added_uids = [],
			added_names = [];

		if (names) {

			if (count != names.length) Lava.t("If names array is provided, it must be equal length with values array.");
			added_names = names;

		} else {

			for (; i < count; i++) {

				added_names.push(null);

			}

		}

		for (; i < count; i++) {

			added_uids.push(this._uid++);

		}

		if (start_index == 0) {

			// prepend to beginning
			this._data_uids = added_uids.concat(this._data_uids);
			this._data_values = values.concat(this._data_values);
			this._data_names = added_names.concat(this._data_names);

		} else if (start_index == this._count - 1) {

			// append to the end
			this._data_uids = this._data_uids.concat(added_uids);
			this._data_values = this._data_values.concat(values);
			this._data_names = this._data_names.concat(added_names);

		} else {

			this._data_uids = this._data_uids.slice(0, start_index).concat(added_uids).concat(this._data_uids.slice(start_index));
			this._data_values = this._data_values.slice(0, start_index).concat(values).concat(this._data_values.slice(start_index));
			this._data_names = this._data_names.slice(0, start_index).concat(added_names).concat(this._data_names.slice(start_index));

		}

		this._setLength(this._count + count);

		this._fire('items_added', {
			uids: added_uids,
			values: values,
			names: added_names
		});

		this._fire('collection_changed');

	}
474502
private float limit(float value, float min, float max) {
    return Math.min(Math.max(min, value), max);
  }
1031114
def clips(self, **kwargs):
        
        path = self._get_id_path('clips')

        response = self._GET(path, kwargs)
        self._set_attrs_to_values(response)
        return response
764363
function getArrayFromRange(l, h, s) {
  var a = [];
  s = s || 1;
  for(var i = l; i < h; i += s) {
    a.push(i);
  }
  return a;
}
366506
def pieces(array, chunk_size):
        """"""
        for i in range(0, len(array), chunk_size): yield array[i:i+chunk_size]
494259
function (i, value) {
        this.array.splice(i, 0, value);
        this.set('length', this.array.length);
        events.trigger(this, 'insert_at', i);
    }
234193
def rigthgen(self, value=0):
        """"""
        while True:
            yield self.newarray(self.nplanes_right * self.width, value)
1015651
def _fill(self, values):
        """"""
        zero = self.view.y(min(max(self.zero, self._box.ymin), self._box.ymax))

        # Check to see if the data has been padded with "none's"
        # Fill doesn't work correctly otherwise
        end = len(values) - 1
        while end > 0:
            x, y = values[end]
            if self.missing_value_fill_truncation == "either":
                if x is not None and y is not None:
                    break
            elif self.missing_value_fill_truncation == "x":
                if x is not None:
                    break
            elif self.missing_value_fill_truncation == "y":
                if y is not None:
                    break
            else:
                raise ValueError(
                    "Invalid value ({}) for config key "
                    "'missing_value_fill_truncation';"
                    " Use 'x', 'y' or 'either'".format(
                        self.missing_value_fill_truncation
                    )
                )
            end -= 1

        return ([(values[0][0], zero)] + values + [(values[end][0], zero)])
1277325
function insert(arr, index, values) {
  [].splice.apply(arr, [index, 0].concat(values));
}
924829
def normalize(x, min_value, max_value):
    """"""
    x = (x - min_value) / (max_value - min_value)
    return clip(x, 0, 1)
1312171
function() {
      this.bounds.reset();
      if (this.slices.length) {
        this.bounds.addValue(this.slices[0].start);
        this.bounds.addValue(this.slices[this.slices.length - 1].end);
      }
      for (var id in this.counters) {
        this.counters[id].updateBounds();
        this.bounds.addRange(this.counters[id].bounds);
      }
      if (this.samples_ && this.samples_.length) {
        this.bounds.addValue(this.samples_[0].start);
        this.bounds.addValue(
            this.samples_[this.samples_.length - 1].end);
      }
    }
735560
def limit_step(self, step):
        """"""
        if self.qmax is None:
            return step
        else:
            return np.clip(step, -self.qmax, self.qmax)
23011
private static int bisect(int[] array, double value) {
        int pos = 0;
        for (int element : array) {
            if (value < element)
                break;
            pos++;
        }
        return pos;
    }
776086
def clips_value(self, dvalue):
        """"""
        try:
            return VALUES[type(dvalue)](self._env, dvalue)
        except KeyError:
            if isinstance(dvalue, (list, tuple)):
                return self.list_to_multifield(dvalue)
            if isinstance(dvalue, (clips.facts.Fact)):
                return dvalue._fact
            if isinstance(dvalue, (clips.classes.Instance)):
                return dvalue._ist

        return ffi.NULL
510165
def clamp(min, max)
      value = self
      value = [value, min].max if min
      value = [value, max].min if max
      value
    end