import abc

import numpy

        
class Operator(abc.ABC):
    """docstring for Operator"""

    def __init__(self, hilbert_state_shape):
        super(Operator, self).__init__()
        self.hilbert_state_shape = tuple(hilbert_state_shape)
        self.max_number_of_local_connections = None

    @abc.abstractmethod
    def find_conn(self, v):
        """
        Member function finding the connected elements of the Operator.  
        Starting from a given visible state v, it finds all other visible states v'  
        such that the Operator matrix element H(v,v') is different from zero.
        """
        pass

    def use_state(self, state):
        return True

    def random_states(self, num_of_states):
        """
        Member function return random state of the Operator.
        """
        return numpy.random.choice([-1, 1], size=(num_of_states, ) + self.hilbert_state_shape)


def cube_shape(number_of_spins_in_each_dimention=20, cube_dimention=1, 
               column_or_row=True):
    if cube_dimention == 1:
        return [number_of_spins_in_each_dimention, 1] if column_or_row else [1, number_of_spins_in_each_dimention]
    return [number_of_spins_in_each_dimention, ] * cube_dimention


class OperatorOnGrid(Operator, abc.ABC):
    """docstring for OperatorOnGrid"""
    def __init__(self, hilbert_state_shape=None, pbc=True):
        if hilbert_state_shape is None:
            hilbert_state_shape = cube_shape()
        super(OperatorOnGrid, self).__init__(hilbert_state_shape)
        self.pbc = pbc
cff174802d2cbfe1c98254c8b46bc766893dcd86
<mask token>


class Operator(abc.ABC):
    <mask token>

    def __init__(self, hilbert_state_shape):
        super(Operator, self).__init__()
        self.hilbert_state_shape = tuple(hilbert_state_shape)
        self.max_number_of_local_connections = None
    <mask token>
    <mask token>
    <mask token>


<mask token>


class OperatorOnGrid(Operator, abc.ABC):
    """docstring for OperatorOnGrid"""

    def __init__(self, hilbert_state_shape=None, pbc=True):
        if hilbert_state_shape is None:
            hilbert_state_shape = cube_shape()
        super(OperatorOnGrid, self).__init__(hilbert_state_shape)
        self.pbc = pbc

<mask token>


class Operator(abc.ABC):
    <mask token>

    def __init__(self, hilbert_state_shape):
        super(Operator, self).__init__()
        self.hilbert_state_shape = tuple(hilbert_state_shape)
        self.max_number_of_local_connections = None

    @abc.abstractmethod
    def find_conn(self, v):
        """
        Member function finding the connected elements of the Operator.  
        Starting from a given visible state v, it finds all other visible states v'  
        such that the Operator matrix element H(v,v') is different from zero.
        """
        pass

    def use_state(self, state):
        return True
    <mask token>


<mask token>


class OperatorOnGrid(Operator, abc.ABC):
    """docstring for OperatorOnGrid"""

    def __init__(self, hilbert_state_shape=None, pbc=True):
        if hilbert_state_shape is None:
            hilbert_state_shape = cube_shape()
        super(OperatorOnGrid, self).__init__(hilbert_state_shape)
        self.pbc = pbc

<mask token>


class Operator(abc.ABC):
    """docstring for Operator"""

    def __init__(self, hilbert_state_shape):
        super(Operator, self).__init__()
        self.hilbert_state_shape = tuple(hilbert_state_shape)
        self.max_number_of_local_connections = None

    @abc.abstractmethod
    def find_conn(self, v):
        """
        Member function finding the connected elements of the Operator.  
        Starting from a given visible state v, it finds all other visible states v'  
        such that the Operator matrix element H(v,v') is different from zero.
        """
        pass

    def use_state(self, state):
        return True

    def random_states(self, num_of_states):
        """
        Member function return random state of the Operator.
        """
        return numpy.random.choice([-1, 1], size=(num_of_states,) + self.
            hilbert_state_shape)


def cube_shape(number_of_spins_in_each_dimention=20, cube_dimention=1,
    column_or_row=True):
    if cube_dimention == 1:
        return [number_of_spins_in_each_dimention, 1] if column_or_row else [
            1, number_of_spins_in_each_dimention]
    return [number_of_spins_in_each_dimention] * cube_dimention


class OperatorOnGrid(Operator, abc.ABC):
    """docstring for OperatorOnGrid"""

    def __init__(self, hilbert_state_shape=None, pbc=True):
        if hilbert_state_shape is None:
            hilbert_state_shape = cube_shape()
        super(OperatorOnGrid, self).__init__(hilbert_state_shape)
        self.pbc = pbc

import abc
import numpy


class Operator(abc.ABC):
    """docstring for Operator"""

    def __init__(self, hilbert_state_shape):
        super(Operator, self).__init__()
        self.hilbert_state_shape = tuple(hilbert_state_shape)
        self.max_number_of_local_connections = None

    @abc.abstractmethod
    def find_conn(self, v):
        """
        Member function finding the connected elements of the Operator.  
        Starting from a given visible state v, it finds all other visible states v'  
        such that the Operator matrix element H(v,v') is different from zero.
        """
        pass

    def use_state(self, state):
        return True

    def random_states(self, num_of_states):
        """
        Member function return random state of the Operator.
        """
        return numpy.random.choice([-1, 1], size=(num_of_states,) + self.
            hilbert_state_shape)


def cube_shape(number_of_spins_in_each_dimention=20, cube_dimention=1,
    column_or_row=True):
    if cube_dimention == 1:
        return [number_of_spins_in_each_dimention, 1] if column_or_row else [
            1, number_of_spins_in_each_dimention]
    return [number_of_spins_in_each_dimention] * cube_dimention


class OperatorOnGrid(Operator, abc.ABC):
    """docstring for OperatorOnGrid"""

    def __init__(self, hilbert_state_shape=None, pbc=True):
        if hilbert_state_shape is None:
            hilbert_state_shape = cube_shape()
        super(OperatorOnGrid, self).__init__(hilbert_state_shape)
        self.pbc = pbc

import abc

import numpy

        
class Operator(abc.ABC):
    """docstring for Operator"""

    def __init__(self, hilbert_state_shape):
        super(Operator, self).__init__()
        self.hilbert_state_shape = tuple(hilbert_state_shape)
        self.max_number_of_local_connections = None

    @abc.abstractmethod
    def find_conn(self, v):
        """
        Member function finding the connected elements of the Operator.  
        Starting from a given visible state v, it finds all other visible states v'  
        such that the Operator matrix element H(v,v') is different from zero.
        """
        pass

    def use_state(self, state):
        return True

    def random_states(self, num_of_states):
        """
        Member function return random state of the Operator.
        """
        return numpy.random.choice([-1, 1], size=(num_of_states, ) + self.hilbert_state_shape)


def cube_shape(number_of_spins_in_each_dimention=20, cube_dimention=1, 
               column_or_row=True):
    if cube_dimention == 1:
        return [number_of_spins_in_each_dimention, 1] if column_or_row else [1, number_of_spins_in_each_dimention]
    return [number_of_spins_in_each_dimention, ] * cube_dimention


class OperatorOnGrid(Operator, abc.ABC):
    """docstring for OperatorOnGrid"""
    def __init__(self, hilbert_state_shape=None, pbc=True):
        if hilbert_state_shape is None:
            hilbert_state_shape = cube_shape()
        super(OperatorOnGrid, self).__init__(hilbert_state_shape)
        self.pbc = pbc