foscat 2025.8.4__py3-none-any.whl → 2025.9.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
foscat/FoCUS.py CHANGED
@@ -6,7 +6,7 @@ import numpy as np
6
6
  import foscat.HealSpline as HS
7
7
  from scipy.interpolate import griddata
8
8
 
9
- TMPFILE_VERSION = "V7_0"
9
+ TMPFILE_VERSION = "V9_0"
10
10
 
11
11
 
12
12
  class FoCUS:
@@ -36,7 +36,7 @@ class FoCUS:
36
36
  mpi_rank=0
37
37
  ):
38
38
 
39
- self.__version__ = "2025.08.4"
39
+ self.__version__ = "2025.09.3"
40
40
  # P00 coeff for normalization for scat_cov
41
41
  self.TMPFILE_VERSION = TMPFILE_VERSION
42
42
  self.P1_dic = None
@@ -648,7 +648,7 @@ class FoCUS:
648
648
  return rim
649
649
 
650
650
  # --------------------------------------------------------
651
- def ud_grade_2(self, im, axis=0, cell_ids=None, nside=None):
651
+ def ud_grade_2(self, im, axis=0, cell_ids=None, nside=None,max_poll=False):
652
652
 
653
653
  if self.use_2D:
654
654
  ishape = list(im.shape)
@@ -711,12 +711,21 @@ class FoCUS:
711
711
 
712
712
  else:
713
713
  shape = list(im.shape)
714
- if cell_ids is not None:
715
- sim, new_cell_ids = self.backend.binned_mean(im, cell_ids)
716
- return sim, new_cell_ids
714
+ if max_poll:
715
+ if cell_ids is not None:
716
+ sim, new_cell_ids = self.backend.binned_mean(im, cell_ids,reduce='max')
717
+ return sim, new_cell_ids
717
718
 
718
- return self.backend.bk_reduce_mean(
719
- self.backend.bk_reshape(im, shape[0:-1]+[shape[-1]//4,4]), axis=-1
719
+ return self.backend.bk_reduce_max(
720
+ self.backend.bk_reshape(im, shape[0:-1]+[shape[-1]//4,4]), axis=-1
721
+ ),None
722
+ else:
723
+ if cell_ids is not None:
724
+ sim, new_cell_ids = self.backend.binned_mean(im, cell_ids,reduce='mean')
725
+ return sim, new_cell_ids
726
+
727
+ return self.backend.bk_reduce_mean(
728
+ self.backend.bk_reshape(im, shape[0:-1]+[shape[-1]//4,4]), axis=-1
720
729
  ),None
721
730
 
722
731
  # --------------------------------------------------------
@@ -725,6 +734,7 @@ class FoCUS:
725
734
  nouty=None,
726
735
  cell_ids=None,
727
736
  o_cell_ids=None,
737
+ force_init_index=False,
728
738
  nside=None):
729
739
 
730
740
  ishape = list(im.shape)
@@ -806,7 +816,7 @@ class FoCUS:
806
816
  else:
807
817
  lout = nside
808
818
 
809
- if (lout,nout) not in self.pix_interp_val:
819
+ if (lout,nout) not in self.pix_interp_val or force_init_index:
810
820
  if not self.silent:
811
821
  print("compute lout nout", lout, nout)
812
822
  if cell_ids is None:
@@ -837,7 +847,7 @@ class FoCUS:
837
847
 
838
848
  self.pix_interp_val[(lout,nout)] = 1
839
849
  self.weight_interp_val[(lout,nout)] = self.backend.bk_SparseTensor(
840
- self.backend.bk_constant(indice),
850
+ self.backend.bk_constant(indice.T),
841
851
  self.backend.bk_constant(self.backend.bk_cast(w)),
842
852
  dense_shape=[i_npix,o_cell_ids.shape[0]],
843
853
  )
@@ -848,12 +858,9 @@ class FoCUS:
848
858
  o_cell_ids=np.tile(cell_ids,ratio)*ratio+np.repeat(np.arange(ratio),cell_ids.shape[0])
849
859
  i_npix=cell_ids.shape[0]
850
860
 
851
- #level=int(np.log2(lout)) # nside=128
852
-
853
- #sp = HS.heal_spline(level,gamma=2.0)
854
-
861
+
855
862
  th, ph = hp.pix2ang(
856
- nout, o_cell_ids, nest=True
863
+ nout, self.backend.to_numpy(o_cell_ids), nest=True
857
864
  )
858
865
 
859
866
  all_idx,www=hp.get_interp_weights(lout,th,ph,nest=True)
@@ -866,7 +873,7 @@ class FoCUS:
866
873
  sorter = np.argsort(hidx)
867
874
 
868
875
  index=sorter[np.searchsorted(hidx,
869
- cell_ids,
876
+ self.backend.to_numpy(cell_ids),
870
877
  sorter=sorter)]
871
878
 
872
879
  mask = -np.ones([hidx.shape[0]])
@@ -892,7 +899,7 @@ class FoCUS:
892
899
 
893
900
  self.pix_interp_val[(lout,nout)] = 1
894
901
  self.weight_interp_val[(lout,nout)] = self.backend.bk_SparseTensor(
895
- self.backend.bk_constant(indice),
902
+ self.backend.bk_constant(indice.T),
896
903
  self.backend.bk_constant(self.backend.bk_cast(w)),
897
904
  dense_shape=[i_npix,o_cell_ids.shape[0]],
898
905
  )
@@ -1317,19 +1324,10 @@ class FoCUS:
1317
1324
  nside,
1318
1325
  )
1319
1326
  )
1320
-
1321
- '''
1322
- nn=self.NORIENT*12*nside**2
1323
- idxEB=np.concatenate([tmp,tmp,tmp,tmp],0)
1324
- idxEB[tmp.shape[0]:2*tmp.shape[0],0]+=12*nside**2
1325
- idxEB[3*tmp.shape[0]:,0]+=12*nside**2
1326
- idxEB[2*tmp.shape[0]:,1]+=nn
1327
-
1328
- tmpEB=np.zeros([tmpw.shape[0]*4],dtype='complex')
1329
- '''
1327
+
1330
1328
  import foscat.HOrientedConvol as hs
1331
1329
 
1332
- hconvol=hs.HOrientedConvol(nside,3*self.KERNELSZ,cell_ids=cell_ids)
1330
+ hconvol=hs.HOrientedConvol(nside,4*self.KERNELSZ+1,cell_ids=cell_ids)
1333
1331
 
1334
1332
  if cell_ids is None:
1335
1333
  l_cell_ids=np.arange(12*nside**2)
@@ -1432,23 +1430,6 @@ class FoCUS:
1432
1430
  for k in range(self.NORIENT):
1433
1431
  indice_1_0[(4*k+2)*ndata:(4*k+4)*ndata]+=self.NORIENT*l_cell_ids.shape[0]
1434
1432
  indice_1_0[(4*k)*ndata:(4*k+4)*ndata]+=k*l_cell_ids.shape[0]
1435
- '''
1436
- import matplotlib.pyplot as plt
1437
- plt.figure()
1438
- plt.subplot(2,2,1)
1439
- plt.plot(indice_1_0)
1440
- plt.subplot(2,2,2)
1441
- plt.plot(indice_1_1)
1442
- plt.subplot(2,2,3)
1443
- plt.plot(wav.real)
1444
- plt.subplot(2,2,4)
1445
- plt.plot(abs(wav))
1446
-
1447
- iarg=np.argsort(indice_1_0)
1448
- indice_1_1=indice_1_1[iarg]
1449
- indice_1_0=indice_1_0[iarg]
1450
- wav=wav[iarg]
1451
- '''
1452
1433
 
1453
1434
  indice=np.concatenate([indice_1_1[:,None],indice_1_0[:,None]],1)
1454
1435
 
@@ -1457,52 +1438,9 @@ class FoCUS:
1457
1438
  indice_2_1[3*ndata:4*ndata]+=l_cell_ids.shape[0]
1458
1439
  indice_2_0=np.tile(np.repeat(np.arange(l_cell_ids.shape[0]),nvalid),4)
1459
1440
  indice_2_0[2*ndata:]+=l_cell_ids.shape[0]
1460
- '''
1461
- plt.figure()
1462
- plt.subplot(2,2,1)
1463
- plt.plot(indice_2_0)
1464
- plt.subplot(2,2,2)
1465
- plt.plot(indice_2_1)
1466
- plt.subplot(2,2,3)
1467
- plt.plot(wav.real)
1468
- plt.subplot(2,2,4)
1469
- plt.plot(wwav)
1470
1441
 
1471
- iarg=np.argsort(indice_2_0)
1472
- indice_2_1=indice_2_1[iarg]
1473
- indice_2_0=indice_2_0[iarg]
1474
- wwav=wwav[iarg]
1475
- '''
1476
1442
  indice2=np.concatenate([indice_2_1[:,None],indice_2_0[:,None]],1)
1477
1443
 
1478
- '''
1479
- for k in range(self.NORIENT*12*nside**2):
1480
- if k%(nside**2)==0:
1481
- print('Init index 1/2 spin=%d Please wait %d done against %d nside=%d kernel=%d'%(spin,k//(nside**2),
1482
- self.NORIENT*12,
1483
- nside,
1484
- self.KERNELSZ))
1485
- idx=np.where(tmp[:,1]==k)[0]
1486
-
1487
- im=np.zeros([12*nside**2])
1488
- im[tmp[idx,0]]=tmpw[idx].real
1489
- almR=hp.map2alm(hp.reorder(im,n2r=True))
1490
- im[tmp[idx,0]]=tmpw[idx].imag
1491
- almI=hp.map2alm(hp.reorder(im,n2r=True))
1492
-
1493
- i,q,u=hp.alm2map_spin([almR,almR*0,0*almR],nside,spin,3*nside-1)
1494
- i2,q2,u2=hp.alm2map_spin([almI,0*almI,0*almI],nside,spin,3*nside-1)
1495
-
1496
- tmpEB[idx]=hp.reorder(i,r2n=True)[tmp[idx,0]]+1J*hp.reorder(i2,r2n=True)[tmp[idx,0]]
1497
- tmpEB[idx+tmp.shape[0]]=hp.reorder(q,r2n=True)[tmp[idx,0]]+1J*hp.reorder(q2,r2n=True)[tmp[idx,0]]
1498
-
1499
- i,q,u=hp.alm2map_spin([0*almR,almR,0*almR],nside,spin,3*nside-1)
1500
- i2,q2,u2=hp.alm2map_spin([0*almI,almI,0*almI],nside,spin,3*nside-1)
1501
-
1502
- tmpEB[idx+2*tmp.shape[0]]=hp.reorder(i,r2n=True)[tmp[idx,0]]+1J*hp.reorder(i2,r2n=True)[tmp[idx,0]]
1503
- tmpEB[idx+3*tmp.shape[0]]=hp.reorder(q,r2n=True)[tmp[idx,0]]+1J*hp.reorder(q2,r2n=True)[tmp[idx,0]]
1504
-
1505
- '''
1506
1444
  self.save_index("%s/FOSCAT_%s_W%d_%d_%d_PIDX-SPIN%d.fst"% (self.TEMPLATE_PATH,
1507
1445
  self.TMPFILE_VERSION,
1508
1446
  self.KERNELSZ**2,
@@ -1510,7 +1448,7 @@ class FoCUS:
1510
1448
  nside,
1511
1449
  spin
1512
1450
  ),
1513
- indice
1451
+ indice.T
1514
1452
  )
1515
1453
  self.save_index("%s/FOSCAT_%s_W%d_%d_%d_WAVE-SPIN%d.fst"% (self.TEMPLATE_PATH,
1516
1454
  self.TMPFILE_VERSION,
@@ -1521,49 +1459,6 @@ class FoCUS:
1521
1459
  ),
1522
1460
  wav
1523
1461
  )
1524
- '''
1525
- tmp = self.read_index(
1526
- "%s/FOSCAT_%s_W%d_%d_%d_PIDX2-SPIN0.fst"
1527
- % (
1528
- self.TEMPLATE_PATH,
1529
- TMPFILE_VERSION,
1530
- l_kernel**2,
1531
- self.NORIENT,
1532
- nside
1533
- )
1534
- )
1535
-
1536
- tmpw = self.read_index("%s/FOSCAT_%s_W%d_%d_%d_SMOO-SPIN0.fst"% (
1537
- self.TEMPLATE_PATH,
1538
- self.TMPFILE_VERSION,
1539
- self.KERNELSZ**2,
1540
- self.NORIENT,
1541
- nside,
1542
- )
1543
- )
1544
- for k in range(12*nside**2):
1545
- if k%(nside**2)==0:
1546
- print('Init index 2/2 spin=%d Please wait %d done against %d nside=%d kernel=%d'%(spin,k//(nside**2),
1547
- 12,
1548
- nside,
1549
- self.KERNELSZ))
1550
- idx=np.where(tmp[:,1]==k)[0]
1551
-
1552
- im=np.zeros([12*nside**2])
1553
- im[tmp[idx,0]]=tmpw[idx]
1554
- almR=hp.map2alm(hp.reorder(im,n2r=True))
1555
-
1556
- i,q,u=hp.alm2map_spin([almR,almR*0,0*almR],nside,spin,3*nside-1)
1557
-
1558
- tmpEB[idx]=hp.reorder(i,r2n=True)[tmp[idx,0]]
1559
- tmpEB[idx+tmp.shape[0]]=hp.reorder(q,r2n=True)[tmp[idx,0]]
1560
-
1561
- i,q,u=hp.alm2map_spin([0*almR,almR,0*almR],nside,spin,3*nside-1)
1562
-
1563
- tmpEB[idx+2*tmp.shape[0]]=hp.reorder(i,r2n=True)[tmp[idx,0]]
1564
- tmpEB[idx+3*tmp.shape[0]]=hp.reorder(q,r2n=True)[tmp[idx,0]]
1565
-
1566
- '''
1567
1462
  self.save_index("%s/FOSCAT_%s_W%d_%d_%d_PIDX2-SPIN%d.fst"% (self.TEMPLATE_PATH,
1568
1463
  self.TMPFILE_VERSION,
1569
1464
  self.KERNELSZ**2,
@@ -1571,7 +1466,7 @@ class FoCUS:
1571
1466
  nside,
1572
1467
  spin
1573
1468
  ),
1574
- indice2
1469
+ indice2.T
1575
1470
  )
1576
1471
  self.save_index("%s/FOSCAT_%s_W%d_%d_%d_SMOO-SPIN%d.fst"% (self.TEMPLATE_PATH,
1577
1472
  self.TMPFILE_VERSION,
@@ -1584,7 +1479,6 @@ class FoCUS:
1584
1479
  )
1585
1480
 
1586
1481
  else:
1587
- '''
1588
1482
  if l_kernel == 5:
1589
1483
  pw = 0.5
1590
1484
  pw2 = 0.5
@@ -1599,145 +1493,55 @@ class FoCUS:
1599
1493
  pw = 0.5
1600
1494
  pw2 = 0.25
1601
1495
  threshold = 4e-5
1602
- '''
1603
- import foscat.HOrientedConvol as hs
1604
-
1605
- hconvol=hs.HOrientedConvol(nside,l_kernel,cell_ids=cell_ids)
1606
-
1607
- orientations=np.pi*np.arange(self.NORIENT)/self.NORIENT
1608
-
1609
- wav,indice,wwav,indice2=hconvol.make_wavelet_matrix(orientations,
1610
- polar=True,
1611
- return_index=True,
1612
- return_smooth=True)
1496
+
1497
+ import foscat.SphericalStencil as hs
1498
+ import torch
1613
1499
 
1614
- '''
1615
- if cell_ids is not None and nside>256:
1616
- if not isinstance(cell_ids, np.ndarray):
1617
- cell_ids = self.backend.to_numpy(cell_ids)
1618
- th, ph = hp.pix2ang(nside, cell_ids, nest=True)
1619
- x, y, z = hp.pix2vec(nside, cell_ids, nest=True)
1620
-
1621
- t, p = hp.pix2ang(nside, cell_ids, nest=True)
1622
- phi = [p[k] / np.pi * 180 for k in range(ncell)]
1623
- thi = [t[k] / np.pi * 180 for k in range(ncell)]
1624
-
1625
- indice2 = np.zeros([ncell * 64, 2], dtype="int")
1626
- indice = np.zeros([ncell * 64 * self.NORIENT, 2], dtype="int")
1627
- wav = np.zeros([ncell * 64 * self.NORIENT], dtype="complex")
1628
- wwav = np.zeros([ncell * 64 * self.NORIENT], dtype="float")
1629
-
1500
+ if cell_ids is None:
1501
+ l_cell_ids=np.arange(12*nside**2)
1630
1502
  else:
1503
+ l_cell_ids=cell_ids
1631
1504
 
1632
- th, ph = hp.pix2ang(nside, np.arange(12 * nside**2), nest=True)
1633
- x, y, z = hp.pix2vec(nside, np.arange(12 * nside**2), nest=True)
1634
-
1635
- t, p = hp.pix2ang(nside, np.arange(12 * nside * nside), nest=True)
1636
- phi = [p[k] / np.pi * 180 for k in range(12 * nside * nside)]
1637
- thi = [t[k] / np.pi * 180 for k in range(12 * nside * nside)]
1638
-
1639
- indice2 = np.zeros([12 * nside * nside * 64, 2],
1640
- dtype="int")
1505
+ if isinstance(l_cell_ids,torch.Tensor):
1506
+ l_cell_ids=self.backend.to_numpy(l_cell_ids)
1641
1507
 
1642
- indice = np.zeros(
1643
- [12 * nside * nside * 64 * self.NORIENT, 2],
1644
- dtype="int"
1645
- )
1646
- wav = np.zeros(
1647
- [12 * nside * nside * 64 * self.NORIENT],
1648
- dtype="complex"
1649
- )
1650
- wwav = np.zeros(
1651
- [12 * nside * nside * 64 * self.NORIENT],
1652
- dtype="float"
1653
- )
1654
- iv = 0
1655
- iv2 = 0
1656
-
1657
- for iii in range(ncell):
1658
- if cell_ids is None:
1659
- if iii % (nside * nside) == nside * nside - 1:
1660
- if not self.silent:
1661
- print(
1662
- "Pre-compute nside=%6d %.2f%%"
1663
- % (nside, 100 * iii / (12 * nside * nside))
1664
- )
1665
-
1666
- if cell_ids is not None:
1667
- hidx = np.where(
1668
- (x - x[iii]) ** 2 + (y - y[iii]) ** 2 + (z - z[iii]) ** 2
1669
- < (2 * np.pi / nside) ** 2
1670
- )[0]
1671
- else:
1672
- hidx = hp.query_disc(
1673
- nside,
1674
- [x[iii], y[iii], z[iii]],
1675
- 2 * np.pi / nside,
1676
- nest=True,
1677
- )
1678
-
1679
- R = hp.Rotator(rot=[phi[iii], -thi[iii]], eulertype="ZYZ")
1680
-
1681
- t2, p2 = R(th[hidx], ph[hidx])
1682
-
1683
- vec2 = hp.ang2vec(t2, p2)
1684
-
1685
- x2 = vec2[:, 0]
1686
- y2 = vec2[:, 1]
1687
- z2 = vec2[:, 2]
1688
-
1689
- ww = np.exp(
1690
- -pw2
1691
- * ((nside) ** 2)
1692
- * ((x2) ** 2 + (y2) ** 2 + (z2 - 1.0) ** 2)
1693
- )
1694
- idx = np.where((ww**2) > threshold)[0]
1695
- nval2 = len(idx)
1696
- indice2[iv2 : iv2 + nval2, 1] = iii
1697
- indice2[iv2 : iv2 + nval2, 0] = hidx[idx]
1698
- wwav[iv2 : iv2 + nval2] = ww[idx] / np.sum(ww[idx])
1699
- iv2 += nval2
1700
-
1701
- for l_rotation in range(self.NORIENT):
1702
-
1703
- angle = (
1704
- l_rotation / 4.0 * np.pi
1705
- - phi[iii] / 180.0 * np.pi * (z[hidx] > 0)
1706
- - (180.0 - phi[iii]) / 180.0 * np.pi * (z[hidx] < 0)
1707
- )
1708
-
1709
- # posi=2*(0.5-(z[hidx]<0))
1710
-
1711
- axes = y2 * np.cos(angle) - x2 * np.sin(angle)
1712
- wresr = ww * np.cos(pw * axes * (nside) * np.pi)
1713
- wresi = ww * np.sin(pw * axes * (nside) * np.pi)
1714
-
1715
- vnorm = wresr * wresr + wresi * wresi
1716
- idx = np.where(vnorm > threshold)[0]
1717
-
1718
- nval = len(idx)
1719
- indice[iv : iv + nval, 1] = iii + l_rotation * ncell
1720
- indice[iv : iv + nval, 0] = hidx[idx]
1721
- # print([hidx[k] for k in idx])
1722
- # print(hp.query_disc(nside, [x[iii],y[iii],z[iii]], np.pi/nside,nest=True))
1723
- normr = np.mean(wresr[idx])
1724
- normi = np.mean(wresi[idx])
1725
-
1726
- val = wresr[idx] - normr + 1j * (wresi[idx] - normi)
1727
- r = abs(val).sum()
1728
-
1729
- if r > 0:
1730
- val = val / r
1508
+ hconvol=hs.SphericalStencil(nside,
1509
+ l_kernel,
1510
+ cell_ids=l_cell_ids,
1511
+ n_gauges=self.NORIENT,
1512
+ gauge_type='cosmo')
1513
+
1514
+ xx=np.tile(np.arange(self.KERNELSZ)-self.KERNELSZ//2,self.KERNELSZ).reshape(self.KERNELSZ*self.KERNELSZ)
1515
+
1516
+ wwr=hconvol.to_tensor((np.exp(-pw2*(xx**2+(xx.T)**2))*np.cos(pw*xx*np.pi)).reshape(1,1,self.KERNELSZ*self.KERNELSZ))
1517
+ wwr-=wwr.mean()
1518
+ wwi=hconvol.to_tensor((np.exp(-pw2*(xx**2+(xx.T)**2))*np.sin(pw*xx*np.pi)).reshape(1,1,self.KERNELSZ*self.KERNELSZ))
1519
+ wwi-=wwi.mean()
1520
+ wwr/=(abs(wwr+1J*wwi)).sum()
1521
+ wwi/=(abs(wwr+1J*wwi)).sum()
1522
+
1523
+ wavr,indice,mshape=hconvol.make_matrix(wwr)
1524
+ wavi,indice,mshape=hconvol.make_matrix(wwi)
1731
1525
 
1732
- wav[iv : iv + nval] = val
1733
- iv += nval
1526
+ wav=hconvol.to_numpy(wavr)+1J*hconvol.to_numpy(wavi)
1527
+ indice=hconvol.to_numpy(indice)
1734
1528
 
1735
- indice = indice[:iv, :]
1736
- wav = wav[:iv]
1737
- indice2 = indice2[:iv2, :]
1738
- wwav = wwav[:iv2]
1739
- '''
1529
+
1530
+ hconvol=hs.SphericalStencil(nside,
1531
+ l_kernel,
1532
+ cell_ids=l_cell_ids,
1533
+ n_gauges=1,
1534
+ gauge_type='cosmo')
1535
+
1536
+
1537
+ ww=hconvol.to_tensor((np.exp(-pw2*(xx**2+(xx.T)**2))).reshape(1,1,self.KERNELSZ*self.KERNELSZ))
1538
+ ww/=ww.sum()
1539
+
1540
+ wwav,indice2,mshape=hconvol.make_matrix(ww)
1740
1541
 
1542
+ wwav=hconvol.to_numpy(wwav)
1543
+ indice2=hconvol.to_numpy(indice2)
1544
+
1741
1545
  if cell_ids is None:
1742
1546
  if not self.silent:
1743
1547
  print(
@@ -1795,6 +1599,7 @@ class FoCUS:
1795
1599
  ),
1796
1600
  wwav,
1797
1601
  )
1602
+
1798
1603
  if self.use_2D:
1799
1604
  if l_kernel**2 == 9:
1800
1605
  if self.rank == 0:
@@ -1879,7 +1684,7 @@ class FoCUS:
1879
1684
  spin,
1880
1685
  )
1881
1686
  )
1882
-
1687
+ '''
1883
1688
  if cell_ids is not None:
1884
1689
  idx_map=-np.ones([12*nside**2],dtype='int32')
1885
1690
  lcell_ids=cell_ids
@@ -1931,6 +1736,7 @@ class FoCUS:
1931
1736
  ww=np.bincount(tmp[:,1],weights=np.sqrt(wr*wr+wi*wi))
1932
1737
  wr/=ww[tmp[:,1]]
1933
1738
  wi/=ww[tmp[:,1]]
1739
+ '''
1934
1740
 
1935
1741
  else:
1936
1742
  tmp = indice
@@ -1941,6 +1747,7 @@ class FoCUS:
1941
1747
 
1942
1748
 
1943
1749
  if spin==0:
1750
+
1944
1751
  wr = self.backend.bk_SparseTensor(
1945
1752
  self.backend.bk_constant(tmp),
1946
1753
  self.backend.bk_constant(self.backend.bk_cast(wr)),