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

Remove pointless indexsets.tabulate parameter include_data #138

Open
wants to merge 1 commit into
base: enh/professional-grade-mypy
Choose a base branch
from

Conversation

glatterf42
Copy link
Member

Partly closes #137: this PR removes the include_data parameter, but doesn't add any way to check the length of the indexset.data. For that you still have to get the indexset somehow and access the attribute directly.

Please note that I did quickly check if including len(data) would easily be possible. I don't think it is because indexset.data is a @property on the DB model class at the moment, so not loaded automatically when using tabulate. That's because base.tabulate() uses pd.read_sql(), which only reads in the columns of the returned data model (not relationships or attributes built on them).
In contrast, e.g. base.list() returns a list of data models and their attributes can be accessed normally.
Thus, it seems to me that there's no quick way to change that for indexset.tabulate(), though it can definitely be done; either through rewriting base.tabulate() (think: SELECT all resulting rows first, load their .data, then turn into pd.DataFrame) or by accessing the DB twice (think: use base.tabulate()as usual, then use e.g.base.list()to get the.datadata and put it into a new column). Neither of those options seems desirable to me at the moment and I don't think it's necessary to comply with themessage_ix` API, so i would ignore that part of #137 for now (at least, if not forever).

@glatterf42 glatterf42 added the enhancement New feature or request label Nov 27, 2024
@glatterf42 glatterf42 self-assigned this Nov 27, 2024
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.9%. Comparing base (c18ed42) to head (79b2c14).

Additional details and impacted files
@@                      Coverage Diff                      @@
##           enh/professional-grade-mypy    #138     +/-   ##
=============================================================
- Coverage                         86.9%   86.9%   -0.1%     
=============================================================
  Files                              228     228             
  Lines                             8141    8135      -6     
=============================================================
- Hits                              7081    7075      -6     
  Misses                            1060    1060             
Files with missing lines Coverage Δ
ixmp4/core/optimization/indexset.py 92.6% <100.0%> (ø)
ixmp4/data/abstract/optimization/indexset.py 80.6% <100.0%> (ø)
ixmp4/data/api/optimization/indexset.py 97.6% <100.0%> (ø)
ixmp4/data/db/base.py 91.8% <ø> (-0.1%) ⬇️
ixmp4/data/db/optimization/indexset/repository.py 98.1% <100.0%> (-0.2%) ⬇️
ixmp4/server/rest/optimization/indexset.py 100.0% <ø> (ø)

@glatterf42 glatterf42 force-pushed the remove/pointless-tabulate-parameter branch from d1f01fa to 50d6fae Compare November 27, 2024 11:16
@glatterf42 glatterf42 force-pushed the remove/pointless-tabulate-parameter branch from 50d6fae to 79b2c14 Compare November 29, 2024 13:23
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