Пример #1
0
    def _grad_action(
        self,
        links: Array,
        beta: float = 1.,
        flatten: bool = True,
    ) -> Array:
        """Compute the gradient of the action for the input lattice links."""
        if len(links.shape) == 1:
            links = links.reshape(self.shape)

        grad_arr = np.zeros(links.shape)
        for n in self.iter_sites():
            for u in range(self.dim):
                grad = np.floating(0.0)
                for v in range(self.dim):
                    if v != u:
                        m = tuple(np.mod((n - self.bases[v]), self.site_idxs))
                        p1 = self._plaq_op(n, u, v, links)
                        p2 = self._plaq_op(m, u, v, links)
                        staple = (np.trace(p1).imag() - np.trace(p2).imag())
                        grad += staple / self.link_shape[0]
                        # dsdp1 = self._grad_action_op(p1)
                        # dsdp2 = self._grad_action_op(p2)

                grad_arr[n][u] = beta * grad
        if flatten:
            return grad_arr.flatten()

        return grad_arr
Пример #2
0
 def default(self, obj):
     if isinstance(obj, int):
         return numpy.integer(obj)
     elif isinstance(obj, float):
         return numpy.floating(obj)
     #elif isinstance(obj, numpy.ndarray):
     #return obj.tolist()
     else:
         return super(MyDecoder, self).default(obj)
Пример #3
0
np.int32(A())  # E: incompatible type
np.int64(A())  # E: incompatible type
np.uint8(A())  # E: incompatible type
np.uint16(A())  # E: incompatible type
np.uint32(A())  # E: incompatible type
np.uint64(A())  # E: incompatible type

np.void("test")  # E: incompatible type

np.generic(1)  # E: Cannot instantiate abstract class
np.number(1)  # E: Cannot instantiate abstract class
np.integer(1)  # E: Cannot instantiate abstract class
np.signedinteger(1)  # E: Cannot instantiate abstract class
np.unsignedinteger(1)  # E: Cannot instantiate abstract class
np.inexact(1)  # E: Cannot instantiate abstract class
np.floating(1)  # E: Cannot instantiate abstract class
np.complexfloating(1)  # E: Cannot instantiate abstract class
np.character("test")  # E: Cannot instantiate abstract class
np.flexible(b"test")  # E: Cannot instantiate abstract class

np.float64(value=0.0)  # E: Unexpected keyword argument
np.int64(value=0)  # E: Unexpected keyword argument
np.uint64(value=0)  # E: Unexpected keyword argument
np.complex128(value=0.0j)  # E: Unexpected keyword argument
np.str_(value='bob')  # E: No overload variant
np.bytes_(value=b'test')  # E: No overload variant
np.void(value=b'test')  # E: Unexpected keyword argument
np.bool_(value=True)  # E: Unexpected keyword argument
np.datetime64(value="2019")  # E: No overload variant
np.timedelta64(value=0)  # E: Unexpected keyword argument