Skip to content

Commit 1c85597

Browse files
FanwangMmsricher
andauthored
Fix import issue (theochem#78)
* Use absolute import path * Try src folder * Fix pyci C ext. module import * Update FanCI to use new C ext. module --------- Co-authored-by: Michelle Richer <michellericher93@gmail.com>
1 parent 9164c49 commit 1c85597

File tree

10 files changed

+30
-31
lines changed

10 files changed

+30
-31
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ OBJECTS := $(patsubst %.cpp,%.o,$(wildcard pyci/src/*.cpp))
7070
# -------------
7171

7272
.PHONY: all
73-
all: pyci/pyci.so.$(PYCI_VERSION) pyci/pyci.so.$(VERSION_MAJOR) pyci/pyci.so
73+
all: pyci/_pyci.so.$(PYCI_VERSION) pyci/_pyci.so.$(VERSION_MAJOR) pyci/_pyci.so
7474

7575
.PHONY: test
7676
test:
7777
$(PYTHON) -m pytest -sv ./pyci
7878

7979
.PHONY: clean
8080
clean:
81-
rm -rf pyci/src/*.o pyci/pyci.so*
81+
rm -rf pyci/src/*.o pyci/_pyci.so*
8282

8383
.PHONY: cleandeps
8484
cleandeps:
@@ -94,13 +94,13 @@ compile_flags.txt:
9494
pyci/src/%.o: pyci/src/%.cpp pyci/include/pyci.h $(DEPS)
9595
$(CXX) $(CFLAGS) $(DEFS) -c $(<) -o $(@)
9696

97-
pyci/pyci.so.$(PYCI_VERSION): $(OBJECTS)
97+
pyci/_pyci.so.$(PYCI_VERSION): $(OBJECTS)
9898
$(CXX) $(CFLAGS) $(DEFS) -shared $(^) -o $(@)
9999

100-
pyci/pyci.so.$(VERSION_MAJOR): pyci/pyci.so.$(PYCI_VERSION)
100+
pyci/_pyci.so.$(VERSION_MAJOR): pyci/_pyci.so.$(PYCI_VERSION)
101101
ln -sf $(notdir $(<)) $(@)
102102

103-
pyci/pyci.so: pyci/pyci.so.$(PYCI_VERSION)
103+
pyci/_pyci.so: pyci/_pyci.so.$(PYCI_VERSION)
104104
ln -sf $(notdir $(<)) $(@)
105105

106106
deps/eigen:

pyci/__init__.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@
1515

1616
r"""PyCI module."""
1717

18-
from .pyci import __version__, c_long, c_ulong, c_double, sparse_op
19-
20-
from .pyci import secondquant_op, wavefunction, one_spin_wfn, two_spin_wfn
21-
from .pyci import doci_wfn, fullci_wfn, genci_wfn, sparse_op
22-
from .pyci import get_num_threads, set_num_threads, popcnt, ctz
23-
from .pyci import compute_overlap, compute_rdms, compute_transition_rdms
24-
from .pyci import add_hci, compute_enpt2
25-
26-
from .utility import make_senzero_integrals, reduce_senzero_integrals, spinize_rdms
27-
from .utility import odometer_one_spin, odometer_two_spin
28-
29-
from .excitation_ci import add_excitations
30-
from .seniority_ci import add_seniorities
31-
from .gkci import add_gkci
32-
from .cost_ci import add_cost
18+
from pyci._pyci import __version__, c_long, c_ulong, c_double
19+
from pyci._pyci import secondquant_op, wavefunction, one_spin_wfn, two_spin_wfn
20+
from pyci._pyci import doci_wfn, fullci_wfn, genci_wfn, sparse_op
21+
from pyci._pyci import get_num_threads, set_num_threads, popcnt, ctz
22+
from pyci._pyci import compute_overlap, compute_rdms, compute_transition_rdms
23+
from pyci._pyci import add_hci, compute_enpt2
24+
25+
from pyci.utility import make_senzero_integrals, reduce_senzero_integrals, spinize_rdms
26+
from pyci.utility import odometer_one_spin, odometer_two_spin
27+
28+
from pyci.excitation_ci import add_excitations
29+
from pyci.seniority_ci import add_seniorities
30+
from pyci.gkci import add_gkci
31+
from pyci.cost_ci import add_cost
3332

3433

3534
__all__ = [

pyci/cost_ci.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
r"""PyCI Griebel-Knapek CI module."""
1717

18-
from . import pyci
18+
from pyci.utility import odometer_one_spin, odometer_two_spin
19+
import pyci._pyci as pyci
1920

2021

2122
__all__ = [
@@ -47,8 +48,8 @@ def add_cost(wfn, cost, q_max, t=-0.5):
4748
"""
4849
# Run odometer algorithm
4950
if isinstance(wfn, (pyci.doci_wfn, pyci.genci_wfn)):
50-
pyci.odometer_one_spin(wfn, cost, q_max=q_max, t=t)
51+
odometer_one_spin(wfn, cost, q_max=q_max, t=t)
5152
elif isinstance(wfn, pyci.fullci_wfn):
52-
pyci.odometer_two_spin(wfn, cost, q_max=q_max, t=t)
53+
odometer_two_spin(wfn, cost, q_max=q_max, t=t)
5354
else:
5455
raise TypeError(f"invalid `wfn` type `{type(wfn)}`; must be `pyci.wavefunction`")

pyci/fanci/ap1rog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import pyci
1212

13-
from ..pyci import AP1roGObjective
13+
from pyci._pyci import AP1roGObjective
1414
from .fanci import FanCI
1515

1616

pyci/fanci/apig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import pyci
1111

12-
from ..pyci import APIGObjective
12+
from pyci._pyci import APIGObjective
1313
from .fanci import FanCI
1414

1515

pyci/gkci.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
import numpy as np
1919

2020
from scipy.special import gammaln, polygamma
21-
import pyci
22-
21+
import pyci._pyci as pyci
2322

2423

2524
__all__ = [

pyci/seniority_ci.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import numpy as np
2121

22-
from . import pyci
22+
import pyci._pyci as pyci
2323

2424

2525
__all__ = [

pyci/src/binding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using namespace pyci;
2626
Section: Python C extension.
2727
*/
2828

29-
BEGIN_MODULE(pyci, m)
29+
BEGIN_MODULE(_pyci, m)
3030

3131
/*
3232
Section: Initialization

pyci/utility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
r"""PyCI utility module."""
1717

1818
import numpy as np
19-
import pyci
19+
import pyci._pyci as pyci
2020

2121
__all__ = [
2222
"make_senzero_integrals",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ packages = [
8282
[tool.setuptools.package-data]
8383
# Non-Python files to include in the package
8484
"pyci" = [
85-
"pyci.so", # Compiled C++ extension
85+
"_pyci.so", # Compiled C++ extension
8686
"include/*.h", # C++ header files
8787
"src/*.cpp" # C++ source files
8888
]

0 commit comments

Comments
 (0)