TMgen
TMgen copied to clipboard
Build requirements and Cython type correction
This pull request includes three distinct fixes/enhancements:
- The
setup.pyscript requires importingnumpyandcythonearly in the script's execution to configure the Cython extensions (numpy.get_include(),cythonize()). However, these packages were not automatically present within the isolated build environment used by pip and thesetuptools.build_metabackend for collecting build requirements, even if they were installed in the user's main environment. This fix addsnumpyandcythonto the[build-system].requireslist inpyproject.toml. This explicitly declares them as necessary dependencies for performing the build itself, ensuring they are installed within the isolated build environment beforesetup.pyis evaluated for configuration and build requirements. - The
_peak_mean_cyclefunction insrc/tmgen/models.pyxusesnumpy.linspace(..., n, ...)where thenargument is expected bynumpy.linspaceto be an integer. However, the Cython function signature declarednas adouble(cdef numpy.ndarray _peak_mean_cycle(double freq, double n, ...)). Ifnwere passed as a non-integerdouble, this would lead to aTypeErrorat runtime when callingnumpy.linspace. The type of thenparameter in thecdeffunction signature for_peak_mean_cyclehas been changed fromdoubletoint. - The lognormal_tm traffic matrix generation function was implemented in src/tmgen/models.pyx but was not properly exposed as part of the public API of the tmgen.models module. This meant it couldn't be reliably imported and used (e.g., from tmgen.models import lognormal_tm).