class_docstr: Base class for testing Profet tasks.
class_docstr_tok: ["Base","class","for","testing","Profet","tasks","."]
docstr: BUG: Space.keys() returns *sorted* keys that don't match the ordering in
  `get_search_space`, so the values returned by any space using `space.sample()` are not
  consistent with the ordering of the returned dict from `get_search_space` of the tasks.
  
  This wouldn't be a big deal if the samples from `space.sample()` were dictionaries, but
  since they are tuples, there is no way of knowing what the ordering of the keys and values
  are.
  
  Dicts are sorted since python 3.7, there's no need to use OrderedDict anymore, and getting
  things in a different order than you declared them is just confusing.
  
  Doing this, for example, would be a very subtle bug:
  
  ```
  hparam_tuple = task.space.sample()
  hparam = dict(zip(task.get_search_space(), hparam_tuple))
  ```
  This hasn't been a problem for the other tasks because they have a single dimension `x`.
  
  This is why I'm using the `sample` function above, so that I don't have to reach
  into the task to get the space in order to create dicts, and so the ordering isn't a
  problem anymore.
docstr_tok: ["BUG",":","Space.keys","(",")","returns","*","sorted","*","keys","that","do","n't","match","the","ordering","in","`","get_search_space","`",",","so","the","values","returned","by","any","space","using","`","space.sample","(",")","`","are","not","consistent","with","the","ordering","of","the","returned","dict","from","`","get_search_space","`","of","the","tasks",".","This","would","n't","be","a","big","deal","if","the","samples","from","`","space.sample","(",")","`","were","dictionaries",",","but","since","they","are","tuples",",","there","is","no","way","of","knowing","what","the","ordering","of","the","keys","and","values","are",".","Dicts","are","sorted","since","python","3.7",",","there","'s","no","need","to","use","OrderedDict","anymore",",","and","getting","things","in","a","different","order","than","you","declared","them","is","just","confusing",".","Doing","this",",","for","example",",","would","be","a","very","subtle","bug",":","``","`","hparam_tuple","=","task.space.sample","(",")","hparam","=","dict","(","zip","(","task.get_search_space","(",")",",","hparam_tuple",")",")","``","`","This","has","n't","been","a","problem","for","the","other","tasks","because","they","have","a","single","dimension","`","x","`",".","This","is","why","I","'m","using","the","`","sample","`","function","above",",","so","that","I","do","n't","have","to","reach","into","the","task","to","get","the","space","in","order","to","create","dicts",",","and","so","the","ordering","is","n't","a","problem","anymore","."]
code: def test_space_attribute(
      self,
      profet_train_config: MetaModelConfig,
      profet_input_dir: Path,
      checkpoint_dir: Path,
  ):
      """
      BUG: Space.keys() returns *sorted* keys that don't match the ordering in
      `get_search_space`, so the values returned by any space using `space.sample()` are not
      consistent with the ordering of the returned dict from `get_search_space` of the tasks.
  
      This wouldn't be a big deal if the samples from `space.sample()` were dictionaries, but
      since they are tuples, there is no way of knowing what the ordering of the keys and values
      are.
  
      Dicts are sorted since python 3.7, there's no need to use OrderedDict anymore, and getting
      things in a different order than you declared them is just confusing.
  
      Doing this, for example, would be a very subtle bug:
  
      ```
      hparam_tuple = task.space.sample()
      hparam = dict(zip(task.get_search_space(), hparam_tuple))
      ```
      This hasn't been a problem for the other tasks because they have a single dimension `x`.
  
      This is why I'm using the `sample` function above, so that I don't have to reach
      into the task to get the space in order to create dicts, and so the ordering isn't a
      problem anymore.
      """
      task = self.Task(
          model_config=profet_train_config,
          input_dir=profet_input_dir,
          checkpoint_dir=checkpoint_dir,
      )
      assert isinstance(task.space, Space)
      # BUG mentioned above:
      # assert task.space.keys() == task.get_search_space().keys()
  
      # Check that all keys are present, no matter the ordering.
      assert set(task.space.keys()) == set(
          task.get_search_space().keys()
      )
  
imports: from dataclasses import asdict, replace
  from logging import getLogger
  from pathlib import Path
  from typing import ClassVar, Type
  import numpy
  import pytest
  from _pytest.tmpdir import TempPathFactory
  from orion.algo.space import Space
  from typing import List, Union, overload
  from pytest_mock import MockerFixture
  from orion.benchmark.task.profet.profet_task import MetaModelConfig, ProfetTask
  from orion.core.worker.trial import Trial
  from .conftest import REAL_PROFET_DATA_DIR, is_nonempty_dir
label_desc: Use image node_id 7 for calling the ProfetTaskTests obj's underlying member method code with example usage: obj.test_space_attribute(profet_train_config, profet_input_dir, checkpoint_dir) without return types