python/pycubool/vector.py
def generate(cls, nrows, density: float):
        """
        Generate vector of specified size with desired values density.

        >>> vector = Vector.generate(nrows=4, density=0.5)
        >>> print(vector)
        '
          0 |   1 |   0
          1 |   . |   1
          2 |   . |   2
          3 |   1 |   3
        '

        :param nrows: Vector dimension
        :param density: Vector values density, must be within [0, 1]
        :return: Generated vector
        """

        density = min(1.0, max(density, 0.0))
        nvals_max = nrows
        nvals_to_gen = int(nvals_max * density)

        m = nrows
        rows = list()

        for i in range(nvals_to_gen):
            rows.append(random.randrange(0, m))

        return Vector.from_list(nrows=nrows, rows=rows, is_sorted=False, no_duplicates=False)

        Generate vector of specified size with desired values density.

        >>> vector = Vector.generate(nrows=4, density=0.5)
        >>> print(vector)
        '
          0 |   1 |   0
          1 |   . |   1
          2 |   . |   2
          3 |   1 |   3
        '

        :param nrows: Vector dimension
        :param density: Vector values density, must be within [0, 1]
        :return: Generated vector
        
Generate vector of specified size with desired values density.
Generate vector of specified size with desired values density .
def generate(cls, nrows, density: float):
        density = min(1.0, max(density, 0.0))
        nvals_max = nrows
        nvals_to_gen = int(nvals_max * density)
        m = nrows
        rows = list()
        for i in range(nvals_to_gen):
            rows.append(random.randrange(0, m))
        return Vector.from_list(nrows=nrows, rows=rows, is_sorted=False, no_duplicates=False)
def generate ( cls , nrows , density : float ) : density = min ( 1.0 , max ( density , 0.0 ) ) nvals_max = nrows nvals_to_gen = int ( nvals_max * density ) m = nrows rows = list ( ) for i in range ( nvals_to_gen ) : rows . append ( random . randrange ( 0 , m ) ) return Vector . from_list ( nrows = nrows , rows = rows , is_sorted = False , no_duplicates = False )
Generate vector of specified size with desired values density.
Generate vector of specified size with desired values density .
"""
        Generate vector of specified size with desired values density.

        >>> vector = Vector.generate(nrows=4, density=0.5)
        >>> print(vector)
        '
          0 |   1 |   0
          1 |   . |   1
          2 |   . |   2
          3 |   1 |   3
        '

        :param nrows: Vector dimension
        :param density: Vector values density, must be within [0, 1]
        :return: Generated vector
        """
None
cls
nrows
None
density
float
Vector values density, must be within [0, 1]
Vector values density must be within [ 0 1 ]