Skip to content

CLN: fix invalid escapes - #5361

Closed
jbrockmendel wants to merge 15 commits into
statsmodels:masterfrom
jbrockmendel:W605b
Closed

jbrockmendel wants to merge 15 commits into
statsmodels:masterfrom
jbrockmendel:W605b

Conversation

@jbrockmendel

Copy link
Copy Markdown
Contributor

Some of these I recognize as having fixed before; let's finally get this over with and stop seeing DeprecationWarnings.

Zillions of unfixed ones in statsmodels/examples, most of them of the form "C:[username]..."

@coveralls

coveralls commented Nov 2, 2018 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.04%) to 84.495% when pulling 4117cf9 on jbrockmendel:W605b into 82d75bf on statsmodels:master.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

@thequackdaddy ping. Let’s teamwork this mama-jama.

@thequackdaddy

Copy link
Copy Markdown
Member

My employer is currently rolling out company values. One of them is “Teamwork divides the task and multiplies the success.” I’m a big fan of that one.

But I’m afraid of some of this. Seems some of these changes seem like they foul up the currently-working-albeit-incorrectly-typed LaTeX docstrinfs. Is there a way to have
(or did you use) a program/script to smartly decide when to change the string to a raw string vs add escape chars?

"support = np.linspace(-np.pi*a, np.pi*a, 100)\n",
"andrew = norms.AndrewWave(a=a)\n",
"plot_weights(support, andrew.weights, ['$-\\pi*a$', '0', '$\\pi*a$'], [-np.pi*a, 0, np.pi*a]);"
"plot_weights(support, andrew.weights, [r'$-\\pi*a$', r'0', r'$\\pi*a$'], [-np.pi*a, 0, np.pi*a]);"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these line already has double backslashes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When this gets rendered into python it is a single slash

@josef-pkt josef-pkt Nov 8, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

>>> r'$-\\pi*a$', r'0', r'$\\pi*a$'
('$-\\\\pi*a$', '0', '$\\\\pi*a$')

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How did you you produce this? i.e. did you copy/paste the line from the .ipynb into the REPL? Because I'm pretty sure the relevant thing to do is run the .ipynb through the script to convert it to a .py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I copied the string r'$-\\pi*a$', r'0', r'$\\pi*a$' to an interpreter (spyder python shell).
when I copy it in a regular jupyter notebook, then I get the same.
It is a string that goes to matplotlib, so the only reliable check would be to see how the plot in the notebook looks like.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted this edit, and rebased the branch.

@josef-pkt

Copy link
Copy Markdown
Member

all the regular expressions need the raw string r, which are the largest number of related warnings in the test runs, AFAICS.

I'm not sure for some of the others and docstrings might need actual proof reading.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

@thequackdaddy I can respect a healthy dose of caution. This Pr grew pretty big, but I’m happy to break it into pieces of whatever size reviewers will find comfortable. Mainly I’m interested in maintaining positive makes momentum.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

#5353 might be more regex-heavy (and much smaller). Lucky thing things like this don’t need deep knowledge of statsmodels, so any of the many talented, attractive contributors are qualified to review.

@josef-pkt

Copy link
Copy Markdown
Member

one unclear to me:
why does pandas read_csv delimiter \s+' need a raw string, eg. '\t cannot have a raw string because we mean "tab".
I just checked pandas doc and at least in the text \s+' is used without r`

I think the latex in docstrings should be standardized to r (unless it requires just one or two double backslashes)

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

Pandas docs/ dir is currently failing linting. Does that help explain anything?

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

Are we planning on fixing these at some point?

@josef-pkt

Copy link
Copy Markdown
Member

yes, but not this week
(I'm mostly offline this week because I'm required to watch replacing close to 30 windows in our new home.)

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

(I'm mostly offline this week because I'm required to watch replacing close to 30 windows in our new home.)

Yikes. I'm going to choose to believe that the old ones were lost in a truly epic ninja battle in which you single handedly kept the world safe for democracy.

(also, delegation is a thing)

@josef-pkt

Copy link
Copy Markdown
Member

I checked the python 3.7 documentation and the treatment of escape characters has not changed, AFAICS.
Only the specified escape sequences need double backslash, or raw string.
However, I agree that using raw strings is cleaner.

I just checked the current sphinx documentation for devel:
\|z\| is rendered correctly as vertical line with or without the raw string r'..'

@codecov

codecov Bot commented Nov 8, 2018

Copy link
Copy Markdown

Codecov Report

Merging #5361 into master will decrease coverage by 0.06%.
The diff coverage is 81.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5361      +/-   ##
==========================================
- Coverage   81.73%   81.66%   -0.07%     
==========================================
  Files         569      569              
  Lines       89809    89770      -39     
  Branches    10027     9304     -723     
==========================================
- Hits        73401    73312      -89     
- Misses      14132    14177      +45     
- Partials     2276     2281       +5
Impacted Files Coverage Δ
statsmodels/sandbox/tsa/diffusion.py 0% <ø> (ø) ⬆️
statsmodels/tools/eval_measures.py 96.15% <ø> (ø) ⬆️
statsmodels/sandbox/nonparametric/kernel_extras.py 31.17% <ø> (ø) ⬆️
statsmodels/sandbox/regression/penalized.py 69.79% <ø> (ø) ⬆️
statsmodels/genmod/families/links.py 96% <ø> (ø) ⬆️
statsmodels/tsa/statespace/tools.py 73.79% <ø> (ø) ⬆️
statsmodels/regression/mixed_linear_model.py 88.8% <ø> (-0.18%) ⬇️
statsmodels/stats/stattools.py 99.05% <ø> (ø) ⬆️
...atsmodels/tsa/regime_switching/markov_switching.py 87.38% <ø> (ø) ⬆️
statsmodels/sandbox/tsa/example_arma.py 0% <ø> (ø) ⬆️
... and 48 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 14fb572...517e2ce. Read the comment docs.

@codecov

codecov Bot commented Nov 8, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #5361 into master will decrease coverage by 0.27%.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5361      +/-   ##
==========================================
- Coverage   82.02%   81.75%   -0.28%     
==========================================
  Files         588      569      -19     
  Lines       93026    89851    -3175     
  Branches    10313    10022     -291     
==========================================
- Hits        76307    73455    -2852     
+ Misses      14357    14126     -231     
+ Partials     2362     2270      -92
Impacted Files Coverage Δ
statsmodels/tools/eval_measures.py 96.15% <ø> (ø) ⬆️
statsmodels/sandbox/nonparametric/kernel_extras.py 31.17% <ø> (ø) ⬆️
statsmodels/sandbox/regression/penalized.py 69.79% <ø> (ø) ⬆️
statsmodels/tsa/statespace/tools.py 73.79% <ø> (ø) ⬆️
statsmodels/stats/stattools.py 99.11% <ø> (ø) ⬆️
...atsmodels/tsa/regime_switching/markov_switching.py 87.38% <ø> (ø) ⬆️
statsmodels/sandbox/tsa/diffusion.py 0% <ø> (ø) ⬆️
statsmodels/sandbox/tsa/example_arma.py 0% <ø> (ø) ⬆️
statsmodels/sandbox/stats/diagnostic.py 58.97% <ø> (+0.33%) ⬆️
statsmodels/genmod/families/links.py 96% <ø> (ø) ⬆️
... and 80 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82d75bf...4117cf9. Read the comment docs.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

rebased

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

rebased

@bashtage bashtage mentioned this pull request Apr 30, 2019
@jbrockmendel
jbrockmendel deleted the W605b branch May 2, 2019 17:24
@bashtage bashtage added the rejected Used for PRs with changes that are not acceptable label Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rejected Used for PRs with changes that are not acceptable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants