MCPcopy Create free account
hub / github.com/cosdata/cosdata / generate_random_sparse_vector

Function generate_random_sparse_vector

tests/test-usv.py:146–156  ·  view source on GitHub ↗
(id, dimension, non_zero_dims)

Source from the content-addressed store, hash-verified

144
145
146def generate_random_sparse_vector(id, dimension, non_zero_dims):
147 # Generate a random number of non-zero dimensions between 20 and 100
148 actual_non_zero_dims = random.randint(20, non_zero_dims)
149
150 # Generate unique indices
151 indices = sorted(random.sample(range(dimension), actual_non_zero_dims))
152
153 # Generate values between 0 and 2.0
154 values = np.random.uniform(0.0, 2.0, actual_non_zero_dims).tolist()
155
156 return {"id": str(id), "indices": indices, "values": values}
157
158
159def generate_dataset(num_vectors, dimension, max_non_zero_dims):

Callers 1

generate_datasetFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected