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

A sneaky invalid escape? #131

Open
AlecThomson opened this issue Nov 7, 2024 · 3 comments · May be fixed by #132
Open

A sneaky invalid escape? #131

AlecThomson opened this issue Nov 7, 2024 · 3 comments · May be fixed by #132

Comments

@AlecThomson
Copy link

Hi all,

I found something interesting on (basic import) testing a new package of mine. Nox + pytest picked up the following error on trying to import radio-beam:

__________________________________________________________________________________ ERROR collecting tests/test_package.py __________________________________________________________________________________
.nox/tests/lib/python3.11/site-packages/_pytest/python.py:493: in importtestmodule
    mod = import_path(
.nox/tests/lib/python3.11/site-packages/_pytest/pathlib.py:582: in import_path
    importlib.import_module(module_name)
../../../miniforge3/envs/arm311/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1204: in _gcd_import
    ???
<frozen importlib._bootstrap>:1176: in _find_and_load
    ???
<frozen importlib._bootstrap>:1147: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
.nox/tests/lib/python3.11/site-packages/_pytest/assertion/rewrite.py:184: in exec_module
    exec(co, module.__dict__)
tests/test_package.py:5: in <module>
    import featherpy as m
.nox/tests/lib/python3.11/site-packages/featherpy/__init__.py:10: in <module>
    from .core import *  # noqa: F403
.nox/tests/lib/python3.11/site-packages/featherpy/core.py:17: in <module>
    from radio_beam import Beam
.nox/tests/lib/python3.11/site-packages/radio_beam/__init__.py:7: in <module>
    from .multiple_beams import Beams
E     File "/Users/tho822/My Drive/repos/FeatherPy/.nox/tests/lib/python3.11/site-packages/radio_beam/multiple_beams.py", line 337
E       '''
E       ^^^
E   SyntaxError: invalid escape sequence '\e'

The offending line seems to be here

.

I can't see any funky characters directly, but it also seems to highlight the (admittedly very unimportant) inconsistent docstring quotes. Would you be open to adopting a switch to """ for all docstrings following PEP-257?

@AlecThomson AlecThomson linked a pull request Nov 7, 2024 that will close this issue
@a-detiste
Copy link
Contributor

I'm not sure that helps. I used this patch:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087040

--- a/radio_beam/multiple_beams.py
+++ b/radio_beam/multiple_beams.py
@@ -334,7 +334,7 @@
                 self.largest_beam(includemask)]
 
     def common_beam(self, includemask=None, method='pts', **kwargs):
-        '''
+        r'''
         Return the smallest common beam size. For set of two beams,
         the solution is solved analytically. All larger sets solve for the
         minimum volume ellipse using the

@keflavich
Copy link
Contributor

Yeah, the problem is in the latex. r''' is probably the right solution, though I might slightly prefer to s/\e/\\e/ (replace single-escape with double-escape) for a text block this large

@AlecThomson
Copy link
Author

Gah, apologies for not reading down a few lines further! 🫤 I've added the latex escapes to the latex, if that's useful. I've gone with the double-escape version, but can go with the raw-string if that's preferred.

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 a pull request may close this issue.

3 participants