summaryrefslogtreecommitdiff
path: root/doc/source
diff options
context:
space:
mode:
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/_static/numpy.css40
-rw-r--r--doc/source/_templates/indexcontent.html2
-rw-r--r--doc/source/_templates/layout.html14
-rw-r--r--doc/source/about.rst62
-rw-r--r--doc/source/dev/conduct/code_of_conduct.rst163
-rw-r--r--doc/source/dev/conduct/report_handling_manual.rst220
-rw-r--r--doc/source/dev/development_workflow.rst37
-rw-r--r--doc/source/dev/index.rst2
-rw-r--r--doc/source/doc_conventions.rst23
-rw-r--r--doc/source/docs/howto_document.rst37
-rw-r--r--doc/source/f2py/allocarr_session.dat9
-rw-r--r--doc/source/f2py/common_session.dat6
-rw-r--r--doc/source/f2py/moddata_session.dat14
-rw-r--r--doc/source/glossary.rst513
-rw-r--r--doc/source/reference/arrays.indexing.rst8
-rw-r--r--doc/source/reference/arrays.interface.rst10
-rw-r--r--doc/source/reference/c-api/array.rst8
-rw-r--r--doc/source/reference/c-api/config.rst15
-rw-r--r--doc/source/reference/c-api/dtype.rst12
-rw-r--r--doc/source/reference/c-api/iterator.rst2
-rw-r--r--doc/source/reference/c-api/types-and-structures.rst4
-rw-r--r--doc/source/reference/routines.set.rst5
-rw-r--r--doc/source/user/basics.rec.rst11
-rw-r--r--doc/source/user/index.rst7
-rw-r--r--doc/source/user/quickstart.rst2
25 files changed, 407 insertions, 819 deletions
diff --git a/doc/source/_static/numpy.css b/doc/source/_static/numpy.css
new file mode 100644
index 000000000..22d08cc0d
--- /dev/null
+++ b/doc/source/_static/numpy.css
@@ -0,0 +1,40 @@
+@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;0,900;1,400;1,700;1,900&family=Open+Sans:ital,wght@0,400;0,600;1,400;1,600&display=swap');
+
+.navbar-brand img {
+ height: 75px;
+}
+.navbar-brand {
+ height: 75px;
+}
+
+body {
+ font-family: 'Open Sans', sans-serif;
+ color:#4A4A4A; /* numpy.org body color */
+}
+
+pre, code {
+ font-size: 100%;
+ line-height: 155%;
+}
+
+h1 {
+ font-style: "Lato", sans-serif;
+ color: #013243; /* warm black */
+ font-weight: 700;
+ letter-spacing: -.04em;
+ text-align: right;
+ margin-top: 3rem;
+ margin-bottom: 4rem;
+ font-size: 3rem;
+}
+
+
+h2 {
+ color: #4d77cf; /* han blue */
+ letter-spacing: -.03em;
+}
+
+h3 {
+ color: #013243; /* warm black */
+ letter-spacing: -.03em;
+}
diff --git a/doc/source/_templates/indexcontent.html b/doc/source/_templates/indexcontent.html
index 5929e755d..6633aa9be 100644
--- a/doc/source/_templates/indexcontent.html
+++ b/doc/source/_templates/indexcontent.html
@@ -56,7 +56,7 @@
<p class="biglink"><a class="biglink" href="{{ pathto("bugs") }}">Reporting bugs</a></p>
<p class="biglink"><a class="biglink" href="{{ pathto("release") }}">Release Notes</a></p>
</td><td width="50%">
- <p class="biglink"><a class="biglink" href="{{ pathto("about") }}">About NumPy</a></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("doc_conventions") }}">Document conventions</a></p>
<p class="biglink"><a class="biglink" href="{{ pathto("license") }}">License of NumPy</a></p>
</td></tr>
</table>
diff --git a/doc/source/_templates/layout.html b/doc/source/_templates/layout.html
index 0b0ba6271..e2812fdd5 100644
--- a/doc/source/_templates/layout.html
+++ b/doc/source/_templates/layout.html
@@ -1,16 +1,10 @@
{% extends "!layout.html" %}
{%- block extrahead %}
- <!-- this is added via javascript in versionwarning.js -->
+{{ super() }}
+<link rel="stylesheet" href="{{ pathto('_static/numpy.css', 1) }}" type="text/css" />
+
+ <!-- PR #17220: This is added via javascript in versionwarning.js -->
<!-- link rel="canonical" href="http://numpy.org/doc/stable/{{ pagename }}{{ file_suffix }}" / -->
-<style>
-.navbar-brand img {
- height: 75px;
-}
-.navbar-brand {
- height: 75px;
-}
-</style>
-{{ super() }}
{% endblock %}
diff --git a/doc/source/about.rst b/doc/source/about.rst
deleted file mode 100644
index 3e83833d1..000000000
--- a/doc/source/about.rst
+++ /dev/null
@@ -1,62 +0,0 @@
-About NumPy
-===========
-
-NumPy is the fundamental package
-needed for scientific computing with Python. This package contains:
-
-- a powerful N-dimensional :ref:`array object <arrays>`
-- sophisticated :ref:`(broadcasting) functions <ufuncs>`
-- basic :ref:`linear algebra functions <routines.linalg>`
-- basic :ref:`Fourier transforms <routines.fft>`
-- sophisticated :ref:`random number capabilities <numpyrandom>`
-- tools for integrating Fortran code
-- tools for integrating C/C++ code
-
-Besides its obvious scientific uses, *NumPy* can also be used as an
-efficient multi-dimensional container of generic data. Arbitrary
-data types can be defined. This allows *NumPy* to seamlessly and
-speedily integrate with a wide variety of databases.
-
-NumPy is a successor for two earlier scientific Python libraries:
-Numeric and Numarray.
-
-NumPy community
----------------
-
-NumPy is a distributed, volunteer, open-source project. *You* can help
-us make it better; if you believe something should be improved either
-in functionality or in documentation, don't hesitate to contact us --- or
-even better, contact us and participate in fixing the problem.
-
-Our main means of communication are:
-
-- `scipy.org website <https://scipy.org/>`__
-
-- `Mailing lists <https://scipy.org/scipylib/mailing-lists.html>`__
-
-- `NumPy Issues <https://github.com/numpy/numpy/issues>`__ (bug reports go here)
-
-- `Old NumPy Trac <http://projects.scipy.org/numpy>`__ (dead link)
-
-More information about the development of NumPy can be found at our `Developer Zone <https://scipy.scipy.org/scipylib/dev-zone.html>`__.
-
-The project management structure can be found at our :doc:`governance page <dev/governance/index>`
-
-
-About this documentation
-========================
-
-Conventions
------------
-
-Names of classes, objects, constants, etc. are given in **boldface** font.
-Often they are also links to a more detailed documentation of the
-referred object.
-
-This manual contains many examples of use, usually prefixed with the
-Python prompt ``>>>`` (which is not a part of the example code). The
-examples assume that you have first entered::
-
->>> import numpy as np
-
-before running the examples.
diff --git a/doc/source/dev/conduct/code_of_conduct.rst b/doc/source/dev/conduct/code_of_conduct.rst
deleted file mode 100644
index f2f0a536d..000000000
--- a/doc/source/dev/conduct/code_of_conduct.rst
+++ /dev/null
@@ -1,163 +0,0 @@
-NumPy Code of Conduct
-=====================
-
-
-Introduction
-------------
-
-This code of conduct applies to all spaces managed by the NumPy project,
-including all public and private mailing lists, issue trackers, wikis, blogs,
-Twitter, and any other communication channel used by our community. The NumPy
-project does not organise in-person events, however events related to our
-community should have a code of conduct similar in spirit to this one.
-
-This code of conduct should be honored by everyone who participates in
-the NumPy community formally or informally, or claims any affiliation with the
-project, in any project-related activities and especially when representing the
-project, in any role.
-
-This code is not exhaustive or complete. It serves to distill our common
-understanding of a collaborative, shared environment and goals. Please try to
-follow this code in spirit as much as in letter, to create a friendly and
-productive environment that enriches the surrounding community.
-
-
-Specific Guidelines
--------------------
-
-We strive to:
-
-1. Be open. We invite anyone to participate in our community. We prefer to use
- public methods of communication for project-related messages, unless
- discussing something sensitive. This applies to messages for help or
- project-related support, too; not only is a public support request much more
- likely to result in an answer to a question, it also ensures that any
- inadvertent mistakes in answering are more easily detected and corrected.
-
-2. Be empathetic, welcoming, friendly, and patient. We work together to resolve
- conflict, and assume good intentions. We may all experience some frustration
- from time to time, but we do not allow frustration to turn into a personal
- attack. A community where people feel uncomfortable or threatened is not a
- productive one.
-
-3. Be collaborative. Our work will be used by other people, and in turn we will
- depend on the work of others. When we make something for the benefit of the
- project, we are willing to explain to others how it works, so that they can
- build on the work to make it even better. Any decision we make will affect
- users and colleagues, and we take those consequences seriously when making
- decisions.
-
-4. Be inquisitive. Nobody knows everything! Asking questions early avoids many
- problems later, so we encourage questions, although we may direct them to
- the appropriate forum. We will try hard to be responsive and helpful.
-
-5. Be careful in the words that we choose. We are careful and respectful in
- our communication and we take responsibility for our own speech. Be kind to
- others. Do not insult or put down other participants. We will not accept
- harassment or other exclusionary behaviour, such as:
-
- - Violent threats or language directed against another person.
- - Sexist, racist, or otherwise discriminatory jokes and language.
- - Posting sexually explicit or violent material.
- - Posting (or threatening to post) other people's personally identifying information ("doxing").
- - Sharing private content, such as emails sent privately or non-publicly,
- or unlogged forums such as IRC channel history, without the sender's consent.
- - Personal insults, especially those using racist or sexist terms.
- - Unwelcome sexual attention.
- - Excessive profanity. Please avoid swearwords; people differ greatly in their sensitivity to swearing.
- - Repeated harassment of others. In general, if someone asks you to stop, then stop.
- - Advocating for, or encouraging, any of the above behaviour.
-
-
-Diversity Statement
--------------------
-
-The NumPy project welcomes and encourages participation by everyone. We are
-committed to being a community that everyone enjoys being part of. Although
-we may not always be able to accommodate each individual's preferences, we try
-our best to treat everyone kindly.
-
-No matter how you identify yourself or how others perceive you: we welcome you.
-Though no list can hope to be comprehensive, we explicitly honour diversity in:
-age, culture, ethnicity, genotype, gender identity or expression, language,
-national origin, neurotype, phenotype, political beliefs, profession, race,
-religion, sexual orientation, socioeconomic status, subculture and technical
-ability, to the extent that these do not conflict with this code of conduct.
-
-
-Though we welcome people fluent in all languages, NumPy development is
-conducted in English.
-
-Standards for behaviour in the NumPy community are detailed in the Code of
-Conduct above. Participants in our community should uphold these standards
-in all their interactions and help others to do so as well (see next section).
-
-
-Reporting Guidelines
---------------------
-
-We know that it is painfully common for internet communication to start at or
-devolve into obvious and flagrant abuse. We also recognize that sometimes
-people may have a bad day, or be unaware of some of the guidelines in this Code
-of Conduct. Please keep this in mind when deciding on how to respond to a
-breach of this Code.
-
-For clearly intentional breaches, report those to the Code of Conduct committee
-(see below). For possibly unintentional breaches, you may reply to the person
-and point out this code of conduct (either in public or in private, whatever is
-most appropriate). If you would prefer not to do that, please feel free to
-report to the Code of Conduct Committee directly, or ask the Committee for
-advice, in confidence.
-
-You can report issues to the NumPy Code of Conduct committee, at
-numpy-conduct@googlegroups.com. Currently, the committee consists of:
-
-- Stefan van der Walt
-- Melissa Weber Mendonça
-- Anirudh Subramanian
-
-If your report involves any members of the committee, or if they feel they have
-a conflict of interest in handling it, then they will recuse themselves from
-considering your report. Alternatively, if for any reason you feel
-uncomfortable making a report to the committee, then you can also contact:
-
-- Senior `NumFOCUS staff <https://numfocus.org/code-of-conduct#persons-responsible>`__: conduct@numfocus.org
-
-
-Incident reporting resolution & Code of Conduct enforcement
------------------------------------------------------------
-
-*This section summarizes the most important points, more details can be found
-in* :ref:`CoC_reporting_manual`.
-
-We will investigate and respond to all complaints. The NumPy Code of Conduct
-Committee and the NumPy Steering Committee (if involved) will protect the
-identity of the reporter, and treat the content of complaints as confidential
-(unless the reporter agrees otherwise).
-
-In case of severe and obvious breaches, e.g. personal threat or violent, sexist
-or racist language, we will immediately disconnect the originator from NumPy
-communication channels; please see the manual for details.
-
-In cases not involving clear severe and obvious breaches of this code of
-conduct, the process for acting on any received code of conduct violation
-report will be:
-
-1. acknowledge report is received
-2. reasonable discussion/feedback
-3. mediation (if feedback didn't help, and only if both reporter and reportee agree to this)
-4. enforcement via transparent decision (see :ref:`CoC_resolutions`) by the
- Code of Conduct Committee
-
-The committee will respond to any report as soon as possible, and at most
-within 72 hours.
-
-
-Endnotes
---------
-
-We are thankful to the groups behind the following documents, from which we
-drew content and inspiration:
-
-- `The SciPy Code of Conduct <https://docs.scipy.org/doc/scipy/reference/dev/conduct/code_of_conduct.html>`_
-
diff --git a/doc/source/dev/conduct/report_handling_manual.rst b/doc/source/dev/conduct/report_handling_manual.rst
deleted file mode 100644
index d39b615bb..000000000
--- a/doc/source/dev/conduct/report_handling_manual.rst
+++ /dev/null
@@ -1,220 +0,0 @@
-:orphan:
-
-.. _CoC_reporting_manual:
-
-NumPy Code of Conduct - How to follow up on a report
-----------------------------------------------------
-
-This is the manual followed by NumPy's Code of Conduct Committee. It's used
-when we respond to an issue to make sure we're consistent and fair.
-
-Enforcing the Code of Conduct impacts our community today and for the future.
-It's an action that we do not take lightly. When reviewing enforcement
-measures, the Code of Conduct Committee will keep the following values and
-guidelines in mind:
-
-* Act in a personal manner rather than impersonal. The Committee can engage
- the parties to understand the situation, while respecting the privacy and any
- necessary confidentiality of reporters. However, sometimes it is necessary
- to communicate with one or more individuals directly: the Committee's goal is
- to improve the health of our community rather than only produce a formal
- decision.
-
-* Emphasize empathy for individuals rather than judging behavior, avoiding
- binary labels of "good" and "bad/evil". Overt, clear-cut aggression and
- harassment exists and we will be address that firmly. But many scenarios
- that can prove challenging to resolve are those where normal disagreements
- devolve into unhelpful or harmful behavior from multiple parties.
- Understanding the full context and finding a path that re-engages all is
- hard, but ultimately the most productive for our community.
-
-* We understand that email is a difficult medium and can be isolating.
- Receiving criticism over email, without personal contact, can be
- particularly painful. This makes it especially important to keep an
- atmosphere of open-minded respect of the views of others. It also means
- that we must be transparent in our actions, and that we will do everything
- in our power to make sure that all our members are treated fairly and with
- sympathy.
-
-* Discrimination can be subtle and it can be unconscious. It can show itself
- as unfairness and hostility in otherwise ordinary interactions. We know
- that this does occur, and we will take care to look out for it. We would
- very much like to hear from you if you feel you have been treated unfairly,
- and we will use these procedures to make sure that your complaint is heard
- and addressed.
-
-* Help increase engagement in good discussion practice: try to identify where
- discussion may have broken down and provide actionable information, pointers
- and resources that can lead to positive change on these points.
-
-* Be mindful of the needs of new members: provide them with explicit support
- and consideration, with the aim of increasing participation from
- underrepresented groups in particular.
-
-* Individuals come from different cultural backgrounds and native languages.
- Try to identify any honest misunderstandings caused by a non-native speaker
- and help them understand the issue and what they can change to avoid causing
- offence. Complex discussion in a foreign language can be very intimidating,
- and we want to grow our diversity also across nationalities and cultures.
-
-*Mediation*: voluntary, informal mediation is a tool at our disposal. In
-contexts such as when two or more parties have all escalated to the point of
-inappropriate behavior (something sadly common in human conflict), it may be
-useful to facilitate a mediation process. This is only an example: the
-Committee can consider mediation in any case, mindful that the process is meant
-to be strictly voluntary and no party can be pressured to participate. If the
-Committee suggests mediation, it should:
-
-* Find a candidate who can serve as a mediator.
-* Obtain the agreement of the reporter(s). The reporter(s) have complete
- freedom to decline the mediation idea, or to propose an alternate mediator.
-* Obtain the agreement of the reported person(s).
-* Settle on the mediator: while parties can propose a different mediator than
- the suggested candidate, only if common agreement is reached on all terms can
- the process move forward.
-* Establish a timeline for mediation to complete, ideally within two weeks.
-
-The mediator will engage with all the parties and seek a resolution that is
-satisfactory to all. Upon completion, the mediator will provide a report
-(vetted by all parties to the process) to the Committee, with recommendations
-on further steps. The Committee will then evaluate these results (whether
-satisfactory resolution was achieved or not) and decide on any additional
-action deemed necessary.
-
-
-How the committee will respond to reports
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-When the committee (or a committee member) receives a report, they will first
-determine whether the report is about a clear and severe breach (as defined
-below). If so, immediate action needs to be taken in addition to the regular
-report handling process.
-
-Clear and severe breach actions
-+++++++++++++++++++++++++++++++
-
-We know that it is painfully common for internet communication to start at or
-devolve into obvious and flagrant abuse. We will deal quickly with clear and
-severe breaches like personal threats, violent, sexist or racist language.
-
-When a member of the Code of Conduct committee becomes aware of a clear and
-severe breach, they will do the following:
-
-* Immediately disconnect the originator from all NumPy communication channels.
-* Reply to the reporter that their report has been received and that the
- originator has been disconnected.
-* In every case, the moderator should make a reasonable effort to contact the
- originator, and tell them specifically how their language or actions
- qualify as a "clear and severe breach". The moderator should also say
- that, if the originator believes this is unfair or they want to be
- reconnected to NumPy, they have the right to ask for a review, as below, by
- the Code of Conduct Committee.
- The moderator should copy this explanation to the Code of Conduct Committee.
-* The Code of Conduct Committee will formally review and sign off on all cases
- where this mechanism has been applied to make sure it is not being used to
- control ordinary heated disagreement.
-
-Report handling
-+++++++++++++++
-
-When a report is sent to the committee they will immediately reply to the
-reporter to confirm receipt. This reply must be sent within 72 hours, and the
-group should strive to respond much quicker than that.
-
-If a report doesn't contain enough information, the committee will obtain all
-relevant data before acting. The committee is empowered to act on the Steering
-Council’s behalf in contacting any individuals involved to get a more complete
-account of events.
-
-The committee will then review the incident and determine, to the best of their
-ability:
-
-* What happened.
-* Whether this event constitutes a Code of Conduct violation.
-* Who are the responsible party(ies).
-* Whether this is an ongoing situation, and there is a threat to anyone's
- physical safety.
-
-This information will be collected in writing, and whenever possible the
-group's deliberations will be recorded and retained (i.e. chat transcripts,
-email discussions, recorded conference calls, summaries of voice conversations,
-etc).
-
-It is important to retain an archive of all activities of this committee to
-ensure consistency in behavior and provide institutional memory for the
-project. To assist in this, the default channel of discussion for this
-committee will be a private mailing list accessible to current and future
-members of the committee as well as members of the Steering Council upon
-justified request. If the Committee finds the need to use off-list
-communications (e.g. phone calls for early/rapid response), it should in all
-cases summarize these back to the list so there's a good record of the process.
-
-The Code of Conduct Committee should aim to have a resolution agreed upon within
-two weeks. In the event that a resolution can't be determined in that time, the
-committee will respond to the reporter(s) with an update and projected timeline
-for resolution.
-
-
-.. _CoC_resolutions:
-
-Resolutions
-~~~~~~~~~~~
-
-The committee must agree on a resolution by consensus. If the group cannot reach
-consensus and deadlocks for over a week, the group will turn the matter over to
-the Steering Council for resolution.
-
-
-Possible responses may include:
-
-* Taking no further action
-
- - if we determine no violations have occurred.
- - if the matter has been resolved publicly while the committee was considering responses.
-
-* Coordinating voluntary mediation: if all involved parties agree, the
- Committee may facilitate a mediation process as detailed above.
-* Remind publicly, and point out that some behavior/actions/language have been
- judged inappropriate and why in the current context, or can but hurtful to
- some people, requesting the community to self-adjust.
-* A private reprimand from the committee to the individual(s) involved. In this
- case, the group chair will deliver that reprimand to the individual(s) over
- email, cc'ing the group.
-* A public reprimand. In this case, the committee chair will deliver that
- reprimand in the same venue that the violation occurred, within the limits of
- practicality. E.g., the original mailing list for an email violation, but
- for a chat room discussion where the person/context may be gone, they can be
- reached by other means. The group may choose to publish this message
- elsewhere for documentation purposes.
-* A request for a public or private apology, assuming the reporter agrees to
- this idea: they may at their discretion refuse further contact with the
- violator. The chair will deliver this request. The committee may, if it
- chooses, attach "strings" to this request: for example, the group may ask a
- violator to apologize in order to retain one’s membership on a mailing list.
-* A "mutually agreed upon hiatus" where the committee asks the individual to
- temporarily refrain from community participation. If the individual chooses
- not to take a temporary break voluntarily, the committee may issue a
- "mandatory cooling off period".
-* A permanent or temporary ban from some or all NumPy spaces (mailing lists,
- gitter.im, etc.). The group will maintain records of all such bans so that
- they may be reviewed in the future or otherwise maintained.
-
-Once a resolution is agreed upon, but before it is enacted, the committee will
-contact the original reporter and any other affected parties and explain the
-proposed resolution. The committee will ask if this resolution is acceptable,
-and must note feedback for the record.
-
-Finally, the committee will make a report to the NumPy Steering Council (as
-well as the NumPy core team in the event of an ongoing resolution, such as a
-ban).
-
-The committee will never publicly discuss the issue; all public statements will
-be made by the chair of the Code of Conduct Committee or the NumPy Steering
-Council.
-
-
-Conflicts of Interest
-~~~~~~~~~~~~~~~~~~~~~
-
-In the event of any conflict of interest, a committee member must immediately
-notify the other members, and recuse themselves if necessary.
diff --git a/doc/source/dev/development_workflow.rst b/doc/source/dev/development_workflow.rst
index d5a49a9f9..1665cfddb 100644
--- a/doc/source/dev/development_workflow.rst
+++ b/doc/source/dev/development_workflow.rst
@@ -188,6 +188,16 @@ Standard acronyms to start the commit message with are::
REL: related to releasing numpy
+.. _workflow_mailing_list:
+
+Get the mailing list's opinion
+=======================================================
+
+If you plan a new feature or API change, it's wisest to first email the
+NumPy `mailing list <https://mail.python.org/mailman/listinfo/numpy-discussion>`_
+asking for comment. If you haven't heard back in a week, it's
+OK to ping the list again.
+
.. _asking-for-merging:
Asking for your changes to be merged with the main repo
@@ -197,15 +207,24 @@ When you feel your work is finished, you can create a pull request (PR). Github
has a nice help page that outlines the process for `filing pull requests`_.
If your changes involve modifications to the API or addition/modification of a
-function, you should
-
-- send an email to the `NumPy mailing list`_ with a link to your PR along with
- a description of and a motivation for your changes. This may generate
- changes and feedback. It might be prudent to start with this step if your
- change may be controversial.
-- add a release note to the ``doc/release/upcoming_changes/`` directory,
- following the instructions and format in the
- ``doc/release/upcoming_changes/README.rst`` file.
+function, add a release note to the ``doc/release/upcoming_changes/``
+directory, following the instructions and format in the
+``doc/release/upcoming_changes/README.rst`` file.
+
+
+.. _workflow_PR_timeline:
+
+Getting your PR reviewed
+========================
+
+We review pull requests as soon as we can, typically within a week. If you get
+no review comments within two weeks, feel free to ask for feedback by
+adding a comment on your PR (this will notify maintainers).
+
+If your PR is large or complicated, asking for input on the numpy-discussion
+mailing list may also be useful.
+
+
.. _rebasing-on-master:
diff --git a/doc/source/dev/index.rst b/doc/source/dev/index.rst
index c4f35b68f..020df0b2b 100644
--- a/doc/source/dev/index.rst
+++ b/doc/source/dev/index.rst
@@ -9,7 +9,6 @@ Contributing to NumPy
.. toctree::
:hidden:
- conduct/code_of_conduct
Git Basics <gitwash/index>
development_environment
development_workflow
@@ -293,7 +292,6 @@ The rest of the story
.. toctree::
:maxdepth: 2
- conduct/code_of_conduct
Git Basics <gitwash/index>
development_environment
development_workflow
diff --git a/doc/source/doc_conventions.rst b/doc/source/doc_conventions.rst
new file mode 100644
index 000000000..e2bc419d1
--- /dev/null
+++ b/doc/source/doc_conventions.rst
@@ -0,0 +1,23 @@
+.. _documentation_conventions:
+
+##############################################################################
+Documentation conventions
+##############################################################################
+
+- Names that look like :func:`numpy.array` are links to detailed
+ documentation.
+
+- Examples often include the Python prompt ``>>>``. This is not part of the
+ code and will cause an error if typed or pasted into the Python
+ shell. It can be safely typed or pasted into the IPython shell; the ``>>>``
+ is ignored.
+
+- Examples often use ``np`` as an alias for ``numpy``; that is, they assume
+ you've run::
+
+ >>> import numpy as np
+
+- If you're a code contributor writing a docstring, see :ref:`docstring_intro`.
+
+- If you're a writer contributing ordinary (non-docstring) documentation, see
+ :ref:`userdoc_guide`.
diff --git a/doc/source/docs/howto_document.rst b/doc/source/docs/howto_document.rst
index 9f9068ab3..ff726c67c 100644
--- a/doc/source/docs/howto_document.rst
+++ b/doc/source/docs/howto_document.rst
@@ -1,12 +1,41 @@
.. _howto-document:
-A Guide to NumPy/SciPy Documentation
-====================================
+A Guide to NumPy Documentation
+==============================
+
+.. _userdoc_guide:
User documentation
-*******************
-NumPy text documents should follow the `Google developer documentation style guide <https://developers.google.com/style>`_.
+******************
+- In general, we follow the
+ `Google developer documentation style guide <https://developers.google.com/style>`_.
+
+- NumPy style governs cases where:
+
+ - Google has no guidance, or
+ - We prefer not to use the Google style
+
+ Our current rules:
+
+ - We pluralize *index* as *indices* rather than
+ `indexes <https://developers.google.com/style/word-list#letter-i>`_,
+ following the precedent of :func:`numpy.indices`.
+
+ - For consistency we also pluralize *matrix* as *matrices*.
+
+- Grammatical issues inadequately addressed by the NumPy or Google rules are
+ decided by the section on "Grammar and Usage" in the most recent edition of
+ the `Chicago Manual of Style
+ <https://en.wikipedia.org/wiki/The_Chicago_Manual_of_Style>`_.
+
+- We welcome being
+ `alerted <https://github.com/numpy/numpy/issues>`_ to cases
+ we should add to the NumPy style rules.
+
+
+
+.. _docstring_intro:
Docstrings
**********
diff --git a/doc/source/f2py/allocarr_session.dat b/doc/source/f2py/allocarr_session.dat
index 754d9cb8b..ba168c22a 100644
--- a/doc/source/f2py/allocarr_session.dat
+++ b/doc/source/f2py/allocarr_session.dat
@@ -1,8 +1,11 @@
>>> import allocarr
>>> print(allocarr.mod.__doc__)
-b - 'f'-array(-1,-1), not allocated
-foo - Function signature:
- foo()
+b : 'f'-array(-1,-1), not allocated
+foo()
+
+Wrapper for ``foo``.
+
+
>>> allocarr.mod.foo()
b is not allocated
diff --git a/doc/source/f2py/common_session.dat b/doc/source/f2py/common_session.dat
index 0a38bec27..2595bfbd5 100644
--- a/doc/source/f2py/common_session.dat
+++ b/doc/source/f2py/common_session.dat
@@ -1,8 +1,8 @@
>>> import common
>>> print(common.data.__doc__)
-i - 'i'-scalar
-x - 'i'-array(4)
-a - 'f'-array(2,3)
+i : 'i'-scalar
+x : 'i'-array(4)
+a : 'f'-array(2,3)
>>> common.data.i = 5
>>> common.data.x[1] = 2
diff --git a/doc/source/f2py/moddata_session.dat b/doc/source/f2py/moddata_session.dat
index e3c758041..824bd86fc 100644
--- a/doc/source/f2py/moddata_session.dat
+++ b/doc/source/f2py/moddata_session.dat
@@ -1,10 +1,14 @@
>>> import moddata
>>> print(moddata.mod.__doc__)
-i - 'i'-scalar
-x - 'i'-array(4)
-a - 'f'-array(2,3)
-foo - Function signature:
- foo()
+i : 'i'-scalar
+x : 'i'-array(4)
+a : 'f'-array(2,3)
+b : 'f'-array(-1,-1), not allocated
+foo()
+
+Wrapper for ``foo``.
+
+
>>> moddata.mod.i = 5
>>> moddata.mod.x[:2] = [1,2]
diff --git a/doc/source/glossary.rst b/doc/source/glossary.rst
index 4a59c990b..17071c8f1 100644
--- a/doc/source/glossary.rst
+++ b/doc/source/glossary.rst
@@ -6,20 +6,27 @@ Glossary
(`n`,)
- A tuple with one element. The trailing comma distinguishes a one-element
- tuple from a parenthesized ``n``.
+ A parenthesized number followed by a comma denotes a tuple with one
+ element. The trailing comma distinguishes a one-element tuple from a
+ parenthesized ``n``.
-1
- Used as a dimension entry, ``-1`` instructs NumPy to choose the length
- that will keep the total number of elements the same.
+ - **In a dimension entry**, instructs NumPy to choose the length
+ that will keep the total number of array elements the same.
+ >>> np.arange(12).reshape(4, -1).shape
+ (4, 3)
- ``...``
- An :py:data:`Ellipsis`
+ - **In an index**, any negative value
+ `denotes <https://docs.python.org/dev/faq/programming.html#what-s-a-negative-index>`_
+ indexing from the right.
- **When indexing an array**, shorthand that the missing axes, if they
- exist, are full slices.
+ . . .
+ An :py:data:`Ellipsis`.
+
+ - **When indexing an array**, shorthand that the missing axes, if they
+ exist, are full slices.
>>> a = np.arange(24).reshape(2,3,4)
@@ -35,13 +42,13 @@ Glossary
>>> a[0,...,0].shape
(3,)
- It can be used at most once; ``a[...,0,...]`` raises an :exc:`IndexError`.
+ It can be used at most once; ``a[...,0,...]`` raises an :exc:`IndexError`.
- **In printouts**, NumPy substitutes ``...`` for the middle elements of
- large arrays. To see the entire array, use `numpy.printoptions`
+ - **In printouts**, NumPy substitutes ``...`` for the middle elements of
+ large arrays. To see the entire array, use `numpy.printoptions`
- ``:``
+ :
The Python :term:`python:slice`
operator. In ndarrays, slicing can be applied to every
axis:
@@ -73,14 +80,14 @@ Glossary
For details, see :ref:`combining-advanced-and-basic-indexing`.
- ``<``
+ <
In a dtype declaration, indicates that the data is
:term:`little-endian` (the bracket is big on the right). ::
>>> dt = np.dtype('<f') # little-endian single-precision float
- ``>``
+ >
In a dtype declaration, indicates that the data is
:term:`big-endian` (the bracket is big on the left). ::
@@ -95,54 +102,67 @@ Glossary
along an axis
- Axes are defined for arrays with more than one dimension. A
- 2-dimensional array has two corresponding axes: the first running
- vertically downwards across rows (axis 0), and the second running
- horizontally across columns (axis 1).
+ An operation `along axis n` of array ``a`` behaves as if its argument
+ were an array of slices of ``a`` where each slice has a successive
+ index of axis `n`.
- Many operations can take place along one of these axes. For example,
- we can sum each row of an array, in which case we operate along
- columns, or axis 1::
+ For example, if ``a`` is a 3 x `N` array, an operation along axis 0
+ behaves as if its argument were an array containing slices of each row:
- >>> x = np.arange(12).reshape((3,4))
+ >>> np.array((a[0,:], a[1,:], a[2,:])) #doctest: +SKIP
- >>> x
- array([[ 0, 1, 2, 3],
- [ 4, 5, 6, 7],
- [ 8, 9, 10, 11]])
+ To make it concrete, we can pick the operation to be the array-reversal
+ function :func:`numpy.flip`, which accepts an ``axis`` argument. We
+ construct a 3 x 4 array ``a``:
- >>> x.sum(axis=1)
- array([ 6, 22, 38])
+ >>> a = np.arange(12).reshape(3,4)
+ >>> a
+ array([[ 0, 1, 2, 3],
+ [ 4, 5, 6, 7],
+ [ 8, 9, 10, 11]])
+ Reversing along axis 0 (the row axis) yields
- array
- A homogeneous container of numerical elements. Each element in the
- array occupies a fixed amount of memory (hence homogeneous), and
- can be a numerical element of a single type (such as float, int
- or complex) or a combination (such as ``(float, int, float)``). Each
- array has an associated data-type (or ``dtype``), which describes
- the numerical type of its elements::
+ >>> np.flip(a,axis=0)
+ array([[ 8, 9, 10, 11],
+ [ 4, 5, 6, 7],
+ [ 0, 1, 2, 3]])
- >>> x = np.array([1, 2, 3], float)
+ Recalling the definition of `along an axis`, ``flip`` along axis 0 is
+ treating its argument as if it were
- >>> x
- array([ 1., 2., 3.])
+ >>> np.array((a[0,:], a[1,:], a[2,:]))
+ array([[ 0, 1, 2, 3],
+ [ 4, 5, 6, 7],
+ [ 8, 9, 10, 11]])
- >>> x.dtype # floating point number, 64 bits of memory per element
- dtype('float64')
+ and the result of ``np.flip(a,axis=0)`` is to reverse the slices:
+ >>> np.array((a[2,:],a[1,:],a[0,:]))
+ array([[ 8, 9, 10, 11],
+ [ 4, 5, 6, 7],
+ [ 0, 1, 2, 3]])
- # More complicated data type: each array element is a combination of
- # and integer and a floating point number
- >>> np.array([(1, 2.0), (3, 4.0)], dtype=[('x', np.int64), ('y', float)])
- array([(1, 2.), (3, 4.)], dtype=[('x', '<i8'), ('y', '<f8')])
- Fast element-wise operations, called a :term:`ufunc`, operate on arrays.
+ array
+ Used synonymously in the NumPy docs with :term:`ndarray`.
array_like
- Any sequence that can be interpreted as an ndarray. This includes
- nested lists, tuples, scalars and existing arrays.
+ Any :doc:`scalar <reference/arrays.scalars>` or
+ :term:`python:sequence`
+ that can be interpreted as an ndarray. In addition to ndarrays
+ and scalars this category includes lists (possibly nested and with
+ different element types) and tuples. Any argument accepted by
+ :doc:`numpy.array <reference/generated/numpy.array>`
+ is array_like. ::
+
+ >>> a = np.array([[1, 2.0], [0, 0], (1+1j, 3.)])
+
+ >>> a
+ array([[1.+0.j, 2.+0.j],
+ [0.+0.j, 0.+0.j],
+ [1.+1.j, 3.+0.j]])
array scalar
@@ -152,7 +172,6 @@ Glossary
axis
-
Another term for an array dimension. Axes are numbered left to right;
axis 0 is the first element in the shape tuple.
@@ -167,7 +186,6 @@ Glossary
>>> a
array([[[ 0, 1, 2],
[ 3, 4, 5]],
- <BLANKLINE>
[[ 6, 7, 8],
[ 9, 10, 11]]])
@@ -206,19 +224,16 @@ Glossary
.base
If an array does not own its memory, then its
- :doc:`base <reference/generated/numpy.ndarray.base>` attribute
- returns the object whose memory the array is referencing. That object
- may be borrowing the memory from still another object, so the
- owning object may be ``a.base.base.base...``. Despite advice to the
- contrary, testing ``base`` is not a surefire way to determine if two
- arrays are :term:`view`\ s.
+ :doc:`base <reference/generated/numpy.ndarray.base>` attribute returns
+ the object whose memory the array is referencing. That object may be
+ referencing the memory from still another object, so the owning object
+ may be ``a.base.base.base...``. Some writers erroneously claim that
+ testing ``base`` determines if arrays are :term:`view`\ s. For the
+ correct way, see :func:`numpy.shares_memory`.
big-endian
- When storing a multi-byte value in memory as a sequence of bytes, the
- sequence addresses/sends/stores the most significant byte first (lowest
- address) and the least significant byte last (highest address). Common in
- micro-processors and used for transmission of data over network protocols.
+ See `Endianness <https://en.wikipedia.org/wiki/Endianness>`_.
BLAS
@@ -226,244 +241,145 @@ Glossary
broadcast
- NumPy can do operations on arrays whose shapes are mismatched::
+ *broadcasting* is NumPy's ability to process ndarrays of
+ different sizes as if all were the same size.
- >>> x = np.array([1, 2])
- >>> y = np.array([[3], [4]])
+ It permits an elegant do-what-I-mean behavior where, for instance,
+ adding a scalar to a vector adds the scalar value to every element.
- >>> x
- array([1, 2])
+ >>> a = np.arange(3)
+ >>> a
+ array([0, 1, 2])
- >>> y
- array([[3],
- [4]])
+ >>> a + [3, 3, 3]
+ array([3, 4, 5])
+
+ >>> a + 3
+ array([3, 4, 5])
- >>> x + y
- array([[4, 5],
- [5, 6]])
+ Ordinarly, vector operands must all be the same size, because NumPy
+ works element by element -- for instance, ``c = a * b`` is ::
- See `basics.broadcasting` for more information.
+ c[0,0,0] = a[0,0,0] * b[0,0,0]
+ c[0,0,1] = a[0,0,1] * b[0,0,1]
+ ...
+
+ But in certain useful cases, NumPy can duplicate data along "missing"
+ axes or "too-short" dimensions so shapes will match. The duplication
+ costs no memory or time. For details, see
+ :doc:`Broadcasting. <user/basics.broadcasting>`
C order
- See `row-major`
+ Same as :term:`row-major`.
column-major
- A way to represent items in a N-dimensional array in the 1-dimensional
- computer memory. In column-major order, the leftmost index "varies the
- fastest": for example the array::
-
- [[1, 2, 3],
- [4, 5, 6]]
+ See `Row- and column-major order <https://en.wikipedia.org/wiki/Row-_and_column-major_order>`_.
- is represented in the column-major order as::
- [1, 4, 2, 5, 3, 6]
+ contiguous
+ An array is contiguous if
+ * it occupies an unbroken block of memory, and
+ * array elements with higher indexes occupy higher addresses (that
+ is, no :term:`stride` is negative).
- Column-major order is also known as the Fortran order, as the Fortran
- programming language uses it.
copy
-
See :term:`view`.
- decorator
- An operator that transforms a function. For example, a ``log``
- decorator may be defined to print debugging information upon
- function execution::
-
- >>> def log(f):
- ... def new_logging_func(*args, **kwargs):
- ... print("Logging call with parameters:", args, kwargs)
- ... return f(*args, **kwargs)
- ...
- ... return new_logging_func
-
- Now, when we define a function, we can "decorate" it using ``log``::
-
- >>> @log
- ... def add(a, b):
- ... return a + b
-
- Calling ``add`` then yields:
-
- >>> add(1, 2)
- Logging call with parameters: (1, 2) {}
- 3
-
-
- dictionary
- Resembling a language dictionary, which provides a mapping between
- words and descriptions thereof, a Python dictionary is a mapping
- between two objects::
-
- >>> x = {1: 'one', 'two': [1, 2]}
-
- Here, `x` is a dictionary mapping keys to values, in this case
- the integer 1 to the string "one", and the string "two" to
- the list ``[1, 2]``. The values may be accessed using their
- corresponding keys::
-
- >>> x[1]
- 'one'
-
- >>> x['two']
- [1, 2]
-
- Note that dictionaries are not stored in any specific order. Also,
- most mutable (see *immutable* below) objects, such as lists, may not
- be used as keys.
-
- For more information on dictionaries, read the
- `Python tutorial <https://docs.python.org/tutorial/>`_.
-
-
dimension
-
See :term:`axis`.
dtype
-
The datatype describing the (identically typed) elements in an ndarray.
It can be changed to reinterpret the array contents. For details, see
:doc:`Data type objects (dtype). <reference/arrays.dtypes>`
fancy indexing
-
Another term for :term:`advanced indexing`.
field
- In a :term:`structured data type`, each sub-type is called a `field`.
+ In a :term:`structured data type`, each subtype is called a `field`.
The `field` has a name (a string), a type (any valid dtype), and
- an optional `title`. See :ref:`arrays.dtypes`
+ an optional `title`. See :ref:`arrays.dtypes`.
Fortran order
- See `column-major`
+ Same as :term:`column-major`.
flattened
- Collapsed to a one-dimensional array. See `numpy.ndarray.flatten`
- for details.
+ See :term:`ravel`.
homogeneous
- Describes a block of memory comprised of blocks, each block comprised of
- items and of the same size, and blocks are interpreted in exactly the
- same way. In the simplest case each block contains a single item, for
- instance int32 or float64.
-
+ All elements of a homogeneous array have the same type. ndarrays, in
+ contrast to Python lists, are homogeneous. The type can be complicated,
+ as in a :term:`structured array`, but all elements have that type.
- immutable
- An object that cannot be modified after execution is called
- immutable. Two common examples are strings and tuples.
+ NumPy `object arrays <#term-object-array>`_, which contain references to
+ Python objects, fill the role of heterogeneous arrays.
itemsize
The size of the dtype element in bytes.
- list
- A Python container that can hold any number of objects or items.
- The items do not have to be of the same type, and can even be
- lists themselves::
-
- >>> x = [2, 2.0, "two", [2, 2.0]]
-
- The list `x` contains 4 items, each which can be accessed individually::
-
- >>> x[2] # the string 'two'
- 'two'
-
- >>> x[3] # a list, containing an integer 2 and a float 2.0
- [2, 2.0]
-
- It is also possible to select more than one item at a time,
- using *slicing*::
-
- >>> x[0:2] # or, equivalently, x[:2]
- [2, 2.0]
-
- In code, arrays are often conveniently expressed as nested lists::
-
-
- >>> np.array([[1, 2], [3, 4]])
- array([[1, 2],
- [3, 4]])
-
- For more information, read the section on lists in the `Python
- tutorial <https://docs.python.org/tutorial/>`_. For a mapping
- type (key-value), see *dictionary*.
-
-
little-endian
- When storing a multi-byte value in memory as a sequence of bytes, the
- sequence addresses/sends/stores the least significant byte first (lowest
- address) and the most significant byte last (highest address). Common in
- x86 processors.
+ See `Endianness <https://en.wikipedia.org/wiki/Endianness>`_.
mask
- A boolean array, used to select only certain elements for an operation::
+ A boolean array used to select only certain elements for an operation:
- >>> x = np.arange(5)
- >>> x
- array([0, 1, 2, 3, 4])
+ >>> x = np.arange(5)
+ >>> x
+ array([0, 1, 2, 3, 4])
- >>> mask = (x > 2)
- >>> mask
- array([False, False, False, True, True])
+ >>> mask = (x > 2)
+ >>> mask
+ array([False, False, False, True, True])
- >>> x[mask] = -1
- >>> x
- array([ 0, 1, 2, -1, -1])
+ >>> x[mask] = -1
+ >>> x
+ array([ 0, 1, 2, -1, -1])
masked array
- Array that suppressed values indicated by a mask::
+ Bad or missing data can be cleanly ignored by putting it in a masked
+ array, which has an internal boolean array indicating invalid
+ entries. Operations with masked arrays ignore these entries. ::
- >>> x = np.ma.masked_array([np.nan, 2, np.nan], [True, False, True])
- >>> x
+ >>> a = np.ma.masked_array([np.nan, 2, np.nan], [True, False, True])
+ >>> a
masked_array(data=[--, 2.0, --],
mask=[ True, False, True],
fill_value=1e+20)
- >>> x + [1, 2, 3]
+ >>> a + [1, 2, 3]
masked_array(data=[--, 4.0, --],
mask=[ True, False, True],
fill_value=1e+20)
-
- Masked arrays are often used when operating on arrays containing
- missing or invalid entries.
+ For details, see :doc:`Masked arrays. <reference/maskedarray>`
matrix
- A 2-dimensional ndarray that preserves its two-dimensional nature
- throughout operations. It has certain special operations, such as ``*``
- (matrix multiplication) and ``**`` (matrix power), defined::
-
- >>> x = np.mat([[1, 2], [3, 4]])
- >>> x
- matrix([[1, 2],
- [3, 4]])
-
- >>> x**2
- matrix([[ 7, 10],
- [15, 22]])
+ NumPy's two-dimensional
+ :doc:`matrix class <reference/generated/numpy.matrix>`
+ should no longer be used; use regular ndarrays.
ndarray
- See *array*.
+ :doc:`NumPy's basic structure <reference/arrays>`.
object array
-
An array whose dtype is ``object``; that is, it contains references to
Python objects. Indexing the array dereferences the Python objects, so
unlike other ndarrays, an object array has the ability to hold
@@ -471,72 +387,43 @@ Glossary
ravel
-
- `numpy.ravel` and `numpy.ndarray.flatten` both flatten an ndarray. ``ravel``
- will return a view if possible; ``flatten`` always returns a copy.
-
- Flattening collapses a multi-dimensional array to a single dimension;
+ :doc:`numpy.ravel \
+ <reference/generated/numpy.ravel>`
+ and :doc:`numpy.flatten \
+ <reference/generated/numpy.ndarray.flatten>`
+ both flatten an ndarray. ``ravel`` will return a view if possible;
+ ``flatten`` always returns a copy.
+
+ Flattening collapses a multimdimensional array to a single dimension;
details of how this is done (for instance, whether ``a[n+1]`` should be
the next row or next column) are parameters.
record array
- An :term:`ndarray` with :term:`structured data type` which has been
- subclassed as ``np.recarray`` and whose dtype is of type ``np.record``,
- making the fields of its data type to be accessible by attribute.
-
-
- reference
- If ``a`` is a reference to ``b``, then ``(a is b) == True``. Therefore,
- ``a`` and ``b`` are different names for the same Python object.
+ A :term:`structured array` with allowing access in an attribute style
+ (``a.field``) in addition to ``a['field']``. For details, see
+ :doc:`numpy.recarray. <reference/generated/numpy.recarray>`
row-major
- A way to represent items in a N-dimensional array in the 1-dimensional
- computer memory. In row-major order, the rightmost index "varies
- the fastest": for example the array::
-
- [[1, 2, 3],
- [4, 5, 6]]
-
- is represented in the row-major order as::
-
- [1, 2, 3, 4, 5, 6]
-
- Row-major order is also known as the C order, as the C programming
- language uses it. New NumPy arrays are by default in row-major order.
+ See `Row- and column-major order <https://en.wikipedia.org/wiki/Row-_and_column-major_order>`_.
+ NumPy creates arrays in row-major order by default.
- slice
- Used to select only certain elements from a sequence:
+ scalar
+ In NumPy, usually a synonym for :term:`array scalar`.
- >>> x = range(5)
- >>> x
- [0, 1, 2, 3, 4]
- >>> x[1:3] # slice from 1 to 3 (excluding 3 itself)
- [1, 2]
-
- >>> x[1:5:2] # slice from 1 to 5, but skipping every second element
- [1, 3]
-
- >>> x[::-1] # slice a sequence in reverse
- [4, 3, 2, 1, 0]
-
- Arrays may have more than one dimension, each which can be sliced
- individually:
-
- >>> x = np.array([[1, 2], [3, 4]])
- >>> x
- array([[1, 2],
- [3, 4]])
-
- >>> x[:, 1]
- array([2, 4])
+ shape
+ A tuple showing the length of each dimension of an ndarray. The
+ length of the tuple itself is the number of dimensions
+ (:doc:`numpy.ndim <reference/generated/numpy.ndarray.ndim>`).
+ The product of the tuple elements is the number of elements in the
+ array. For details, see
+ :doc:`numpy.ndarray.shape <reference/generated/numpy.ndarray.shape>`.
stride
-
Physical memory is one-dimensional; strides provide a mechanism to map
a given index to an address in memory. For an N-dimensional array, its
``strides`` attribute is an N-element tuple; advancing from index
@@ -555,56 +442,70 @@ Glossary
<https://arxiv.org/pdf/1102.1523.pdf>`_
- structure
- See :term:`structured data type`
-
-
structured array
-
Array whose :term:`dtype` is a :term:`structured data type`.
structured data type
- A data type composed of other datatypes
+ Users can create arbitrarily complex :term:`dtypes <dtype>`
+ that can include other arrays and dtypes. These composite dtypes are called
+ :doc:`structured data types. <user/basics.rec>`
- subarray data type
- A :term:`structured data type` may contain a :term:`ndarray` with its
- own dtype and shape:
+ subarray
+ An array nested in a :term:`structured data type`, as ``b`` is here:
+
+ >>> dt = np.dtype([('a', np.int32), ('b', np.float32, (3,))])
+ >>> np.zeros(3, dtype=dt)
+ array([(0, [0., 0., 0.]), (0, [0., 0., 0.]), (0, [0., 0., 0.])],
+ dtype=[('a', '<i4'), ('b', '<f4', (3,))])
- >>> dt = np.dtype([('a', np.int32), ('b', np.float32, (3,))])
- >>> np.zeros(3, dtype=dt)
- array([(0, [0., 0., 0.]), (0, [0., 0., 0.]), (0, [0., 0., 0.])],
- dtype=[('a', '<i4'), ('b', '<f4', (3,))])
+
+ subarray data type
+ An element of a structured datatype that behaves like an ndarray.
title
- In addition to field names, structured array fields may have an
- associated :ref:`title <titles>` which is an alias to the name and is
- commonly used for plotting.
+ An alias for a field name in a structured datatype.
+
+
+ type
+ In NumPy, usually a synonym for :term:`dtype`. For the more general
+ Python meaning, :term:`see here. <python:type>`
ufunc
- Universal function. A fast element-wise, :term:`vectorized
- <vectorization>` array operation. Examples include ``add``, ``sin`` and
- ``logical_or``.
+ NumPy's fast element-by-element computation (:term:`vectorization`)
+ gives a choice which function gets applied. The general term for the
+ function is ``ufunc``, short for ``universal function``. NumPy routines
+ have built-in ufuncs, but users can also
+ :doc:`write their own. <reference/ufuncs>`
vectorization
- Optimizing a looping block by specialized code. In a traditional sense,
- vectorization performs the same operation on multiple elements with
- fixed strides between them via specialized hardware. Compilers know how
- to take advantage of well-constructed loops to implement such
- optimizations. NumPy uses :ref:`vectorization <whatis-vectorization>`
- to mean any optimization via specialized code performing the same
- operations on multiple elements, typically achieving speedups by
- avoiding some of the overhead in looking up and converting the elements.
-
+ NumPy hands off array processing to C, where looping and computation are
+ much faster than in Python. To exploit this, programmers using NumPy
+ eliminate Python loops in favor of array-to-array operations.
+ :term:`vectorization` can refer both to the C offloading and to
+ structuring NumPy code to leverage it.
view
- An array that does not own its data, but refers to another array's
- data instead. For example, we may create a view that only shows
- every second element of another array::
+ Without touching underlying data, NumPy can make one array appear
+ to change its datatype and shape.
+
+ An array created this way is a `view`, and NumPy often exploits the
+ performance gain of using a view versus making a new array.
+
+ A potential drawback is that writing to a view can alter the original
+ as well. If this is a problem, NumPy instead needs to create a
+ physically distinct array -- a `copy`.
+
+ Some NumPy routines always return views, some always return copies, some
+ may return one or the other, and for some the choice can be specified.
+ Responsiblity for managing views and copies falls to the programmer.
+ :func:`numpy.shares_memory` will check whether ``b`` is a view of
+ ``a``, but an exact answer isn't always feasible, as the documentation
+ page explains.
>>> x = np.arange(5)
>>> x
@@ -618,15 +519,3 @@ Glossary
>>> y
array([3, 2, 4])
-
- wrapper
- Python is a high-level (highly abstracted, or English-like) language.
- This abstraction comes at a price in execution speed, and sometimes
- it becomes necessary to use lower level languages to do fast
- computations. A wrapper is code that provides a bridge between
- high and the low level languages, allowing, e.g., Python to execute
- code written in C or Fortran.
-
- Examples include ctypes, SWIG and Cython (which wraps C and C++)
- and f2py (which wraps Fortran).
-
diff --git a/doc/source/reference/arrays.indexing.rst b/doc/source/reference/arrays.indexing.rst
index 180a79dae..b2a9f1d21 100644
--- a/doc/source/reference/arrays.indexing.rst
+++ b/doc/source/reference/arrays.indexing.rst
@@ -34,7 +34,7 @@ Basic Slicing and Indexing
Basic slicing extends Python's basic concept of slicing to N
dimensions. Basic slicing occurs when *obj* is a :class:`slice` object
(constructed by ``start:stop:step`` notation inside of brackets), an
-integer, or a tuple of slice objects and integers. :const:`Ellipsis`
+integer, or a tuple of slice objects and integers. :py:data:`Ellipsis`
and :const:`newaxis` objects can be interspersed with these as
well.
@@ -43,7 +43,7 @@ well.
In order to remain backward compatible with a common usage in
Numeric, basic slicing is also initiated if the selection object is
any non-ndarray and non-tuple sequence (such as a :class:`list`) containing
- :class:`slice` objects, the :const:`Ellipsis` object, or the :const:`newaxis`
+ :class:`slice` objects, the :py:data:`Ellipsis` object, or the :const:`newaxis`
object, but not for integer arrays or other embedded sequences.
.. index::
@@ -129,7 +129,7 @@ concepts to remember include:
[5],
[6]]])
-- :const:`Ellipsis` expands to the number of ``:`` objects needed for the
+- :py:data:`Ellipsis` expands to the number of ``:`` objects needed for the
selection tuple to index all dimensions. In most cases, this means that
length of the expanded selection tuple is ``x.ndim``. There may only be a
single ellipsis present.
@@ -333,7 +333,7 @@ the subspace defined by the basic indexing (excluding integers) and the
subspace from the advanced indexing part. Two cases of index combination
need to be distinguished:
-* The advanced indexes are separated by a slice, :const:`Ellipsis` or :const:`newaxis`.
+* The advanced indexes are separated by a slice, :py:data:`Ellipsis` or :const:`newaxis`.
For example ``x[arr1, :, arr2]``.
* The advanced indexes are all next to each other.
For example ``x[..., arr1, arr2, :]`` but *not* ``x[arr1, :, 1]``
diff --git a/doc/source/reference/arrays.interface.rst b/doc/source/reference/arrays.interface.rst
index 73e4aef0c..49772a298 100644
--- a/doc/source/reference/arrays.interface.rst
+++ b/doc/source/reference/arrays.interface.rst
@@ -231,13 +231,15 @@ as::
The flags member may consist of 5 bits showing how the data should be
interpreted and one bit showing how the Interface should be
-interpreted. The data-bits are :const:`CONTIGUOUS` (0x1),
-:const:`FORTRAN` (0x2), :const:`ALIGNED` (0x100), :const:`NOTSWAPPED`
-(0x200), and :const:`WRITEABLE` (0x400). A final flag
-:const:`ARR_HAS_DESCR` (0x800) indicates whether or not this structure
+interpreted. The data-bits are :c:macro:`NPY_ARRAY_C_CONTIGUOUS` (0x1),
+:c:macro:`NPY_ARRAY_F_CONTIGUOUS` (0x2), :c:macro:`NPY_ARRAY_ALIGNED` (0x100),
+:c:macro:`NPY_ARRAY_NOTSWAPPED` (0x200), and :c:macro:`NPY_ARRAY_WRITEABLE` (0x400). A final flag
+:c:macro:`NPY_ARR_HAS_DESCR` (0x800) indicates whether or not this structure
has the arrdescr field. The field should not be accessed unless this
flag is present.
+ .. c:macro:: NPY_ARR_HAS_DESCR
+
.. admonition:: New since June 16, 2006:
In the past most implementations used the ``desc`` member of the ``PyCObject``
diff --git a/doc/source/reference/c-api/array.rst b/doc/source/reference/c-api/array.rst
index cfe4d2d51..9fe45d2de 100644
--- a/doc/source/reference/c-api/array.rst
+++ b/doc/source/reference/c-api/array.rst
@@ -3259,6 +3259,8 @@ Memory management
:c:data:`NPY_USE_PYMEM` is 0, if :c:data:`NPY_USE_PYMEM` is 1, then
the Python memory allocator is used.
+ .. c:macro:: NPY_USE_PYMEM
+
.. c:function:: int PyArray_ResolveWritebackIfCopy(PyArrayObject* obj)
If ``obj.flags`` has :c:data:`NPY_ARRAY_WRITEBACKIFCOPY` or (deprecated)
@@ -3289,9 +3291,13 @@ be accomplished using two groups of macros. Typically, if one macro in
a group is used in a code block, all of them must be used in the same
code block. Currently, :c:data:`NPY_ALLOW_THREADS` is defined to the
python-defined :c:data:`WITH_THREADS` constant unless the environment
-variable :c:data:`NPY_NOSMP` is set in which case
+variable ``NPY_NOSMP`` is set in which case
:c:data:`NPY_ALLOW_THREADS` is defined to be 0.
+.. c:macro:: NPY_ALLOW_THREADS
+
+.. c:macro:: WITH_THREADS
+
Group 1
"""""""
diff --git a/doc/source/reference/c-api/config.rst b/doc/source/reference/c-api/config.rst
index c3e2c98af..cec5b973a 100644
--- a/doc/source/reference/c-api/config.rst
+++ b/doc/source/reference/c-api/config.rst
@@ -52,12 +52,15 @@ information is available to the pre-processor.
.. c:macro:: NPY_SIZEOF_LONG_DOUBLE
- sizeof(longdouble) (A macro defines **NPY_SIZEOF_LONGDOUBLE** as well.)
+.. c:macro:: NPY_SIZEOF_LONGDOUBLE
+
+ sizeof(longdouble)
.. c:macro:: NPY_SIZEOF_PY_INTPTR_T
- Size of a pointer on this platform (sizeof(void \*)) (A macro defines
- NPY_SIZEOF_INTP as well.)
+.. c:macro:: NPY_SIZEOF_INTP
+
+ Size of a pointer on this platform (sizeof(void \*))
Platform information
@@ -102,6 +105,12 @@ Platform information
One of :c:data:`NPY_CPU_BIG`, :c:data:`NPY_CPU_LITTLE`,
or :c:data:`NPY_CPU_UNKNOWN_ENDIAN`.
+ .. c:macro:: NPY_CPU_BIG
+
+ .. c:macro:: NPY_CPU_LITTLE
+
+ .. c:macro:: NPY_CPU_UNKNOWN_ENDIAN
+
Compiler directives
-------------------
diff --git a/doc/source/reference/c-api/dtype.rst b/doc/source/reference/c-api/dtype.rst
index a04d85212..47b998302 100644
--- a/doc/source/reference/c-api/dtype.rst
+++ b/doc/source/reference/c-api/dtype.rst
@@ -414,6 +414,12 @@ Printf Formatting
For help in printing, the following strings are defined as the correct
format specifier in printf and related commands.
- :c:data:`NPY_LONGLONG_FMT`, :c:data:`NPY_ULONGLONG_FMT`,
- :c:data:`NPY_INTP_FMT`, :c:data:`NPY_UINTP_FMT`,
- :c:data:`NPY_LONGDOUBLE_FMT`
+.. c:macro:: NPY_LONGLONG_FMT
+
+.. c:macro:: NPY_ULONGLONG_FMT
+
+.. c:macro:: NPY_INTP_FMT
+
+.. c:macro:: NPY_UINTP_FMT
+
+.. c:macro:: NPY_LONGDOUBLE_FMT
diff --git a/doc/source/reference/c-api/iterator.rst b/doc/source/reference/c-api/iterator.rst
index 7eac8c367..ae96bb3fb 100644
--- a/doc/source/reference/c-api/iterator.rst
+++ b/doc/source/reference/c-api/iterator.rst
@@ -1264,7 +1264,7 @@ functions provide that information.
NPY_MAX_INTP is placed in the stride.
Once the iterator is prepared for iteration (after a reset if
- :c:data:`NPY_DELAY_BUFALLOC` was used), call this to get the strides
+ :c:data:`NPY_ITER_DELAY_BUFALLOC` was used), call this to get the strides
which may be used to select a fast inner loop function. For example,
if the stride is 0, that means the inner loop can always load its
value into a variable once, then use the variable throughout the loop,
diff --git a/doc/source/reference/c-api/types-and-structures.rst b/doc/source/reference/c-api/types-and-structures.rst
index ee57d4680..cc961df3a 100644
--- a/doc/source/reference/c-api/types-and-structures.rst
+++ b/doc/source/reference/c-api/types-and-structures.rst
@@ -315,7 +315,7 @@ PyArrayDescr_Type and PyArray_Descr
Bits set for the object data-type: ( :c:data:`NPY_LIST_PICKLE`
\| :c:data:`NPY_USE_GETITEM` \| :c:data:`NPY_ITEM_IS_POINTER` \|
- :c:data:`NPY_REFCOUNT` \| :c:data:`NPY_NEEDS_INIT` \|
+ :c:data:`NPY_ITEM_REFCOUNT` \| :c:data:`NPY_NEEDS_INIT` \|
:c:data:`NPY_NEEDS_PYAPI`).
.. c:function:: PyDataType_FLAGCHK(PyArray_Descr *dtype, int flags)
@@ -1395,7 +1395,7 @@ PyArrayInterface
as the *descr* key in :obj:`__array_interface__`). This can be
``NULL`` if *typekind* and *itemsize* provide enough
information. This field is also ignored unless
- :c:data:`ARR_HAS_DESCR` flag is on in *flags*.
+ :c:data:`NPY_ARR_HAS_DESCR` flag is on in *flags*.
Internally used structures
diff --git a/doc/source/reference/routines.set.rst b/doc/source/reference/routines.set.rst
index b12d3d5f5..149c33a8b 100644
--- a/doc/source/reference/routines.set.rst
+++ b/doc/source/reference/routines.set.rst
@@ -3,6 +3,11 @@ Set routines
.. currentmodule:: numpy
+.. autosummary::
+ :toctree: generated/
+
+ lib.arraysetops
+
Making proper sets
------------------
.. autosummary::
diff --git a/doc/source/user/basics.rec.rst b/doc/source/user/basics.rec.rst
index f579b0d85..bb4ed89e9 100644
--- a/doc/source/user/basics.rec.rst
+++ b/doc/source/user/basics.rec.rst
@@ -575,11 +575,14 @@ Record Arrays
=============
As an optional convenience numpy provides an ndarray subclass,
-:class:`numpy.recarray`, and associated helper functions in the
-:mod:`numpy.lib.recfunctions` submodule (aliased as ``numpy.rec``), that allows
-access to fields of structured arrays by attribute instead of only by index.
-Record arrays also use a special datatype, :class:`numpy.record`, that allows
+:class:`numpy.recarray` that allows access to fields of structured arrays by
+attribute instead of only by index.
+Record arrays use a special datatype, :class:`numpy.record`, that allows
field access by attribute on the structured scalars obtained from the array.
+The :mod:`numpy.rec` module provides functions for creating recarrays from
+various objects.
+Additional helper functions for creating and manipulating structured arrays
+can be found in :mod:`numpy.lib.recfunctions`.
The simplest way to create a record array is with ``numpy.rec.array``::
diff --git a/doc/source/user/index.rst b/doc/source/user/index.rst
index 3a79f0f2e..11a019b48 100644
--- a/doc/source/user/index.rst
+++ b/doc/source/user/index.rst
@@ -26,7 +26,10 @@ classes contained in the package, see the :ref:`reference`.
howtos_index
-.. These are stuck here to avoid the "WARNING: document isn't included in any
+.. Links to these files are placed directly in the top-level html
+ (doc/source/_templates/indexcontent.html, which appears for the URLs
+ numpy.org/devdocs and numpy.org/doc/XX) and are not in any toctree, so
+ we include them here to avoid a "WARNING: document isn't included in any
toctree" message
.. toctree::
@@ -39,5 +42,5 @@ classes contained in the package, see the :ref:`reference`.
../docs/index
../bugs
../release
- ../about
+ ../doc_conventions
../license
diff --git a/doc/source/user/quickstart.rst b/doc/source/user/quickstart.rst
index b1af81886..8e38234c5 100644
--- a/doc/source/user/quickstart.rst
+++ b/doc/source/user/quickstart.rst
@@ -23,7 +23,7 @@ https://scipy.org/install.html for instructions.
**Learner profile**
This tutorial is intended as a quick overview of
-algebra and arrays in NumPy and want to understand how n-dimensional
+algebra and arrays in NumPy. It demonstrates how n-dimensional
(:math:`n>=2`) arrays are represented and can be manipulated. In particular, if
you don't know how to apply common functions to n-dimensional arrays (without
using for-loops), or if you want to understand axis and shape properties for