we3lab / we3lab/eeco

BUG: check that `_var_index` exists in the utility methods

Open
#64 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs triage
Dominant language
Python
Stars
11
Forks
4
Avg merge
5d 4h
Merged PRs (30d)
1

Description

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of eeco.


Description

There are numerous instances of model._var_index being accessed in utils.py without checking that we have created that attribute. Since _var_index is automatically created within EECO and not intended to be made by the user, it would be good to ensure we check for its existence along any code paths where it may have not been created.

Further discussion of this issue can be found in this PR thread: https://github.com/we3lab/eeco/pull/50/changes#r3786497573

Expected Behavior

If _var_index does not already exist, then it should be created with the built-in method create_pyomo_model_index_ref.

If _var_index does exist, then it should be left untouched.

Reproduction

There are numerous ways to create an AttributeError. For example, calling utils.multiply() with a model object that does not have the attribute _var_index.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in utils.py by locating the utility methods that access model._var_index, then read create_pyomo_model_index_ref and the PR discussion linked in the issue. Exercise a method such as utils.multiply with a model lacking _var_index, and verify that missing attributes are created while existing _var_index values remain untouched.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.