Пример #1
0
 def test_write_log10(self):
     expected = "a [10.0, 1000.0] [100.0]l"
     cs = ConfigurationSpace()
     cs.add_hyperparameter(
         UniformFloatHyperparameter("a", 10, 1000, log=True))
     value = pcs.write(cs)
     self.assertEqual(expected, value)
Пример #2
0
 def test_write_q_float(self):
     expected = "Q16_float_a [16.0, 1024.0] [520.0]"
     cs = ConfigurationSpace()
     cs.add_hyperparameter(
         UniformFloatHyperparameter("float_a", 16, 1024, q=16))
     value = pcs.write(cs)
     self.assertEqual(expected, value)
Пример #3
0
 def test_write_q_int(self):
     expected = "Q16_int_a [16, 1024] [520]i"
     cs = ConfigurationSpace()
     cs.add_hyperparameter(
         UniformIntegerHyperparameter("int_a", 16, 1024, q=16))
     value = pcs.write(cs)
     self.assertEqual(expected, value)
Пример #4
0
 def test_build_forbidden(self):
     expected = "a {a, b, c} [a]\nb {a, b, c} [c]\n\n" \
                "{a=a, b=a}\n{a=a, b=b}\n{a=b, b=a}\n{a=b, b=b}"
     cs = ConfigurationSpace()
     a = CategoricalHyperparameter("a", ["a", "b", "c"], "a")
     b = CategoricalHyperparameter("b", ["a", "b", "c"], "c")
     cs.add_hyperparameter(a)
     cs.add_hyperparameter(b)
     fb = ForbiddenAndConjunction(ForbiddenInClause(a, ["a", "b"]),
                                  ForbiddenInClause(b, ["a", "b"]))
     cs.add_forbidden_clause(fb)
     value = pcs.write(cs)
     self.assertIn(expected, value)
Пример #5
0
    def test_read_write(self):
        # Some smoke tests whether reading, writing, reading alters makes the
        #  configspace incomparable
        this_file = os.path.abspath(__file__)
        this_directory = os.path.dirname(this_file)
        configuration_space_path = os.path.join(this_directory, "..",
                                                "test_searchspaces")
        configuration_space_path = os.path.abspath(configuration_space_path)
        configuration_space_path = os.path.join(configuration_space_path,
                                                "spear-params-mixed.pcs")
        with open(configuration_space_path) as fh:
            cs = pcs.read(fh)

        tf = tempfile.NamedTemporaryFile()
        name = tf.name
        tf.close()
        with open(name, 'w') as fh:
            pcs_string = pcs.write(cs)
            fh.write(pcs_string)
        with open(name, 'r') as fh:
            pcs_new = pcs.read(fh)

        self.assertEqual(pcs_new, cs, msg=(pcs_new, cs))
Пример #6
0
 def test_write_log_int(self):
     expected = "int_log_a [1, 6] [2]il"
     cs = ConfigurationSpace()
     cs.add_hyperparameter(int_log_a)
     value = pcs.write(cs)
     self.assertEqual(expected, value)