Skip to content

Commit 8cdef57

Browse files
committed
Merge pull request #615 from skrah/separate_datashape
Separate ndt from array and callables.
2 parents 798b4ad + 9b2b8c4 commit 8cdef57

27 files changed

+375
-184
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ BreakBeforeBraces: Stroustrup
66
Cpp11BracedListStyle: true
77
NamespaceIndentation: Inner
88
AlwaysBreakTemplateDeclarations: true
9-
9+
ColumnLimit: 120

CMakeLists.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,26 +157,33 @@ cython_add_module(dynd.nd.array dynd.nd.array_pyx True
157157
dynd/src/array_as_pep3118.cpp
158158
dynd/src/array_as_numpy.cpp
159159
dynd/src/array_from_py.cpp
160-
dynd/src/array_from_py_typededuction.cpp
161160
dynd/src/assign.cpp
162-
dynd/src/conversions.cpp
161+
dynd/src/array_conversions.cpp
163162
dynd/src/copy_from_numpy_arrfunc.cpp
164163
dynd/src/init.cpp
165164
dynd/src/functional.cpp
166165
dynd/src/numpy_interop.cpp
166+
dynd/src/type_conversions.cpp
167+
dynd/src/type_deduction.cpp
167168
dynd/src/types/pyobject_type.cpp
168169
)
169170

170171
cython_add_module(dynd.config dynd.config_pyx True
171172
dynd/include/exception_translation.hpp
172-
dynd/src/conversions.cpp
173+
dynd/src/array_conversions.cpp
174+
dynd/src/type_conversions.cpp
175+
dynd/src/type_deduction.cpp
173176
${CMAKE_CURRENT_BINARY_DIR}/dynd/src/git_version.cpp
174177
)
175178

176179
foreach(module dynd.ndt.type dynd.ndt.json dynd.nd.callable dynd.nd.functional dynd.nd.registry)
177-
cython_add_module(${module} ${module}_pyx True dynd/src/conversions.cpp)
180+
cython_add_module(${module} ${module}_pyx True
181+
# Additional C++ source files:
182+
dynd/src/type_conversions.cpp
183+
dynd/src/array_conversions.cpp)
178184
endforeach(module)
179185

186+
180187
# Run a postprocess script to work around some Cython bugs
181188
# that haven't been fixed in the latest release.
182189
postprocess_cython( postprocess.py dynd.ndt.type_postprocess dynd.ndt.type_pyx dynd.ndt.type)

dynd/cpp/types/categorical_type.pxd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2+
# Disabled until categorical_type::make takes a std::vector<T>
3+
4+
"""
15
from ..type cimport type
26
from ..array cimport array
37
@@ -6,3 +10,4 @@ from ...config cimport translate_exception
610
cdef extern from "dynd/types/categorical_type.hpp" namespace "dynd::ndt":
711
type dynd_make_categorical_type "dynd::ndt::categorical_type::make" (array&) except +translate_exception
812
type factor_categorical(array&) except +translate_exception
13+
"""

dynd/include/conversions.hpp renamed to dynd/include/array_conversions.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,11 @@
44

55
#include <dynd/array.hpp>
66
#include <dynd/callable.hpp>
7-
#include <dynd/type.hpp>
87

98
#include "visibility.hpp"
109

1110
namespace pydynd {
1211

13-
PYDYND_API dynd::ndt::type &type_to_cpp_ref(PyObject *);
14-
PYDYND_API PyTypeObject *get_type_pytypeobject();
15-
PYDYND_API PyObject *type_from_cpp(const dynd::ndt::type &);
16-
PYDYND_API dynd::ndt::type dynd_ndt_as_cpp_type(PyObject *);
17-
PYDYND_API dynd::ndt::type dynd_ndt_cpp_type_for(PyObject *);
18-
1912
PYDYND_API dynd::nd::array &array_to_cpp_ref(PyObject *);
2013
PYDYND_API PyTypeObject *get_array_pytypeobject();
2114
PYDYND_API PyObject *array_from_cpp(const dynd::nd::array &);

dynd/include/array_from_py.hpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include <dynd/types/type_id.hpp>
1212

13-
#include "array_from_py_typededuction.hpp"
1413
#include "visibility.hpp"
1514

1615
#include <dynd/array.hpp>
@@ -35,24 +34,6 @@ PYDYND_API dynd::nd::array array_from_py(PyObject *obj, uint32_t access_flags,
3534

3635
PYDYND_API dynd::ndt::type xtype_for_prefix(PyObject *obj);
3736

38-
inline dynd::ndt::type xarray_from_pylist(PyObject *obj)
39-
{
40-
// TODO: Add ability to specify access flags (e.g. immutable)
41-
// Do a pass through all the data to deduce its type and shape
42-
std::vector<intptr_t> shape;
43-
dynd::ndt::type tp(dynd::void_id);
44-
Py_ssize_t size = PyList_GET_SIZE(obj);
45-
shape.push_back(size);
46-
for (Py_ssize_t i = 0; i < size; ++i) {
47-
deduce_pylist_shape_and_dtype(PyList_GET_ITEM(obj, i), shape, tp, 1);
48-
}
49-
50-
if (tp.get_id() == dynd::void_id) {
51-
tp = dynd::ndt::type(dynd::int32_id);
52-
}
53-
54-
return dynd::ndt::make_type(shape.size(), shape.data(), tp);
55-
}
5637

5738
void init_array_from_py();
5839

dynd/include/array_functions.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
#include "array_as_numpy.hpp"
2727
#include "array_as_pep3118.hpp"
2828
#include "array_from_py.hpp"
29-
#include "conversions.hpp"
29+
#include "array_conversions.hpp"
30+
#include "utility_functions.hpp"
3031
#include "type_functions.hpp"
3132
#include "types/pyobject_type.hpp"
32-
#include "utility_functions.hpp"
3333
#include "visibility.hpp"
3434

3535
namespace pydynd {

dynd/include/kernels/apply_jit_kernel.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#include <dynd/kernels/base_kernel.hpp>
44
#include <array_functions.hpp>
55
#include <utility_functions.hpp>
6-
#include <type_functions.hpp>
76

8-
#include "conversions.hpp"
7+
#include "type_functions.hpp"
8+
#include "array_conversions.hpp"
99

1010
namespace pydynd {
1111
namespace nd {

dynd/include/kernels/apply_pyobject_kernel.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <dynd/kernels/base_kernel.hpp>
44
#include <dynd/func/assignment.hpp>
55

6+
#include "array_conversions.hpp"
67
#include "type_functions.hpp"
78
#include "types/pyobject_type.hpp"
89

dynd/include/kernels/assign_from_pyobject_kernel.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
#include <dynd/types/categorical_type.hpp>
1515
#include <dynd/types/var_dim_type.hpp>
1616

17-
#include "array_from_py_typededuction.hpp"
1817
#include "array_functions.hpp"
19-
#include "conversions.hpp"
18+
#include "array_conversions.hpp"
2019
#include "copy_from_numpy_arrfunc.hpp"
2120
#include "type_functions.hpp"
21+
#include "type_deduction.hpp"
2222
#include "types/pyobject_type.hpp"
2323

2424
using namespace dynd;

dynd/include/numpy_interop.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <vector>
1616

1717
#include "utility_functions.hpp"
18+
#include "type_functions.hpp"
1819

1920
// Define this to 1 or 0 depending on whether numpy interop
2021
// should be compiled in.
@@ -48,6 +49,7 @@
4849
#include <dynd/array.hpp>
4950
#include <dynd/type.hpp>
5051
#include <dynd/types/fixed_string_type.hpp>
52+
#include <dynd/types/struct_type.hpp>
5153

5254
#include <numpy/ndarrayobject.h>
5355
#include <numpy/ufuncobject.h>
@@ -538,6 +540,4 @@ typedef struct {
538540
} // namespace pydynd
539541
#endif // !DYND_NUMPY_INTEROP
540542

541-
#include "type_functions.hpp"
542-
543543
#endif // _DYND__NUMPY_INTEROP_HPP_

0 commit comments

Comments
 (0)