def __init__(self, random_node_creator: RandomNodeCreator, number_of_root_nodes: int) -> None: """ The constructor of the RandomInputHandler class. The constructor sets the number of root nodes, the number of nodes per root node and the number of node levels in the setting package. Parameters ---------- random_node_creator : input_output_handler.input_handler.random_node_creator.RandomNodeCreator The random node creator which creates a single random root node. number_of_root_nodes : int The number of root nodes to create. """ log_init_arguments( logging.getLogger(__name__).debug, self.__class__.__name__, random_node_creator=random_node_creator.__class__.__name__, number_of_root_nodes=number_of_root_nodes) super().__init__() setting.set_number_of_root_nodes(number_of_root_nodes) setting.set_number_of_nodes_per_root_node( random_node_creator.number_of_nodes_per_root_node) setting.set_number_of_node_levels( random_node_creator.number_of_node_levels) self._random_node_creator = random_node_creator
def test_reset(self): setting.set_number_of_root_nodes(5) setting.set_number_of_nodes_per_root_node(3) setting.set_number_of_node_levels(2) setting.reset() self.assertIsNone(setting.beta) self.assertIsNone(hypercubic_setting.beta) self.assertIsNone(hypercuboid_setting.beta) self.assertIsNone(setting.dimension) self.assertIsNone(hypercubic_setting.dimension) self.assertIsNone(hypercuboid_setting.dimension) self.assertIsNone(setting.random_position) self.assertIsNone(hypercubic_setting.random_position) self.assertIsNone(hypercuboid_setting.random_position) self.assertIsNone(setting.periodic_boundaries) self.assertIsNone(hypercubic_setting.periodic_boundaries) self.assertIsNone(hypercuboid_setting.periodic_boundaries) self.assertIsNone(setting.number_of_root_nodes) self.assertIsNone(hypercubic_setting.number_of_root_nodes) self.assertIsNone(hypercuboid_setting.number_of_root_nodes) self.assertIsNone(setting.number_of_nodes_per_root_node) self.assertIsNone(hypercubic_setting.number_of_nodes_per_root_node) self.assertIsNone(hypercuboid_setting.number_of_nodes_per_root_node) self.assertIsNone(setting.number_of_node_levels) self.assertIsNone(hypercubic_setting.number_of_node_levels) self.assertIsNone(hypercuboid_setting.number_of_node_levels) self.assertIsNone(hypercubic_setting.system_length) self.assertIsNone(hypercuboid_setting.system_lengths) self.assertIsNone(hypercubic_setting.system_length_over_two) self.assertIsNone(hypercuboid_setting.system_lengths_over_two)
def setUp(self) -> None: setting.HypercubicSetting(beta=1.0, dimension=3, system_length=1.0) # Set these so the settings are initialized setting.set_number_of_root_nodes(2) setting.set_number_of_nodes_per_root_node(2) setting.set_number_of_node_levels(1) # noinspection PyArgumentEqualDefault self._potential = InversePowerCoulombBoundingPotential(prefactor=1.6)
def test_initialized(self): self.assertFalse(hypercubic_setting.initialized()) self.assertFalse(hypercuboid_setting.initialized()) setting.set_number_of_root_nodes(3) self.assertFalse(hypercubic_setting.initialized()) self.assertFalse(hypercuboid_setting.initialized()) setting.set_number_of_nodes_per_root_node(1) self.assertFalse(hypercubic_setting.initialized()) self.assertFalse(hypercuboid_setting.initialized()) setting.set_number_of_node_levels(1) self.assertFalse(hypercubic_setting.initialized()) self.assertTrue(hypercuboid_setting.initialized())
def setUp(self) -> None: setting.HypercubicSetting(beta=1.0, dimension=3, system_length=1.0) # Set these so the settings are initialized setting.set_number_of_root_nodes(2) setting.set_number_of_nodes_per_root_node(2) setting.set_number_of_node_levels(1) self._potential = MergedImageCoulombPotential(alpha=3.45, fourier_cutoff=6, position_cutoff=2, prefactor=1.0) self._variant_potential = MergedImageCoulombPotential( alpha=5.0, fourier_cutoff=9, position_cutoff=2)
def test_integer_casting_number_of_nodes_per_root_node(self): setting.set_number_of_nodes_per_root_node(33.0) self.assertEqual(setting.number_of_nodes_per_root_node, 33) self.assertIsNone(hypercubic_setting.number_of_nodes_per_root_node) self.assertEqual(hypercuboid_setting.number_of_nodes_per_root_node, 33)
def test_number_of_nodes_per_root_node_zero_raises_error(self): with self.assertRaises(AttributeError): setting.set_number_of_nodes_per_root_node(0)
def test_set_number_of_nodes_per_root_node(self): setting.set_number_of_nodes_per_root_node(2) self.assertEqual(setting.number_of_nodes_per_root_node, 2) self.assertIsNone(hypercubic_setting.number_of_nodes_per_root_node) self.assertEqual(hypercuboid_setting.number_of_nodes_per_root_node, 2)