Skip to content

DOC: Created fundamentals doc for explanations in ufunc reference doc #19516

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

Merged
merged 6 commits into from
Aug 12, 2021

Conversation

Mukulikaa
Copy link
Contributor

Closes #16924

Changes:

  1. Moved all explanations from ufuncs.rst to a new doc in the Fundamentals section named basics.ufunc.rst.
  2. I have named the new doc as Universal functions (ufunc) basics but other suggestions are welcome.
  3. I have also rearranged the order of the sections a bit from the original doc. Let me know if it makes sense or should I change it back :)
  4. ufuncs.py in numpy/doc has a few examples in it but apart from that the explanations are more or else the same. I thought we could incorporate some examples into the new basics.ufunc.rst doc and remove the ufuncs.py file.

Let me know what y'all think!

cc: @melissawm @rossbar 🙂

Copy link
Member

@melissawm melissawm left a comment

Choose a reason for hiding this comment

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

Hi Mukulika! I like the organization and new examples, thanks for that!

I left a couple of comments about formatting (mostly links). I think I understand your goal with reorganizing the order of the sections but can you explain?

Finally, I haven't checked all the details to see if any of that text is outdated, but I'm trusting it's not. If it is maybe it can be updated in a follow-up.

Co-authored-by: Melissa Weber Mendonça <melissawm@gmail.com>
@Mukulikaa
Copy link
Contributor Author

Mukulikaa commented Aug 4, 2021

Thanks for helping me with the links @melissawm! As for the broadcasting section- I was wondering if we could remove most of it from here since the information already exists in the Broadcasting doc. We could add a line about Broadcastable arrays in the Broadcasting doc itself and shift the section link there. I am not sure if I should do it in this PR itself or make a separate one.

I think I understand your goal with reorganizing the order of the sections but can you explain?

The flow I thought about-

  • A brief introduction about ufuncs
  • How to use these ufuncs? - their methods and arguments
  • What will be the result after using these methods? - output type determination
  • How do ufuncs work? - broadcasting, type casting, internal buffers
  • Additional information for writing my own ufuncs - error handling
  • Additional information about ufuncs that doesn't require modifying the ufuncs themselves- overriding ufunc behavior

@Mukulikaa Mukulikaa marked this pull request as ready for review August 4, 2021 11:32
@melissawm
Copy link
Member

Yes about broadcasting - I'd keep the first part:

Each universal function takes array inputs and produces array outputs
by performing the core function element-wise on the inputs (where an
element is generally a scalar, but can be a vector or higher-order
sub-array for generalized ufuncs). Standard
broadcasting rules are applied so that inputs not sharing exactly the
same shapes can still be usefully operated on.

but maybe link to the main broadcasting doc for the rest (making sure no information is lost in the process)

As for the organization that makes total sense, thanks!

@Mukulikaa
Copy link
Contributor Author

I moved the Broadcastable arrays section to the Broadcasting doc. The "rules" that were written in that section are already explained in the doc so I decided to remove them. Also, let me know if this branch needs a rebase because I had to merge my broadcasting branch into this one and it adds an extra merge commit 🙂

@melissawm
Copy link
Member

melissawm commented Aug 11, 2021

You probably do need a rebase - but otherwise this looks good! Thanks for the great work here, @Mukulikaa !

I'll approve but wait for @rossbar to take a look :)

Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

Very nice work @Mukulikaa ! This is a big re-organization and you've done a nice job of moving & consolidating the relevant info on ufuncs and broadcasting without (AFAICT) losing anything - no small feat!

The page on ufuncs in the reference guide now reads much more like reference material, and the material that was in the theory.broadcasting doc is now much more discoverable. Thanks!

@rossbar rossbar merged commit 4a1c0bf into numpy:main Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: Create a documentation subpage for ufunc
3 participants