Skip to content

AttributeError: module 'netket.hilbert' has no attribute 'constraint' #1970

Answered by PhilipVinc
alex-shilcusky asked this question in Q&A
Discussion options

You must be logged in to vote

Can you share the whole error?
And can you share the exact version of netket installed by doing pip freeze | grep netket or equivalent command?

If I run on the last (3.15.1) netket the following code runs fine:

import netket as nk
from netket.utils import struct

import jax; import jax.numpy as jnp

class SumConstraint(nk.hilbert.constraint.DiscreteHilbertConstraint):
    # A simple constraint checking that the total sum of the elements
    # in the configuration is equal to a given value.

    # The value must be set as a pytree_node=False field, meaning
    # that it is a constant and changes to this value represent different
    # constraints.
    total_sum : float = struct.field(pytre…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@alex-shilcusky
Comment options

Answer selected by alex-shilcusky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants