Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Simplify svg font expansion logic. #24066

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

Merged
merged 1 commit into from
Oct 3, 2022
Merged

Simplify svg font expansion logic. #24066

merged 1 commit into from
Oct 3, 2022

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 1, 2022

We can delay quoting and deduplication until quite late.

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

We can delay quoting and deduplication until quite late.
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Optional comment on quoting.


def _get_all_quoted_names(prop):
# only quote specific names, not generic names
return [name if name in fm.font_family_aliases else repr(name)
Copy link
Member

Choose a reason for hiding this comment

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

We have used repr() before and it seems to have worked, but technically repr() is not exactly quoting. Would both single and double quotes be ok? Unlikely, but in theory Python could change that in repr (or possibly more likely an interpreter other than CPython could use other quotes). Also, can we be sure we will never have byte strings here?

It's more defensive to f-string the quotes explicitly.

Copy link
Member

Choose a reason for hiding this comment

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

Do browsers / svg viewers / svg care about double vs single quotes?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should be safe on byte strings though (I would say a byte string as a font name is a bug or at least un-defined behavior).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Single and double quotes are equally valid, and backslash-escaping quotes is valid as well: https://developer.mozilla.org/en-US/docs/Web/CSS/string

@tacaswell tacaswell added this to the v3.7.0 milestone Oct 2, 2022
@tacaswell
Copy link
Member

Both test failures are

 E       PIL.UnidentifiedImageError: cannot identify image file '/home/vsts/work/1/s/result_images/test_axes/hexbin_empty.png'

which is because we now have to tests that use the same underlying file

@image_comparison(['hexbin_empty.png'], remove_text=True)
def test_hexbin_empty():
# From #3886: creating hexbin from empty dataset raises ValueError
ax = plt.gca()
ax.hexbin([], [])
@image_comparison(['hexbin_empty.png'], remove_text=True)
def test_hexbin_log_empty():
# From #23922: creating hexbin with log scaling from empty
# dataset raises ValueError
ax = plt.gca()
ax.hexbin([], [], bins='log')

@tacaswell tacaswell merged commit 00b60ad into matplotlib:main Oct 3, 2022
@tacaswell
Copy link
Member

Merged and left the discussion about quotes to #24080

@anntzer anntzer deleted the svgf branch October 3, 2022 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants