Add Cython flake8 file

Change-Id: I0ea3c209b98fec7347e8fae62748b7830de5dacf
This commit is contained in:
Wes McKinney committed 2017-08-01 15:33:22 -04:00
1 parent f10e8d1fdd
commit 7ffa6135cc
8 files changed
+65 -31

No files matched your search

+3
View File
@@ -97,6 +97,9 @@ python_version_tests() {
# Fail fast on style checks
flake8 pyarrow
# Check Cython files with some checks turned off
flake8 --config=.flake8.cython pyarrow
# Build C++ libraries
rebuild_arrow_libraries
+20
View File
@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
[flake8]
filename = *.pyx,*.px*
ignore = E211, E901,E225,E226,E227
+1
View File
@@ -49,6 +49,7 @@ build. Check for style errors before submitting your pull request with:
```
flake8 pyarrow
flake8 --config=.flake8.cython pyarrow
```
### Building from Source
+6 -3
View File
@@ -19,6 +19,10 @@
# distutils: language = c++
# cython: embedsignature = True
import numpy as np
import multiprocessing
import os
cdef extern from 'arrow/python/init.h':
int arrow_init_numpy() except -1
@@ -27,15 +31,13 @@ cdef extern from 'arrow/python/config.h' namespace 'arrow::py':
arrow_init_numpy()
import numpy as np
set_numpy_nan(np.nan)
import multiprocessing
import os
cdef int CPU_COUNT = int(
os.environ.get('OMP_NUM_THREADS',
max(multiprocessing.cpu_count() // 2, 1)))
def cpu_count():
"""
Returns
@@ -49,6 +51,7 @@ def cpu_count():
"""
return CPU_COUNT
def set_cpu_count(count):
global CPU_COUNT
CPU_COUNT = max(int(count), 1)
+25 -18
View File
@@ -25,17 +25,18 @@ from pyarrow.includes.libarrow cimport (CArray, CSchema, CStatus,
cdef extern from "parquet/api/schema.h" namespace "parquet::schema" nogil:
cdef cppclass Node:
pass
cdef cppclass Node:
pass
cdef cppclass GroupNode(Node):
pass
cdef cppclass GroupNode(Node):
pass
cdef cppclass PrimitiveNode(Node):
pass
cdef cppclass PrimitiveNode(Node):
pass
cdef cppclass ColumnPath:
c_string ToDotString()
cdef cppclass ColumnPath:
c_string ToDotString()
cdef extern from "parquet/api/schema.h" namespace "parquet" nogil:
enum ParquetType" parquet::Type::type":
@@ -59,8 +60,10 @@ cdef extern from "parquet/api/schema.h" namespace "parquet" nogil:
ParquetLogicalType_DATE" parquet::LogicalType::DATE"
ParquetLogicalType_TIME_MILLIS" parquet::LogicalType::TIME_MILLIS"
ParquetLogicalType_TIME_MICROS" parquet::LogicalType::TIME_MICROS"
ParquetLogicalType_TIMESTAMP_MILLIS" parquet::LogicalType::TIMESTAMP_MILLIS"
ParquetLogicalType_TIMESTAMP_MICROS" parquet::LogicalType::TIMESTAMP_MICROS"
ParquetLogicalType_TIMESTAMP_MILLIS\
" parquet::LogicalType::TIMESTAMP_MILLIS"
ParquetLogicalType_TIMESTAMP_MICROS\
" parquet::LogicalType::TIMESTAMP_MICROS"
ParquetLogicalType_UINT_8" parquet::LogicalType::UINT_8"
ParquetLogicalType_UINT_16" parquet::LogicalType::UINT_16"
ParquetLogicalType_UINT_32" parquet::LogicalType::UINT_32"
@@ -83,8 +86,10 @@ cdef extern from "parquet/api/schema.h" namespace "parquet" nogil:
ParquetEncoding_PLAIN_DICTIONARY" parquet::Encoding::PLAIN_DICTIONARY"
ParquetEncoding_RLE" parquet::Encoding::RLE"
ParquetEncoding_BIT_PACKED" parquet::Encoding::BIT_PACKED"
ParquetEncoding_DELTA_BINARY_PACKED" parquet::Encoding::DELTA_BINARY_PACKED"
ParquetEncoding_DELTA_LENGTH_BYTE_ARRAY" parquet::Encoding::DELTA_LENGTH_BYTE_ARRAY"
ParquetEncoding_DELTA_BINARY_PACKED\
" parquet::Encoding::DELTA_BINARY_PACKED"
ParquetEncoding_DELTA_LENGTH_BYTE_ARRAY\
" parquet::Encoding::DELTA_LENGTH_BYTE_ARRAY"
ParquetEncoding_DELTA_BYTE_ARRAY" parquet::Encoding::DELTA_BYTE_ARRAY"
ParquetEncoding_RLE_DICTIONARY" parquet::Encoding::RLE_DICTIONARY"
@@ -231,13 +236,15 @@ cdef extern from "parquet/arrow/reader.h" namespace "parquet::arrow" nogil:
cdef extern from "parquet/arrow/schema.h" namespace "parquet::arrow" nogil:
CStatus FromParquetSchema(const SchemaDescriptor* parquet_schema,
const shared_ptr[const CKeyValueMetadata]& key_value_metadata,
shared_ptr[CSchema]* out)
CStatus FromParquetSchema(
const SchemaDescriptor* parquet_schema,
const shared_ptr[const CKeyValueMetadata]& key_value_metadata,
shared_ptr[CSchema]* out)
CStatus ToParquetSchema(const CSchema* arrow_schema,
const shared_ptr[const CKeyValueMetadata]& key_value_metadata,
shared_ptr[SchemaDescriptor]* out)
CStatus ToParquetSchema(
const CSchema* arrow_schema,
const shared_ptr[const CKeyValueMetadata]& key_value_metadata,
shared_ptr[SchemaDescriptor]* out)
cdef extern from "parquet/arrow/writer.h" namespace "parquet::arrow" nogil:
+5 -4
View File
@@ -279,8 +279,8 @@ cdef class ColumnSchema:
max_repetition_level: {3}
physical_type: {4}
logical_type: {5}""".format(self.name, self.path, self.max_definition_level,
self.max_repetition_level, physical_type,
logical_type)
self.max_repetition_level, physical_type,
logical_type)
property name:
@@ -514,7 +514,7 @@ cdef class ParquetReader:
with nogil:
check_status(self.reader.get()
.ReadSchemaField(field_index, &carray));
.ReadSchemaField(field_index, &carray))
array.init(carray)
return array
@@ -553,7 +553,8 @@ cdef class ParquetWriter:
def __cinit__(self, where, Schema schema, use_dictionary=None,
compression=None, version=None,
MemoryPool memory_pool=None, use_deprecated_int96_timestamps=False):
MemoryPool memory_pool=None,
use_deprecated_int96_timestamps=False):
cdef:
shared_ptr[FileOutputStream] filestream
shared_ptr[WriterProperties] properties
+4 -5
View File
@@ -66,8 +66,8 @@ def array(object sequence, DataType type=None, MemoryPool memory_pool=None,
array : pyarrow.Array
"""
cdef:
shared_ptr[CArray] sp_array
CMemoryPool* pool
shared_ptr[CArray] sp_array
CMemoryPool* pool
pool = maybe_unbox_memory_pool(memory_pool)
if type is None:
@@ -78,13 +78,13 @@ def array(object sequence, DataType type=None, MemoryPool memory_pool=None,
ConvertPySequence(
sequence, pool, &sp_array, type.sp_type
)
)
)
else:
check_status(
ConvertPySequence(
sequence, pool, &sp_array, type.sp_type, size
)
)
)
return pyarrow_wrap_array(sp_array)
@@ -401,7 +401,6 @@ strides: {2}""".format(self.type, self.shape, self.strides)
return py_strides
cdef wrap_array_output(PyObject* output):
cdef object obj = PyObject_to_object(output)
+1 -1
View File
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
#----------------------------------------------------------------------
# ---------------------------------------------------------------------
# Implement legacy Feather file format