|
22 | 22 | from muse.commodities import CommodityUsage |
23 | 23 | from muse.timeslices import setup_module |
24 | 24 |
|
25 | | -# Constants |
26 | 25 | RANDOM_SEED = 123 |
27 | 26 |
|
28 | 27 | DEFAULT_TIMESLICES = """ |
@@ -207,6 +206,8 @@ def coords() -> Mapping: |
207 | 206 | """ |
208 | 207 | return { |
209 | 208 | "technology": ["burger_flipper", "soda_shaker", "deep_frier", "salad_arranger"], |
| 209 | + "tech_type": ["solid", "liquid", "solid", "liquid"], |
| 210 | + "fuel": ["person", "person", "oil", "person"], |
210 | 211 | "region": ["ASEAN", "USA"], |
211 | 212 | "year": [2010, 2030], |
212 | 213 | "commodity": [ |
@@ -279,16 +280,14 @@ def technologies(coords: Mapping) -> Dataset: |
279 | 280 | Dataset with technology characteristics |
280 | 281 | """ |
281 | 282 | result = Dataset(coords=coords) |
282 | | - |
283 | | - result["comm_type"] = ("commodity", coords["comm_type"]) |
284 | | - result["tech_type"] = "technology", ["solid", "liquid", "solid", "liquid"] |
285 | | - |
| 283 | + result["comm_type"] = "commodity", coords["comm_type"] |
| 284 | + result["tech_type"] = "technology", coords["tech_type"] |
| 285 | + result["fuel"] = "technology", coords["fuel"] |
286 | 286 | result = result.set_coords(("comm_type", "tech_type")) |
287 | 287 |
|
288 | | - # Generate random variables |
| 288 | + # We have a single agent with a share of 1 for all technologies |
289 | 289 | result["agent_share"] = var_generator(result, ["technology", "region", "year"]) |
290 | 290 | result["agent_share"] /= np.sum(result.agent_share) |
291 | | - result["agent_share_zero"] = result["agent_share"] * 0 |
292 | 291 |
|
293 | 292 | # first create a mask so each tech will have consistent inputs/outputs across years |
294 | 293 | # and regions |
@@ -638,54 +637,6 @@ def capacity(technologies: Dataset) -> DataArray: |
638 | 637 | return create_fake_capacity(20, technologies) |
639 | 638 |
|
640 | 639 |
|
641 | | -@fixture |
642 | | -def settings(tmpdir) -> dict: |
643 | | - """Generate settings for testing. |
644 | | -
|
645 | | - Args: |
646 | | - tmpdir: Temporary directory path |
647 | | -
|
648 | | - Returns: |
649 | | - Dictionary with test settings |
650 | | - """ |
651 | | - import toml |
652 | | - |
653 | | - from muse.readers import DEFAULT_SETTINGS_PATH |
654 | | - from muse.readers.toml import format_paths |
655 | | - |
656 | | - def drop_optionals(settings: dict) -> None: |
657 | | - """Remove optional settings from dictionary.""" |
658 | | - for k, v in list(settings.items()): |
659 | | - if v == "OPTIONAL": |
660 | | - settings.pop(k) |
661 | | - elif isinstance(v, Mapping): |
662 | | - drop_optionals(v) |
663 | | - |
664 | | - settings = toml.load(DEFAULT_SETTINGS_PATH) |
665 | | - drop_optionals(settings) |
666 | | - out = format_paths(settings, cwd=tmpdir, path=tmpdir, muse_sectors=tmpdir) |
667 | | - |
668 | | - # Add required settings |
669 | | - required = { |
670 | | - "time_framework": [2010, 2015, 2020], |
671 | | - "regions": ["MEX"], |
672 | | - "equilibrium": False, |
673 | | - "maximum_iterations": 3, |
674 | | - "tolerance": 0.1, |
675 | | - "interpolation_mode": "linear", |
676 | | - } |
677 | | - out.update(required) |
678 | | - |
679 | | - # Add required carbon budget settings |
680 | | - carbon_budget_required = { |
681 | | - "budget": [420000, 413000, 403000], |
682 | | - "commodities": ["CO2f", "CO2r", "CH4", "N2O"], |
683 | | - } |
684 | | - out["carbon_budget_control"].update(carbon_budget_required) |
685 | | - |
686 | | - return out |
687 | | - |
688 | | - |
689 | 640 | @fixture(autouse=True) |
690 | 641 | def warnings_as_errors(request): |
691 | 642 | """Configure warnings to be treated as errors during testing. |
@@ -762,16 +713,3 @@ def saveme(module_name: str, registry_name: str): |
762 | 713 | map(next, iterators) |
763 | 714 | yield |
764 | 715 | map(next, iterators) |
765 | | - |
766 | | - |
767 | | -@fixture |
768 | | -def rng(request): |
769 | | - """Create a random number generator for testing. |
770 | | -
|
771 | | - Args: |
772 | | - request: Pytest request object |
773 | | -
|
774 | | - Returns: |
775 | | - Random number generator instance |
776 | | - """ |
777 | | - return default_rng(getattr(request.config.option, "randomly_seed", None)) |
0 commit comments