prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  ExactSampler is not resetting at construction time
  Exact Sampler should call Reset at construction time 
  
  
  </issue>
  <code>
  [start of netket/sampler/exact_sampler.py]
  1 import numpy as _np
  2 from .abstract_sampler import AbstractSampler
  3 from ..machine.density_matrix import AbstractDensityMatrix
  4 from ..hilbert import DoubledHilbert
  5 import netket.random
  6 
  7 
  8 class ExactSampler(AbstractSampler):
  9     r"""
  10     This sampler generates i.i.d. samples from $$|\Psi(s)|^2$$.
  11     In order to perform exact sampling, $$|\Psi(s)|^2$$ is precomputed an all
  12     the possible values of the quantum numbers $$s$$. This sampler has thus an
  13     exponential cost with the number of degrees of freedom, and cannot be used
  14     for large systems, where Metropolis-based sampling are instead a viable
  15     option.
  16     """
  17 
  18     def __init__(self, machine, sample_size=16):
  19         r"""
  20         Constructs a new ``ExactSampler`` given a machine.
  21 
  22         Args:
  23             machine: A machine $$\Psi(s)$$ used for the sampling.
  24                      The probability distribution being sampled
  25                      from is $$F(\Psi(s))$$, where the function
  26                      $$F(X)$$, is arbitrary, by default $$F(X)=|X|^2$$.
  27 
  28             sample_size: The number of independent samples to be generated at each invocation of __next__.
  29         """
  30         super().__init__(machine, sample_size)
  31         if isinstance(machine, AbstractDensityMatrix):
  32             self.hilbert = DoubledHilbert(machine.hilbert)
  33         else:
  34             self.hilbert = machine.hilbert
  35         self._machine_pow = 2.0
  36 
  37     def reset(self, init_random=False):
  38         self._prob = _np.absolute(self.machine.to_array()) ** self.machine_pow
  39         self._prob /= self._prob.sum()
  40 
  41     def __next__(self):
  42         numbers = netket.random.choice(
  43             self._prob.size, size=self.sample_shape[0], replace=True, p=self._prob
  44         )
  45         return self.hilbert.numbers_to_states(numbers)
  46 
  47     def generate_samples(self, n_samples, init_random=False, samples=None):
  48 
  49         if samples is None:
  50             samples = _np.zeros((n_samples, self.sample_shape[0], self.sample_shape[1]))
  51 
  52         numbers = netket.random.choice(
  53             self._prob.size,
  54             size=self.sample_shape[0] * n_samples,
  55             replace=True,
  56             p=self._prob,
  57         )
  58         samples[:] = self.hilbert.numbers_to_states(numbers).reshape(samples.shape)
  59 
  60         return samples
  61 
  62     @property
  63     def machine_pow(self):
  64         return self._machine_pow
  65 
  66     @machine_pow.setter
  67     def machine_pow(self, m_power):
  68         self._machine_pow = m_power
  69         self.reset()
  70
  [end of netket/sampler/exact_sampler.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/netket/sampler/exact_sampler.py b/netket/sampler/exact_sampler.py
  --- a/netket/sampler/exact_sampler.py
  +++ b/netket/sampler/exact_sampler.py
  @@ -33,6 +33,7 @@
           else:
               self.hilbert = machine.hilbert
           self._machine_pow = 2.0
  +        self.reset()
   
       def reset(self, init_random=False):
           self._prob = _np.absolute(self.machine.to_array()) ** self.machine_pow
  
verification_info: {"golden_diff": "diff --git a/netket/sampler/exact_sampler.py b/netket/sampler/exact_sampler.py\n--- a/netket/sampler/exact_sampler.py\n+++ b/netket/sampler/exact_sampler.py\n@@ -33,6 +33,7 @@\n         else:\n             self.hilbert = machine.hilbert\n         self._machine_pow = 2.0\n+        self.reset()\n \n     def reset(self, init_random=False):\n         self._prob = _np.absolute(self.machine.to_array()) ** self.machine_pow\n", "issue": "ExactSampler is not resetting at construction time\nExact Sampler should call Reset at construction time \r\n\n", "before_files": [{"content": "import numpy as _np\nfrom .abstract_sampler import AbstractSampler\nfrom ..machine.density_matrix import AbstractDensityMatrix\nfrom ..hilbert import DoubledHilbert\nimport netket.random\n\n\nclass ExactSampler(AbstractSampler):\n    r\"\"\"\n    This sampler generates i.i.d. samples from $$|\\Psi(s)|^2$$.\n    In order to perform exact sampling, $$|\\Psi(s)|^2$$ is precomputed an all\n    the possible values of the quantum numbers $$s$$. This sampler has thus an\n    exponential cost with the number of degrees of freedom, and cannot be used\n    for large systems, where Metropolis-based sampling are instead a viable\n    option.\n    \"\"\"\n\n    def __init__(self, machine, sample_size=16):\n        r\"\"\"\n        Constructs a new ``ExactSampler`` given a machine.\n\n        Args:\n            machine: A machine $$\\Psi(s)$$ used for the sampling.\n                     The probability distribution being sampled\n                     from is $$F(\\Psi(s))$$, where the function\n                     $$F(X)$$, is arbitrary, by default $$F(X)=|X|^2$$.\n\n            sample_size: The number of independent samples to be generated at each invocation of __next__.\n        \"\"\"\n        super().__init__(machine, sample_size)\n        if isinstance(machine, AbstractDensityMatrix):\n            self.hilbert = DoubledHilbert(machine.hilbert)\n        else:\n            self.hilbert = machine.hilbert\n        self._machine_pow = 2.0\n\n    def reset(self, init_random=False):\n        self._prob = _np.absolute(self.machine.to_array()) ** self.machine_pow\n        self._prob /= self._prob.sum()\n\n    def __next__(self):\n        numbers = netket.random.choice(\n            self._prob.size, size=self.sample_shape[0], replace=True, p=self._prob\n        )\n        return self.hilbert.numbers_to_states(numbers)\n\n    def generate_samples(self, n_samples, init_random=False, samples=None):\n\n        if samples is None:\n            samples = _np.zeros((n_samples, self.sample_shape[0], self.sample_shape[1]))\n\n        numbers = netket.random.choice(\n            self._prob.size,\n            size=self.sample_shape[0] * n_samples,\n            replace=True,\n            p=self._prob,\n        )\n        samples[:] = self.hilbert.numbers_to_states(numbers).reshape(samples.shape)\n\n        return samples\n\n    @property\n    def machine_pow(self):\n        return self._machine_pow\n\n    @machine_pow.setter\n    def machine_pow(self, m_power):\n        self._machine_pow = m_power\n        self.reset()\n", "path": "netket/sampler/exact_sampler.py"}]}