code: def test_space_api():
      # TODO: Refactor - Use PyTest - Break this up into multiple tests
      space = Space(
          [
              (0.0, 1.0),
              (-5, 5),
              ("a", "b", "c"),
              (1.0, 5.0, "log-uniform"),
              ("e", "f"),
          ]
      )
  
      cat_space = Space([(1, "r"), (1.0, "r")])
      assert isinstance(cat_space.dimensions[0], Categorical)
      assert isinstance(cat_space.dimensions[1], Categorical)
  
      assert_equal(len(space.dimensions), 5)
      assert isinstance(space.dimensions[0], Real)
      assert isinstance(space.dimensions[1], Integer)
      assert isinstance(space.dimensions[2], Categorical)
      assert isinstance(space.dimensions[3], Real)
      assert isinstance(space.dimensions[4], Categorical)
  
      samples = space.rvs(n_samples=10, random_state=0)
      assert_equal(len(samples), 10)
      assert_equal(len(samples[0]), 5)
  
      assert isinstance(samples, list)
      for n in range(4):
          assert isinstance(samples[n], list)
  
      assert isinstance(samples[0][0], numbers.Real)
      assert isinstance(samples[0][1], numbers.Integral)
      assert isinstance(samples[0][2], str)
      assert isinstance(samples[0][3], numbers.Real)
      assert isinstance(samples[0][4], str)
  
      samples_transformed = space.transform(samples)
      assert_equal(samples_transformed.shape[0], len(samples))
      assert_equal(samples_transformed.shape[1], 1 + 1 + 3 + 1 + 1)
  
      # our space contains mixed types, this means we can't use
      # `array_allclose` or similar to check points are close after a round-trip
      # of transformations
      for orig, round_trip in zip(
          samples, space.inverse_transform(samples_transformed)
      ):
          assert space.distance(orig, round_trip) < 1.0e-8
  
      samples = space.inverse_transform(samples_transformed)
      assert isinstance(samples[0][0], numbers.Real)
      assert isinstance(samples[0][1], numbers.Integral)
      assert isinstance(samples[0][2], str)
      assert isinstance(samples[0][3], numbers.Real)
      assert isinstance(samples[0][4], str)
  
      for b1, b2 in zip(
          space.bounds,
          [
              (0.0, 1.0),
              (-5, 5),
              np.asarray(["a", "b", "c"]),
              (1.0, 5.0),
              np.asarray(["e", "f"]),
          ],
      ):
          assert_array_equal(b1, b2)
  
      for b1, b2 in zip(
          space.transformed_bounds,
          [
              (0.0, 1.0),
              (-5, 5),
              (0.0, 1.0),
              (0.0, 1.0),
              (0.0, 1.0),
              (np.log10(1.0), np.log10(5.0)),
              (0.0, 1.0),
          ],
      ):
          assert_array_equal(b1, b2)
  
imports: from hyperparameter_hunter.optimization.backends.skopt.engine import Optimizer
  from hyperparameter_hunter.space.dimensions import Real, Integer, Categorical
  from hyperparameter_hunter.space.space_core import Space, check_dimension, normalize_dimensions
  import numbers
  import numpy
  import pytest
  from sklearn.utils.testing import assert_array_almost_equal, assert_array_equal, assert_equal
label_desc: Use image node_id 13 for calling a global function with example usage: test_space_api() without return types