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

Add a subsection for modification of variable bounds in docs #269

Closed
wants to merge 1 commit into from

Conversation

fwitte
Copy link

@fwitte fwitte commented Apr 9, 2024

I was trying to modify variable bounds instead of creating additional constraints for already instantiated variables and could not find a subsection in the respective chapter. It does not work with something like variable.loc[slice, other_slice].lower = 42 and I did not immediately understand why, so I thought a hint on how to do this might be useful.

If this is bad practice, I would be happy to get a rejection of the PR (and also be curious why it would be :)).

Thank you!

@fwitte fwitte changed the title Add a subsection for modification of variable bounds Add a subsection for modification of variable bounds in docs Apr 9, 2024
Copy link

codecov bot commented Apr 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.78%. Comparing base (3c11dc5) to head (8678fa7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #269      +/-   ##
==========================================
- Coverage   88.94%   85.78%   -3.16%     
==========================================
  Files          15       15              
  Lines        3645     3645              
  Branches      856      856              
==========================================
- Hits         3242     3127     -115     
- Misses        279      403     +124     
+ Partials      124      115       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fwitte
Copy link
Author

fwitte commented Apr 9, 2024

I blindly overlook the section, I was only reading the variables one... Nevertheless, including how to slice variable.lower.loc[slice, other] instead of variable.loc[slice, other].lower might be useful

@fwitte fwitte closed this Apr 9, 2024
@FabianHofmann
Copy link
Collaborator

@fwitte thank you for your contribution. Setting the bounds on a selection of variables does not work, as the .loc function returns a copy of the original data. Therefore, the bound will only set to the copy and not the variable selection itself. Would you mind adding a note there, that this case is not supported (yet)?

@FabianHofmann
Copy link
Collaborator

I blindly overlook the section, I was only reading the variables one... Nevertheless, including how to slice variable.lower.loc[slice, other] instead of variable.loc[slice, other].lower might be useful

no worries

@fwitte
Copy link
Author

fwitte commented Apr 9, 2024

It does work, if you access the xarray.DataArray like this: variable.lower.loc[slice, other], not sure if it is intentional.

@fwitte
Copy link
Author

fwitte commented Apr 9, 2024

I added the hint and explanation, which of both version work. It is now in the Variables section. If this is of interest, let me know if I should reopen the PR and/or move the information to the Modifying the Model section.

Have a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants