The selection that indexes missing targets
Selecting molecular samples across shards crashes when optional labels or weights have no rows to select.
What’s going wrong
ML practice for DeepChem. This is an original teaching adaptation of documented DeepChem behavior, not execution of the upstream package.
A dataset selector joins shards and returns requested sample rows. Labeled inputs work, but requesting rows from an unlabeled dataset crashes. Repair select_rows so every populated column follows the same selection while absent optional columns remain absent.
Input is {"shards":[{"ids":["m1","m2"],"X":[[1,2],[3,4]],"y":[],"w":[]}, ...],"indices":[1,0,1]}. There are 0 to 20 shards and at most 100 total rows. Each shard has equally long ids and X arrays. Identifiers are strings of at most 64 characters, and need not be unique or nonempty. Each X entry is a numeric feature vector of 1 to 8 values. Each y and w is either [] to represent an absent optional column or a numeric array with one value per row. For each optional column separately, its presence is consistent across all nonempty shards; y and w may be independently absent. Empty shards have all four arrays empty. Numbers are finite integers between -1000 and 1000.
Global row order concatenates shards in input order. indices contains 0 to 100 valid nonnegative global row positions; order and repetitions are meaningful. When there are no rows, indices is empty. Print {"X":[...],"y":[...],"w":[...],"ids":[...]}. Each populated column returns exactly the requested rows in indices order, including duplicates. An absent y or w stays [], even for a nonempty selection. An empty selection returns four empty arrays. Preserve zero-valued targets and weights; do not sort or deduplicate the request.
Expected behavior
Preserve requested global row order and duplicates across aligned columns, while leaving absent label and weight columns empty.
Reproduction
{"shards":[{"ids":["a","b"],"X":[[1],[2]],"y":[],"w":[]},{"ids":["c"],"X":[[3]],"y":[],"w":[]}],"indices":[2,0,2]}{"X":[[3],[1],[3]],"y":[],"w":[],"ids":["c","a","c"]}{"shards":[{"ids":["a","b"],"X":[[10],[20]],"y":[0,1],"w":[1,2]}],"indices":[1,0]}{"X":[[20],[10]],"y":[1,0],"w":[2,1],"ids":["b","a"]}{"shards":[{"ids":["a","b"],"X":[[0,1],[2,3]],"y":[0,5],"w":[]}],"indices":[0,1,0]}{"X":[[0,1],[2,3],[0,1]],"y":[0,5,0],"w":[],"ids":["a","b","a"]}Before you begin
- Nested lists
- Indexed selection
- Optional dataset columns
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.