Skip to content

Commit 08dc403

Browse files
committed
Enhance documentation and type hints across main modules
1 parent afc5475 commit 08dc403

6 files changed

Lines changed: 709 additions & 84 deletions

File tree

src/hyperctui/__init__.py

Lines changed: 114 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1+
"""
2+
HyperCTui initialization module.
3+
4+
This module provides constants, helper functions, and configuration settings for the
5+
HyperCT UI application. It includes path definitions, UI styling properties,
6+
and class definitions to organize application structure and data.
7+
"""
8+
19
import os
10+
from typing import Any, Dict, Union
211

312
from qtpy.uic import loadUi
413

@@ -35,7 +44,7 @@
3544
SOURCE_DETECTOR_DISTANCE = 19.855 # m, at SNAP
3645
DETECTOR_OFFSET = 0 # micros
3746

38-
DEFAULT_EVALUATION_REGIONS = {
47+
DEFAULT_EVALUATION_REGIONS: Dict[int, Dict[str, Union[str, int]]] = {
3948
0: {
4049
"name": "Region 1",
4150
"from": 20,
@@ -56,21 +65,73 @@
5665

5766
# main window dimensions
5867
class UiSizeSmall:
68+
"""
69+
Small UI window size configuration.
70+
71+
Attributes
72+
----------
73+
width : int
74+
Width of the UI window in pixels.
75+
height : int
76+
Height of the UI window in pixels.
77+
"""
78+
5979
width = 800
6080
height = 300
6181

6282

6383
class UiSizeLarge:
84+
"""
85+
Large UI window size configuration.
86+
87+
Attributes
88+
----------
89+
width : int
90+
Width of the UI window in pixels.
91+
height : int
92+
Height of the UI window in pixels.
93+
"""
94+
6495
width = 800
6596
height = 800
6697

6798

6899
class DataType:
100+
"""
101+
Constants defining data types used in the application.
102+
103+
Attributes
104+
----------
105+
projection : str
106+
String identifier for projection data.
107+
ob : str
108+
String identifier for open beam data.
109+
"""
110+
69111
projection = "projections"
70112
ob = "ob"
71113

72114

73115
class TabNames:
116+
"""
117+
Names for the application tabs.
118+
119+
Attributes
120+
----------
121+
tab0 : str
122+
Open beam setup tab label.
123+
tab1 : str
124+
Initial projections tab label.
125+
tab2 : str
126+
Crop tab label.
127+
tab3 : str
128+
Rotation center tab label.
129+
tab4 : str
130+
Autonomous reconstruction tab label.
131+
tab5 : str
132+
Settings tab label.
133+
"""
134+
74135
tab0 = " - Setup the open beams"
75136
tab1 = " - Initialize first projections (0\u00b0 and 180\u00b0)"
76137
tab2 = " - Crop"
@@ -80,11 +141,47 @@ class TabNames:
80141

81142

82143
class ObTabNames:
144+
"""
145+
Constants for the open beam tab indices.
146+
147+
Attributes
148+
----------
149+
new_obs : int
150+
Index for the new open beams tab.
151+
selected_obs : int
152+
Index for the selected open beams tab.
153+
"""
154+
83155
new_obs = 0
84156
selected_obs = 1
85157

86158

87159
class EvaluationRegionKeys:
160+
"""
161+
Keys used in evaluation region dictionaries.
162+
163+
Attributes
164+
----------
165+
state : str
166+
Key for checkbox state.
167+
from_value : str
168+
Key for start value.
169+
to_value : str
170+
Key for end value.
171+
id : str
172+
Key for horizontal line ID.
173+
name : str
174+
Key for region name.
175+
label_id : str
176+
Key for label ID.
177+
from_index : str
178+
Key for start file index.
179+
to_index : str
180+
Key for end file index.
181+
str_from_to_value : str
182+
Key for string representation of range.
183+
"""
184+
88185
state = "state of the checkbox"
89186
from_value = "from value"
90187
to_value = "to value"
@@ -96,5 +193,20 @@ class EvaluationRegionKeys:
96193
str_from_to_value = "string form of from -> to range"
97194

98195

99-
def load_ui(ui_filename, baseinstance):
196+
def load_ui(ui_filename: str, baseinstance: Any) -> Any:
197+
"""
198+
Load a Qt UI file and apply it to the specified base instance.
199+
200+
Parameters
201+
----------
202+
ui_filename : str
203+
Path to the UI file to load.
204+
baseinstance : Any
205+
Instance to which the UI should be applied.
206+
207+
Returns
208+
-------
209+
Any
210+
The baseinstance with the UI applied.
211+
"""
100212
return loadUi(ui_filename, baseinstance=baseinstance)

src/hyperctui/__main__.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
#!/usr/bin/env python3
2+
"""
3+
HyperCTui entry point module.
4+
5+
This module serves as the main entry point for the HyperCTui application.
6+
When the package is executed directly (using `python -m hyperctui`), this
7+
module initializes the application and launches the GUI interface.
8+
9+
Examples
10+
--------
11+
To run the application from the command line:
12+
$ python -m hyperctui [arguments]
13+
14+
Notes
15+
-----
16+
The module uses multiprocessing freeze support for compatibility with
17+
packaged executables on Windows platforms.
18+
"""
219

320
import multiprocessing
421
import sys
@@ -9,4 +26,4 @@
926

1027
# Run the GUI
1128
multiprocessing.freeze_support()
12-
sys.exit(main(sys.argv))
29+
sys.exit(main(sys.argv)) # type: List[str]

src/hyperctui/commands_launcher.py

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,71 @@
1+
#!/usr/bin/env python
2+
"""
3+
Module for launching various commands in the HyperCTui application.
4+
5+
This module provides functionality to launch different acquisition and
6+
reconstruction operations through the CommandLauncher class.
7+
"""
8+
19
from hyperctui.utilities.parent import Parent
210

311

412
class CommandLauncher(Parent):
5-
def launch_ob_first_projections_acquisition(self):
13+
"""
14+
Class for launching various command operations in the HyperCTui application.
15+
16+
This class provides methods to trigger different acquisition and
17+
reconstruction processes within the application.
18+
19+
Parameters
20+
----------
21+
*args : tuple
22+
Arguments to pass to the parent class.
23+
**kwargs : dict
24+
Keyword arguments to pass to the parent class.
25+
26+
Attributes
27+
----------
28+
Inherits attributes from Parent class.
29+
"""
30+
31+
def launch_ob_first_projections_acquisition(self) -> None:
32+
"""
33+
Launch open beam first projections acquisition process.
34+
35+
This method handles the acquisition of open beam (OB) projections,
36+
including determining the number of OBs requested and setting an
37+
appropriate title for the operation.
38+
39+
Parameters
40+
----------
41+
None
42+
43+
Returns
44+
-------
45+
None
46+
"""
647
# get the number of OBs requested (if any)
748

849
# get the title
950

1051
pass
1152

12-
def launch_preprocessing_autonomous_reconstruction(self):
53+
def launch_preprocessing_autonomous_reconstruction(self) -> None:
54+
"""
55+
Launch preprocessing and autonomous reconstruction process.
56+
57+
This method sets up and executes the preprocessing and autonomous
58+
reconstruction with appropriate parameters including angles,
59+
evaluation regions, and TOF (Time of Flight) regions.
60+
61+
Parameters
62+
----------
63+
None
64+
65+
Returns
66+
-------
67+
None
68+
"""
1369
# list of angles
1470
# evaluation regions
1571
# TOF regions

0 commit comments

Comments
 (0)