Skip to content
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

Introduce Indexset.remove_data() #158

Open
wants to merge 2 commits into
base: remove-column-class-entirely
Choose a base branch
from

Conversation

glatterf42
Copy link
Member

@glatterf42 glatterf42 commented Feb 3, 2025

For iiasa/ixmp#557, I will next need functions that allow removal of individual keys from Indexsets, Tables, and Parameters. This PR adds such a function for Indexsets.

While working on that function, I found myself thinking: wouldn't it be nice to get some sort of warning if you're trying to remove data from an Indexset, but that Indexset doesn't have that data? This can be checked easily in sqlalchemy, so I added log.info() messages for two cases.
In order to test that these messages are actually logged, I copied over the assert_logs() utility function we have in ixmp and enhanced it with some type hints. Thanks to @khaeru for writing that in the first place!

Note

This PR looks larger than it is because I swapped the order of the tests in the data/ subfolder to be consistent with the other optimization tests. There's no need to verify test_list_indexset and test_tabulate_indexset again.

@glatterf42 glatterf42 added the enhancement New feature or request label Feb 3, 2025
@glatterf42 glatterf42 requested a review from meksor February 3, 2025 12:22
@glatterf42 glatterf42 self-assigned this Feb 3, 2025
Copy link

codecov bot commented Feb 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.4%. Comparing base (9c36f7a) to head (061a25d).

Additional details and impacted files
@@                     Coverage Diff                      @@
##           remove-column-class-entirely    #158   +/-   ##
============================================================
  Coverage                          88.4%   88.4%           
============================================================
  Files                               223     223           
  Lines                              8032    8055   +23     
============================================================
+ Hits                               7103    7126   +23     
  Misses                              929     929           
Files with missing lines Coverage Δ
ixmp4/core/optimization/indexset.py 91.9% <100.0%> (+0.4%) ⬆️
ixmp4/data/abstract/optimization/indexset.py 96.4% <100.0%> (+0.1%) ⬆️
ixmp4/data/api/optimization/indexset.py 97.7% <100.0%> (+0.1%) ⬆️
ixmp4/data/db/optimization/indexset/repository.py 98.4% <100.0%> (+0.3%) ⬆️
ixmp4/server/rest/optimization/indexset.py 100.0% <100.0%> (ø)

@glatterf42 glatterf42 force-pushed the enh/introduce-indexset-remove-data branch from c3877f1 to 9145994 Compare February 4, 2025 08:12
@glatterf42 glatterf42 force-pushed the enh/introduce-indexset-remove-data branch from 9145994 to 061a25d Compare February 5, 2025 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant