Skip to content

Commit 0d0073a

Browse files
authored
COMPAT: Change khcomplex64/128_t typedefs (#54375)
* COMPAT: Change khcomplex64/128_t typedefs * Spacing, use double * Use double more places * Go back to old fix * Check both, cant repo locally * Rule out pandas inference * Use np.nan insted of float(nan)
1 parent 232d84e commit 0d0073a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

pandas/_libs/include/pandas/vendored/klib/khash_python.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
#include <Python.h>
33

44

5-
// use numpy's definitions for complex
6-
#include <numpy/arrayobject.h>
7-
typedef npy_complex64 khcomplex64_t;
8-
typedef npy_complex128 khcomplex128_t;
5+
typedef struct {
6+
float real;
7+
float imag;
8+
} khcomplex64_t;
9+
typedef struct {
10+
double real;
11+
double imag;
12+
} khcomplex128_t;
913

1014

1115

pandas/tests/io/formats/test_printing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ def test_multiindex_long_element():
237237
@pytest.mark.parametrize("as_frame", [True, False])
238238
def test_ser_df_with_complex_nans(data, output, as_frame):
239239
# GH#53762, GH#53841
240-
obj = pd.Series(data)
240+
obj = pd.Series(np.array(data))
241241
if as_frame:
242242
obj = obj.to_frame(name="val")
243243
reprs = [f"{i} {val}" for i, val in enumerate(output)]
244244
expected = f"{'val': >{len(reprs[0])}}\n" + "\n".join(reprs)
245245
else:
246246
reprs = [f"{i} {val}" for i, val in enumerate(output)]
247247
expected = "\n".join(reprs) + "\ndtype: complex128"
248-
assert str(obj) == expected
248+
assert str(obj) == expected, f"\n{str(obj)}\n\n{expected}"

0 commit comments

Comments
 (0)