-
Notifications
You must be signed in to change notification settings - Fork 8
Fold packages #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fold packages #611
Conversation
Consolidate the ccl_factory module into modeling_tools to improve code organization. The CCL factory functionality is closely related to the modeling tools and belongs in the same module. Changes: - Move ccl_factory submodules into modeling_tools as _ccl_* files - Update modeling_tools __init__ to export CCL factory classes - Replace ccl_factory with deprecation wrapper that re-exports - Update all imports across examples, tests, and connectors - Add deprecation warning when ccl_factory is imported - Add tests for deprecated module backward compatibility - Rename test_ccl_factory.py to test_modeling_tools_ccl_factory.py
Correct the module path reference in the two-point integration tutorial from `firecrown.generators.inferred_galaxy_zdist` to `firecrown.generators`, which is the accurate import location for the lens and source redshift bin collections.
The firecrown.parameters module has been moved into firecrown.updatable to better reflect the architectural relationship between parameters and updatable objects. All parameter-related classes (DerivedParameter, DerivedParameterCollection, InternalParameter, ParamsMap, RequiredParameters, SamplerParameter) and functions (handle_unused_params, parameter_get_full_name, register_new_updatable_parameter) are now exported from firecrown.updatable. The old firecrown.parameters module remains as a deprecated compatibility layer that re-exports from firecrown.updatable with deprecation warnings. All imports throughout the codebase have been updated to use firecrown.updatable instead of firecrown.parameters. Tests have been added to verify the deprecated module continues to work correctly with appropriate warnings, and existing parameter tests have been renamed to reflect their new location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR reorganizes Firecrown’s public API by moving ccl_factory into modeling_tools and moving parameter-related classes into updatable, while keeping firecrown.ccl_factory and firecrown.parameters as deprecated re-export shims for backward compatibility.
Changes:
- Move/rehydrate CCL factory types/enums/models under
firecrown.modeling_toolsand update all imports accordingly. - Move/re-export parameter APIs under
firecrown.updatableand update imports across code, tests, examples, and tutorials. - Add deprecation-layer tests for
firecrown.parametersandfirecrown.ccl_factory.
Reviewed changes
Copilot reviewed 93 out of 97 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| tutorial/two_point_scale_cuts.qmd | Update tutorial imports to use firecrown.modeling_tools.CCLFactory. |
| tutorial/two_point_integration.qmd | Update docs to reference constants from firecrown.generators. |
| tutorial/two_point_factory_basics.qmd | Update tutorial imports to firecrown.modeling_tools/firecrown.updatable. |
| tutorial/systematics.qmd | Update tutorial parameter import to firecrown.updatable. |
| tutorial/inferred_zdist.qmd | Update tutorial imports to firecrown.modeling_tools/firecrown.updatable. |
| tests/test_updatable_parameters.py | Consolidate parameter/updatable imports under firecrown.updatable. |
| tests/test_updatable.py | Adjust imports for moved parameter symbols; still imports deprecated module. |
| tests/test_scale_cuts_with_window.py | Update ParamsMap import to firecrown.updatable. |
| tests/test_pt_systematics.py | Update CCLFactory/parameter imports to new modules. |
| tests/test_parameters_deprecated.py | New tests validating firecrown.parameters deprecation shim behavior. |
| tests/test_number_counts_magnification_bias_systematic.py | Update parameter import to firecrown.updatable. |
| tests/test_modeling_tools_ccl_factory.py | Update imports to use firecrown.modeling_tools CCL factory API. |
| tests/test_modeling_tools.py | Update imports to use firecrown.modeling_tools types. |
| tests/test_hm_systematics.py | Update CCLFactory import to firecrown.modeling_tools. |
| tests/test_cmb_factories.py | Update ParamsMap import to firecrown.updatable. |
| tests/test_ccl_factory_deprecated.py | New tests validating firecrown.ccl_factory deprecation shim behavior. |
| tests/test_bug_398.py | Update CCLFactory imports to firecrown.modeling_tools. |
| tests/models/two_point/test_theory.py | Update ParamsMap import to firecrown.updatable. |
| tests/metadata/test_metadata_two_point_sacc.py | Update ParamsMap import to firecrown.updatable. |
| tests/likelihood/test_weak_lensing.py | Update ParamsMap import to firecrown.updatable. |
| tests/likelihood/test_likelihood.py | Update ParamsMap import to firecrown.updatable. |
| tests/likelihood/test_factories.py | Update in-test import to firecrown.modeling_tools.CCLFactory. |
| tests/likelihood/lkdir/lkscript_pure_ccl.py | Update CCL factory imports to firecrown.modeling_tools. |
| tests/likelihood/lkdir/lkscript.py | Update CCLFactory imports to firecrown.modeling_tools. |
| tests/likelihood/lkdir/lkmodule.py | Update derived parameter imports to firecrown.updatable. |
| tests/likelihood/lkdir/lk_sampler_parameter.py | Update CCLFactory imports to firecrown.modeling_tools. |
| tests/likelihood/lkdir/lk_needing_param.py | Update CCLFactory imports to firecrown.modeling_tools. |
| tests/likelihood/lkdir/lk_derived_parameter.py | Update CCLFactory imports to firecrown.modeling_tools. |
| tests/likelihood/gauss_family/test_student_t.py | Update parameter module usage to firecrown.updatable. |
| tests/likelihood/gauss_family/test_const_gaussianPM.py | Update parameter module usage to firecrown.updatable. |
| tests/likelihood/gauss_family/test_const_gaussian.py | Update parameter module usage to firecrown.updatable. |
| tests/likelihood/gauss_family/statistic/test_two_point.py | Update ParamsMap import to firecrown.updatable. |
| tests/likelihood/gauss_family/statistic/test_statistic.py | Update ParamsMap import to firecrown.updatable. |
| tests/likelihood/gauss_family/statistic/source/test_source.py | Update ParamsMap import to firecrown.updatable. |
| tests/likelihood/gauss_family/lkscript_two_point_pure_ccl.py | Update CCL factory imports to firecrown.modeling_tools. |
| tests/likelihood/gauss_family/lkscript_two_point.py | Update CCLFactory imports to firecrown.modeling_tools. |
| tests/likelihood/gauss_family/lkscript_const_gaussian.py | Update CCLFactory imports to firecrown.modeling_tools. |
| tests/integration/models/two_point/test_theory.py | Update ParamsMap import to firecrown.updatable. |
| tests/fctools/test_generate_symbol_map.py | Update symbol scanning tests to target firecrown.updatable. |
| tests/connector/test_mapping.py | Update CCL/ParamsMap imports to new modules. |
| tests/connector/numcosmo/test_numcosmo_mapping.py | Update amplitude parameter import to firecrown.modeling_tools. |
| tests/connector/numcosmo/test_numcosmo_connector.py | Update ParamsMap/CCLCreationMode imports to new modules. |
| tests/connector/cobaya/test_model_likelihood.py | Update ccl_factory alias to import firecrown.modeling_tools. |
| tests/conftest.py | Update ParamsMap import to firecrown.updatable. |
| tests/app/examples/test_des_y1_3x2pt.py | Update ParamsMap import to firecrown.updatable. |
| tests/app/analysis/test_types.py | Update CAMBExtraParams import to firecrown.modeling_tools. |
| firecrown/updatable/_utils.py | Replace deprecated firecrown.parameters import with internal _parameters_map. |
| firecrown/updatable/_types.py | Switch to internal parameter submodules to avoid deprecated layer. |
| firecrown/updatable/_parameters_types.py | Update internal import to renamed _parameters_names. |
| firecrown/updatable/_parameters_required.py | Update internal import to _parameters_types. |
| firecrown/updatable/_parameters_names.py | New module for parameter-name utilities/validation. |
| firecrown/updatable/_parameters_map.py | Update internal import to _parameters_names. |
| firecrown/updatable/_parameters_derived.py | New module housing derived-parameter classes. |
| firecrown/updatable/_collection.py | Switch to internal parameter submodules. |
| firecrown/updatable/_base.py | Switch to internal parameter submodules. |
| firecrown/updatable/init.py | Re-export parameter APIs from firecrown.updatable. |
| firecrown/parameters/init.py | Convert to deprecated shim re-exporting from firecrown.updatable. |
| firecrown/models/two_point/_theory.py | Update ParamsMap import to firecrown.updatable. |
| firecrown/models/cluster/_mass_proxy.py | Switch to direct register_new_updatable_parameter import. |
| firecrown/models/cluster/_kernel.py | Switch to direct register_new_updatable_parameter import. |
| firecrown/models/cluster/_deltasigma.py | Switch to direct register_new_updatable_parameter import. |
| firecrown/modeling_tools/_modeling_tools.py | Update internal imports to new CCL factory submodules. |
| firecrown/modeling_tools/_ccl_types.py | New typed definitions for CCL factory calculator args. |
| firecrown/modeling_tools/_ccl_models.py | Update parameter imports to firecrown.updatable. |
| firecrown/modeling_tools/_ccl_factory.py | Move CCL factory implementation under modeling_tools and update imports. |
| firecrown/modeling_tools/_ccl_enums.py | New enum types for CCL factory (creation mode, amplitude parameter, etc.). |
| firecrown/modeling_tools/init.py | Re-export CCL factory APIs/types/enums from firecrown.modeling_tools. |
| firecrown/likelihood/supernova/_supernova.py | Switch to direct register_new_updatable_parameter import. |
| firecrown/likelihood/number_counts/_systematics.py | Switch to direct register_new_updatable_parameter import. |
| firecrown/likelihood/number_counts/_source.py | Switch parameter-related imports to firecrown.updatable. |
| firecrown/likelihood/factories/_models.py | Update CCLFactory import to firecrown.modeling_tools. |
| firecrown/likelihood/_weak_lensing.py | Switch parameter-related imports to firecrown.updatable. |
| firecrown/likelihood/_student_t.py | Switch to direct register_new_updatable_parameter import. |
| firecrown/likelihood/_gaussfamily.py | Update ParamsMap import to firecrown.updatable. |
| firecrown/likelihood/_base.py | Switch parameter/updatable imports to firecrown.updatable. |
| firecrown/connector/numcosmo/numcosmo.py | Update CCL/ParamsMap imports to new modules. |
| firecrown/connector/numcosmo/helpers.py | Update ccl_factory alias to import firecrown.modeling_tools. |
| firecrown/connector/mapping.py | Update CCL types import source and ParamsMap type annotation. |
| firecrown/connector/cosmosis/likelihood.py | Update CCLCreationMode/ParamsMap imports to new modules. |
| firecrown/connector/cobaya/likelihood.py | Update CCL/ParamsMap imports to new modules. |
| firecrown/ccl_factory/init.py | Convert to deprecated shim re-exporting from firecrown.modeling_tools. |
| firecrown/app/examples/_sn_srd_template.py | Update CCLFactory import to firecrown.modeling_tools. |
| firecrown/app/examples/_des_y1_cosmic_shear_tatt_template.py | Update CCLFactory import to firecrown.modeling_tools. |
| firecrown/app/examples/_des_y1_cosmic_shear_pk_modifier_template.py | Update CCLFactory/parameter imports to new modules. |
| firecrown/app/examples/_des_y1_cosmic_shear_hmia_template.py | Update CCLFactory import to firecrown.modeling_tools. |
| firecrown/app/examples/_des_y1_3x2pt_template.py | Update CCLFactory import to firecrown.modeling_tools. |
| firecrown/app/examples/_des_y1_3x2pt_pt_template.py | Update CCLFactory import to firecrown.modeling_tools. |
| firecrown/app/examples/_cosmic_shear_template.py | Update CCLFactory import to firecrown.modeling_tools. |
| firecrown/app/cosmology.py | Update CAMBExtraParams import to firecrown.modeling_tools. |
| firecrown/app/analysis/_types.py | Update CAMBExtraParams/PoweSpecAmplitudeParameter import to firecrown.modeling_tools. |
| examples/des_y1_3x2pt/factory_PT.py | Update example imports to new modules. |
| examples/des_y1_3x2pt/factory_PM.py | Update CCLFactory import to firecrown.modeling_tools. |
| examples/des_y1_3x2pt/factory.py | Update CCLFactory import to firecrown.modeling_tools. |
| examples/des_y1_3x2pt/des_y1_cosmic_shear_pk_modifier.py | Update ParamsMap/register function/CCLFactory imports to new modules. |
| examples/des_y1_3x2pt/des_y1_cosmic_shear_TATT.py | Update ParamsMap/CCLFactory imports to new modules. |
| examples/des_y1_3x2pt/des_y1_cosmic_shear_HMIA.py | Update ParamsMap/CCLFactory imports to new modules. |
| environment.yml | Pin black version (with formatting that differs from other deps). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| with warnings.catch_warnings(record=True) as w: | ||
| warnings.simplefilter("always") | ||
| # Import should trigger warning | ||
| # pylint: disable=unused-import,import-outside-toplevel | ||
| import firecrown.parameters # noqa: F401 | ||
|
|
||
| # Should have at least one warning (there might be multiple due to | ||
| # imports within the module) | ||
| assert len(w) >= 1 | ||
| # First warning should be a DeprecationWarning | ||
| assert issubclass(w[0].category, DeprecationWarning) | ||
| # Check message content | ||
| assert "firecrown.parameters module is deprecated" in str(w[0].message) | ||
| assert "firecrown.updatable" in str(w[0].message) | ||
|
|
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deprecation-warning assertion is order-dependent: w[0] may not be the firecrown.parameters DeprecationWarning if other warnings are emitted during import (your comment notes there may be multiple). Consider asserting that any captured warning is a DeprecationWarning whose message matches the expected substrings (or use pytest.warns(..., match=...)) to avoid flaky failures.
| ) | ||
| from firecrown import parameters | ||
|
|
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test file imports the deprecated firecrown.parameters module, which will emit a DeprecationWarning (and pytest.ini does not filter it). Unless this file is intended to test the deprecated compatibility layer, prefer importing register_new_updatable_parameter from firecrown.updatable and drop the deprecated module import; otherwise, explicitly filter/silence the warning within the tests.
| - alabaster | ||
| - babel | ||
| - black | ||
| - black = 25.12.0 |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conda dependency pins are usually written without spaces (e.g., black=25.12.0). black = 25.12.0 is inconsistent with the rest of this file and may not be parsed as intended by conda.
| match="firecrown.ccl_factory is deprecated and will be removed", | ||
| ): | ||
| # pylint: disable=import-outside-toplevel,unused-import | ||
| import firecrown.ccl_factory # noqa: F401 |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module 'firecrown.ccl_factory' is imported with both 'import' and 'import from'.
| We just verify the module is importable. | ||
| """ | ||
| # pylint: disable=import-outside-toplevel,unused-import | ||
| import firecrown.ccl_factory # noqa: F401 |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module 'firecrown.ccl_factory' is imported with both 'import' and 'import from'.
| warnings.simplefilter("always") | ||
| # Import should trigger warning | ||
| # pylint: disable=unused-import,import-outside-toplevel | ||
| import firecrown.parameters # noqa: F401 |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module 'firecrown.parameters' is imported with both 'import' and 'import from'.
| def test_parameters_exports_all_names(): | ||
| """All expected names should be available from firecrown.parameters.""" | ||
| # pylint: disable=import-outside-toplevel | ||
| import firecrown.parameters as params |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module 'firecrown.parameters' is imported with both 'import' and 'import from'.
| def test_parameters_exports_are_same_as_updatable(): | ||
| """Exported names should be the same objects as in firecrown.updatable.""" | ||
| # pylint: disable=import-outside-toplevel | ||
| import firecrown.parameters as params |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module 'firecrown.parameters' is imported with both 'import' and 'import from'.
| from firecrown.ccl_factory import CCLFactory, PoweSpecAmplitudeParameter | ||
| import firecrown.parameters as fcp | ||
| from firecrown.modeling_tools import CCLFactory, PoweSpecAmplitudeParameter | ||
| import firecrown.updatable as fcp |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module 'firecrown.updatable' is imported with both 'import' and 'import from'.
| import sacc | ||
|
|
||
| import firecrown.parameters | ||
| import firecrown.updatable |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module 'firecrown.updatable' is imported with both 'import' and 'import from'.
Description
This PR consolidates the
ccl_factorymodule intomodeling_toolsand moves theparametersmodule intoupdatableto improve code organization and better reflect the architectural relationships between these components.The CCL factory functionality is closely related to modeling tools and now resides within the same module. Similarly, parameter-related classes are now part of the
updatablemodule, reflecting their tight coupling with updatable objects.Both old modules (
firecrown.ccl_factoryandfirecrown.parameters) remain as deprecated compatibility layers that re-export from their new locations with deprecation warnings, ensuring backward compatibility for existing code.All imports throughout the codebase (examples, tests, connectors, and tutorials) have been updated to use the new module paths.
Type of Change
Checklist:
The following checklist will make sure that you are following the code style and
guidelines of the project as described in the
contributing page.
bash pre-commit-checkand fixed any issues