Skip to content

Commit f90989a

Browse files
committed
fixing docs
1 parent ac48a94 commit f90989a

File tree

13 files changed

+167
-162
lines changed

13 files changed

+167
-162
lines changed

moha/api.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ class HamiltonianAPI(ABC):
2424
r"""Hamiltonian abstract base class."""
2525

2626
def generate_connectivity_matrix(self):
27-
r"""
28-
29-
Generate connectivity matrix.
27+
r"""Generate connectivity matrix.
3028
3129
Returns
3230
-------
3331
tuple
3432
(dictionary, np.ndarray)
33+
3534
"""
3635
# check if self.connectivity is a matrix
3736
# if so, put assign it to self.connectivity_matrix
@@ -76,8 +75,7 @@ def generate_zero_body_integral(self):
7675

7776
@abstractmethod
7877
def generate_one_body_integral(self, dense: bool, basis: str):
79-
r"""
80-
Generate one body integral in spatial or spin orbital basis.
78+
r"""Generate one body integral in spatial or spin orbital basis.
8179
8280
Parameters
8381
----------
@@ -89,13 +87,13 @@ def generate_one_body_integral(self, dense: bool, basis: str):
8987
Returns
9088
-------
9189
scipy.sparse.csr_matrix or np.ndarray
90+
9291
"""
9392
pass
9493

9594
@abstractmethod
9695
def generate_two_body_integral(self, sym: int, basis: str, dense: bool):
97-
r"""
98-
Generate two body integral in spatial or spinorbital basis.
96+
r"""Generate two body integral in spatial or spinorbital basis.
9997
10098
Parameters
10199
----------
@@ -109,12 +107,12 @@ def generate_two_body_integral(self, sym: int, basis: str, dense: bool):
109107
Returns
110108
-------
111109
scipy.sparse.csr_matrix or np.ndarray
110+
112111
"""
113112
pass
114113

115114
def to_sparse(self, Md):
116-
r"""
117-
Convert dense array of integrals to sparse array in scipy csr format.
115+
r"""Convert dense array of integrals to sparse array in scipy csr.
118116
119117
Parameters
120118
----------
@@ -124,6 +122,7 @@ def to_sparse(self, Md):
124122
Returns
125123
-------
126124
scipy.sparse.csr_matrix
125+
127126
"""
128127
# Finding indices for non-zero elements and shape of Md.
129128
indices = np.array(np.where(Md != 0)).astype(int).T
@@ -156,8 +155,7 @@ def to_sparse(self, Md):
156155
return
157156

158157
def to_dense(self, Ms, dim=2):
159-
r"""
160-
Convert to dense matrix.
158+
r"""Convert to dense matrix.
161159
162160
Convert sparse array of integrals
163161
in scipy csr format to dense numpy array.
@@ -171,6 +169,7 @@ def to_dense(self, Ms, dim=2):
171169
Returns
172170
-------
173171
np.ndarray
172+
174173
"""
175174
# return dense 2D array (default).
176175
if dim == 2:
@@ -190,8 +189,7 @@ def to_dense(self, Ms, dim=2):
190189
raise ValueError("Target output dimension must be either 2 or 4.")
191190

192191
def to_spatial(self, sym: int, dense: bool, nbody: int):
193-
r"""
194-
Convert one-/two- integral matrix from spin-orbital to spatial basis.
192+
r"""Convert one/two integral matrix from spin-orbital to spatial basis.
195193
196194
Parameters
197195
----------
@@ -229,6 +227,7 @@ def to_spatial(self, sym: int, dense: bool, nbody: int):
229227
Assuming that :math:`v_{pqrs}^{abab} = v_{pqrs}^{baba}` and
230228
:math:`v_{pqrs}^{aaaa} = v_{pqrs}^{bbbb}`
231229
:math:`v_{pqrs} = 0.5*(v_{pqrs}^{aaaa} + v_{pqrs}^{abab})`
230+
232231
"""
233232
# Assumption: spatial components of alpha and beta
234233
# spin-orbitals are equivalent
@@ -275,8 +274,7 @@ def to_spatial(self, sym: int, dense: bool, nbody: int):
275274
return spatial_int
276275

277276
def to_spinorbital(self, integral: np.ndarray, sym=1, dense=False):
278-
r"""
279-
Convert one-/two- integral matrix from spatial to spin-orbital basis.
277+
r"""Convert one/two integral matrix from spatial to spin-orbital basis.
280278
281279
Parameters
282280
----------
@@ -290,12 +288,12 @@ def to_spinorbital(self, integral: np.ndarray, sym=1, dense=False):
290288
Returns
291289
-------
292290
None
291+
293292
"""
294293
pass
295294

296295
def save_fcidump(self, f: Union[TextIO, str], nelec=0, spinpol=0):
297-
r"""
298-
Save all parts of hamiltonian in fcidump format.
296+
r"""Save all parts of hamiltonian in fcidump format.
299297
300298
Parameters
301299
----------
@@ -313,6 +311,7 @@ def save_fcidump(self, f: Union[TextIO, str], nelec=0, spinpol=0):
313311
Returns
314312
-------
315313
None
314+
316315
"""
317316
# Open file if it is a string
318317
if isinstance(f, str):
@@ -358,8 +357,7 @@ def save_fcidump(self, f: Union[TextIO, str], nelec=0, spinpol=0):
358357
print(f"{core_energy:23.16e} {0:4d} {0:4d} {0:4d} {0:4d}", file=f)
359358

360359
def save_triqs(self, fname: str, integral):
361-
r"""
362-
Save matrix in triqc format.
360+
r"""Save matrix in triqc format.
363361
364362
Parameters
365363
----------
@@ -371,6 +369,7 @@ def save_triqs(self, fname: str, integral):
371369
Returns
372370
-------
373371
None
372+
374373
"""
375374
pass
376375

@@ -392,6 +391,7 @@ def savez(self, f: Union[TextIO, str]):
392391
```
393392
open("file.npz", "wb") as f:
394393
```
394+
395395
"""
396396
if self.zero_energy is not None:
397397
e0 = self.zero_energy
@@ -412,8 +412,7 @@ def savez(self, f: Union[TextIO, str]):
412412

413413

414414
def expand_sym(sym, integral, nbody):
415-
r"""
416-
Restore permutational symmetry of one- and two-body terms.
415+
r"""Restore permutational symmetry of one- and two-body terms.
417416
418417
Parameters
419418
----------
@@ -459,6 +458,7 @@ def expand_sym(sym, integral, nbody):
459458
permutations considered can be
460459
found in [this site]
461460
(http://vergil.chemistry.gatech.edu/notes/permsymm/permsymm.html).
461+
462462
"""
463463
if sym not in [1, 2, 4, 8]:
464464
raise ValueError("Wrong input symmetry")

moha/gpt/gpt.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010

1111

1212
def map_to_toml(funcs):
13-
"""
14-
Functin that maps the dictionary to the toml-like dictionary.
13+
"""Functin that maps the dictionary to the toml-like dictionary.
1514
1615
Parmaeters:
1716
-----------
1817
funcs: dict
1918
The dictionary that contains the function arguments
2019
21-
Returns:
22-
--------
20+
Returns
21+
-------
2322
toml_dict: dict
2423
The dictionary that contains the toml-like arguments
24+
2525
"""
2626
toml_dict = {}
2727
toml_dict["control"] = {}
@@ -64,15 +64,15 @@ def map_to_toml(funcs):
6464

6565

6666
def load_config():
67-
"""
68-
Load OpenAI API key and model type from config.txt file.
67+
"""Load OpenAI API key and model type from config.txt file.
6968
70-
Returns:
71-
--------
69+
Returns
70+
-------
7271
OPENAI_API_KEY : str
7372
OpenAI API key
7473
GPT_MODEL : str
7574
GPT model type
75+
7676
"""
7777
config_path = Path(__file__).parent / "config.toml"
7878
config = toml.load(config_path)
@@ -87,11 +87,10 @@ def load_config():
8787
def chat_completion_request(messages, model, client,
8888
tools=None,
8989
tool_choice=None):
90-
"""
91-
Request ChatCompletion from OpenAI API.
90+
"""Request ChatCompletion from OpenAI API.
9291
93-
Parameters:
94-
-----------
92+
Parameters
93+
----------
9594
messages : list
9695
List of messages
9796
model : str
@@ -103,10 +102,11 @@ def chat_completion_request(messages, model, client,
103102
tool_choice : dict
104103
Tool choice dictionary
105104
106-
Returns:
107-
--------
105+
Returns
106+
-------
108107
response : dict
109108
ChatCompletion response
109+
110110
"""
111111
try:
112112
response = client.chat.completions.create(
@@ -123,31 +123,31 @@ def chat_completion_request(messages, model, client,
123123

124124

125125
def read_promt():
126-
"""
127-
Read prompt from user.
126+
"""Read prompt from user.
128127
129-
Returns:
130-
--------
128+
Returns
129+
-------
131130
prompt : str
132131
User input prompt
132+
133133
"""
134134
prompt = input("Describe Hamiltonian that needs to be generated: ")
135135
return prompt
136136

137137

138138
def generate_ham(prompt):
139-
"""
140-
Generate Hamiltonian from prompt.
139+
"""Generate Hamiltonian from prompt.
141140
142-
Parameters:
143-
-----------
141+
Parameters
142+
----------
144143
prompt : str
145144
User input prompt
146145
147-
Returns:
148-
--------
146+
Returns
147+
-------
149148
ham : dict
150149
Model Hamiltonian
150+
151151
"""
152152
# get api key and model type
153153
OPENAI_API_KEY, GPT_MODEL = load_config()

moha/gui/gui_utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313

1414
def destroy_widgets(widgets):
15-
r"""
16-
Destroy list of widgets.
15+
r"""Destroy list of widgets.
1716
1817
Parameters
1918
----------
2019
widgets: list
2120
list of widgets to be destroyed
21+
2222
"""
2323
# Destroy old form widgets if they exist
2424
for widget in widgets:
@@ -27,31 +27,31 @@ def destroy_widgets(widgets):
2727

2828

2929
def enable_dropdown_on_click(dropdown, prompt_text):
30-
r"""
31-
Enable dropdown and remove promt text on click.
30+
r"""Enable dropdown and remove promt text on click.
3231
3332
Parameters
3433
----------
3534
dropdown: tk.Dropdown
3635
dropdown object to be enabled
3736
prompt_text: str
3837
initial prompt in the dropdown
38+
3939
"""
4040
if dropdown.get() == prompt_text:
4141
dropdown.state(["!disabled"])
4242
dropdown.set("")
4343

4444

4545
def set_prompt(dropdown, prompt_text):
46-
r"""
47-
Initialize dropdown text to default prompt.
46+
r"""Initialize dropdown text to default prompt.
4847
4948
Parameters
5049
----------
5150
dropdown: tk.Dropdown
5251
dropdown object to be enabled
5352
prompt_text: str
5453
initial prompt in the dropdown
54+
5555
"""
5656
# Initialize dropdown text to default prompt
5757
dropdown.state(["disabled"])
@@ -65,8 +65,7 @@ def set_prompt(dropdown, prompt_text):
6565

6666

6767
def make_title(frame, title, pady=(0, 0), side=tk.TOP):
68-
r"""
69-
Make and display title in frame.
68+
r"""Make and display title in frame.
7069
7170
Parameters
7271
----------
@@ -78,6 +77,7 @@ def make_title(frame, title, pady=(0, 0), side=tk.TOP):
7877
vertical padding of the title
7978
side: one of tk.TOP, tk.BOTTOM, tk.LEFT, tk.RIGHT
8079
the side which the title will be packed
80+
8181
"""
8282
title_font = ("Arial", 12, "bold")
8383
title_frame = tk.Frame(frame)

0 commit comments

Comments
 (0)