Rename investmentset marketset#1371
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1371 +/- ##
==========================================
- Coverage 89.80% 89.68% -0.12%
==========================================
Files 58 59 +1
Lines 8524 8406 -118
Branches 8524 8406 -118
==========================================
- Hits 7655 7539 -116
+ Misses 556 550 -6
- Partials 313 317 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tsmbland
left a comment
There was a problem hiding this comment.
On board with the name change. I think some of the stuff moved over from simulation::investment to simulation::market should probably still belong in simulation::investment, particularly the select_assets functions, and possibly even get_demand_portion_for_market and get_responsible_agents. That get's a bit messy since select_assets is a method of MarketSet. I think you can define methods away from where the struct lives, but maybe that's messy, and maybe select_assets would be better as a standalone function anyway?
@alexdewar what do you think?
alexdewar
left a comment
There was a problem hiding this comment.
Looking good! I've suggested a few tweaks
| /// agent's portion of the commodity demand and the number of years elapsed since the previous | ||
| /// milestone year). | ||
| fn calculate_investment_limits_for_candidates( | ||
| pub fn calculate_investment_limits_for_candidates( |
There was a problem hiding this comment.
This function and get_asset_options are only used in market.rs now, so they could be left private and moved there.
select_best_assets is also only used in market.rs, but given that that's the heart of the investment-related code, I feel like it fits better in investment.rs.
Do you agree @tsmbland?
There was a problem hiding this comment.
I do think all the core investment-related code should be in investment.rs, and leave market.rs for generic market-related stuff like the iter and display implementations
There was a problem hiding this comment.
I've given things a bit of a shuffle, trying to accommodate both of your suggestions 😅
I've tried to use a bit of logic based on how/where the functions are used and how they're described in their docstrings (and names), but I obviously have no personal feelings on the matter so am happy to move things as you see fit.
| /// Assets are selected for a single market using `select_assets_for_single_market` | ||
| Single((CommodityID, RegionID)), | ||
| /// Assets are selected for a group of markets which forms a cycle. | ||
| /// Experimental: handled by `select_assets_for_cycle` and guarded by the broken options | ||
| /// parameter. | ||
| Cycle(Vec<(CommodityID, RegionID)>), | ||
| /// Assets are selected for a layer of independent `MarketSet`s |
There was a problem hiding this comment.
These identifiers can be turned into links for the docs:
| /// Assets are selected for a single market using `select_assets_for_single_market` | |
| Single((CommodityID, RegionID)), | |
| /// Assets are selected for a group of markets which forms a cycle. | |
| /// Experimental: handled by `select_assets_for_cycle` and guarded by the broken options | |
| /// parameter. | |
| Cycle(Vec<(CommodityID, RegionID)>), | |
| /// Assets are selected for a layer of independent `MarketSet`s | |
| /// Assets are selected for a single market using [`select_assets_for_single_market`] | |
| Single((CommodityID, RegionID)), | |
| /// Assets are selected for a group of markets which forms a cycle. | |
| /// Experimental: handled by [`select_assets_for_cycle`]. May not work in every case. | |
| Cycle(Vec<(CommodityID, RegionID)>), | |
| /// Assets are selected for a layer of independent [`MarketSet`]s |
Edit: Also changed the text for Cycle as it's no longer a hidden option.
There was a problem hiding this comment.
@alexdewar there may be a reason why these weren't linked before:
Generating API documentation
Documenting muse2 v2.1.0 (/home/runner/work/MUSE2/MUSE2)
error: public documentation for `Single` links to private item `select_assets_for_single_market`
Error: --> src/simulation/market.rs:26:57
|
26 | /// Assets are selected for a single market using [`select_assets_for_single_market`]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
|
= note: this link resolves only because you passed `--document-private-items`, but will break without
= note: `-D rustdoc::private-intra-doc-links` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(rustdoc::private_intra_doc_links)]`
error: public documentation for `Cycle` links to private item `select_assets_for_cycle`
Error: --> src/simulation/market.rs:29:36
|
29 | /// Experimental: handled by [`select_assets_for_cycle`]. May not work in every case.
| ^^^^^^^^^^^^^^^^^^^^^^^ this item is private
|
= note: this link resolves only because you passed `--document-private-items`, but will break without
Ha, I just messaged you suggesting kind of the opposite (moving more things to |
Co-authored-by: Alex Dewar <alexdewar@users.noreply.github.com>
alexdewar
left a comment
There was a problem hiding this comment.
I'd be happy with this, but I thought we settled on moving more stuff out of market.rs, so it was pretty much just MarketSet? Could make the MarketSet::select_assets a regular function and put it in investment.rs.
I don't mind merging as is though -- investment.rs is quite long as it is. What do you think @tsmbland?
In terms of the cargo doc errors, I think we should fix it by making the functions pub. It makes sense that it would complain about private things being referred to in doc comments for public things as cargo doc doesn't document private items by default.
My vote would be to keep this in |
How about we merge this for now (once |
Description
This PR:
InvestmentSetand associated functions out of theinvestmentmodule into a newmarketmodule (with some (un)educated guesses at which functions should be moved, and which functions should remain but be made public))InvestmentSettoMarketSetgraph::investmentto reflect these changes (also with some guesswork at which terminology should be updated)Fixes #1337
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks