From bad99a190490319d86bd5c7f9f23ac2fc4e72598 Mon Sep 17 00:00:00 2001 From: Joshua Storck Date: Thu, 20 Oct 2016 16:22:41 -0400 Subject: [PATCH] Adding operator+[=] and operator/[=] for FloatingArray and IntegerArray. This includes a design change that obviates the need for an ArrayView. Instead, every array has an internal offset. Shallow copy is achieved by copy constructor, though the current set of copy constructors don't yet support a slice. Deep copy is still achieved through the Copy virtual function. More detailed explanation of the changes: * Adding copy/move constructors for {Floating,Integer,Numeric}Array * Adding various method for marking/getting nulls (valid bits) in integer arrays * Changing data() and mutable_data() in NumericArray so that they return a pointer that starts at the array's offset * Addition of Addable/Divisable classes (similar to Boost operators) for easy support of operator[+/] * Unit test scaffolding for testing permutations of left/right hand side types on arithmetic operators * Implementing IntegerArray::operator/, IntegerArray::operator+= FloatingArray::operator/=, FloatingArray::operator+= --- CMakeLists.txt | 2 +- pandas/native.pxd | 2 +- pandas/native.pyx | 2 +- src/pandas/array-test.cc | 171 +++++++++++++++++++ src/pandas/array.cc | 5 +- src/pandas/array.h | 25 ++- src/pandas/type.h | 4 +- src/pandas/types/category.cc | 3 + src/pandas/types/category.h | 11 +- src/pandas/types/numeric.cc | 99 +++++++++-- src/pandas/types/numeric.h | 297 +++++++++++++++++++++++++++++++-- src/pandas/types/numeric_fwd.h | 42 +++++ 12 files changed, 607 insertions(+), 56 deletions(-) create mode 100644 src/pandas/types/numeric_fwd.h diff --git a/CMakeLists.txt b/CMakeLists.txt index be51d7c96..4daeeab4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,7 @@ endif() # GCC cannot always verify whether strict aliasing rules are indeed followed due to # fundamental limitations in escape analysis, which can result in subtle bad code generation. # This has a small perf hit but worth it to avoid hard to debug crashes. -set(CXX_COMMON_FLAGS "-std=c++11 -fno-strict-aliasing -msse4.2 -Wall -Wno-sign-compare -Wno-deprecated -pthread -D__STDC_FORMAT_MACROS") +set(CXX_COMMON_FLAGS "-std=c++1y -fno-strict-aliasing -msse4.2 -Wall -Wno-sign-compare -Wno-deprecated -pthread -D__STDC_FORMAT_MACROS") # compiler flags for different build types (run 'cmake -DCMAKE_BUILD_TYPE= .') # For all builds: diff --git a/pandas/native.pxd b/pandas/native.pxd index 429993804..8a624d04b 100644 --- a/pandas/native.pxd +++ b/pandas/native.pxd @@ -74,7 +74,7 @@ cdef extern from "pandas/api.h" namespace "pandas": c_bool Equals(const DataType& other) string ToString() - ctypedef shared_ptr[DataType] TypePtr + ctypedef shared_ptr[const DataType] TypePtr cdef cppclass Int8Type(DataType): pass diff --git a/pandas/native.pyx b/pandas/native.pyx index b700dedbe..9d7de4b8b 100644 --- a/pandas/native.pyx +++ b/pandas/native.pyx @@ -277,7 +277,7 @@ cdef Array wrap_array(const lp.ArrayPtr& arr): cdef PandasType wrap_type(const lp.TypePtr& sp_type): cdef: - lp.DataType* type = sp_type.get() + const lp.DataType* type = sp_type.get() PandasType result if type.type() == lp.TypeId_CATEGORY: diff --git a/src/pandas/array-test.cc b/src/pandas/array-test.cc index 04acf5ba9..fe050576a 100644 --- a/src/pandas/array-test.cc +++ b/src/pandas/array-test.cc @@ -45,6 +45,177 @@ TEST_F(TestArray, Attrs) { ASSERT_EQ(values_.size(), array_->length()); } +template