class_docstr: Test top-level API for singletask_to_multitask ML models.
docstr: Test that to_singletask works.
docstr_tok: ["Test","that","to_singletask","works","."]
code: def test_to_singletask(self):
      """Test that to_singletask works."""
      num_datapoints = 100
      num_features = 10
      num_tasks = 10
      # Generate data
      X = np.random.rand(num_datapoints, num_features)
      y = np.random.randint(2, size=(num_datapoints, num_tasks))
      w = np.random.randint(2, size=(num_datapoints, num_tasks))
      ids = np.array(["id"] * num_datapoints)
  
      dataset = dc.data.DiskDataset.from_numpy(X, y, w, ids)
  
      task_dirs = []
      try:
          for task in range(num_tasks):
              task_dirs.append(tempfile.mkdtemp())
          singletask_datasets = (
              dc.models.SingletaskToMultitask._to_singletask(
                  dataset, task_dirs
              )
          )
          for task in range(num_tasks):
              singletask_dataset = singletask_datasets[task]
              X_task, y_task, w_task, ids_task = (
                  singletask_dataset.X,
                  singletask_dataset.y,
                  singletask_dataset.w,
                  singletask_dataset.ids,
              )
              w_nonzero = w[:, task] != 0
              np.testing.assert_array_equal(X_task, X[w_nonzero != 0])
              np.testing.assert_array_equal(
                  y_task.flatten(), y[:, task][w_nonzero != 0]
              )
              np.testing.assert_array_equal(
                  w_task.flatten(), w[:, task][w_nonzero != 0]
              )
              np.testing.assert_array_equal(
                  ids_task, ids[w_nonzero != 0]
              )
      finally:
          # Cleanup
          for task_dir in task_dirs:
              shutil.rmtree(task_dir)
  
file_path: deepchem/deepchem/models/tests/test_singletask_to_multitask.py
imports: import tempfile
  import shutil
  import unittest
  import numpy
  import deepchem
label_desc: Use image node_id 1 for calling the TestSingletasktoMultitask obj's underlying member method code with example usage: obj.test_to_singletask() without return types