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

[pre-commit.ci] pre-commit autoupdate #204

Merged
merged 4 commits into from
Jul 11, 2023

Conversation

pre-commit-ci bot added 2 commits July 3, 2023 18:36
updates:
- [github.com/adamchainz/blacken-docs: 1.13.0 → 1.14.0](adamchainz/blacken-docs@1.13.0...1.14.0)
- [github.com/charliermarsh/ruff-pre-commit: v0.0.260 → v0.0.275](astral-sh/ruff-pre-commit@v0.0.260...v0.0.275)
@neutrinoceros
Copy link
Member

Looks like ruff upgrading string interpolation style leads to syntax errors when said interpolated strings are processed through eval, but only on Python 3.8 and 3.9;
It may be the case that unyt is doing something fragile with string interpolation, or that string interpolation rules are slightly different in Python 3.10 and ruff wrongly assumes the change is backward compatible for all Python versions.
I don't have the time necessary to sort it out at the moment but I intend to come back to this later.

@neutrinoceros neutrinoceros marked this pull request as draft July 3, 2023 20:20
@neutrinoceros
Copy link
Member

The issue is that formatting methods are not equivalent for unyt_quantity objects

>>> import unyt as un
>>> a=1.0*un.cm
>>> print("%f" % a)
1.000000
>>> print("{:f}".format(a))
1.000000 cm

Note that this isn't dependent on the Python version we just happen to not hit the broken code on Python>=3.10 because many tests still require nose. Let me see if this can be fixed in unyt

@neutrinoceros
Copy link
Member

I currently do not understand how to change the behaviour of "%f" % a (overriding __mod__ and __rmod__ operators on unyt_array doesn't work), and even if it's possible, it would resolve the issue here, so let's try to use views instead.

@neutrinoceros neutrinoceros force-pushed the pre-commit-ci-update-config branch from 7c958fe to 1de1116 Compare July 10, 2023 17:40
@@ -364,8 +364,7 @@ def write_source_files(self, sources, wavelengths):
fhandle.write(str(source.radius) + " ")
fhandle.write(str(source.mass) + " ")
fhandle.write(
"%f %f %f"
% (source.position[0], source.position[1], source.position[2])
f"{source.position[0]:f} {source.position[1]:f} {source.position[2]:f}"
Copy link
Member

Choose a reason for hiding this comment

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

I suspect this is a breaking change too and that this function isn't fully tested

Copy link
Member

Choose a reason for hiding this comment

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

checked. It's not breaking because RadMC3DSource.position is a list of floats, without explicit units.

@neutrinoceros neutrinoceros marked this pull request as ready for review July 11, 2023 07:46
@neutrinoceros neutrinoceros merged commit 2006013 into main Jul 11, 2023
@neutrinoceros neutrinoceros deleted the pre-commit-ci-update-config branch July 11, 2023 07:46
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.

1 participant