Test reading and writing head position quaternion parameters.
(tmp_path)
| 141 | |
| 142 | @testing.requires_testing_data |
| 143 | def test_read_write_head_pos(tmp_path): |
| 144 | """Test reading and writing head position quaternion parameters.""" |
| 145 | temp_name = tmp_path / "temp.pos" |
| 146 | # This isn't a 100% valid quat matrix but it should be okay for tests |
| 147 | head_pos_rand = np.random.RandomState(0).randn(20, 10) |
| 148 | # This one is valid |
| 149 | head_pos_read = read_head_pos(pos_fname) |
| 150 | for head_pos_orig in (head_pos_rand, head_pos_read): |
| 151 | write_head_pos(temp_name, head_pos_orig) |
| 152 | head_pos = read_head_pos(temp_name) |
| 153 | assert_allclose(head_pos_orig, head_pos, atol=1e-3) |
| 154 | # Degenerate cases |
| 155 | pytest.raises(TypeError, write_head_pos, 0, head_pos_read) # not filename |
| 156 | pytest.raises(ValueError, write_head_pos, temp_name, "foo") # not array |
| 157 | pytest.raises(ValueError, write_head_pos, temp_name, head_pos_read[:, :9]) |
| 158 | pytest.raises(TypeError, read_head_pos, 0) |
| 159 | pytest.raises(OSError, read_head_pos, "101") |
| 160 | |
| 161 | |
| 162 | @testing.requires_testing_data |
nothing calls this directly
no test coverage detected