def test_correct_vector_mc(self, monkeypatch):
        """Test if function correctly constructs the feature vector. The
        ``prob_event_mc`` function called within ``feature_vector_mc`` is monkeypatched
        to return hard-coded outputs that depend only on the photon number in the event."""

        with monkeypatch.context() as m:
            m.setattr(
                similarity,
                "prob_event_mc",
                lambda _graph, photons, max_count, n_mean, samples, loss: 1.0 / photons,
            )
            graph = nx.complete_graph(8)
            fv = similarity.feature_vector_mc(graph, [2, 4, 8], 1)

        assert fv == [0.5, 0.25, 0.125]
 def test_low_count(self):
     """Test if function raises a ``ValueError`` if ``max_count_per_mode`` is negative."""
     g = nx.complete_graph(10)
     with pytest.raises(ValueError, match="Maximum number of photons"):
         similarity.feature_vector_mc(g, [2, 4], -1)
 def test_bad_event_photon_numbers_mc(self):
     """Test if function raises a ``ValueError`` when input a minimum photon number that is
     below zero."""
     with pytest.raises(ValueError, match="Cannot request events with photon number below zero"):
         graph = nx.complete_graph(4)
         similarity.feature_vector_mc(graph, [-1, 4], 1)
 def test_invalid_loss(self):
     """Test if function raises a ``ValueError`` when the loss parameter is specified outside
     of range."""
     g = nx.complete_graph(10)
     with pytest.raises(ValueError, match="Loss parameter must take a value between zero and"):
         similarity.feature_vector_mc(g, [2, 4], loss=2)
 def test_invalid_n_mean(self):
     """Test if function raises a ``ValueError`` when the mean photon number is specified to
     be negative."""
     g = nx.complete_graph(10)
     with pytest.raises(ValueError, match="Mean photon number must be non-negative"):
         similarity.feature_vector_mc(g, [2, 4], n_mean=-1)
 def test_invalid_samples(self):
     """Test if function raises a ``ValueError`` when a number of samples less than one is
     requested."""
     g = nx.complete_graph(10)
     with pytest.raises(ValueError, match="Number of samples must be at least one"):
         similarity.feature_vector_mc(g, [2, 4], samples=0)