Supplies utility function for core and controls
test_df = pd.DataFrame({"filepath": ["fileA", "fileA", "fileB", "fileB"], "label": ["labelA", "labelB", "labelA", "labelA"]})
mixing_matrix = calculate_mixing_matrix(test_df, "filepath", "label")
assert all(mixing_matrix == pd.DataFrame({"values": [1, 1, 1, 0], "col_name": ["labelA","labelB","labelA","labelB"], "row_name": ["labelA","labelA","labelB","labelB"]}))
mixing_matrix, mapping = calculate_mixing_matrix(test_df, "filepath", "label", return_df=False)
assert mapping == {"labelA": 0, "labelB": 1}
assert (mixing_matrix == np.array([[1,1], [1,0]])).all()
dates_df = pd.DataFrame([datetime.datetime(2020, 1, 1), datetime.datetime(2020, 1, 1)], columns=["dates"])
min_date, max_date = get_min_and_max_dates(dates_df["dates"])
assert min_date.day == max_date.day-1
Bokeh requries images to be in a hw format where each value is a 32bit integer where each of the 8bit sequences contains the rgb and alpha values.
Wrapper around the draw_record
function from icevision. The aspect ratio of the image will be preserved when only width or height is given (scaling the other accordingly).