import unittest
import numpy as np

import parafermions as pf

class Test(unittest.TestCase):

    def test_pe_degeneracy(self):
        # should initialise with all zeros
        N, l = 8, 0.2
        pe = pf.PeschelEmerySpinHalf(N, l, dtype=np.dtype('float64'))
        d, v = pe.Diagonalise(k=100)
        assert(np.sum(d[1:11:2]-d[:11:2]) < 1e-10)

        N, l = 8, 1.0
        pe = pf.PeschelEmerySpinHalf(N, l, dtype=np.dtype('float64'))
        d, v = pe.Diagonalise(k=100)
        assert((d[1]-d[0]) < 1e-15)
        assert(np.sum(d[1:11:2]-d[:11:2]) > 1e-2)

import unittest
import numpy as np

import parafermions as pf

class Test(unittest.TestCase):

    def test_pe_degeneracy(self):
        # should initialise with all zeros
        N, l = 8, 0.0
        pe = pf.PeschelEmerySpinHalf(N, l, dtype=np.dtype('float64'))
        d, v = pe.Diagonalise(k=100)
        # check that all eigenvalues are degenerate
        assert(np.sum(d[1:10:2]-d[:10:2]) < 1e-10)

        N, l = 8, 1.0
        pe = pf.PeschelEmerySpinHalf(N, l, dtype=np.dtype('float64'))
        d, v = pe.Diagonalise(k=100)
        # check only the ground state eigenvalues are degenerate
        assert((d[1]-d[0]) < 1e-15)
        assert(np.sum(d[1:10:2]-d[:10:2]) > 1e-2)

Update slicing so that array sizes match
Update slicing so that array sizes match

  import unittest
  import numpy as np
  
  import parafermions as pf
  
  class Test(unittest.TestCase):
  
      def test_pe_degeneracy(self):
          # should initialise with all zeros
-         N, l = 8, 0.2
+         N, l = 8, 0.0
          pe = pf.PeschelEmerySpinHalf(N, l, dtype=np.dtype('float64'))
          d, v = pe.Diagonalise(k=100)
+         # check that all eigenvalues are degenerate
-         assert(np.sum(d[1:11:2]-d[:11:2]) < 1e-10)
+         assert(np.sum(d[1:10:2]-d[:10:2]) < 1e-10)
  
          N, l = 8, 1.0
          pe = pf.PeschelEmerySpinHalf(N, l, dtype=np.dtype('float64'))
          d, v = pe.Diagonalise(k=100)
+         # check only the ground state eigenvalues are degenerate
          assert((d[1]-d[0]) < 1e-15)
-         assert(np.sum(d[1:11:2]-d[:11:2]) > 1e-2)
+         assert(np.sum(d[1:10:2]-d[:10:2]) > 1e-2)
  
Update slicing so that array sizes match
## Code Before:
import unittest
import numpy as np

import parafermions as pf

class Test(unittest.TestCase):

    def test_pe_degeneracy(self):
        # should initialise with all zeros
        N, l = 8, 0.2
        pe = pf.PeschelEmerySpinHalf(N, l, dtype=np.dtype('float64'))
        d, v = pe.Diagonalise(k=100)
        assert(np.sum(d[1:11:2]-d[:11:2]) < 1e-10)

        N, l = 8, 1.0
        pe = pf.PeschelEmerySpinHalf(N, l, dtype=np.dtype('float64'))
        d, v = pe.Diagonalise(k=100)
        assert((d[1]-d[0]) < 1e-15)
        assert(np.sum(d[1:11:2]-d[:11:2]) > 1e-2)

## Instruction:
Update slicing so that array sizes match
## Code After:
import unittest
import numpy as np

import parafermions as pf

class Test(unittest.TestCase):

    def test_pe_degeneracy(self):
        # should initialise with all zeros
        N, l = 8, 0.0
        pe = pf.PeschelEmerySpinHalf(N, l, dtype=np.dtype('float64'))
        d, v = pe.Diagonalise(k=100)
        # check that all eigenvalues are degenerate
        assert(np.sum(d[1:10:2]-d[:10:2]) < 1e-10)

        N, l = 8, 1.0
        pe = pf.PeschelEmerySpinHalf(N, l, dtype=np.dtype('float64'))
        d, v = pe.Diagonalise(k=100)
        # check only the ground state eigenvalues are degenerate
        assert((d[1]-d[0]) < 1e-15)
        assert(np.sum(d[1:10:2]-d[:10:2]) > 1e-2)
