Skip to content

Commit 5f15ca0

Browse files
Remove the return_nulls kwarg (#57)
* Remove the return_nulls kwarg * Fix format string specifier for fetchdictarray; update docs
1 parent 71146c0 commit 5f15ca0

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

src/npcontainer.cpp

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,8 @@ query_desc_to_dictarray(query_desc &qd, const char *null_suffix)
16721672
* @return A Python dictionary filled with numpy arrays
16731673
*/
16741674
static PyObject *
1675-
create_fill_dictarray(Cursor *cursor, npy_intp nrows, const char *null_suffix, PyObject *target_dtypes)
1675+
create_fill_dictarray(Cursor *cursor, npy_intp nrows, const char *null_suffix,
1676+
PyObject *target_dtypes)
16761677
{
16771678
query_desc qd;
16781679
if (perform_array_query(qd, cursor, nrows, lowercase(), null_suffix != 0, target_dtypes) != 0) {
@@ -1683,8 +1684,6 @@ create_fill_dictarray(Cursor *cursor, npy_intp nrows, const char *null_suffix, P
16831684

16841685
static const char *Cursor_npfetch_kwnames[] = {
16851686
"size", // keyword to read the maximum number of rows. Defaults to all.
1686-
"return_nulls", // keyword to make a given fetch to add boolean columns for
1687-
// nulls
16881687
"null_suffix", // keyword providing the string to use as suffix
16891688
"target_dtypes", // dict of numpy dtypes to use for each column
16901689
NULL
@@ -1712,18 +1711,16 @@ Cursor_fetchdictarray(PyObject *self, PyObject *args, PyObject *kwargs)
17121711
}
17131712

17141713
Py_ssize_t nrows = -1;
1715-
bool return_nulls = false;
1716-
const char *null_suffix = "_isnull";
1714+
const char *null_suffix = NULL;
17171715
PyObject *target_dtypes = NULL;
17181716

17191717
if (
17201718
!PyArg_ParseTupleAndKeywords(
17211719
args,
17221720
kwargs,
1723-
"|npsO",
1721+
"|nsO",
17241722
const_cast<char **>(Cursor_npfetch_kwnames),
17251723
&nrows,
1726-
&return_nulls,
17271724
&null_suffix,
17281725
&target_dtypes
17291726
)
@@ -1738,13 +1735,13 @@ Cursor_fetchdictarray(PyObject *self, PyObject *args, PyObject *kwargs)
17381735
CAN_USE_DATETIME = true;
17391736
}
17401737

1741-
PyObject *dictarr = create_fill_dictarray(cursor, nrows, return_nulls ? null_suffix : 0, target_dtypes);
1738+
PyObject *dictarr = create_fill_dictarray(cursor, nrows, null_suffix, target_dtypes);
17421739
Py_DECREF(numpy);
17431740
return dictarr;
17441741
}
17451742

17461743
char fetchdictarray_doc[] =
1747-
"fetchdictarray(size=-1, return_nulls=False, null_suffix='_isnull', target_dtypes=None)\n"
1744+
"fetchdictarray(size=-1, null_suffix=None, target_dtypes=None)\n"
17481745
" --> a dictionary of column arrays.\n"
17491746
"\n"
17501747
"Fetch as many rows as specified by size into a dictionary of NumPy\n"
@@ -1755,32 +1752,29 @@ char fetchdictarray_doc[] =
17551752
"\n"
17561753
"Parameters\n"
17571754
"----------\n"
1758-
"size : int, optional\n"
1755+
"size : Optional[int]\n"
17591756
" The number of rows to fetch. Use -1 (the default) to fetch all\n"
17601757
" remaining rows.\n"
1761-
"return_nulls : boolean, optional\n"
1762-
" If True, information about null values will be included adding a\n"
1763-
" boolean array using as key a string built by concatenating the\n"
1764-
" column name and null_suffix.\n"
1765-
"target_dtypes : dict, optional\n"
1758+
"null_suffix : Optional[str]\n"
1759+
" If specified, a new boolean column named `<column_name><null_suffix>` will be\n"
1760+
" included in the output, with values indicating which values in `<column_name>` were\n"
1761+
" null in the original array. If None, no such column will be included.\n"
1762+
"target_dtypes : Optional[dict]\n"
17661763
" If provided, this mapping between {column name: dtype} coerces \n"
17671764
" the values read from the database into arrays of the requested\n"
17681765
" dtypes.\n"
1769-
"null_suffix : string, optional\n"
1770-
" A string used as a suffix when building the key for null values.\n"
1771-
" Only used if return_nulls is True.\n"
17721766
"\n"
17731767
"Returns\n"
17741768
"-------\n"
1775-
"out: dict\n"
1769+
"dict\n"
17761770
" A dictionary mapping column names to an ndarray holding its values\n"
17771771
" for the fetched rows. The dictionary will use the column name as\n"
17781772
" key for the ndarray containing values associated to that column.\n"
17791773
" Optionally, null information for nullable columns will be provided\n"
17801774
" by adding additional boolean columns named after the nullable column\n"
17811775
" concatenated to null_suffix\n"
17821776
"\n"
1783-
"Remarks\n"
1777+
"Notes\n"
17841778
"-------\n"
17851779
"Similar to fetchmany(size), but returning a dictionary of NumPy ndarrays\n"
17861780
"for the results instead of a Python list of tuples of objects, reducing\n"

0 commit comments

Comments
 (0)