Skip to content

Commit e5b06f0

Browse files
committed
Refactor __init__: add utilities, docs & license init
Reorganize src/radarsimpy/__init__.py: group and simplify imports (combine simulator imports), add section headers for clarity, and move/explicitly label automatic license initialization. Export new utility functions in __all__ (get_version, get_info, print_info, check_installation, hello) and provide expanded docstrings, examples, and improved formatted output for those helpers. Minor cleanup of comments and presentation (emoji/text fixes) to make package metadata and module entry point clearer. No behavioral change to core API besides adding utility helpers and documentation improvements.
1 parent 59883da commit e5b06f0

File tree

1 file changed

+120
-32
lines changed

1 file changed

+120
-32
lines changed

src/radarsimpy/__init__.py

Lines changed: 120 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,37 +38,50 @@
3838
3939
"""
4040

41+
# =============================================================================
42+
# Imports
43+
# =============================================================================
44+
4145
# Core radar system components
4246
from .radar import Radar
4347
from .transmitter import Transmitter
4448
from .receiver import Receiver
4549

4650
# Simulation engines
47-
# try:
48-
from .simulator import sim_radar
49-
from .simulator import sim_lidar
50-
from .simulator import sim_rcs
51-
from .license import set_license, is_licensed, get_license_info
51+
from .simulator import sim_radar, sim_lidar, sim_rcs
5252

53+
# License management
54+
from .license import set_license, is_licensed, get_license_info
5355

54-
set_license()
55-
56-
# Signal processing and analysis tools
56+
# Signal processing and analysis modules
5757
from . import processing
5858
from . import tools
5959

6060
# 3D mesh utilities
6161
from . import mesh_kit
6262

63-
# Package metadata
63+
# =============================================================================
64+
# License Initialization
65+
# =============================================================================
66+
67+
# Automatically initialize license from module directory
68+
set_license()
69+
70+
# =============================================================================
71+
# Package Metadata
72+
# =============================================================================
73+
6474
__version__ = "15.0.1"
6575
__author__ = "RadarSimX"
6676
__email__ = "info@radarsimx.com"
6777
__url__ = "https://radarsimx.com"
6878
__license__ = "Proprietary"
6979
__description__ = "A comprehensive radar simulation library for Python"
7080

71-
# Public API - modules and functions available for import
81+
# =============================================================================
82+
# Public API
83+
# =============================================================================
84+
7285
__all__ = [
7386
# Core Components
7487
"Radar",
@@ -82,7 +95,7 @@
8295
"set_license",
8396
"is_licensed",
8497
"get_license_info",
85-
# Processing and Analysis
98+
# Processing and Analysis Modules
8699
"processing",
87100
"tools",
88101
"mesh_kit",
@@ -91,15 +104,33 @@
91104
"__author__",
92105
"__email__",
93106
"__url__",
107+
# Utility Functions
108+
"get_version",
109+
"get_info",
110+
"print_info",
111+
"check_installation",
112+
"hello",
94113
]
95114

115+
# =============================================================================
116+
# Utility Functions
117+
# =============================================================================
118+
96119

97120
def get_version():
98121
"""
99122
Get the current version of RadarSimPy.
100123
101-
Returns:
102-
str: Version string in semantic versioning format
124+
Returns
125+
-------
126+
str
127+
Version string in semantic versioning format (e.g., "15.0.1")
128+
129+
Examples
130+
--------
131+
>>> import radarsimpy as rs
132+
>>> rs.get_version()
133+
'15.0.1'
103134
"""
104135
return __version__
105136

@@ -108,8 +139,30 @@ def get_info():
108139
"""
109140
Get comprehensive information about the RadarSimPy installation.
110141
111-
Returns:
112-
dict: Dictionary containing package information, capabilities, and dependencies
142+
This function collects information about the package version, platform,
143+
available modules, and installed dependencies.
144+
145+
Returns
146+
-------
147+
dict
148+
Dictionary containing:
149+
150+
- **package** (str): Package name
151+
- **version** (str): Current version
152+
- **author** (str): Package author
153+
- **website** (str): Official website URL
154+
- **python_version** (str): Python interpreter version
155+
- **platform** (str): Operating system and platform information
156+
- **modules** (dict): Available RadarSimPy modules and their descriptions
157+
- **simulation_engines** (dict): Available simulation engines and descriptions
158+
- **dependencies** (dict): Installed optional dependencies and their versions
159+
160+
Examples
161+
--------
162+
>>> import radarsimpy as rs
163+
>>> info = rs.get_info()
164+
>>> print(f"RadarSimPy version: {info['version']}")
165+
>>> print(f"NumPy installed: {info['dependencies']['numpy']}")
113166
"""
114167
import sys
115168
import platform
@@ -172,7 +225,21 @@ def get_info():
172225

173226

174227
def print_info():
175-
"""Print formatted information about the RadarSimPy installation."""
228+
"""
229+
Print formatted information about the RadarSimPy installation.
230+
231+
This function displays package version, platform details, core modules,
232+
simulation engines, and dependency status in a readable format.
233+
234+
Examples
235+
--------
236+
>>> import radarsimpy as rs
237+
>>> rs.print_info()
238+
RadarSimPy v15.0.1
239+
Author: RadarSimX
240+
Website: https://radarsimx.com
241+
...
242+
"""
176243
info = get_info()
177244

178245
print(f"\n{info['package']} v{info['version']}")
@@ -181,34 +248,42 @@ def print_info():
181248
print(f"Python: {info['python_version']}")
182249
print(f"Platform: {info['platform']}")
183250

184-
print("\n📡 Capabilities:")
185-
for capability, available in info["capabilities"].items():
186-
status = "✅ Available" if available else "❌ Not Available"
187-
print(f" {capability.replace('_', ' ').title()}: {status}")
188-
189251
print("\n📦 Core Modules:")
190252
for module, description in info["modules"].items():
191253
print(f" {module}: {description}")
192254

193-
if "simulation_engines" in info and isinstance(info["simulation_engines"], dict):
194-
print("\n🎯 Simulation Engines:")
195-
for engine, description in info["simulation_engines"].items():
196-
print(f" {engine}: {description}")
255+
print("\n🎯 Simulation Engines:")
256+
for engine, description in info["simulation_engines"].items():
257+
print(f" {engine}: {description}")
197258

198259
print("\n🔧 Dependencies:")
199260
for dep, version in info["dependencies"].items():
200261
if version == "Not installed":
201262
print(f" {dep}: ❌ {version}")
202263
else:
203264
print(f" {dep}: ✅ v{version}")
265+
print()
204266

205267

206268
def check_installation():
207269
"""
208270
Check if RadarSimPy is properly installed and functional.
209271
210-
Returns:
211-
bool: True if installation appears complete, False otherwise
272+
Verifies that core components are importable and required dependencies
273+
are available. Reports any installation issues found.
274+
275+
Returns
276+
-------
277+
bool
278+
True if installation appears complete and functional, False if issues detected
279+
280+
Examples
281+
--------
282+
>>> import radarsimpy as rs
283+
>>> if rs.check_installation():
284+
... print("Ready to use!")
285+
✅ RadarSimPy installation appears complete
286+
Ready to use!
212287
"""
213288
issues = []
214289

@@ -236,9 +311,20 @@ def check_installation():
236311
return True
237312

238313

239-
# Convenience function for getting started
240314
def hello():
241-
"""Print a welcome message and basic usage information."""
315+
"""
316+
Print a welcome message and basic usage information.
317+
318+
Displays a friendly introduction to RadarSimPy with quick start examples
319+
and helpful resources for getting started.
320+
321+
Examples
322+
--------
323+
>>> import radarsimpy as rs
324+
>>> rs.hello()
325+
🎯 Welcome to RadarSimPy!
326+
...
327+
"""
242328
print(
243329
"""
244330
🎯 Welcome to RadarSimPy!
@@ -259,14 +345,16 @@ def hello():
259345
>>> range_doppler = rs.processing.range_doppler_fft(result['baseband'])
260346
261347
💡 License: Automatically detected from module directory (license_RadarSimPy_*.lic)
262-
Or manually specify: rs.set_license('/path/to/license.lic')
263348
264-
📚 Documentation: https://radarsimx.github.io/radarsimpy/
349+
📚 Documentation: https://radarsimx.github.io/radarsimpy/
265350
💬 Support: info@radarsimx.com
266351
"""
267352
)
268353

269354

270-
# For development and debugging
355+
# =============================================================================
356+
# Module Entry Point (for development and debugging)
357+
# =============================================================================
358+
271359
if __name__ == "__main__":
272360
print_info()

0 commit comments

Comments
 (0)