Skip to content

add (again) graph argument to hilbert constructors with depwarn

Vicentini Filippo requested to merge graph into master

Created by: PhilipVinc

With this PR:

Python 3.8.5 (default, Jul 21 2020, 10:48:26)
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import netket as nk
>>> g=nk.graph.Edgeless(3)
>>> hi=nk.hilbert.Spin(1/2, graph=g)
/Users/filippovicentini/Dropbox/Ricerca/Codes/Python/netket/netket/hilbert/_deprecations.py:7: FutureWarning:
            The ``graph`` argument for hilbert spaces has been deprecated in v3.0.
			It has been replaced by the argument ``N`` accepting an integer, with
			the number of nodese in the graph.

			You can update your code by passing `N=_your_graph.n_nodes`.
			If you are also using Ising, Heisemberg, BoseHubbard or GraphOperator
			hamiltonians you must now provide them with the extra argument
			``graph=_your_graph``, as they no longer take it from the hilbert space.

  warn_deprecation(
>>> hi
Spin(s=1/2, N=3)
>>> hi2=nk.hilbert.Spin(1/2, graph=g, N=3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/filippovicentini/Dropbox/Ricerca/Codes/Python/netket/netket/hilbert/spin.py", line 40, in __init__
    N = graph_to_N_depwarn(N=N, graph=graph)
  File "/Users/filippovicentini/Dropbox/Ricerca/Codes/Python/netket/netket/hilbert/_deprecations.py", line 23, in graph_to_N_depwarn
    raise ValueError(
ValueError: Graph object can only take one argumnent among N and graph (deprecated).

Merge request reports