qupled 1.0.0__tar.gz → 1.0.1__tar.gz

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.
Files changed (35) hide show
  1. qupled-1.0.1/PKG-INFO +11 -0
  2. {qupled-1.0.0 → qupled-1.0.1}/pyproject.toml +1 -1
  3. qupled-1.0.1/src/qupled.egg-info/PKG-INFO +11 -0
  4. qupled-1.0.1/src/qupled.egg-info/SOURCES.txt +27 -0
  5. qupled-1.0.1/src/qupled.egg-info/top_level.txt +1 -0
  6. qupled-1.0.1/tests/test_esa.py +31 -0
  7. qupled-1.0.1/tests/test_esa_native.py +43 -0
  8. qupled-1.0.1/tests/test_examples.py +79 -0
  9. qupled-1.0.1/tests/test_hdf.py +172 -0
  10. qupled-1.0.1/tests/test_plot.py +32 -0
  11. qupled-1.0.1/tests/test_qstls.py +78 -0
  12. qupled-1.0.1/tests/test_qstls_iet.py +124 -0
  13. qupled-1.0.1/tests/test_qstls_input.py +125 -0
  14. qupled-1.0.1/tests/test_qstls_native.py +89 -0
  15. qupled-1.0.1/tests/test_qvs.py +139 -0
  16. qupled-1.0.1/tests/test_qvs_input.py +177 -0
  17. qupled-1.0.1/tests/test_qvs_native.py +63 -0
  18. qupled-1.0.1/tests/test_rpa.py +107 -0
  19. qupled-1.0.1/tests/test_rpa_input.py +188 -0
  20. qupled-1.0.1/tests/test_rpa_native.py +42 -0
  21. qupled-1.0.1/tests/test_stls.py +74 -0
  22. qupled-1.0.1/tests/test_stls_iet.py +66 -0
  23. qupled-1.0.1/tests/test_stls_input.py +153 -0
  24. qupled-1.0.1/tests/test_stls_native.py +90 -0
  25. qupled-1.0.1/tests/test_vsstls.py +80 -0
  26. qupled-1.0.1/tests/test_vsstls_input.py +163 -0
  27. qupled-1.0.1/tests/test_vsstls_native.py +51 -0
  28. qupled-1.0.0/LICENSE +0 -674
  29. qupled-1.0.0/PKG-INFO +0 -103
  30. qupled-1.0.0/README.md +0 -90
  31. qupled-1.0.0/src/qupled.egg-info/PKG-INFO +0 -103
  32. qupled-1.0.0/src/qupled.egg-info/SOURCES.txt +0 -7
  33. qupled-1.0.0/src/qupled.egg-info/top_level.txt +0 -1
  34. {qupled-1.0.0 → qupled-1.0.1}/setup.cfg +0 -0
  35. {qupled-1.0.0 → qupled-1.0.1}/src/qupled.egg-info/dependency_links.txt +0 -0
qupled-1.0.1/PKG-INFO ADDED
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.1
2
+ Name: qupled
3
+ Version: 1.0.1
4
+ Summary: qupled: a package to investigate quantum plasmas via the dielectric formalism
5
+ Author-email: Federico Lucco Castello <federico.luccocastello@gmail.com>
6
+ Classifier: Programming Language :: Python :: 3.10
7
+ Classifier: Operating System :: MacOS
8
+ Classifier: Operating System :: POSIX :: Linux
9
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
10
+ Requires-Python: <3.13,>=3.10
11
+ Description-Content-Type: text/markdown
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "qupled"
7
- version = "1.0.0"
7
+ version = "1.0.1"
8
8
  description = "qupled: a package to investigate quantum plasmas via the dielectric formalism"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10, <3.13"
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.1
2
+ Name: qupled
3
+ Version: 1.0.1
4
+ Summary: qupled: a package to investigate quantum plasmas via the dielectric formalism
5
+ Author-email: Federico Lucco Castello <federico.luccocastello@gmail.com>
6
+ Classifier: Programming Language :: Python :: 3.10
7
+ Classifier: Operating System :: MacOS
8
+ Classifier: Operating System :: POSIX :: Linux
9
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
10
+ Requires-Python: <3.13,>=3.10
11
+ Description-Content-Type: text/markdown
@@ -0,0 +1,27 @@
1
+ pyproject.toml
2
+ src/qupled.egg-info/PKG-INFO
3
+ src/qupled.egg-info/SOURCES.txt
4
+ src/qupled.egg-info/dependency_links.txt
5
+ src/qupled.egg-info/top_level.txt
6
+ tests/test_esa.py
7
+ tests/test_esa_native.py
8
+ tests/test_examples.py
9
+ tests/test_hdf.py
10
+ tests/test_plot.py
11
+ tests/test_qstls.py
12
+ tests/test_qstls_iet.py
13
+ tests/test_qstls_input.py
14
+ tests/test_qstls_native.py
15
+ tests/test_qvs.py
16
+ tests/test_qvs_input.py
17
+ tests/test_qvs_native.py
18
+ tests/test_rpa.py
19
+ tests/test_rpa_input.py
20
+ tests/test_rpa_native.py
21
+ tests/test_stls.py
22
+ tests/test_stls_iet.py
23
+ tests/test_stls_input.py
24
+ tests/test_stls_native.py
25
+ tests/test_vsstls.py
26
+ tests/test_vsstls_input.py
27
+ tests/test_vsstls_native.py
@@ -0,0 +1 @@
1
+ CMakeFiles
@@ -0,0 +1,31 @@
1
+ import os
2
+ import pytest
3
+ from qupled.classic import ESA
4
+
5
+
6
+ @pytest.fixture
7
+ def esa():
8
+ return ESA()
9
+
10
+
11
+ @pytest.fixture
12
+ def esa_input():
13
+ return ESA.Input(1.0, 1.0)
14
+
15
+
16
+ def test_default(esa):
17
+ assert esa.hdfFileName == None
18
+
19
+
20
+ def test_compute(esa, esa_input, mocker):
21
+ mockMPITime = mocker.patch("qupled.util.MPI.timer", return_value=0)
22
+ mockMPIBarrier = mocker.patch("qupled.util.MPI.barrier")
23
+ mockCompute = mocker.patch("qupled.qupled.ESA.compute")
24
+ mockCheckStatusAndClean = mocker.patch("qupled.classic.ESA._checkStatusAndClean")
25
+ mockSave = mocker.patch("qupled.classic.ESA._save")
26
+ esa.compute(esa_input)
27
+ assert mockMPITime.call_count == 2
28
+ assert mockMPIBarrier.call_count == 1
29
+ assert mockCompute.call_count == 1
30
+ assert mockCheckStatusAndClean.call_count == 1
31
+ assert mockSave.call_count == 1
@@ -0,0 +1,43 @@
1
+ import os
2
+ import pytest
3
+ import qupled.qupled as qp
4
+
5
+
6
+ def test_esa_properties():
7
+ assert issubclass(qp.ESA, qp.Rpa)
8
+ scheme = qp.ESA(qp.RpaInput())
9
+ assert hasattr(scheme, "idr")
10
+ assert hasattr(scheme, "sdr")
11
+ assert hasattr(scheme, "slfc")
12
+ assert hasattr(scheme, "ssf")
13
+ assert hasattr(scheme, "ssfHF")
14
+ with pytest.raises(RuntimeError) as excinfo:
15
+ hasattr(scheme, "uInt")
16
+ assert excinfo.value.args[0] == "No data to compute the internal energy"
17
+ assert hasattr(scheme, "wvg")
18
+ assert hasattr(scheme, "recovery")
19
+
20
+
21
+ def test_esa_compute():
22
+ inputs = qp.RpaInput()
23
+ inputs.coupling = 1.0
24
+ inputs.degeneracy = 1.0
25
+ inputs.theory = "RPA"
26
+ inputs.chemicalPotential = [-10, 10]
27
+ inputs.cutoff = 10.0
28
+ inputs.matsubara = 128
29
+ inputs.resolution = 0.1
30
+ inputs.intError = 1.0e-5
31
+ inputs.threads = 1
32
+ scheme = qp.ESA(inputs)
33
+ scheme.compute()
34
+ nx = scheme.wvg.size
35
+ assert nx >= 3
36
+ assert scheme.idr.shape[0] == nx
37
+ assert scheme.idr.shape[1] == inputs.matsubara
38
+ assert scheme.sdr.size == nx
39
+ assert scheme.slfc.size == nx
40
+ assert scheme.ssf.size == nx
41
+ assert scheme.ssfHF.size == nx
42
+ assert scheme.recovery == ""
43
+ assert scheme.rdf(scheme.wvg).size == nx
@@ -0,0 +1,79 @@
1
+ import os
2
+ import glob
3
+ import importlib
4
+ import pytest
5
+
6
+
7
+ def cleanExampleFiles():
8
+ for fileExtension in ["h5", "bin", "zip"]:
9
+ fileNames = glob.glob("*." + fileExtension)
10
+ for fileName in fileNames:
11
+ os.remove(fileName)
12
+
13
+
14
+ def runExample(exampleName, mocker):
15
+ try:
16
+ mockPlotShow = mocker.patch("matplotlib.pyplot.show")
17
+ importlib.import_module(exampleName)
18
+ finally:
19
+ cleanExampleFiles()
20
+
21
+
22
+ def runExampleWithError(exampleName, mocker, expectedErrorMessage):
23
+ try:
24
+ mockPlotShow = mocker.patch("matplotlib.pyplot.show")
25
+ with pytest.raises(SystemExit) as excinfo:
26
+ importlib.import_module(exampleName)
27
+ assert excinfo.value.code == expectedErrorMessage
28
+ finally:
29
+ cleanExampleFiles()
30
+
31
+
32
+ def test_fixedAdrQstls(mocker):
33
+ runExampleWithError(
34
+ "fixedAdrQstls", mocker, "Error while solving the dielectric theory"
35
+ )
36
+
37
+
38
+ def test_fixedAdrQstlsIet(mocker):
39
+ runExample("fixedAdrQstlsIet", mocker)
40
+
41
+
42
+ def test_fixedAdrQVSStls(mocker):
43
+ runExample("fixedAdrQVSStls", mocker)
44
+
45
+
46
+ def test_initialGuessQstls(mocker):
47
+ runExample("initialGuessQstls", mocker)
48
+
49
+
50
+ def test_initialGuessQstlsIet(mocker):
51
+ runExample("initialGuessQstlsIet", mocker)
52
+
53
+
54
+ def test_initialGuessStls(mocker):
55
+ runExample("initialGuessStls", mocker)
56
+
57
+
58
+ def test_solveQuantumSchemes(mocker):
59
+ runExample("solveQuantumSchemes", mocker)
60
+
61
+
62
+ def test_solveQVSStls(mocker):
63
+ runExample("solveQVSStls", mocker)
64
+
65
+
66
+ def test_solveRpaAndESA(mocker):
67
+ runExample("solveRpaAndESA", mocker)
68
+
69
+
70
+ def test_solveStls(mocker):
71
+ runExample("solveStls", mocker)
72
+
73
+
74
+ def test_solveStlsIet(mocker):
75
+ runExample("solveStlsIet", mocker)
76
+
77
+
78
+ def test_solveVSStls(mocker):
79
+ runExample("solveVSStls", mocker)
@@ -0,0 +1,172 @@
1
+ import os
2
+ import pytest
3
+ import numpy as np
4
+ import pandas as pd
5
+ from qupled.util import Hdf
6
+
7
+
8
+ @pytest.fixture
9
+ def hdf_instance():
10
+ return Hdf()
11
+
12
+
13
+ def mockOutput(hdfFileName):
14
+ data1D = np.zeros(2)
15
+ data2D = np.zeros((2, 2))
16
+ pd.DataFrame(
17
+ {
18
+ "coupling": 0.0,
19
+ "degeneracy": 0.0,
20
+ "error": 0.0,
21
+ "theory": "theory",
22
+ "resolution": 0.0,
23
+ "cutoff": 0,
24
+ "matsubara": 0,
25
+ },
26
+ index=["info"],
27
+ ).to_hdf(hdfFileName, key="info", mode="w")
28
+ pd.DataFrame(data1D).to_hdf(hdfFileName, key="alpha")
29
+ pd.DataFrame(data2D).to_hdf(hdfFileName, key="adr")
30
+ pd.DataFrame(data1D).to_hdf(hdfFileName, key="bf")
31
+ pd.DataFrame(data1D).to_hdf(hdfFileName, key="fxcGrid")
32
+ pd.DataFrame(data2D).to_hdf(hdfFileName, key="fxci")
33
+ pd.DataFrame(data2D).to_hdf(hdfFileName, key="idr")
34
+ pd.DataFrame(data1D).to_hdf(hdfFileName, key="rdf")
35
+ pd.DataFrame(data1D).to_hdf(hdfFileName, key="rdfGrid")
36
+ pd.DataFrame(data1D).to_hdf(hdfFileName, key="sdr")
37
+ pd.DataFrame(data1D).to_hdf(hdfFileName, key="slfc")
38
+ pd.DataFrame(data1D).to_hdf(hdfFileName, key="ssf")
39
+ pd.DataFrame(data1D).to_hdf(hdfFileName, key="ssfHF")
40
+ pd.DataFrame(data1D).to_hdf(hdfFileName, key="wvg")
41
+
42
+
43
+ def mockRdfOutput(hdfFileName):
44
+ wvgData = np.arange(0, 5, 0.1)
45
+ ssfData = np.ones(len(wvgData))
46
+ pd.DataFrame(
47
+ {
48
+ "coupling": 1.0,
49
+ "degeneracy": 1.0,
50
+ "error": 0.0,
51
+ "theory": "theory",
52
+ "resolution": 0.0,
53
+ "cutoff": 0,
54
+ "matsubara": 0,
55
+ },
56
+ index=["info"],
57
+ ).to_hdf(hdfFileName, key="info", mode="w")
58
+ pd.DataFrame(ssfData).to_hdf(hdfFileName, key="ssf")
59
+ pd.DataFrame(wvgData).to_hdf(hdfFileName, key="wvg")
60
+
61
+
62
+ def test_set_entries(hdf_instance):
63
+ for key, entry in hdf_instance.entries.items():
64
+ if entry.entryType == "numpy":
65
+ value = np.array([1, 2, 3, 4])
66
+ elif entry.entryType == "numpy2D":
67
+ value = np.array([1, 2, 3, 4]).reshape((2, 2))
68
+ elif entry.entryType == "number":
69
+ value = 42
70
+ elif entry.entryType == "string":
71
+ value = "test_value"
72
+ else:
73
+ assert False
74
+
75
+ # Set value
76
+ hdf_instance.entries[key] = value
77
+
78
+
79
+ def test_read(hdf_instance):
80
+ hdfFileName = "testOutput.h5"
81
+ mockOutput(hdfFileName)
82
+ allHdfEntries = hdf_instance.entries.keys()
83
+ readData = hdf_instance.read(hdfFileName, allHdfEntries)
84
+ try:
85
+ for entry in allHdfEntries:
86
+ if entry in [
87
+ "coupling",
88
+ "degeneracy",
89
+ "error",
90
+ "resolution",
91
+ "cutoff",
92
+ "matsubara",
93
+ ]:
94
+ assert readData[entry] == 0.0
95
+ elif entry in [
96
+ "bf",
97
+ "fxcGrid",
98
+ "rdf",
99
+ "rdfGrid",
100
+ "sdr",
101
+ "slfc",
102
+ "ssf",
103
+ "ssfHF",
104
+ "wvg",
105
+ "alpha",
106
+ ]:
107
+ assert np.array_equal(readData[entry], np.zeros(2))
108
+ elif entry in ["adr", "fxci", "idr"]:
109
+ assert np.array_equal(readData[entry], np.zeros((2, 2)))
110
+ elif entry in ["theory"]:
111
+ assert readData[entry] == "theory"
112
+ else:
113
+ assert False
114
+ with pytest.raises(SystemExit) as excinfo:
115
+ hdf_instance.read(hdfFileName, "dummyEntry")
116
+ assert excinfo.value.code == "Unknown entry"
117
+ finally:
118
+ os.remove(hdfFileName)
119
+
120
+
121
+ def test_inspect(hdf_instance):
122
+ hdfFileName = "testOutput.h5"
123
+ mockOutput(hdfFileName)
124
+ allHdfEntries = hdf_instance.entries.keys()
125
+ inspectData = hdf_instance.inspect(hdfFileName)
126
+ try:
127
+ for entry in allHdfEntries:
128
+ assert entry in list(inspectData.keys())
129
+ assert inspectData[entry] == hdf_instance.entries[entry].description
130
+ finally:
131
+ os.remove(hdfFileName)
132
+
133
+
134
+ def test_plot(hdf_instance, mocker):
135
+ hdfFileName = "testOutput.h5"
136
+ mockPlotShow = mocker.patch("matplotlib.pyplot.show")
137
+ mockOutput(hdfFileName)
138
+ toPlot = ["rdf", "adr", "idr", "fxci", "bf", "sdr", "slfc", "ssf", "ssfHF", "alpha"]
139
+ try:
140
+ hdf_instance.plot(hdfFileName, toPlot)
141
+ assert mockPlotShow.call_count == len(toPlot)
142
+ with pytest.raises(SystemExit) as excinfo:
143
+ hdf_instance.plot(hdfFileName, "dummyQuantityToPlot")
144
+ assert excinfo.value.code == "Unknown quantity to plot"
145
+ finally:
146
+ os.remove(hdfFileName)
147
+
148
+
149
+ def test_computeRdf(hdf_instance):
150
+ hdfFileName = "testOutput.h5"
151
+ mockRdfOutput(hdfFileName)
152
+ try:
153
+ hdf_instance.computeRdf(hdfFileName, np.arange(0, 10, 0.1), False)
154
+ inspectData = hdf_instance.inspect(hdfFileName)
155
+ assert "rdf" not in list(inspectData.keys())
156
+ assert "rdfGrid" not in list(inspectData.keys())
157
+ hdf_instance.computeRdf(hdfFileName, np.arange(0, 10, 0.1), True)
158
+ inspectData = hdf_instance.inspect(hdfFileName)
159
+ assert "rdf" in list(inspectData.keys())
160
+ assert "rdfGrid" in list(inspectData.keys())
161
+ finally:
162
+ os.remove(hdfFileName)
163
+
164
+
165
+ def test_computeInternalEnergy(hdf_instance):
166
+ hdfFileName = "testOutput.h5"
167
+ mockRdfOutput(hdfFileName)
168
+ try:
169
+ uint = hdf_instance.computeInternalEnergy(hdfFileName)
170
+ assert uint == 0.0
171
+ finally:
172
+ os.remove(hdfFileName)
@@ -0,0 +1,32 @@
1
+ import os
2
+ import pytest
3
+ import numpy as np
4
+ from qupled.util import Plot
5
+
6
+
7
+ @pytest.fixture
8
+ def plot_instance():
9
+ return Plot
10
+
11
+
12
+ def test_plot1D(plot_instance, mocker):
13
+ mockPlotShow = mocker.patch("matplotlib.pyplot.show")
14
+ x = np.arange(0, 10, 0.1)
15
+ y = np.zeros(len(x))
16
+ plot_instance.plot1D(x, y, "x", "y")
17
+ assert mockPlotShow.call_count == 1
18
+
19
+
20
+ def test_plot1DParametric(plot_instance, mocker):
21
+ mockPlotShow = mocker.patch("matplotlib.pyplot.show")
22
+ x = np.arange(0, 10, 0.1)
23
+ y = np.zeros((len(x), 2))
24
+ parameter = np.array([0, 1])
25
+ plot_instance.plot1DParametric(x, y, "x", "y", parameter)
26
+ assert mockPlotShow.call_count == 1
27
+ try:
28
+ parameter = np.array([1, 2])
29
+ plot_instance.plot1DParametric(x, y, "x", "y", parameter)
30
+ assert False
31
+ except:
32
+ assert mockPlotShow.call_count == 1
@@ -0,0 +1,78 @@
1
+ import os
2
+ import pytest
3
+ import numpy as np
4
+ from qupled.qupled import Qstls as QstlsNative
5
+ from qupled.util import Hdf
6
+ from qupled.quantum import Qstls
7
+
8
+
9
+ @pytest.fixture
10
+ def qstls():
11
+ return Qstls()
12
+
13
+
14
+ @pytest.fixture
15
+ def qstls_input():
16
+ return Qstls.Input(1.0, 1.0)
17
+
18
+
19
+ def test_default(qstls):
20
+ assert qstls.hdfFileName is None
21
+
22
+
23
+ def test_compute(qstls, qstls_input, mocker):
24
+ mockMPITime = mocker.patch("qupled.util.MPI.timer", return_value=0)
25
+ mockMPIBarrier = mocker.patch("qupled.util.MPI.barrier")
26
+ mockCompute = mocker.patch("qupled.qupled.Qstls.compute")
27
+ mockCheckStatusAndClean = mocker.patch("qupled.quantum.Qstls._checkStatusAndClean")
28
+ mockSave = mocker.patch("qupled.quantum.Qstls._save")
29
+ qstls.compute(qstls_input)
30
+ assert mockMPITime.call_count == 2
31
+ assert mockMPIBarrier.call_count == 1
32
+ assert mockCompute.call_count == 1
33
+ assert mockCheckStatusAndClean.call_count == 1
34
+ assert mockSave.call_count == 1
35
+
36
+
37
+ def test_save(qstls, qstls_input, mocker):
38
+ mockMPIIsRoot = mocker.patch("qupled.util.MPI.isRoot")
39
+ try:
40
+ scheme = QstlsNative(qstls_input.toNative())
41
+ qstls.hdfFileName = qstls._getHdfFile(scheme.inputs)
42
+ qstls._save(scheme)
43
+ assert mockMPIIsRoot.call_count == 3
44
+ assert os.path.isfile(qstls.hdfFileName)
45
+ inspectData = Hdf().inspect(qstls.hdfFileName)
46
+ expectedEntries = [
47
+ "coupling",
48
+ "degeneracy",
49
+ "theory",
50
+ "error",
51
+ "resolution",
52
+ "cutoff",
53
+ "matsubara",
54
+ "adr",
55
+ "idr",
56
+ "sdr",
57
+ "slfc",
58
+ "ssf",
59
+ "ssfHF",
60
+ "wvg",
61
+ ]
62
+ for entry in expectedEntries:
63
+ assert entry in inspectData
64
+ finally:
65
+ os.remove(qstls.hdfFileName)
66
+
67
+
68
+ def test_getInitialGuess(mocker):
69
+ arr = np.ones(10)
70
+ mockHdfRead = mocker.patch(
71
+ "qupled.util.Hdf.read",
72
+ return_value={"wvg": arr, "ssf": arr, "adr": arr, "matsubara": 10},
73
+ )
74
+ guess = Qstls.getInitialGuess("dummyFileName")
75
+ assert np.array_equal(guess.wvg, arr)
76
+ assert np.array_equal(guess.ssf, arr)
77
+ assert np.array_equal(guess.adr, arr)
78
+ assert np.array_equal(guess.matsubara, 10)
@@ -0,0 +1,124 @@
1
+ import os
2
+ import pytest
3
+ import numpy as np
4
+ from qupled.qupled import Qstls as QstlsNative
5
+ from qupled.util import Hdf
6
+ from qupled.quantum import QstlsIet
7
+
8
+
9
+ @pytest.fixture
10
+ def qstls_iet():
11
+ return QstlsIet()
12
+
13
+
14
+ @pytest.fixture
15
+ def qstls_iet_input():
16
+ return QstlsIet.Input(1.0, 1.0, "QSTLS-HNC")
17
+
18
+
19
+ def test_default(qstls_iet):
20
+ assert qstls_iet.hdfFileName is None
21
+
22
+
23
+ def test_compute(qstls_iet, qstls_iet_input, mocker):
24
+ mockMPITime = mocker.patch("qupled.util.MPI.timer", return_value=0)
25
+ mockMPIBarrier = mocker.patch("qupled.util.MPI.barrier")
26
+ mockUnpack = mocker.patch("qupled.quantum.QstlsIet._unpackFixedAdrFiles")
27
+ mockCompute = mocker.patch("qupled.quantum.QstlsIet._compute")
28
+ mockSave = mocker.patch("qupled.quantum.QstlsIet._save")
29
+ mockZip = mocker.patch("qupled.quantum.QstlsIet._zipFixedAdrFiles")
30
+ mockClean = mocker.patch("qupled.quantum.QstlsIet._cleanFixedAdrFiles")
31
+ qstls_iet.compute(qstls_iet_input)
32
+ assert mockMPITime.call_count == 2
33
+ assert mockMPIBarrier.call_count == 1
34
+ assert mockUnpack.call_count == 1
35
+ assert mockCompute.call_count == 1
36
+ assert mockSave.call_count == 1
37
+ assert mockZip.call_count == 1
38
+ assert mockClean.call_count == 1
39
+
40
+
41
+ def test_unpackFixedAdrFiles_no_files(qstls_iet, qstls_iet_input, mocker):
42
+ mockMPIIsRoot = mocker.patch("qupled.util.MPI.isRoot")
43
+ mockZip = mocker.patch("qupled.quantum.zf.ZipFile.__init__", return_value=None)
44
+ mockExtractAll = mocker.patch("qupled.quantum.zf.ZipFile.extractall")
45
+ qstls_iet._unpackFixedAdrFiles(qstls_iet_input)
46
+ assert mockMPIIsRoot.call_count == 1
47
+ assert mockZip.call_count == 0
48
+ assert mockExtractAll.call_count == 0
49
+
50
+
51
+ def test_unpackFixedAdrFiles_with_files(qstls_iet, qstls_iet_input, mocker):
52
+ mockMPIIsRoot = mocker.patch("qupled.util.MPI.isRoot")
53
+ mockZip = mocker.patch("qupled.quantum.zf.ZipFile.__init__", return_value=None)
54
+ mockExtractAll = mocker.patch("qupled.quantum.zf.ZipFile.extractall")
55
+ qstls_iet_input.fixediet = "testFile.zip"
56
+ qstls_iet._unpackFixedAdrFiles(qstls_iet_input)
57
+ assert mockMPIIsRoot.call_count == 1
58
+ assert mockZip.call_count == 1
59
+ assert mockExtractAll.call_count == 1
60
+
61
+
62
+ def test_zipFixedAdrFiles_no_file(qstls_iet, qstls_iet_input, mocker, capsys):
63
+ mockMPIIsRoot = mocker.patch("qupled.util.MPI.isRoot")
64
+ mockZip = mocker.patch("qupled.quantum.zf.ZipFile.__init__", return_value=None)
65
+ mockGlob = mocker.patch(
66
+ "qupled.quantum.glob", return_value={"binFile1", "binFile2"}
67
+ )
68
+ mockRemove = mocker.patch("os.remove")
69
+ mockWrite = mocker.patch("qupled.quantum.zf.ZipFile.write")
70
+ qstls_iet._zipFixedAdrFiles(qstls_iet_input)
71
+ assert mockMPIIsRoot.call_count == 1
72
+ assert mockZip.call_count == 1
73
+ assert mockGlob.call_count == 1
74
+ assert mockRemove.call_count == 2
75
+ assert mockWrite.call_count == 2
76
+
77
+
78
+ def test_cleanFixedAdrFiles_no_files(qstls_iet, qstls_iet_input, mocker, capsys):
79
+ mockMPIIsRoot = mocker.patch("qupled.util.MPI.isRoot")
80
+ mockRemove = mocker.patch("qupled.quantum.rmtree")
81
+ qstls_iet._cleanFixedAdrFiles(qstls_iet_input)
82
+ assert mockMPIIsRoot.call_count == 1
83
+ assert mockRemove.call_count == 0
84
+
85
+
86
+ def test_cleanFixedAdrFiles_with_files(qstls_iet, qstls_iet_input, mocker, capsys):
87
+ mockMPIIsRoot = mocker.patch("qupled.util.MPI.isRoot")
88
+ mockIsDir = mocker.patch("os.path.isdir", return_value=True)
89
+ mockRemove = mocker.patch("qupled.quantum.rmtree")
90
+ qstls_iet._cleanFixedAdrFiles(qstls_iet_input)
91
+ assert mockMPIIsRoot.call_count == 1
92
+ assert mockRemove.call_count == 1
93
+
94
+
95
+ def test_save(qstls_iet, qstls_iet_input, mocker):
96
+ mockMPIIsRoot = mocker.patch("qupled.util.MPI.isRoot")
97
+ try:
98
+ scheme = QstlsNative(qstls_iet_input.toNative())
99
+ qstls_iet.hdfFileName = qstls_iet._getHdfFile(scheme.inputs)
100
+ qstls_iet._save(scheme)
101
+ assert mockMPIIsRoot.call_count == 4
102
+ assert os.path.isfile(qstls_iet.hdfFileName)
103
+ inspectData = Hdf().inspect(qstls_iet.hdfFileName)
104
+ expectedEntries = [
105
+ "coupling",
106
+ "degeneracy",
107
+ "theory",
108
+ "error",
109
+ "resolution",
110
+ "cutoff",
111
+ "matsubara",
112
+ "adr",
113
+ "idr",
114
+ "sdr",
115
+ "slfc",
116
+ "bf",
117
+ "ssf",
118
+ "ssfHF",
119
+ "wvg",
120
+ ]
121
+ for entry in expectedEntries:
122
+ assert entry in inspectData
123
+ finally:
124
+ os.remove(qstls_iet.hdfFileName)