[ 
https://issues.apache.org/jira/browse/ARROW-2240?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16384200#comment-16384200
 ] 

ASF GitHub Bot commented on ARROW-2240:
---------------------------------------

wesm commented on a change in pull request #1686: ARROW-2240: [Python] Array 
initialization with leading numpy nan fails with exception
URL: https://github.com/apache/arrow/pull/1686#discussion_r171970987
 
 

 ##########
 File path: cpp/src/arrow/python/python-test.cc
 ##########
 @@ -367,5 +367,20 @@ TEST_F(DecimalTest, UpdateWithNaN) {
   ASSERT_EQ(std::numeric_limits<int32_t>::min(), metadata.scale());
 }
 
+TEST(PythonTest, ConstructStringArrayWithLeadingZeros) {
+  PyAcquireGIL lock;
+
+  OwnedRef list_ref(PyList_New(2));
+  PyObject* list = list_ref.obj();
+  std::string str("str");
+
+  ASSERT_EQ(0, PyList_SetItem(list, 0, PyFloat_FromDouble(NAN)));
+  ASSERT_EQ(0, PyList_SetItem(list, 1, PyUnicode_FromString(str.c_str())));
+
+  std::shared_ptr<Array> out;
+  auto pool = default_memory_pool();
+  ASSERT_OK(ConvertPySequence(list, pool, &out));
+}
 
 Review comment:
   OK, let's leave them both here then =)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Array initialization with leading numpy nan fails with exception
> -------------------------------------------------------------------------
>
>                 Key: ARROW-2240
>                 URL: https://issues.apache.org/jira/browse/ARROW-2240
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Python
>    Affects Versions: 0.8.0
>            Reporter: Florian Jetter
>            Priority: Minor
>              Labels: pull-request-available
>
>  
> Arrow initialization fails for string arrays with leading numpy NAN
> {code:java}
> import pyarrow as pa
> import numpy as np
> pa.array([np.nan, 'str'])
> # Py3: ArrowException: Unknown error: must be real number, not str
> # Py2: ArrowException: Unknown error: a float is required{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to