Numpy: np.conj vs np.conjugate

Created on 29 May 2017  路  4Comments  路  Source: numpy/numpy

Both numpy.conj and numpy.conjugate exist, and in fact the docs for conj show examples that use conjugate:

https://docs.scipy.org/doc/numpy-1.12.0/reference/generated/numpy.conj.html

Furthermore, the page for numpy.conjugate doesn't exist. It would be nice to make this more consistent, e.g. change the examples in for the conj page to use conjugate, or add a note to the conj docs that either can be used.

04 - Documentation

Most helpful comment

While we're at it, probably good to ensure we note that they are, in fact, just aliases:

In [2]: np.conj is np.conjugate
Out[2]: True

All 4 comments

While we're at it, probably good to ensure we note that they are, in fact, just aliases:

In [2]: np.conj is np.conjugate
Out[2]: True

See also np.max and np.amax, for which I feel we should be encouraging the former

Hi. I would like to take this up and wanted to propose a workflow.
We can create a separate page for np.conjugate as well and include relevant examples in that page. Also, change the examples in np.conj page to use conj and mention in both the pages that they are aliases of each other and provide reference in the See Also section.
This is to maintain consistency with the documentation of aliases as is done with for e.g., np.random.random function Please let me know if I can go ahead with this flow. Thanks!

@kritisingh1 - since the two functions are the same -- np.conj is np.conjugate -- you only need to update the one docstring that they share. I think I would use np.conjugate everywhere, since it is generally good not to use abbreviations (and conj is created explicitly as an alias in ufuncmodule.c). Also, that happens to need the least change: the docstring could just mention that np.conj is an alias. To save you searching: the docstrings are in numpy/core/code_generators/ufunc_docstrings.py

Then, the next step is to ensure that documentation pages for both functions get generated. Here, you have to adjust both docs/source/reference/routines.umath.src and docs/source/reference/ufuncs.rst.

While you are at it, would it be possible to also also update the docstring of remainder to mention mod is an alias? Also, I'm not quite sure the list in ufuncs.rst is in fact up to date. It might be good to compare with what we actually expose:

import numpy
ufuncs = [key for key in dir(numpy) if isinstance(getattr(numpy, key), numpy.ufunc)]
Was this page helpful?
0 / 5 - 0 ratings