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
Documentation correction of pyvw.py #2336
Conversation
@jackgerrits @gramhagen Please review the changes. The updated doc of pyvw.py with this diff is attached here. |
I have made the suggested changes. Please find the updated doc attached here. |
@jackgerrits Please review this. Thanks! |
I don't know if you have already check this so if not then
We can modify this length but Can you please follow this check in the doc. |
I will have a look at that and wrap the lines within 72 characters following the PEP8 style. |
@jackgerrits @gramhagen I have used numpy doc format of documentation, and PEP8 style to wrap the lines. Please review the changes. |
Please review this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, have you been able to run any python tests to make sure functionality didn't change?
It passes all the tests locally. |
Using repr with return the string wrapped in quotes, as it is the representation of that. Passing this to dedent will break the intended functionality of dedent. I really don't see a reason to combine repr and dedent |
Yes, I checked that it didn't work in all cases. I can fix it another way |
Hi @jackgerrits, I have added a new function to resolve this. It works in the following way:
|
What is the issue you are trying to solve here? If you're just trying to wrap long strings then you just have adjacent string literals. https://stackoverflow.com/questions/3346230/wrap-long-lines-in-python |
In order to display long lines(which here are broken into multiple lines because of length bounds, mostly error messages) as the single line at the user end instead to directly showing these multiple lines with indentation |
Okay, all you need to do is have string literals broken over several lines. They are automatically concatenated. Check out the link. |
python/vowpalwabbit/pyvw.py
Outdated
@@ -2,12 +2,35 @@ | |||
"""Python binding for pylibvw class""" | |||
|
|||
from __future__ import division | |||
import pylibvw | |||
from pylibvw import example as pylibvw_example, vw as pylibvw_vw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You must also import predictor and search.
This is technically changing the public interface of the package, so I am hesitant to merge this atm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to import it only when needed. It is because it creates a significant time difference in importing the module. Have a look at #2369(comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this break the public interface? Or is it still possible to do the below?
from vowpalwabbit import pyvw
pyvw.pylibvw.search...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't break the public interface. Just I meant to import required classes from pylibvw. Other functionalities remains the same as they are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahha, I wonder how will pyvw. pylibvw.search
work. As there is no such class/function named pylibvw
in pyvw
. So, I think this should not work presently too. I am not aware if python allows this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this break the public interface? Or is it still possible to do the below?
This won't work even in current master.
>>> from vowpalwabbit import pyvw
>>> pyvw.pylibvw.vw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'vowpalwabbit.pyvw' has no attribute 'pylibvw'
This PR seems to have turned into 2 things:
It looks like the original PR was to do with documentation. Can you please open a separate PR for the code changes? It's already a big one and I don't want to complicate this review further |
Sure! I will revert the changes related to code. And keep this limited to documentation. I will wait for this to merge, and then open related to code/lint |
I have limited this to doc fixes. I will be waiting for this to be merged for code fixes |
@jackgerrits Can you please restart Travis CI? |
Travis seems to be having some issues. Can you try pushing an empty commit to retrigger it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small change requested on prediction_type
python/vowpalwabbit/pyvw.py
Outdated
@@ -155,7 +155,7 @@ def get_prediction(ec, prediction_type): | |||
>>> import pylibvw | |||
>>> vw = pyvw.vw(quiet=True) | |||
>>> ex = vw.example('1 |a two features |b more features here') | |||
>>> pyvw.get_prediction(ex, pylibvw.vw.pSCALAR) | |||
>>> pyvw.get_prediction(ex, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you using an integer here? Please use the enum
Thanks @jackgerrits |
Fixes #2267
Description
After changing the documentation style to numpy docstyle in #2305, this PR aims at changing the docs of
pyvw.py
accordingly.