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

refactor handout-tips scripts #94

Closed
wants to merge 5 commits into from

Conversation

jimustafa
Copy link
Contributor

@lgtm-com
Copy link

lgtm-com bot commented Nov 18, 2021

This pull request introduces 3 alerts and fixes 5 when merging fa241e2 into 5f45dcb - view on LGTM.com

new alerts:

  • 3 for Variable defined multiple times

fixed alerts:

  • 4 for Unused import
  • 1 for Variable defined multiple times

scripts/tips.py Outdated Show resolved Hide resolved
scripts/tips.py Outdated Show resolved Hide resolved
scripts/tips.py Outdated Show resolved Hide resolved
scripts/tips.py Outdated Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Nov 19, 2021

This pull request fixes 5 alerts when merging 7224cc5 into 5f45dcb - view on LGTM.com

fixed alerts:

  • 4 for Unused import
  • 1 for Variable defined multiple times

@rougier
Copy link
Member

rougier commented Nov 22, 2021

I prefer to have one file / one idea because I find difficult some time to get the code corresponding to an image when there are several examples in the same file (e.g. gallery). Furthermore, what do we gain by having a single file?

@timhoffm
Copy link
Member

timhoffm commented Nov 22, 2021

I don't have a strong opinion either way. Out of curiosity: what makes multiple files more manageable? The main obstacle is finding the appropriate name for a figure. Whether I then open [name].py or search for "[name].pdf" (from the savefig command) in a single file is no big difference.

@rougier
Copy link
Member

rougier commented Nov 22, 2021

Look for example https://matplotlib.org/2.0.2/examples/statistics/boxplot_demo.html. Source is compact but as a user, if you're interested in a specific subfigure, it takes your some time to identify the code. Having one script / figure make it easier to get the relevant code.

@jimustafa
Copy link
Contributor Author

Admittedly, consolidating the scripts is probably just a matter of taste. There may be some benefit in being able to more easily recognize code patterns and keeping things DRY. Could also be easier to keep a consistent style with a single file. Either way, not a big deal.

@lgtm-com
Copy link

lgtm-com bot commented Nov 23, 2021

This pull request fixes 5 alerts when merging e204e24 into c26b5c4 - view on LGTM.com

fixed alerts:

  • 4 for Unused import
  • 1 for Variable defined multiple times

- can help make things a bit more DRY
- remove unused tip-post-processing.py script
- replace calls to `plt` with `fig` or `ax` equivalents
Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

Mostly minor things.

But also, I see tip-post-processing.py was deleted, and I don't see it in the merged script?

fig.patch.set_alpha(0.0)
n = 1

fontsize = 18
Copy link
Member

Choose a reason for hiding this comment

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

Unused?

Comment on lines +107 to +112
fig = plt.figure(figsize=(5, 0.5))
fig.patch.set_alpha(0.0)
n = 1

fontsize = 18
ax = plt.subplot(n, 1, 1)
Copy link
Member

@QuLogic QuLogic Mar 29, 2023

Choose a reason for hiding this comment

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

Join fig, and ax, I think?

Suggested change
fig = plt.figure(figsize=(5, 0.5))
fig.patch.set_alpha(0.0)
n = 1
fontsize = 18
ax = plt.subplot(n, 1, 1)
fig, ax = plt.subplots(figsize=(5, 0.5))
fig.patch.set_alpha(0.0)
fontsize = 18

Comment on lines +87 to +88
# Setup a plot such that only the bottom spine is shown
def setup(ax):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Setup a plot such that only the bottom spine is shown
def setup(ax):
def setup(ax):
"""Setup a plot such that only the bottom spine is shown."""

Comment on lines +98 to +101
ax.tick_params(which='major', width=1.00)
ax.tick_params(which='major', length=5)
ax.tick_params(which='minor', width=0.75)
ax.tick_params(which='minor', length=2.5)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ax.tick_params(which='major', width=1.00)
ax.tick_params(which='major', length=5)
ax.tick_params(which='minor', width=0.75)
ax.tick_params(which='minor', length=2.5)
ax.tick_params(which='major', width=1.0, length=5)
ax.tick_params(which='minor', width=0.75, length=2.5)

Comment on lines +136 to +137
fig = plt.figure(figsize=(2, 2))
ax = plt.subplot()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fig = plt.figure(figsize=(2, 2))
ax = plt.subplot()
fig, ax = plt.subplots(figsize=(2, 2))

fig = plt.figure(figsize=(2, 2), dpi=100)
ax = fig.add_axes(rect)
n = 500
np.random.seed(5)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
np.random.seed(5)
np.random.seed(123)

@rougier
Copy link
Member

rougier commented Mar 29, 2023

Again, I don't see the advantage of having a single script. I think it is easier to have well named isolated scripts that make things easier to find for the user.

@jimustafa
Copy link
Contributor Author

Again, I don't see the advantage of having a single script. I think it is easier to have well named isolated scripts that make things easier to find for the user.

I get it. Was not sure a decision was made on this PR, so I just rebased so that it could be merged. Combining the scripts could help reduce repetition, especially as we add more per-script configuration, as in #127 and #129.

Anyways, I will close for now, and can reopen if opinion changes. Thanks!

@jimustafa jimustafa closed this Mar 30, 2023
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

4 participants