Reorganize math module into meaningful submodules#1179
Conversation
|
Hi there, this is jenkins continuous integration... |
1 similar comment
|
Hi there, this is jenkins continuous integration... |
Split the monolithic helpers.py (32 functions) into well-organized submodules: - vector_operations.py: dot product, cross product, norms, normalize, invert - coordinate_transformations.py: geographical/cartesian, zonal/meridional - vertical_operations.py: vertical level averaging and differences - gradient.py: finite difference gradient operators - distance.py: arc length, torus distance/difference - math_utils.py: typed sqrt utility (renamed from xp_utils.py) Updated all importing files to use the new specific modules. Kept helpers.py and xp_utils.py as backward-compatibility re-export layers. Agent-Logs-Url: https://github.com/C2SM/icon4py/sessions/3c71fb19-6b8b-4040-b9bb-597e501cac32 Co-authored-by: jcanton <5622559+jcanton@users.noreply.github.com>
Agent-Logs-Url: https://github.com/C2SM/icon4py/sessions/3c71fb19-6b8b-4040-b9bb-597e501cac32 Co-authored-by: jcanton <5622559+jcanton@users.noreply.github.com>
|
@copilot remove the backwards compatibility: always import the new structure and change any consumer that needs changing. if useful for long names come up with aliases (e.g. coord_trans) only change the imports for maths, leave the rest unchanged |
…orts Remove backward-compat re-exports from helpers.py and xp_utils.py. Change all math imports to module-level pattern with aliases: - coordinate_transformations → coord_trans - vector_operations → vector_ops - vertical_operations → vertical_ops For GT4Py field operators/programs that require direct function references (DSL limitation: "Functions can only be called directly"), module-level bindings are used to maintain the module import pattern while satisfying the GT4Py constraint. Agent-Logs-Url: https://github.com/C2SM/icon4py/sessions/3c99f8d2-657f-4b5f-96a2-dd39d78293cd Co-authored-by: jcanton <5622559+jcanton@users.noreply.github.com>
Done in 65a5451. Removed all backward-compat re-exports from One caveat: GT4Py's DSL parser doesn't support Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot please revert the edits in modules that only use imports for gt4py programs/field operators: the direct imports were cleaner in those files. |
Files that only use math imports in GT4Py field operators/programs are reverted to the cleaner direct import style: from icon4py.model.common.math.module import func Files with only regular Python usage keep the module-level pattern: from icon4py.model.common.math import module Agent-Logs-Url: https://github.com/C2SM/icon4py/sessions/ebedf149-78f1-40f0-9555-02850b2e7441 Co-authored-by: jcanton <5622559+jcanton@users.noreply.github.com>
Done in 912fad7. Reverted all GT4Py-only files to direct imports ( |
helpers.pywas a 662-line catch-all with 32 functions spanning unrelated concerns (vector ops, coordinate transforms, vertical averaging, gradients, distances).xp_utils.pyhad an opaque name for a single function.New module structure
vector_operations.py— dot/cross product, norms, normalization, inversion (10 functions)coordinate_transformations.py— geographical ↔ cartesian, zonal/meridional conversions (10 functions)vertical_operations.py— vertical level averaging and differences (5 functions)gradient.py— finite difference gradient operators (2 functions)distance.py— arc length on spheres, torus geometry (3 functions)math_utils.py— typed sqrt wrapper, renamed fromxp_utils.py(1 function)Import conventions
Two import patterns are used depending on context:
Regular Python files use module-level imports with aliases:
Standard aliases:
coord_trans,vector_ops,vertical_ops.GT4Py files (containing
@gtx.field_operator/@gtx.program) use direct imports, since GT4Py's DSL parser does not supportmodule.func()syntax:No backward-compat re-exports —
helpers.pyandxp_utils.pyare emptied. All consumers are updated.Other
__init__.pynow documents the submodule layoutmeridonal→meridional)operators.py,derivative.py,projection.py,smagorinsky.py,stencils/✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.