Repository: PennyLaneAI/pennylane (python)

Issue:
Please expose device._shot_vector via public property
This is a features request: Please expose the shot vector via some public and documented property of the device. Thank you!

This is inspired by me needing to predict the output shape of certain QNodes and in case of a non trivial shot vector and all observables being owned by an `expval` the shape is 
```
(sum([shot_tuple.copies for shot_tuple in self.device._shot_vector]), len(self.measurements))
```
(where self is a tape).

Pull request:
Shot vector property
Fixes #1164 

Patch:
diff --git a/pennylane/_device.py b/pennylane/_device.py
index b1697ef14..d07080323 100644
--- a/pennylane/_device.py
+++ b/pennylane/_device.py
@@ -264,6 +264,33 @@ class Device(abc.ABC):
                 "Shots must be a single non-negative integer or a sequence of non-negative integers."
             )
 
+    @property
+    def shot_vector(self):
+        """list[.ShotTuple[int, int]]: Returns the shot vector, a sparse
+        representation of the shot sequence used by the device
+        when evaluating QNodes.
+
+        **Example**
+
+        >>> dev = qml.device("default.qubit", wires=2, shots=[3, 1, 2, 2, 2, 2, 6, 1, 1, 5, 12, 10, 10])
+        >>> dev.shots
+        57
+        >>> dev.shot_vector
+        [ShotTuple(shots=3, copies=1),
+         ShotTuple(shots=1, copies=1),
+         ShotTuple(shots=2, copies=4),
+         ShotTuple(shots=6, copies=1),
+         ShotTuple(shots=1, copies=2),
+         ShotTuple(shots=5, copies=1),
+         ShotTuple(shots=12, copies=1),
+         ShotTuple(shots=10, copies=2)]
+
+        The sparse representation of the shot
+        sequence is returned, where tuples indicate the number of times a shot
+        integer is repeated.
+        """
+        return self._shot_vector
+
     def define_wire_map(self, wires):
         """Create the map from user-provided wire labels to the wire labels used by the device.
 


Test patch:
diff --git a/tests/test_device.py b/tests/test_device.py
index ab0b4c873..79d3ae64c 100644
--- a/tests/test_device.py
+++ b/tests/test_device.py
@@ -164,6 +164,19 @@ def mock_device(monkeypatch):
 
         yield get_device
 
+def test_shot_vector_property():
+    dev = qml.device("default.qubit", wires=1, shots=[1, 3, 3, 4, 4, 4, 3])
+    shot_vector = dev.shot_vector
+    assert len(shot_vector) == 4
+    assert shot_vector[0].shots == 1
+    assert shot_vector[0].copies == 1
+    assert shot_vector[1].shots == 3
+    assert shot_vector[1].copies == 2
+    assert shot_vector[2].shots == 4
+    assert shot_vector[2].copies == 3
+    assert shot_vector[3].shots == 3
+    assert shot_vector[3].copies == 1
+
 
 class TestDeviceSupportedLogic:
     """Test the logic associated with the supported operations and observables"""