| 697 | } |
| 698 | |
| 699 | Status TestNoneAndNaN() { |
| 700 | OwnedRef list_ref(PyList_New(4)); |
| 701 | PyObject* list = list_ref.obj(); |
| 702 | |
| 703 | ASSERT_NE(list, nullptr); |
| 704 | |
| 705 | OwnedRef decimal_constructor_; |
| 706 | OwnedRef decimal_module; |
| 707 | RETURN_NOT_OK(internal::ImportModule("decimal", &decimal_module)); |
| 708 | RETURN_NOT_OK( |
| 709 | internal::ImportFromModule(decimal_module.obj(), "Decimal", &decimal_constructor_)); |
| 710 | PyObject* constructor = decimal_constructor_.obj(); |
| 711 | PyObject* decimal_value = internal::DecimalFromString(constructor, "1.234"); |
| 712 | ASSERT_NE(decimal_value, nullptr); |
| 713 | |
| 714 | Py_INCREF(Py_None); |
| 715 | PyObject* missing_value1 = Py_None; |
| 716 | ASSERT_NE(missing_value1, nullptr); |
| 717 | |
| 718 | PyObject* missing_value2 = PyFloat_FromDouble(NPY_NAN); |
| 719 | ASSERT_NE(missing_value2, nullptr); |
| 720 | |
| 721 | PyObject* missing_value3 = internal::DecimalFromString(constructor, "nan"); |
| 722 | ASSERT_NE(missing_value3, nullptr); |
| 723 | |
| 724 | // This steals a reference to each object, so we don't need to decref them later, |
| 725 | // just the list |
| 726 | ASSERT_EQ(0, PyList_SetItem(list, 0, decimal_value)); |
| 727 | ASSERT_EQ(0, PyList_SetItem(list, 1, missing_value1)); |
| 728 | ASSERT_EQ(0, PyList_SetItem(list, 2, missing_value2)); |
| 729 | ASSERT_EQ(0, PyList_SetItem(list, 3, missing_value3)); |
| 730 | |
| 731 | PyConversionOptions options; |
| 732 | ASSERT_RAISES(TypeError, ConvertPySequence(list, nullptr, options)); |
| 733 | |
| 734 | options.from_pandas = true; |
| 735 | auto chunked = std::move(ConvertPySequence(list, nullptr, options)).ValueOrDie(); |
| 736 | ASSERT_EQ(chunked->num_chunks(), 1); |
| 737 | |
| 738 | auto arr = chunked->chunk(0); |
| 739 | ASSERT_TRUE(arr->IsValid(0)); |
| 740 | ASSERT_TRUE(arr->IsNull(1)); |
| 741 | ASSERT_TRUE(arr->IsNull(2)); |
| 742 | ASSERT_TRUE(arr->IsNull(3)); |
| 743 | |
| 744 | return Status::OK(); |
| 745 | } |
| 746 | |
| 747 | Status TestMixedPrecisionAndScale() { |
| 748 | std::vector<std::string> strings{{"0.001", "1.01E5", "1.01E5"}}; |
nothing calls this directly
no test coverage detected