def test_shoot_graph(mol_with_subgraph): """ Test that :func:`average_beads.do_average_bead` fails if a subgraph is missing. """ del mol_with_subgraph.nodes[1]['graph'] with pytest.raises(ValueError): average_beads.do_average_bead(mol_with_subgraph)
def test_shoot_weight(mol_with_subgraph, weight): """ Test that :func:`average_beads.do_average_bead` fails if a weight is missing. """ del mol_with_subgraph.nodes[0]['graph'].nodes[1][weight] with pytest.raises(KeyError): average_beads.do_average_bead( mol_with_subgraph, ignore_missing_graphs=False, weight=weight, )
def test_do_average_bead(mol_with_subgraph, weight): """ Test normal operation of :func:`average_beads.do_average_bead`. """ result_mol = average_beads.do_average_bead( mol_with_subgraph, ignore_missing_graphs=False, weight=weight, ) target_key = 'target {}'.format(weight) target_positions = np.stack([node[target_key] for node in mol_with_subgraph.nodes.values()]) positions = np.stack([node['position'] for node in mol_with_subgraph.nodes.values()]) assert np.allclose(positions, target_positions, equal_nan=True)