Skip to content

Conversation

@sufikaur
Copy link
Contributor

Fixes/Resolves:

Issue 1679
See idaes PR 1683

Summary/Motivation:

Changes proposed in this PR:

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@ksbeattie ksbeattie added the Priority:High High Priority Issue or PR label Nov 13, 2025
@sufikaur
Copy link
Contributor Author

After looking at each test, I think that the warnings can be disabled globally.
There are 2 tests that I would like others to confirm will not run into issues.

Currently, I have disabled on each line, but after reviewing, they can be generalized

return blk.chemical_flow_mass[t, j] == pyunits.convert(
chemical_dosage * blk.properties[t].flow_vol,
chemical_dosage
* blk.properties[t].flow_vol, # don't fully understand this test
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would appreciate someone else looking at this test. @bknueven do you recall this model?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, if clunky.

That said, I think in many, many places, instead of suppressing pylint we should instead add an additional else clause which raises an exception. WaterTAP is big enough that we should have our own exceptions anyways.

E.g., in this case the else clause could raise a WaterTAPDeveloperError, or if we want to be cute, a FronzenPipes error. It doesn't even need a message if we know we'll never hit the else clause upon inspection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking a look and sounds good-- suppressing was a temporary step and throwing a dev error makes sense.

@sufikaur sufikaur requested a review from ksbeattie as a code owner November 19, 2025 01:57
Comment on lines 81 to 84
molecule = ""
if len(components) == 1:
molecule = components[0]
elif len(components) == 2:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is another case where we should raise an exception if neither condition is satisfied.

@sufikaur sufikaur requested a review from bknueven November 20, 2025 21:55
Comment on lines 90 to 91
# can fix by initizalizing msg or can disable message
msg = "Message failed to initialize."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably just replace the else clause with a generic WaterTAPDeveloperError because the issue is that the else clause is calling a message that hasn't necessarily been initialized yet, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember there was a reason we did a msg here and not an error or log ... I think

Comment on lines 106 to 110
# contactor_cost_coeff_data, other_cost_param_data, energy_consumption_coeff_data = (
# {},
# {},
# {},
# ) # other option is to initialize as empty dicts and fill based on contactor type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this solution is fine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirming, this solution meaning the initializing empty dicts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Comment on lines 865 to 868
# take a look at this test together
iscale.set_scaling_factor(
self.uv_intensity, sf # pylint: disable=used-before-assignment
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean by this comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly referring to the comment about the if statement below. Needed more eyes in particular on this test

Comment on lines 873 to 875
iscale.set_scaling_factor(
self.exposure_time, sf
) # why is this one set inside the if but none of the rest?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - this should not be inside the if statement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't all be inside the if statement? I think the fact that they are outside is causing the sf possibly used before assignment error

I simply disabled for now since the comment above says that an error would be thrown elsewhere

@sufikaur sufikaur requested a review from MarcusHolly November 26, 2025 20:37
Comment on lines 106 to 110
# contactor_cost_coeff_data, other_cost_param_data, energy_consumption_coeff_data = (
# {},
# {},
# {},
# ) # other option is to initialize as empty dicts and fill based on contactor type
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirming, this solution meaning the initializing empty dicts

Comment on lines 865 to 868
# take a look at this test together
iscale.set_scaling_factor(
self.uv_intensity, sf # pylint: disable=used-before-assignment
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly referring to the comment about the if statement below. Needed more eyes in particular on this test

Comment on lines 873 to 875
iscale.set_scaling_factor(
self.exposure_time, sf
) # why is this one set inside the if but none of the rest?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't all be inside the if statement? I think the fact that they are outside is causing the sf possibly used before assignment error

I simply disabled for now since the comment above says that an error would be thrown elsewhere

Copy link
Contributor

@bknueven bknueven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sufikaur. I found a few more small things, but I think this is about ready.

)
iscale.set_scaling_factor(
self.exposure_time, sf
) # why is this one set inside the if but none of the rest?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the answer here is this one is correct, and the other are wrong. The code doesn't make sense otherwise, right?

)
iscale.set_scaling_factor(self.exposure_time, sf)

iscale.set_scaling_factor(self.exposure_time, sf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to reiterate -- I think all the calls to set_scaling_factor in this method should be inside the associated if statement. That's on the only way this code makes sense.

Comment on lines 105 to 109
contactor_cost_coeff_data, other_cost_param_data, energy_consumption_coeff_data = (
{},
{},
{},
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is another one of those times we should raise an exception in an else. Otherwise we will get an error elsewhere and it'll be difficult to trace back here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this to an else

# touch this var since it is required for this method
self.conc_mol_phase_comp

"""this could also be defined 'state_var["Liq", adjust_by_ion].fix(ion_adjusted)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this doc string / comment???

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

elif ix_type == "anion":
resin_cost = ion_exchange_params.anion_exchange_resin_cost
else:
raise WaterTapDeveloperError(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets checked in the unit model directly via checking of the charge on a component. It should be essentially impossible to get to this point.

... but maybe that is the point of a developer error?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. If somebody changes something upstream which breaks that assumption, we'll catch it here instead of just charging forward.

Comment on lines 90 to 91
# can fix by initizalizing msg or can disable message
msg = "Message failed to initialize."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember there was a reason we did a msg here and not an error or log ... I think

@sufikaur sufikaur requested a review from bknueven December 10, 2025 18:41
@ksbeattie ksbeattie merged commit ed5d54f into watertap-org:main Dec 10, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority:High High Priority Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants