You can send the input as a list of values:
import prtpy
values = [4, 5, 5, 6, 7, 8, 8]
print(prtpy.partition(algorithm=prtpy.partitioning.greedy, numbins=2, items=values))
[[8, 7, 5], [8, 6, 5, 4]]
You can also send the input as a dict mapping items to values; in this case, the partition will show the items:
map_items_to_values = {"a": 4, "b": 5, "b2": 5, "c": 6, "d": 7, "e": 8, "e2": 8}
print(prtpy.partition(algorithm=prtpy.partitioning.greedy, numbins=2, items=map_items_to_values))
[['e', 'd', 'b2'], ['e2', 'c', 'b', 'a']]
For experiments, you can use a numpy random matrix:
import numpy as np
values = np.random.randint(1, 100, 20)
print(values)
print(prtpy.partition(algorithm=prtpy.partitioning.greedy, numbins=3, items=values))
[26 68 35 95 87 50 94 24 16 42 49 76 45 67 16 60 26 77 78 93]
[[95, 77, 76, 49, 45, 24], [94, 78, 68, 60, 35, 26, 16], [93, 87, 67,
50, 42, 26, 16]]
Markdown generated automatically from input_formats.py using Pweave 0.30.3 on 2025-01-26.