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

Update examples #2

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Update examples #2

wants to merge 20 commits into from

Conversation

mitchute
Copy link
Owner

No description provided.

Comment on lines 9 to 13
try:
import matplotlib.pyplot as plt
except ModuleNotFoundError:
pass

Copy link
Owner Author

Choose a reason for hiding this comment

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

@Myoldmopar, can you take a look here before I push it all the way through?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Might consider storing a variable to indicate whether it has been properly imported or not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
try:
import matplotlib.pyplot as plt
except ModuleNotFoundError:
pass
try:
import matplotlib.pyplot as plt
plotting_enabled = True
except ModuleNotFoundError:
plotting_enabled = False

@mitchute
Copy link
Owner Author

@vtnate here's where I'm at with this currently.

@Myoldmopar how should we stage the changes here? There are a handful of changes we could make here.

  1. Get example files cleaned up and running locally and on CI (that's been the focus of this PR to this point).
  2. Clean up installers so a "core" version without Matplotlib can be installed, plus maybe an "extras" version. Feel free to massage the language on the terms. Getting Matplotlib to not be installed by default is the main objective.
  3. Develop an API for computing g-functions and borehole resistance.

Anything else?

Copy link
Collaborator

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

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

Looks good to me. Just a few comments, but ignore if you'd like.

Comment on lines 9 to 13
try:
import matplotlib.pyplot as plt
except ModuleNotFoundError:
pass

Copy link
Collaborator

Choose a reason for hiding this comment

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

Might consider storing a variable to indicate whether it has been properly imported or not.

Comment on lines 9 to 13
try:
import matplotlib.pyplot as plt
except ModuleNotFoundError:
pass

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
try:
import matplotlib.pyplot as plt
except ModuleNotFoundError:
pass
try:
import matplotlib.pyplot as plt
plotting_enabled = True
except ModuleNotFoundError:
plotting_enabled = False

@@ -114,28 +117,28 @@ def main():
# Plot bore field thermal resistances
# -------------------------------------------------------------------------

# Configure figure and axes
fig = gt.utilities._initialize_figure()
if make_plots:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Definitely like this as an optional thing 👍

ax.set_title(f"Relative error relative to the 'similarities' solver "
f"(Field of {N_1} by {N_2} boreholes)")
# Adjust to plot window
fig.tight_layout()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there any chance to compile all the plotting into one place? Maybe a single file/class called plotting.py? There seems to be quite a bit of repetition, but each of these also seems a little different. So no biggie if not. Just a thought.

@@ -11,7 +14,7 @@ def main():
# -------------------------------------------------------------------------

# Filepath to bore field text file
filename = './data/custom_field_32_boreholes.txt'
filename = Path(__file__).parent / "data", "custom_field_32_boreholes.txt"
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@Myoldmopar
Copy link
Collaborator

@Myoldmopar how should we stage the changes here? There are a handful of changes we could make here.

  1. Get example files cleaned up and running locally and on CI (that's been the focus of this PR to this point).
  2. Clean up installers so a "core" version without Matplotlib can be installed, plus maybe an "extras" version. Feel free to massage the language on the terms. Getting Matplotlib to not be installed by default is the main objective.
  3. Develop an API for computing g-functions and borehole resistance.

Anything else?

  • Is # 1 is done now with the current state of this PR? Or are there still examples not running?
  • I'm happy to edit the setup to use optional dependencies. I think the typical way to do this would be to break the setup.py into pygfunction-core and pygfunction or something like that. Where the "full" version depends on core and also adds matplotlib and maybe other future stuff. This could be done as a minimal change in setup.py, but it would be a more substantial change to pypi deployment. So if that's too intrusive, we could also just offer a nice error message to a user if they are trying to generate plots but haven't installed matplotlib (plotting is not available on the default install; to get plotting capability, pip install matplotlib) or something nice like that.
  • We can certainly talk about cleaning up the API here. It shouldn't be too drastic of a change, as we won't break any existing code along the way. I think just building a nice interface on top of it.

@mitchute
Copy link
Owner Author

Thanks, @Myoldmopar !

  • 1 is not complete. There are probably 10-ish more examples that need to be edited. I was just waiting on feedback on the approach before pushing it through.
  • Sure, if you don't mind, go ahead and break into pygfunction-core and pygfunction. FWIW, I prefer to have pygfunction be the version without Matplotlib, and have an extras version, but whatever. I guess we can try it one way, and then discuss it with Massimo when we submit the PR.
  • Sounds good, we'll just develop the API here and Massimo can tell us if he wants it in a separate PR.

@Myoldmopar
Copy link
Collaborator

  • FWIW, I prefer to have pygfunction be the version without Matplotlib, and have an extras version,

I do agree. The only reason I mentioned it is so that people who currently pip install pygfunction will have zero loss of functionality, and we'll simply need to depend on pygfunction-core instead.

@mitchute
Copy link
Owner Author

The only reason I mentioned it is so that people who currently pip install pygfunction will have zero loss of functionality, and we'll simply need to depend on pygfunction-core instead.

Make sense. Thanks.

@mitchute
Copy link
Owner Author

@Myoldmopar is this python 3.8 failure worth fixing given that it is on the verge of obsolescence?

@Myoldmopar
Copy link
Collaborator

Definitely not, time to pull that from the github workflow matrix.

@mitchute
Copy link
Owner Author

Cool. I'll remove it.

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.

3 participants