Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

API: Add .mT attribute for arrays#23762

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
seberg merged 21 commits intonumpy:mainfromKai-Striega:mT
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
21 commits
Select commitHold shift + click to select a range
23f3651
ENH: Add .mT attribute for arrays
Kai-StriegaMay 15, 2023
cdf850e
TST: Fix test names to reflect test behaviour
Kai-StriegaMay 15, 2023
13f0a2e
TST: Increase max_dims for matrix_transpose test
Kai-StriegaMay 15, 2023
086a919
TST: Use `np.broadcast_to` to save memory in test
Kai-StriegaMay 17, 2023
95da479
TST: Avoid using hypothesis in test case
Kai-StriegaMay 17, 2023
e33c002
TST/MAINT: Rename file to be more generic
Kai-StriegaMay 17, 2023
5c346a3
ENH: Raise ValueError for ndim < 2 in .mT
Kai-StriegaMay 17, 2023
58a0e0d
TST: Add test for the existence of `matrix_transpose`
Kai-StriegaMay 20, 2023
710aaed
ENH: Try to create a `matrix_transpose` function
Kai-StriegaMay 20, 2023
0304796
REV: Remove PyArray_MatrixTranspose from C-API
Kai-StriegaMay 22, 2023
bd40405
DOC: Add release note for matrix transpose
Kai-StriegaMay 22, 2023
8115919
TYP: Add typehint for new `.mT` attribute
Kai-StriegaMay 26, 2023
716e85c
ENH: Include PyArray_MatrixTranspose in shape.h
Kai-StriegaMay 30, 2023
6185d19
Merge branch 'numpy:main' into mT
Kai-StriegaMay 31, 2023
f510534
ENH/TST: First attempt to support MaskedArrays
Kai-StriegaJun 12, 2023
6a9a938
ENH: Make ma.MaskedArray.mT return a masked array in all cases
Kai-StriegaJun 12, 2023
d256239
TYP: ma: Add typehint for .mT
Kai-StriegaJun 12, 2023
e244a27
DOC: Document mT property for masked arrays
Kai-StriegaJun 12, 2023
f43dfcc
REL: Remove matrix_transpose function from release note
Kai-StriegaJun 12, 2023
7d3d371
DOC: Add documentation for `ndarray.mT`
Kai-StriegaJun 12, 2023
02529f1
DOC: Document version added
Kai-StriegaJun 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
ENH: Try to create amatrix_transpose function
  • Loading branch information
@Kai-Striega
Kai-Striega committedMay 20, 2023
commit710aaedd5715ae0a2f46f5fc2d9db1478e0d71d0
2 changes: 2 additions & 0 deletionsnumpy/core/code_generators/numpy_api.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -370,6 +370,8 @@ def get_annotations():
'PyDataMem_SetHandler': (304, MinVersion("1.22")),
'PyDataMem_GetHandler': (305, MinVersion("1.22")),
# End 1.22 API
'PyArray_MatrixTranspose': (306, MinVersion("1.25")), # TODO: What does `MinVersion` do?
# End 1.25 API
}

ufunc_types_api = {
Expand Down
9 changes: 1 addition & 8 deletionsnumpy/core/src/multiarray/getset.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -934,14 +934,7 @@ array_transpose_get(PyArrayObject *self, void *NPY_UNUSED(ignored))
static PyObject *
array_matrix_transpose_get(PyArrayObject *self, void *NPY_UNUSED(ignored))
{
int ndim = PyArray_NDIM(self);

if (ndim < 2) {
PyErr_SetString(PyExc_ValueError,
"matrix transpose with ndim < 2 is undefined");
return NULL;
}
return PyArray_SwapAxes(self, ndim - 2, ndim - 1);
return PyArray_MatrixTranspose(self);
}

NPY_NO_EXPORT PyGetSetDef array_getsetlist[] = {
Expand Down
9 changes: 9 additions & 0 deletionsnumpy/core/src/multiarray/methods.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2399,6 +2399,12 @@ array_transpose(PyArrayObject *self, PyObject *args)
return ret;
}

static PyObject *
array_matrix_transpose(PyArrayObject *self)
{
return PyArray_MatrixTranspose(self);
}

#define _CHKTYPENUM(typ) ((typ) ? (typ)->type_num : NPY_NOTYPE)

static PyObject *
Expand DownExpand Up@@ -3081,6 +3087,9 @@ NPY_NO_EXPORT PyMethodDef array_methods[] = {
{"transpose",
(PyCFunction)array_transpose,
METH_VARARGS, NULL},
{"matrix_transpose",
(PyCFunction)array_matrix_transpose,
NULL, NULL},
{"var",
(PyCFunction)array_variance,
METH_VARARGS | METH_KEYWORDS, NULL},
Expand Down
16 changes: 16 additions & 0 deletionsnumpy/core/src/multiarray/shape.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -731,6 +731,22 @@ PyArray_Transpose(PyArrayObject *ap, PyArray_Dims *permute)
return (PyObject *)ret;
}

/*NUMPY_API
* Return Matrix Transpose.
*/
NPY_NO_EXPORT PyObject *
PyArray_MatrixTranspose(PyArrayObject *ap)
{
int ndim = PyArray_NDIM(self);

if (ndim < 2) {
PyErr_SetString(PyExc_ValueError,
"matrix transpose with ndim < 2 is undefined");
return NULL;
}
return PyArray_SwapAxes(self, ndim - 2, ndim - 1);
}

/*
* Sorts items so stride is descending, because C-order
* is the default in the face of ambiguity.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp