Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Fix commands to make doc consistent #14243

Closed
wants to merge 15 commits into from

Conversation

ChaiBapchya
Copy link
Contributor

@ChaiBapchya ChaiBapchya commented Feb 23, 2019

Fixes #14232

Copy link
Contributor

@aaronmarkham aaronmarkham left a comment

Choose a reason for hiding this comment

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

Minor fix requested in the review... otherwise looks good. Thanks for these fixes!
I'd update your overview text to say "fixes #xxxxxxx" so that it should trigger an auto-close when this PR is merged. I'm not sure if "refer to" works the same way.

swapaxes(x, 0, 1) = [[ 1],
[ 2],
[ 3]]
>>> x = mx.nd.array([[1, 2, 3]]) //(1,3) array
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment breaks things. I'd just get rid of it... or put the comment on it's own line.

[ 2, 3]],
[[ 4, 5],
[ 6, 7]]] // (2,2,2) array
>>> x = mx.nd.array([[[ 0, 1],[ 2, 3]],[[ 4, 5],[ 6, 7]]]) // (2,2,2) array
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment breaks things.

@aaronmarkham
Copy link
Contributor

BTW, one reason I can a sort of see why there's this abstraction from Python-specific code, is that this docstrings are pulled into the other API's docs. I'm not saying it's the best way, but it is what's going on. So if each of these sections are updated, and there are tons more in this state, we'll see very pythonic code examples in the R or Scala docs (not just these either). That could make things worse as opposed to these code examples being more of pseudo-code.

@ChaiBapchya
Copy link
Contributor Author

ChaiBapchya commented Feb 26, 2019

@aaronmarkham Thanks for your review. Your point makes sense.

In that case, we need to close this PR and start another PR that changes the examples in Pythonic way to pseudocode

At the moment, there are few examples in Pythonic way, few in pseudo-code.

We need to settle on one.
@aaronmarkham
What do you think is better?
Should we start a discussion on dev for this? or it's too trivial for that?

@aaronmarkham
Copy link
Contributor

I emailed the dev list about this issue yesterday. No response yet. I'm really not sure what the best way to proceed is.... I agree the examples should be executable, but things are complicated by how much is borrowed to support the docs for the other APIs. Let's see what dev@ says.

@vandanavk
Copy link
Contributor

@mxnet-label-bot add [pr-work-in-progress]

@marcoabreu marcoabreu added the pr-work-in-progress PR is still work in progress label Mar 4, 2019
@aaronmarkham
Copy link
Contributor

@ChaiBapchya - here's Mu's response to my question though I'm not sure how it applies to this PR.
@mli Can you take a look at this PR and provide your suggestion?

[ 5., 5.],
[ 6., 6.],
[ 7., 7.],
[ 8., 8.]]
Copy link
Member

Choose a reason for hiding this comment

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

Have the community decided to remove all language-agnostic pseudo code example? Other language binding may loose the only available example

@aaronmarkham
Copy link
Contributor

Let's take the concat operator example. Assume we leave in the pseudo-code as is.
Then we still have something that doesn't execute in the Python API docs. All I'm seeing is auto-summary outputs for ndarray.concat or ndarray.sparse.concat or symbol.concat which just dump whatever is in the concat.cc file's docstring.

So if we were to add the example in runnable python code, where would it go?

@eric-haibin-lin
Copy link
Member

@aaronmarkham it should go to https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/ndarray_doc.py
You can see examples for ndarray.Reshape and ndarray.elemwise_add.

@aaronmarkham
Copy link
Contributor

Ok I asked Mu about that file on the dev list. I am beginning to understand, but I feel like there's a lot missing. Are you saying that 99% of the examples for ndarray do not exist because they're not in that file?
I'm not clear yet on when something goes there versus elsewhere and why there aren't any more xyz_doc.py files.

@eric-haibin-lin
Copy link
Member

I think it's just a way to append python specific examples

@piyushghai
Copy link
Contributor

@ChaiBapchya Can you address the review comments and rebase with the latest master branch ?

@ChaiBapchya
Copy link
Contributor Author

@piyushghai I am still waiting for conclusive next steps. I am not sure if consensus was reached on dev list or the discussion here. Any idea how we can get clarity? Thanks.

@eric-haibin-lin
Copy link
Member

I am suggesting that python specific examples should be added to https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/ndarray_doc.py#L57
Is anything not clear?

@ChaiBapchya ChaiBapchya requested a review from szha as a code owner April 10, 2019 09:15
@ChaiBapchya
Copy link
Contributor Author

@eric-haibin-lin Wanted to verify if the latest commit is correct? Also not sure if all the doc should go in this one file alone or some other separate file and is there any other file that needs to know to "refer to python/ndarray_doc? Just making sure I haven't missed it. Thanks.

Copy link
Contributor

@aaronmarkham aaronmarkham left a comment

Choose a reason for hiding this comment

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

Can you provide a preview link? I'm curious how this is looking and how to compare it to what's live now.

<NDArray 2x2 @cpu(0)>
"""

class ReshapeLikeDoc(NDArrayDoc):
Copy link
Contributor

Choose a reason for hiding this comment

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

How are you deciding when to capitalize?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was actually confused. Originally, there were 2 variants
Capitalized - StackDoc, BroadcastToDoc, ReshapeDoc
Non-capitalized - elemwise_addDoc

I am not sure if I understood the difference. Any help on those lines would be great. Thanks for pointing out.

@ChaiBapchya
Copy link
Contributor Author

@aaronmarkham I'm sorry I'm unaware. Can you tell me where I can find preview links for docs? Thanks.

Copy link
Member

@eric-haibin-lin eric-haibin-lin left a comment

Choose a reason for hiding this comment

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

python/mxnet/ndarray_doc.py Show resolved Hide resolved
python/mxnet/ndarray_doc.py Show resolved Hide resolved
python/mxnet/ndarray_doc.py Show resolved Hide resolved
@aaronmarkham
Copy link
Contributor

Restarted CI job (some MKL-DNN test failed, so let's see if it goes through this time...)

<NDArray 1 @cpu(0)>
"""

class CastDoc(NDArrayDoc):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you think that return type is gone now? Look at prod, then look a the preview....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely no idea why.

python/mxnet/ndarray_doc.py Outdated Show resolved Hide resolved
>>> y = mx.nd.array([[3,3],[4,4],[5,5]])
>>> z = mx.nd.array([[6,6], [7,7],[8,8]])

>>> mx.nd.concat(x,y,z,dim=0)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not seeing this show up in the preview...

Copy link
Member

Choose a reason for hiding this comment

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

I do see it. Did you look at the right one?

http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-14243/7/api/python/ndarray/ndarray.html#mxnet.ndarray.Concat

The preview link is versioned, as mentioned in the pull request checklist:

Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the previous API render the interpreter prompt, but this one does not? It looks close, but I think they're different because it is missing these:
>>> y = mx.nd.array([[3,3],[4,4],[5,5]])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any idea why?

Copy link
Member

Choose a reason for hiding this comment

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

Screen Shot 2019-05-11 at 11 35 36 AM

It looks close, but I think they're different because it is missing these:
>>> y = mx.nd.array([[3,3],[4,4],[5,5]])

I did find this. What do you think is missing????

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya, I guess he was looking at some other preview doc.


Return the elements, either from x or y, depending on the condition.

>>> x = mx.nd.array([[1, 2], [3, 4]])
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't render right.

@aaronmarkham
Copy link
Contributor

There are some rendering issues - likely just needs some extra line returns. Also, I think that because there are operators that use opname and Opname that seem to be similar, the docs functions should map exactly. For example, concat and Concat would have concatDoc and ConcatDoc.

Copy link
Contributor

@aaronmarkham aaronmarkham left a comment

Choose a reason for hiding this comment

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

@karan6181
Copy link
Contributor

@ChaiBapchya Thanks for your contribution!
@eric-haibin-lin Could you please review it again? Thanks!

@ChaiBapchya
Copy link
Contributor Author

Since the launch of the new website, we don't depend on this file anymore. Hence closing this as stale PR

@ChaiBapchya ChaiBapchya closed this Nov 5, 2019
@ChaiBapchya ChaiBapchya deleted the fix_ndarray_api_doc branch November 5, 2019 01:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Doc pr-work-in-progress PR is still work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Many examples of operators in NDArray API are not executable
7 participants