Skip to content

Commit

Permalink
Merge branch 'main' into ioanaif/passing-behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski committed Apr 14, 2022
2 parents 11524c6 + 6270958 commit fc7f9ec
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 44 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@
"contributions": [
"doc"
]
},
{
"login": "Ahmad-AlSubaie",
"name": "Ahmad-AlSubaie",
"avatar_url": "https://avatars.githubusercontent.com/u/32343365?v=4",
"profile": "https://github.com/Ahmad-AlSubaie",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ project(
message(STATUS "CMake version ${CMAKE_VERSION}")
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")

include(CMakeDependentOption)

# Defaults for properties in this directory (and below)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down Expand Up @@ -93,10 +95,16 @@ if(BUILD_TESTING)
endif()

option(PYBUILD "Build Python modules")
cmake_dependent_option(AWKWARD_EXTERNAL_PYBIND11 "Build against an external pybind11" OFF
"PYBUILD" OFF)

# Third tier: Python modules.
if(PYBUILD)
add_subdirectory(pybind11)
if(AWKWARD_EXTERNAL_PYBIND11)
find_package(pybind11 CONFIG REQUIRED)
else()
add_subdirectory(pybind11)
endif()

file(GLOB LAYOUT_SOURCES "src/python/*.cpp")
pybind11_add_module(_ext ${LAYOUT_SOURCES})
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ Thanks especially to the gracious help of Awkward Array contributors (including
<td align="center"><a href="http://www.matthewfeickert.com/"><img src="https://avatars.githubusercontent.com/u/5142394?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Matthew Feickert</b></sub></a><br /><a href="#maintenance-matthewfeickert" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/SantamRC"><img src="https://avatars.githubusercontent.com/u/52635773?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Santam Roy Choudhury</b></sub></a><br /><a href="https://github.com/scikit-hep/awkward-1.0/commits?author=SantamRC" title="Tests">⚠️</a></td>
<td align="center"><a href="http://jeroen.vangoey.be"><img src="https://avatars.githubusercontent.com/u/59344?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Van Goey</b></sub></a><br /><a href="https://github.com/scikit-hep/awkward-1.0/commits?author=BioGeek" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/Ahmad-AlSubaie"><img src="https://avatars.githubusercontent.com/u/32343365?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ahmad-AlSubaie</b></sub></a><br /><a href="https://github.com/scikit-hep/awkward-1.0/commits?author=Ahmad-AlSubaie" title="Code">💻</a></td>
</tr>
</table>

Expand Down
2 changes: 1 addition & 1 deletion pybind11
Submodule pybind11 updated 90 files
+19 −0 .clang-format
+7 −1 .clang-tidy
+5 −5 .github/workflows/ci.yml
+3 −7 .pre-commit-config.yaml
+125 −0 docs/changelog.rst
+1 −1 docs/compiling.rst
+156 −94 include/pybind11/attr.h
+86 −37 include/pybind11/buffer_info.h
+572 −331 include/pybind11/cast.h
+80 −55 include/pybind11/chrono.h
+19 −10 include/pybind11/complex.h
+138 −99 include/pybind11/detail/class.h
+530 −383 include/pybind11/detail/common.h
+53 −28 include/pybind11/detail/descr.h
+175 −93 include/pybind11/detail/init.h
+82 −63 include/pybind11/detail/internals.h
+308 −210 include/pybind11/detail/type_caster_base.h
+10 −6 include/pybind11/detail/typeid.h
+286 −195 include/pybind11/eigen.h
+32 −26 include/pybind11/embed.h
+59 −44 include/pybind11/eval.h
+20 −10 include/pybind11/functional.h
+39 −30 include/pybind11/gil.h
+28 −38 include/pybind11/iostream.h
+710 −493 include/pybind11/numpy.h
+155 −98 include/pybind11/operators.h
+26 −15 include/pybind11/options.h
+980 −682 include/pybind11/pybind11.h
+618 −389 include/pybind11/pytypes.h
+122 −75 include/pybind11/stl.h
+25 −25 include/pybind11/stl/filesystem.h
+300 −262 include/pybind11/stl_bind.h
+6 −7 noxfile.py
+1 −1 pybind11/_version.py
+5 −2 setup.py
+95 −48 tests/constructor_stats.h
+14 −23 tests/cross_module_gil_utils.cpp
+24 −17 tests/local_bindings.h
+63 −37 tests/object.h
+41 −43 tests/pybind11_cross_module_tests.cpp
+12 −11 tests/pybind11_tests.cpp
+17 −11 tests/pybind11_tests.h
+2 −3 tests/test_async.cpp
+45 −37 tests/test_buffers.cpp
+193 −118 tests/test_builtin_casters.cpp
+27 −19 tests/test_call_policies.cpp
+48 −32 tests/test_callbacks.cpp
+15 −18 tests/test_chrono.cpp
+197 −118 tests/test_class.cpp
+5 −3 tests/test_cmake_build/embed.cpp
+32 −35 tests/test_constants_and_functions.cpp
+118 −64 tests/test_copy_move.cpp
+97 −34 tests/test_custom_type_casters.cpp
+4 −0 tests/test_custom_type_casters.py
+37 −18 tests/test_docstring_options.cpp
+130 −77 tests/test_eigen.cpp
+1 −1 tests/test_embed/CMakeLists.txt
+8 −3 tests/test_embed/catch.cpp
+3 −6 tests/test_embed/external_module.cpp
+56 −31 tests/test_embed/test_interpreter.cpp
+34 −49 tests/test_enum.cpp
+15 −16 tests/test_eval.cpp
+71 −59 tests/test_exceptions.cpp
+1 −0 tests/test_exceptions.h
+75 −35 tests/test_factory_constructors.cpp
+21 −23 tests/test_gil_scoped.cpp
+19 −14 tests/test_iostream.cpp
+167 −81 tests/test_kwargs_and_defaults.cpp
+20 −21 tests/test_local_bindings.cpp
+113 −81 tests/test_methods_and_attributes.cpp
+43 −22 tests/test_modules.cpp
+81 −56 tests/test_multiple_inheritance.cpp
+180 −128 tests/test_numpy_array.cpp
+199 −138 tests/test_numpy_dtypes.cpp
+22 −22 tests/test_numpy_dtypes.py
+18 −14 tests/test_numpy_vectorize.cpp
+11 −7 tests/test_opaque_types.cpp
+105 −71 tests/test_operator_overloading.cpp
+15 −9 tests/test_pickling.cpp
+86 −98 tests/test_pytypes.cpp
+166 −104 tests/test_sequences_and_iterators.cpp
+62 −40 tests/test_smart_ptr.cpp
+124 −121 tests/test_stl.cpp
+57 −36 tests/test_stl_binders.cpp
+48 −45 tests/test_tagbased_polymorphic.cpp
+5 −5 tests/test_thread.cpp
+168 −150 tests/test_virtual_functions.cpp
+2 −0 tools/FindCatch.cmake
+16 −3 tools/FindPythonLibsNew.cmake
+1 −1 tools/pybind11Config.cmake.in
4 changes: 1 addition & 3 deletions src/awkward/_connect/_numba/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def globalstring(context, builder, pyvalue):
buf = dynamic_addrs[pyvalue] = numpy.array(pyvalue.encode("utf-8") + b"\x00")
context.add_dynamic_addr(builder, buf.ctypes.data, info=f"str({pyvalue!r})")
ptr = context.get_constant(numba.types.uintp, dynamic_addrs[pyvalue].ctypes.data)
return builder.inttoptr(
ptr, llvmlite.llvmpy.core.Type.pointer(llvmlite.llvmpy.core.Type.int(8))
)
return builder.inttoptr(ptr, llvmlite.ir.PointerType(llvmlite.ir.IntType(8)))


class ArrayBuilderType(numba.types.Type):
Expand Down
4 changes: 1 addition & 3 deletions src/awkward/_v2/_connect/numba/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def globalstring(context, builder, pyvalue):
buf = dynamic_addrs[pyvalue] = numpy.array(pyvalue.encode("utf-8") + b"\x00")
context.add_dynamic_addr(builder, buf.ctypes.data, info=f"str({repr(pyvalue)})")
ptr = context.get_constant(numba.types.uintp, dynamic_addrs[pyvalue].ctypes.data)
return builder.inttoptr(
ptr, llvmlite.llvmpy.core.Type.pointer(llvmlite.llvmpy.core.Type.int(8))
)
return builder.inttoptr(ptr, llvmlite.ir.PointerType(llvmlite.ir.IntType(8)))


class ArrayBuilderType(numba.types.Type):
Expand Down
6 changes: 2 additions & 4 deletions src/awkward/_v2/behaviors/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _string_numba_lower(
context, builder, rettype, viewtype, viewval, viewproxy, attype, atval
):
import numba
import llvmlite.llvmpy.core
import llvmlite.ir

whichpos = ak._v2._connect.numba.layout.posat(
context, builder, viewproxy.pos, viewtype.type.CONTENT
Expand Down Expand Up @@ -213,9 +213,7 @@ def _string_numba_lower(
)
rawptr_cast = builder.inttoptr(
rawptr,
llvmlite.llvmpy.core.Type.pointer(
llvmlite.llvmpy.core.Type.int(numba.intp.bitwidth // 8)
),
llvmlite.ir.PointerType(llvmlite.ir.IntType(numba.intp.bitwidth // 8)),
)
strsize = builder.sub(stop, start)
strsize_cast = ak._v2._connect.numba.layout.castint(
Expand Down
9 changes: 5 additions & 4 deletions src/awkward/_v2/contents/bitmaskedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,11 +634,12 @@ def _to_list(self, behavior):
return out

mask = self.mask_as_bool(valid_when=True, nplike=self.nplike)[: self._length]
content = self._content._to_list(behavior)
out = [None] * self._length
out = self._content._getitem_range(slice(0, self._length))._to_list(behavior)

for i, isvalid in enumerate(mask):
if isvalid:
out[i] = content[i]
if not isvalid:
out[i] = None

return out

def _to_nplike(self, nplike):
Expand Down
9 changes: 5 additions & 4 deletions src/awkward/_v2/contents/bytemaskedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,11 +1035,12 @@ def _to_list(self, behavior):
return out

mask = self.mask_as_bool(valid_when=True, nplike=self.nplike)
content = self._content._to_list(behavior)
out = [None] * self._mask.length
out = self._content._getitem_range(slice(0, len(mask)))._to_list(behavior)

for i, isvalid in enumerate(mask):
if isvalid:
out[i] = content[i]
if not isvalid:
out[i] = None

return out

def _to_nplike(self, nplike):
Expand Down
7 changes: 2 additions & 5 deletions src/awkward/_v2/contents/indexedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,11 +1221,8 @@ def _to_list(self, behavior):
return out

index = self._index.raw(numpy)
content = self._content._to_list(behavior)
out = [None] * index.length
for i, ind in enumerate(index):
out[i] = content[ind]
return out
nextcontent = self._content._carry(ak._v2.index.Index(index), False)
return nextcontent._to_list(behavior)

def _to_nplike(self, nplike):
index = self._index._to_nplike(nplike)
Expand Down
16 changes: 11 additions & 5 deletions src/awkward/_v2/contents/indexedoptionarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,11 +1653,17 @@ def _to_list(self, behavior):
return out

index = self._index.raw(numpy)
content = self._content._to_list(behavior)
out = [None] * len(index)
for i, ind in enumerate(index):
if ind >= 0:
out[i] = content[ind]
not_missing = index >= 0

nextcontent = self._content._carry(
ak._v2.index.Index(index[not_missing]), False
)
out = nextcontent._to_list(behavior)

for i, isvalid in enumerate(not_missing):
if not isvalid:
out.insert(i, None)

return out

def _to_nplike(self, nplike):
Expand Down
33 changes: 24 additions & 9 deletions src/awkward/_v2/contents/listoffsetarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2062,33 +2062,48 @@ def packed(self):
)

def _to_list(self, behavior):
starts, stops = self.starts, self.stops
starts_data = starts.raw(numpy)
stops_data = stops.raw(numpy)[: len(starts_data)]

nonempty = starts_data != stops_data
if numpy.count_nonzero(nonempty) == 0:
mini, maxi = 0, 0
else:
mini = starts_data.min()
maxi = stops_data.max()

starts_data = starts_data - mini
stops_data = stops_data - mini

nextcontent = self._content._getitem_range(slice(mini, maxi))

if self.parameter("__array__") == "bytestring":
content = ak._v2._util.tobytes(self._content.data)
starts, stops = self.starts, self.stops
content = ak._v2._util.tobytes(nextcontent.data)
out = [None] * starts.length
for i in range(starts.length):
out[i] = content[starts[i] : stops[i]]
out[i] = content[starts_data[i] : stops_data[i]]
return out

elif self.parameter("__array__") == "string":
content = ak._v2._util.tobytes(self._content.data)
starts, stops = self.starts, self.stops
content = ak._v2._util.tobytes(nextcontent.data)
out = [None] * starts.length
for i in range(starts.length):
out[i] = content[starts[i] : stops[i]].decode(errors="surrogateescape")
out[i] = content[starts_data[i] : stops_data[i]].decode(
errors="surrogateescape"
)
return out

else:
out = self._to_list_custom(behavior)
if out is not None:
return out

content = self._content._to_list(behavior)
starts, stops = self.starts, self.stops
content = nextcontent._to_list(behavior)
out = [None] * starts.length

for i in range(starts.length):
out[i] = content[starts[i] : stops[i]]
out[i] = content[starts_data[i] : stops_data[i]]
return out

def _to_nplike(self, nplike):
Expand Down
16 changes: 15 additions & 1 deletion src/awkward/_v2/highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,13 @@ def fields(self):
"""
return self._layout.fields

@property
def is_tuple(self):
"""
If True, the top-most record structure has no named fields, i.e. it's a tuple.
"""
return self._layout.is_tuple

def _ipython_key_completions_(self):
return self._layout.fields

Expand Down Expand Up @@ -533,7 +540,7 @@ def __iter__(self):
errors="surrogateescape"
)
else:
yield x
yield ak._v2._util.wrap(x, self._behavior)
elif isinstance(x, (ak._v2.contents.Content, ak._v2.record.Record)):
yield ak._v2._util.wrap(x, self._behavior)
else:
Expand Down Expand Up @@ -1580,6 +1587,13 @@ def fields(self):
"""
return self._layout.array.fields

@property
def is_tuple(self):
"""
If True, the top-most record structure has no named fields, i.e. it's a tuple.
"""
return self._layout.array.is_tuple

def _ipython_key_completions_(self):
return self._layout.array.fields

Expand Down
6 changes: 2 additions & 4 deletions src/awkward/behaviors/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _string_numba_lower(
context, builder, rettype, viewtype, viewval, viewproxy, attype, atval
):
import numba
import llvmlite.llvmpy.core
import llvmlite.ir

whichpos = ak._connect._numba.layout.posat(
context, builder, viewproxy.pos, viewtype.type.CONTENT
Expand Down Expand Up @@ -228,9 +228,7 @@ def _string_numba_lower(
)
rawptr_cast = builder.inttoptr(
rawptr,
llvmlite.llvmpy.core.Type.pointer(
llvmlite.llvmpy.core.Type.int(numba.intp.bitwidth // 8)
),
llvmlite.ir.PointerType(llvmlite.ir.IntType(numba.intp.bitwidth // 8)),
)
strsize = builder.sub(stop, start)
strsize_cast = ak._connect._numba.castint(
Expand Down

0 comments on commit fc7f9ec

Please sign in to comment.