dasi.cost.utils

Cost utilities.

Functions

df_to_np_ranged(min_col, max_col, df[, …])

Expand a pandas data frame, which has min and max span columns defined, into a numpy ndarray.

duplicates(b[, axis])

Find duplicates within the specified axes.

flatten_axis(a[, axis, copy])

Flatten the array along the specified axes.

lexargmin(a, axis)

square_broadcast(a, b[, a_axis, b_axis])

Broadcast b to the a_axis of ndarray ‘a’ and perform a hstack.

unshape(shape, axis)

Classes

Slicer

Functions

df_to_np_ranged(min_col, max_col, df[, …])

Expand a pandas data frame, which has min and max span columns defined, into a numpy ndarray.

duplicates(b[, axis])

Find duplicates within the specified axes.

flatten_axis(a[, axis, copy])

Flatten the array along the specified axes.

square_broadcast(a, b[, a_axis, b_axis])

Broadcast b to the a_axis of ndarray ‘a’ and perform a hstack.

dasi.cost.utils.df_to_np_ranged(min_col, max_col, df, cols=None, dtype=None)[source]

Expand a pandas data frame, which has min and max span columns defined, into a numpy ndarray. Specific columns to include in the expansion can be defined in the remaining_cols argument, else all columns are used.

For example:

df = pd.DataFrame([
  [0, 10, 10], [10, 20, 100]
], columns=['min', 'max', 'x'])
a = df_to_np_ranged('min', 'max', df, dtype=np.float64)
assert a.shape == (20, 2)
assert a[5] == [5., 10.]
assert a[17] == [17., 100.]
dasi.cost.utils.duplicates(b, axis=None)[source]

Find duplicates within the specified axes.

If axis not provided, flatten array and return duplicates.

dasi.cost.utils.flatten_axis(a, axis=None, copy=True)[source]

Flatten the array along the specified axes.

dasi.cost.utils.square_broadcast(a, b, a_axis=0, b_axis=1)[source]

Broadcast b to the a_axis of ndarray ‘a’ and perform a hstack.