Constructs a vector of the given dtype backed by the given array without checking or modifying any of the array elements
773329
function newVector(array, dtype) {
  validateDtype(dtype);
  var proto = PROTO_MAP[dtype];
  var vector = Object.create(proto);
  vector._init(array);
  return vector;
}
1240965
def _prepare_src_array(source_array, dtype):
    
    if not isinstance(source_array, NDArray) and not isinstance(source_array, np.ndarray):
        try:
            source_array = np.array(source_array, dtype=dtype)
        except:
            raise TypeError('values must be array like object')
    return source_array
721554
def _as_array(arr, dtype=None):
    
    if arr is None:
        return None
    if isinstance(arr, np.ndarray) and dtype is None:
        return arr
    if isinstance(arr, integer_types + (float,)):
        arr = [arr]
    out = np.asarray(arr)
    if dtype is not None:
        if out.dtype != dtype:
            out = out.astype(dtype)
    if out.dtype not in _ACCEPTED_ARRAY_DTYPES:
        raise ValueError("'arr' seems to have an invalid dtype: "
                         "{0:s}".format(str(out.dtype)))
    return out
924456
function( f ) {
			var i, vec, newArr = [];

			for ( i = 0; i < this.array.length; i++ ) {
				newArr.push(f(this.array[i]));
			}
			vec = new $.Vector();
			return vec.update(newArr);
		}
25425
def _dtype_array(self):
        """"""
        attrtype = []
        attrdiff = []

        for key in self._headers:
            if self.attr[key][0] == 'continuous':
                attrtype.append(1)
            else:
                attrtype.append(0)
            attrdiff.append(self.attr[key][3])

        attrtype = np.array(attrtype)
        cidx = np.where(attrtype == 1)[0]
        didx = np.where(attrtype == 0)[0]

        attrdiff = np.array(attrdiff)

        return attrdiff, cidx, didx
467486
def vector_check(vector):
    
    for i in vector:
        if isinstance(i, int) is False:
            return False
        if i < 0:
            return False
    return True
195521
def _interleaved_dtype(
        blocks: List[Block]
) -> Optional[Union[np.dtype, ExtensionDtype]]:
    
    if not len(blocks):
        return None

    return find_common_type([b.dtype for b in blocks])
304941
def recast opts={}
      opts.each do |vector_name, dtype|
        self[vector_name].cast(dtype: dtype)
      end
    end
439740
def patternVector(self, vector):
        
        if not self.patterned: return vector
        if type(vector) == int:
            if self.getWord(vector) != '':
                return self.getWord(vector)
            else:
                return vector
        elif type(vector) == float:
            if self.getWord(vector) != '':
                return self.getWord(vector)
            else:
                return vector
        elif type(vector) == str:
            return vector
        elif type(vector) == list:
            if self.getWord(vector) != '':
                return self.getWord(vector)
        # should be a list
        vec = []
        for v in vector:
            if self.getWord(v) != '':
                retval = self.getWord(v)
                vec.append( retval )
            else:
                retval = self.patternVector(v)
                vec.append( retval )                
        return vec
1088266
@SuppressWarnings("unchecked")
    @Override
    public Vector<Integer> readVectorInt() {
        log.debug("readVectorInt");
        int type = readInteger();
        if ((type & 1) == 0) {
            return (Vector<Integer>) getReference(type >> 1);
        }
        int len = type >> 1;
        Vector<Integer> array = new Vector<Integer>(len);
        storeReference(array);
        @SuppressWarnings("unused")
        int ref2 = readInteger();
        for (int j = 0; j < len; ++j) {
            array.add(buf.getInt());
        }
        return array;
    }
1318147
def apply_to_vector(self, vector):
        
        if isinstance(vector, np.ndarray):
            vector = vector.tolist()

        libfn = utils.get_lib_fn('transformVector%s' % (self._libsuffix))
        return np.asarray(libfn(self.pointer, vector))
1008758
function isTypedArray( v ) {
	var i;
	v = typeName( v );
	for ( i = 0; i < NAMES.length; i++ ) {
		if ( NAMES[ i ] === v ) {
			return true;
		}
	}
	return false;
}
1094467
def GetVectorAsNumpy(self, flags, off):
        
        offset = self.Vector(off)
        length = self.VectorLen(off) # TODO: length accounts for bytewidth, right?
        numpy_dtype = N.to_numpy_type(flags)
        return encode.GetVectorAsNumpy(numpy_dtype, self.Bytes, length, offset)
323156
def vector(vect_in):
    
    if isinstance(vect_in, cadquery.Vector):
        return vect_in
    elif isinstance(vect_in, (tuple, list)):
        return cadquery.Vector(vect_in)

    raise CastingError(
        "Cannot cast object type of {!r} to a vector".format(vect_in)
    )
1328658
def read_array(self, dtype, count=-1, out=None):
        """"""
        fh = self._fh
        dtype = numpy.dtype(dtype)

        if count < 0:
            size = self._size if out is None else out.nbytes
            count = size // dtype.itemsize
        else:
            size = count * dtype.itemsize

        result = numpy.empty(count, dtype) if out is None else out

        if result.nbytes != size:
            raise ValueError('size mismatch')

        n = fh.readinto(result)
        if n != size:
            raise ValueError('failed to read %i bytes' % size)

        if not result.dtype.isnative:
            if not dtype.isnative:
                result.byteswap(True)
            result = result.newbyteorder()
        elif result.dtype.isnative != dtype.isnative:
            result.byteswap(True)

        if out is not None:
            if hasattr(out, 'flush'):
                out.flush()

        return result
429843
def _copy_with_dtype(data, dtype):
    
    result = np.empty(data.shape, dtype)
    result[...] = data
    return result
1176573
def _vector(x, type='row'):
    """"""
    if isinstance(x, (list, tuple)):
        x = np.array(x, dtype=np.float32)
    elif not isinstance(x, np.ndarray):
        x = np.array([x], dtype=np.float32)
    assert x.ndim == 1
    if type == 'column':
        x = x[:, None]
    return x