summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/_add_newdocs.py57
-rw-r--r--numpy/core/multiarray.py2
-rw-r--r--numpy/core/numeric.py5
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c44
4 files changed, 2 insertions, 106 deletions
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index 36fc9d7d6..0dc46b6ad 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -1034,7 +1034,7 @@ add_newdoc('numpy.core.multiarray', 'fromstring',
A string containing the data.
dtype : data-type, optional
The data type of the array; default: float. For binary input data,
- the data must be in exactly this format. Most builtin numeric types are
+ the data must be in exactly this format. Most builtin numeric types are
supported and extension types may be supported.
.. versionadded:: 1.18.0
@@ -1484,59 +1484,6 @@ add_newdoc('numpy.core.multiarray', 'promote_types',
""")
-if sys.version_info.major < 3:
- add_newdoc('numpy.core.multiarray', 'newbuffer',
- """
- newbuffer(size)
-
- Return a new uninitialized buffer object.
-
- Parameters
- ----------
- size : int
- Size in bytes of returned buffer object.
-
- Returns
- -------
- newbuffer : buffer object
- Returned, uninitialized buffer object of `size` bytes.
-
- """)
-
- add_newdoc('numpy.core.multiarray', 'getbuffer',
- """
- getbuffer(obj [,offset[, size]])
-
- Create a buffer object from the given object referencing a slice of
- length size starting at offset.
-
- Default is the entire buffer. A read-write buffer is attempted followed
- by a read-only buffer.
-
- Parameters
- ----------
- obj : object
-
- offset : int, optional
-
- size : int, optional
-
- Returns
- -------
- buffer_obj : buffer
-
- Examples
- --------
- >>> buf = np.getbuffer(np.ones(5), 1, 3)
- >>> len(buf)
- 3
- >>> buf[0]
- '\\x00'
- >>> buf
- <read-write buffer for 0x8af1e70, size 3, offset 1 at 0x8ba4ec0>
-
- """)
-
add_newdoc('numpy.core.multiarray', 'c_einsum',
"""
c_einsum(subscripts, *operands, out=None, dtype=None, order='K',
@@ -3951,7 +3898,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('tolist',
Examples
--------
- For a 1D array, ``a.tolist()`` is almost the same as ``list(a)``,
+ For a 1D array, ``a.tolist()`` is almost the same as ``list(a)``,
except that ``tolist`` changes numpy scalars to Python scalars:
>>> a = np.uint32([1, 2])
diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py
index 01fca1df5..5749afdcc 100644
--- a/numpy/core/multiarray.py
+++ b/numpy/core/multiarray.py
@@ -41,8 +41,6 @@ __all__ = [
'set_string_function', 'set_typeDict', 'shares_memory', 'test_interrupt',
'tracemalloc_domain', 'typeinfo', 'unpackbits', 'unravel_index', 'vdot',
'where', 'zeros']
-if sys.version_info.major < 3:
- __all__ += ['newbuffer', 'getbuffer']
# For backward compatibility, make sure pickle imports these functions from here
_reconstruct.__module__ = 'numpy.core.multiarray'
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index ae3dcd07a..505218a2e 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -19,8 +19,6 @@ from .multiarray import (
min_scalar_type, ndarray, nditer, nested_iters, promote_types,
putmask, result_type, set_numeric_ops, shares_memory, vdot, where,
zeros, normalize_axis_index)
-if sys.version_info[0] < 3:
- from .multiarray import newbuffer, getbuffer
from . import overrides
from . import umath
@@ -65,9 +63,6 @@ __all__ = [
'matmul', 'shares_memory', 'may_share_memory', 'MAY_SHARE_BOUNDS',
'MAY_SHARE_EXACT', 'TooHardError', 'AxisError']
-if sys.version_info[0] < 3:
- __all__.extend(['getbuffer', 'newbuffer'])
-
@set_module('numpy')
class ComplexWarning(RuntimeWarning):
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index 58f64f0bb..2540fba61 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -3293,42 +3293,6 @@ array_datetime_data(PyObject *NPY_UNUSED(dummy), PyObject *args)
return convert_datetime_metadata_to_tuple(meta);
}
-#if !defined(NPY_PY3K)
-static PyObject *
-new_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args)
-{
- int size;
-
- if (!PyArg_ParseTuple(args, "i:buffer", &size)) {
- return NULL;
- }
- return PyBuffer_New(size);
-}
-
-static PyObject *
-buffer_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
-{
- PyObject *obj;
- Py_ssize_t offset = 0, n;
- Py_ssize_t size = Py_END_OF_BUFFER;
- void *unused;
- static char *kwlist[] = {"object", "offset", "size", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds,
- "O|" NPY_SSIZE_T_PYFMT NPY_SSIZE_T_PYFMT ":get_buffer", kwlist,
- &obj, &offset, &size)) {
- return NULL;
- }
- if (PyObject_AsWriteBuffer(obj, &unused, &n) < 0) {
- PyErr_Clear();
- return PyBuffer_FromObject(obj, offset, size);
- }
- else {
- return PyBuffer_FromReadWriteObject(obj, offset, size);
- }
-}
-#endif
-
/*
* Prints floating-point scalars using the Dragon4 algorithm, scientific mode.
* See docstring of `np.format_float_scientific` for description of arguments.
@@ -4137,14 +4101,6 @@ static struct PyMethodDef array_module_methods[] = {
{"is_busday",
(PyCFunction)array_is_busday,
METH_VARARGS | METH_KEYWORDS, NULL},
-#if !defined(NPY_PY3K)
- {"newbuffer",
- (PyCFunction)new_buffer,
- METH_VARARGS, NULL},
- {"getbuffer",
- (PyCFunction)buffer_buffer,
- METH_VARARGS | METH_KEYWORDS, NULL},
-#endif
{"format_longfloat",
(PyCFunction)format_longfloat,
METH_VARARGS | METH_KEYWORDS, NULL},