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

Function generate_random_sparse_vector

tests/test-sparse-vector.py:137–147  ·  view source on GitHub ↗
(id, dimension, non_zero_dims)

Source from the content-addressed store, hash-verified

135
136
137def generate_random_sparse_vector(id, dimension, non_zero_dims):
138 # Generate a random number of non-zero dimensions between 20 and 100
139 actual_non_zero_dims = random.randint(20, non_zero_dims)
140
141 # Generate unique indices
142 indices = sorted(random.sample(range(dimension), actual_non_zero_dims))
143
144 # Generate values between 0 and 2.0
145 values = np.random.uniform(0.0, 2.0, actual_non_zero_dims).tolist()
146
147 return {"id": str(id), "indices": indices, "values": values}
148
149
150def 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