def test_to_2D(): reg = Register3D.cuboid(2, 2, 2) with pytest.raises(ValueError, match="Atoms are not coplanar"): reg.to_2D() reg.to_2D(tol_width=6) reg = Register3D.cuboid(2, 2, 1) reg.to_2D()
def test_drawing3D(): with pytest.raises(ValueError, match="Blockade radius"): reg = Register3D.from_coordinates([(1, 0, 0), (0, 0, 1)]) reg.draw(blockade_radius=0.0) reg = Register3D.cubic(3, 8) with patch("matplotlib.pyplot.show"): with patch("matplotlib.pyplot.savefig"): reg.draw(fig_name="my_register.pdf") reg = Register3D.cuboid(1, 8, 2) with patch("matplotlib.pyplot.show"): reg.draw(blockade_radius=5, draw_half_radius=True, draw_graph=True) with pytest.raises(ValueError, match="'blockade_radius' to draw."): reg.draw(draw_half_radius=True) reg = Register3D.cuboid(2, 2, 2) with patch("matplotlib.pyplot.show"): reg.draw( blockade_radius=5, draw_half_radius=True, draw_graph=True, projection=False, with_labels=True, ) with patch("matplotlib.pyplot.show"): reg.draw( blockade_radius=5, draw_half_radius=True, draw_graph=False, projection=True, with_labels=True, ) reg = Register3D.cubic(1) with pytest.raises(NotImplementedError, match="Needs more than one atom"): reg.draw(blockade_radius=5, draw_half_radius=True)
def test_orthorombic(): # Check rows with pytest.raises(ValueError, match="The number of rows"): Register3D.cuboid(0, 2, 2) # Check columns with pytest.raises(ValueError, match="The number of columns"): Register3D.cuboid(2, 0, 2) # Check layers with pytest.raises(ValueError, match="The number of layers"): Register3D.cuboid(2, 2, 0) # Check spacing with pytest.raises(ValueError, match="Spacing"): Register3D.cuboid(2, 2, 2, 0.0)