Skip to content

Add clone method#81

Merged
chengcli merged 3 commits intomainfrom
cli/add_toon
Jan 27, 2026
Merged

Add clone method#81
chengcli merged 3 commits intomainfrom
cli/add_toon

Conversation

@chengcli
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings January 27, 2026 13:15
@chengcli chengcli requested a review from luminoctum as a code owner January 27, 2026 13:15
Copy link

Copilot AI left a 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 adds clone() methods to several options implementation structs throughout the codebase to enable deep copying of configuration objects. The PR also updates the pydisort dependency from version 1.4.1 to 1.4.5, which is likely required to support the DisortOptions::clone() method used in the new implementations. Additionally, the PR improves the formatting of the report() method in RadiationBandOptionsImpl.

Changes:

  • Added clone() methods to five options implementation structs: ToonMcKay89OptionsImpl, RadiationBandOptionsImpl, RadiationOptionsImpl, OpacityOptionsImpl, and IntegratorOptionsImpl
  • Bumped pydisort version requirement from 1.4.1 to 1.4.5 across build configurations
  • Enhanced report formatting in RadiationBandOptionsImpl to use fmt::format and conditionally display solver options

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/rtsolver/toon_mckay89.hpp Added clone method for ToonMcKay89OptionsImpl using copy constructor
src/radiation/radiation_band.hpp Added clone method with deep copying for disort and toon options; improved report formatting with fmt; added harp_formatter.hpp include
src/radiation/radiation.hpp Added clone method that deep clones the bands vector
src/opacity/opacity_options.hpp Added clone method for OpacityOptionsImpl using copy constructor
src/integrator/integrator.hpp Added clone method for IntegratorOptionsImpl using copy constructor
pyproject.toml Updated pydisort version requirement from 1.4.1 to 1.4.5 in both build-system.requires and dependencies
.github/workflows/ci.yml Updated pydisort version in CI workflow pip install command
.github/workflows/cd.yml Updated pydisort version in CD workflow for both macOS and Linux builds

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 70 to 79
std::shared_ptr<RadiationBandOptionsImpl> clone() const {
auto op = std::make_shared<RadiationBandOptionsImpl>(*this);
if (op->disort() != nullptr) {
op->disort() = op->disort()->clone();
}
if (op->toon() != nullptr) {
op->toon() = op->toon()->clone();
}
return op;
}
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clone method performs a shallow copy of the opacities map. Since OpacityDict is a map of shared_ptr (OpacityOptions), the cloned RadiationBandOptionsImpl will share the same OpacityOptionsImpl objects with the original. This means modifying opacity options in the clone will affect the original and vice versa.

Consider deep cloning the opacities map as well to ensure true independence between the clone and the original:

if (op->opacities().size() > 0) {
  auto& opacities_ref = op->opacities();
  opacities_ref.clear();
  for (auto const& [k, v] : opacities()) {
    opacities_ref[k] = v->clone();
  }
}

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Contributor

Copilot AI commented Jan 27, 2026

@chengcli I've opened a new pull request, #82, to work on those changes. Once the pull request is ready, I'll request review from you.

…82)

* Initial plan

* Add deep cloning for opacities map in clone method

Co-authored-by: chengcli <69489965+chengcli@users.noreply.github.com>

* Final update: deep cloning implementation complete

Co-authored-by: chengcli <69489965+chengcli@users.noreply.github.com>

* Remove CodeQL artifact file

Co-authored-by: chengcli <69489965+chengcli@users.noreply.github.com>

* Update src/radiation/radiation_band.hpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: chengcli <69489965+chengcli@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@chengcli chengcli merged commit 858c4fa into main Jan 27, 2026
3 checks passed
@chengcli chengcli deleted the cli/add_toon branch January 27, 2026 16:30
@github-actions
Copy link
Contributor

🎉 Released v1.8.8!

What's Changed

Full Changelog: v1.8.7...v1.8.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants