Repository: netket/netket

Issue:
Create separate python modules for Sampler etc
Move out the remaining bindings still in `pynetket.cc` 


Discussion:
I am taking care of this

Resolving patch:
diff --git a/Tutorials/PyNetKet/ground_state.py b/Tutorials/PyNetKet/ground_state.py
--- a/Tutorials/PyNetKet/ground_state.py
+++ b/Tutorials/PyNetKet/ground_state.py
@@ -16,33 +16,33 @@
 import netket as nk
 from mpi4py import MPI
 
-#Constructing a 1d lattice
-g = nk.graph.Hypercube(L=20, ndim=1)
+# Constructing a 1d lattice
+g = nk.graph.Hypercube(length=20, ndim=1)
 
 # Hilbert space of spins from given graph
 hi = nk.hilbert.Spin(s=0.5, graph=g)
 
-#Hamiltonian
+# Hamiltonian
 ha = nk.operator.Ising(h=1.0, hilbert=hi)
 
-#Machine
+# Machine
 ma = nk.machine.RbmSpin(hilbert=hi, alpha=1)
-ma.InitRandomPars(seed=1234, sigma=0.01)
+ma.init_random_parameters(seed=1234, sigma=0.01)
 
-#Sampler
-sa = nk.MetropolisLocal(machine=ma)
+# Sampler
+sa = nk.sampler.MetropolisLocal(machine=ma)
 
-#Optimizer
-op = nk.Sgd(learning_rate=0.1)
+# Optimizer
+op = nk.optimizer.Sgd(learning_rate=0.1)
 
-#Variational Monte Carlo
-gs = nk.Vmc(
+# Variational Monte Carlo
+vmc = nk.gs.Vmc(
     hamiltonian=ha,
     sampler=sa,
     optimizer=op,
     nsamples=1000,
-    niter_opt=3000,
+    niter_opt=300,
     output_file='test',
     diag_shift=0.1,
     method='Sr')
-gs.Run()
+vmc.Run()
diff --git a/Tutorials/PyNetKet/hamiltonian.py b/Tutorials/PyNetKet/hamiltonian.py
--- a/Tutorials/PyNetKet/hamiltonian.py
+++ b/Tutorials/PyNetKet/hamiltonian.py
@@ -19,29 +19,29 @@
 import numpy as np
 import scipy.sparse.linalg as sparsediag
 
-#Constructing a 1d lattice
-g = nk.graph.Hypercube(L=20, ndim=1)
+# Constructing a 1d lattice
+g = nk.graph.Hypercube(length=20, ndim=1)
 
-#Hilbert space of spins from given graph
+# Hilbert space of spins from given graph
 hi = nk.hilbert.Spin(s=0.5, graph=g)
 
-#Hamiltonian
+# Hamiltonian
 ha = nk.operator.Ising(h=1.0, hilbert=hi)
 
 print("\n")
 print("Diagonalizing the Hamiltonian with the internal NetKet solver...")
 
 t1 = datetime.now()
-ed_result = nk.LanczosEd(operator=ha, first_n=1, get_groundstate=False)
+ed_result = nk.gs.LanczosEd(operator=ha, first_n=1, get_groundstate=False)
 t2 = datetime.now()
 
 print("Elapsed time =", (t2 - t1).total_seconds(), " s\n")
 
-#Scipy sparse diagonalization
+# Scipy sparse diagonalization
 print("Diagonalizing the Hamiltonian with scipy...")
 
 t1 = datetime.now()
-sm = nk.SparseMatrixWrapper(operator=ha).GetMatrix()
+sm = nk.operator.SparseMatrixWrapper(operator=ha)._matrix
 vals = sparsediag.eigs(sm, k=1, return_eigenvectors=False, which='SR')
 t2 = datetime.now()
 
diff --git a/Tutorials/PyNetKet/sampler.py b/Tutorials/PyNetKet/sampler.py
--- a/Tutorials/PyNetKet/sampler.py
+++ b/Tutorials/PyNetKet/sampler.py
@@ -19,22 +19,22 @@
 from mpi4py import MPI
 import scipy.sparse as sparse
 
-#Constructing a 1d lattice
-g = nk.graph.Hypercube(L=4, ndim=1)
+# Constructing a 1d lattice
+g = nk.graph.Hypercube(length=4, ndim=1)
 
 # Hilbert space of spins from given graph
 hi = nk.hilbert.Spin(s=0.5, graph=g)
 
-#Hamiltonian
+# Hamiltonian
 ha = nk.operator.Ising(h=1.0, hilbert=hi)
 
-#Machine
-ma = nk.RbmSpin(hilbert=hi, alpha=1)
-ma.InitRandomPars(seed=1234, sigma=0.1)
+# Machine
+ma = nk.machine.RbmSpin(hilbert=hi, alpha=1)
+ma.init_random_parameters(seed=1234, sigma=0.1)
 
-#Sampler
-sa = nk.MetropolisLocal(machine=ma)
-sa.Reset(True)
-print(sa.Visible())
-sa.Sweep()
-print(sa.Visible())
+# Sampler
+sa = nk.sampler.MetropolisLocal(machine=ma)
+sa.reset(True)
+print(sa.get_visible())
+sa.sweep()
+print(sa.get_visible())


Test patch:
diff --git a/Test/Hilbert/test_hilbert.py b/Test/Hilbert/test_hilbert.py
--- a/Test/Hilbert/test_hilbert.py
+++ b/Test/Hilbert/test_hilbert.py
@@ -109,7 +109,7 @@ def test_random_states():
 
         if hi.is_discrete():
             rstate = np.zeros(hi.size())
-            rg = nk.RandomEngine(seed=1234)
+            rg = nk.utils.RandomEngine(seed=1234)
             local_states = hi.local_states()
 
             for i in range(100):
diff --git a/Test/Machine/test_machine.py b/Test/Machine/test_machine.py
--- a/Test/Machine/test_machine.py
+++ b/Test/Machine/test_machine.py
@@ -103,7 +103,7 @@ def test_log_derivative():
         # random visibile state
         hi = ma[1]
         assert(hi.size() > 0)
-        rg = nk.RandomEngine(seed=1234)
+        rg = nk.utils.RandomEngine(seed=1234)
         v = np.zeros(hi.size())
 
         for i in range(100):
@@ -134,7 +134,7 @@ def test_log_val_diff():
 
         hi = ma[1]
 
-        rg = nk.RandomEngine(seed=1234)
+        rg = nk.utils.RandomEngine(seed=1234)
 
         # loop over different random states
         for i in range(100):
diff --git a/Test/Operator/test_operator.py b/Test/Operator/test_operator.py
--- a/Test/Operator/test_operator.py
+++ b/Test/Operator/test_operator.py
@@ -39,7 +39,7 @@ def test_produce_elements_in_hilbert():
         assert (len(hi.local_states()) == hi.local_size())
 
         rstate = np.zeros(hi.size())
-        rg = nk.RandomEngine(seed=1234)
+        rg = nk.utils.RandomEngine(seed=1234)
         local_states = hi.local_states()
 
         for i in range(1000):