Skip to content
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

ENH: Support for file-like objects in np.fromfile #4505

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 0 additions & 9 deletions numpy/core/include/numpy/ndarraytypes.h
Expand Up @@ -388,8 +388,6 @@ typedef void (PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *,
* XXX the ignore argument should be removed next time the API version
* is bumped. It used to be the separator.
*/
typedef int (PyArray_ScanFunc)(FILE *fp, void *dptr,
char *ignore, struct _PyArray_Descr *);
typedef int (PyArray_FromStrFunc)(char *s, void *dptr, char **endptr,
struct _PyArray_Descr *);

Expand Down Expand Up @@ -465,13 +463,6 @@ typedef struct {
*/
PyArray_DotFunc *dotfunc;

/*
* Function to scan an ASCII file and
* place a single value plus possible separator
* Can be NULL
*/
PyArray_ScanFunc *scanfunc;

/*
* Function to read a single value from a string
* and adjust the pointer; Can be NULL
Expand Down
101 changes: 0 additions & 101 deletions numpy/core/src/multiarray/arraytypes.c.src
Expand Up @@ -1393,105 +1393,6 @@ static void
/**end repeat**/


/*
*****************************************************************************
** SCAN **
*****************************************************************************
*/


/*
* The first ignore argument is for backwards compatibility.
* Should be removed when the API version is bumped up.
*/

/**begin repeat
* #fname = SHORT, USHORT, INT, UINT,
* LONG, ULONG, LONGLONG, ULONGLONG#
* #type = npy_short, npy_ushort, npy_int, npy_uint,
* npy_long, npy_ulong, npy_longlong, npy_ulonglong#
* #format = "hd", "hu", "d", "u",
* "ld", "lu", NPY_LONGLONG_FMT, NPY_ULONGLONG_FMT#
*/
static int
@fname@_scan(FILE *fp, @type@ *ip, void *NPY_UNUSED(ignore),
PyArray_Descr *NPY_UNUSED(ignored))
{
return fscanf(fp, "%"@format@, ip);
}
/**end repeat**/

/**begin repeat
* #fname = FLOAT, DOUBLE, LONGDOUBLE#
* #type = npy_float, npy_double, npy_longdouble#
*/
static int
@fname@_scan(FILE *fp, @type@ *ip, void *NPY_UNUSED(ignore),
PyArray_Descr *NPY_UNUSED(ignored))
{
double result;
int ret;

ret = NumPyOS_ascii_ftolf(fp, &result);
*ip = (@type@) result;
return ret;
}
/**end repeat**/

static int
HALF_scan(FILE *fp, npy_half *ip, void *NPY_UNUSED(ignore),
PyArray_Descr *NPY_UNUSED(ignored))
{
double result;
int ret;

ret = NumPyOS_ascii_ftolf(fp, &result);
*ip = npy_double_to_half(result);
return ret;
}

/**begin repeat
* #fname = BYTE, UBYTE#
* #type = npy_byte, npy_ubyte#
* #btype = npy_int, npy_uint#
* #format = "d", "u"#
*/
static int
@fname@_scan(FILE *fp, @type@ *ip, void *NPY_UNUSED(ignore),
PyArray_Descr *NPY_UNUSED(ignore2))
{
@btype@ temp;
int num;

num = fscanf(fp, "%"@format@, &temp);
*ip = (@type@) temp;
return num;
}
/**end repeat**/

static int
BOOL_scan(FILE *fp, npy_bool *ip, void *NPY_UNUSED(ignore),
PyArray_Descr *NPY_UNUSED(ignore2))
{
double result;
int ret;

ret = NumPyOS_ascii_ftolf(fp, &result);
*ip = (npy_bool) (result != 0.0);
return ret;
}

/**begin repeat
* #fname = CFLOAT, CDOUBLE, CLONGDOUBLE,
* OBJECT, STRING, UNICODE, VOID,
* DATETIME, TIMEDELTA#
*/

#define @fname@_scan NULL

/**end repeat**/


/*
*****************************************************************************
** FROMSTR **
Expand Down Expand Up @@ -3644,7 +3545,6 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {
(PyArray_CompareFunc*)@from@_compare,
(PyArray_ArgFunc*)@from@_argmax,
(PyArray_DotFunc*)NULL,
(PyArray_ScanFunc*)@from@_scan,
(PyArray_FromStrFunc*)@from@_fromstr,
(PyArray_NonzeroFunc*)@from@_nonzero,
(PyArray_FillFunc*)NULL,
Expand Down Expand Up @@ -3784,7 +3684,6 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {
(PyArray_CompareFunc*)@from@_compare,
(PyArray_ArgFunc*)@from@_argmax,
(PyArray_DotFunc*)@from@_dot,
(PyArray_ScanFunc*)@from@_scan,
(PyArray_FromStrFunc*)@from@_fromstr,
(PyArray_NonzeroFunc*)@from@_nonzero,
(PyArray_FillFunc*)@from@_fill,
Expand Down