├── docs ├── user-guide │ ├── requirements.txt │ ├── cartoon-cartesian.png │ ├── cartoon-combinations.png │ ├── index.md │ ├── how-to-math.md │ ├── how-to-create.md │ ├── how-to-filter.md │ ├── how-to-specialize.md │ ├── how-to-combinatorics.md │ ├── how-to-convert.md │ ├── how-to-examine.md │ ├── how-to-array-properties.md │ ├── how-to-restructure.md │ ├── how-to-strings.md │ └── how-to-use-in-cpp.md ├── image │ ├── favicon.ico │ ├── desire-path.jpg │ ├── logo-300px.png │ ├── how-it-works.svg │ ├── example-array.svg │ ├── bikeroutes-scaling.svg │ ├── awkward-1-0-layers.svg │ ├── example-reduction-sum.svg │ ├── example-reduction-sum-only.svg │ └── github-issues-documentation.png ├── requirements-wasm.txt ├── _static │ ├── image │ │ ├── logo-300px.png │ │ └── logo-300px-white.png │ ├── js │ │ └── awkward.js │ └── css │ │ └── try-awkward-array.css ├── getting-started │ ├── cartoon-cartesian.png │ ├── cartoon-combinations.png │ ├── example-reduction-sum.svg │ └── 8-layer_cube.jpg ├── samples │ └── Android.head.log.gz ├── lite │ └── jupyter-lite.json ├── environment.yml.cog ├── _templates │ ├── redirect.html │ └── funding.html └── requirements.txt ├── src └── awkward │ ├── _meta │ └── __init__.py │ ├── _backends │ └── __init__.py │ ├── _connect │ ├── __init__.py │ ├── numba │ │ └── __init__.py │ ├── rdataframe │ │ └── __init__.py │ ├── jax │ │ └── __init__.py │ ├── cuda │ │ └── cuda_kernels │ │ │ ├── awkward_localindex.cu │ │ │ ├── awkward_IndexedArray_numnull_unique_64.cu │ │ │ ├── awkward_UnionArray_fillindex_count.cu │ │ │ ├── awkward_UnionArray_filltags_const.cu │ │ │ ├── awkward_UnionArray_fillna.cu │ │ │ ├── awkward_IndexedArray_fill_count.cu │ │ │ ├── awkward_UnionArray_fillindex.cu │ │ │ ├── awkward_UnionArray_filltags.cu │ │ │ ├── awkward_index_rpad_and_clip_axis1.cu │ │ │ ├── awkward_IndexedArray_overlay_mask.cu │ │ │ ├── awkward_RegularArray_localindex.cu │ │ │ ├── awkward_ByteMaskedArray_toIndexedOptionArray.cu │ │ │ ├── awkward_ListOffsetArray_flatten_offsets.cu │ │ │ ├── awkward_IndexedArray_fill.cu │ │ │ ├── awkward_IndexedArray_reduce_next_fix_offsets_64.cu │ │ │ ├── awkward_NumpyArray_reduce_mask_ByteMaskedArray_64.cu │ │ │ ├── awkward_ByteMaskedArray_overlay_mask.cu │ │ │ ├── awkward_ListArray_localindex.cu │ │ │ ├── awkward_RegularArray_getitem_carry.cu │ │ │ ├── awkward_index_rpad_and_clip_axis0.cu │ │ │ ├── awkward_NumpyArray_reduce_adjust_starts_64.cu │ │ │ ├── awkward_RegularArray_getitem_next_range_spreadadvanced.cu │ │ │ ├── awkward_RegularArray_getitem_next_array_advanced.cu │ │ │ ├── awkward_ListArray_fill.cu │ │ │ ├── awkward_RegularArray_getitem_next_range.cu │ │ │ ├── awkward_missing_repeat.cu │ │ │ ├── awkward_UnionArray_simplify_one.cu │ │ │ ├── awkward_ListArray_getitem_next_range_spreadadvanced.cu │ │ │ ├── awkward_ListOffsetArray_reduce_nonlocal_nextstarts_64.cu │ │ │ └── awkward_NumpyArray_reduce_adjust_starts_shifts_64.cu │ └── dlpack.py │ ├── behaviors │ ├── __init__.py │ ├── categorical.py │ └── string.py │ ├── builder.py │ ├── forth.py │ ├── errors.py │ ├── _ext.py │ ├── operations │ └── ak_to_cudf.py │ ├── _prettyprint.py │ └── _typetracer.py ├── dev ├── robots.txt ├── cuda-tests │ ├── cuda-tests.timer │ ├── cuda-tests.Dockerfile │ └── cuda-tests.service ├── format-release-prs └── validate-test-names.py ├── awkward-cpp ├── .cmake-format.yaml ├── README.md ├── .gitignore ├── src │ ├── libawkward │ │ └── builder │ │ │ └── Builder.cpp │ ├── awkward_cpp │ │ ├── __init__.py │ │ └── cpu_kernels.py │ ├── cpu-kernels │ │ ├── awkward_IndexedArray_numnull_unique_64.cpp │ │ ├── awkward_reduce_count_64.cpp │ │ ├── awkward_ByteMaskedArray_numnull.cpp │ │ ├── awkward_sorting_ranges_length.cpp │ │ ├── awkward_localindex.cpp │ │ ├── awkward_IndexedArray_reduce_next_fix_offsets_64.cpp │ │ ├── awkward_reduce_sum_int32_bool_64.cpp │ │ ├── awkward_reduce_sum_int64_bool_64.cpp │ │ ├── awkward_NumpyArray_reduce_mask_ByteMaskedArray_64.cpp │ │ ├── unicode.cpp │ │ ├── awkward_NumpyArray_reduce_adjust_starts_64.cpp │ │ ├── awkward_ListOffsetArray_reduce_nonlocal_nextstarts_64.cpp │ │ ├── awkward_sorting_ranges.cpp │ │ ├── awkward_RegularArray_reduce_local_nextparents_64.cpp │ │ ├── awkward_NumpyArray_reduce_adjust_starts_shifts_64.cpp │ │ ├── awkward_ByteMaskedArray_reduce_next_nonlocal_nextshifts_64.cpp │ │ ├── awkward_RegularArray_localindex.cpp │ │ ├── awkward_UnionArray_fillindex_count.cpp │ │ ├── awkward_ListOffsetArray_reduce_local_outoffsets_64.cpp │ │ ├── awkward_ListOffsetArray_reduce_nonlocal_maxcount_offsetscopy_64.cpp │ │ ├── awkward_unique_ranges_bool.cpp │ │ ├── awkward_IndexedArray_fill_count.cpp │ │ ├── awkward_ByteMaskedArray_reduce_next_64.cpp │ │ ├── awkward_UnionArray_filltags_const.cpp │ │ └── awkward_ByteMaskedArray_reduce_next_nonlocal_nextshifts_fromshifts_64.cpp │ └── python │ │ └── _ext.cpp ├── include │ └── awkward │ │ ├── python │ │ ├── io.h │ │ ├── kernel_utils.h │ │ └── forth.h │ │ ├── unicode.h │ │ └── kernel-utils.h ├── docs │ ├── stylesheet.css │ └── footer.html └── .clang-format ├── .DS_Store ├── requirements-test-pypy.txt ├── requirements-test-numpy1.txt ├── studies ├── chep-2019 │ ├── read_rntuple.dat │ ├── read_ttree_rootnumpy.dat │ ├── read_ttree_new.dat │ ├── read_ttree_old.dat │ ├── read_ttree.pdf │ ├── read_ttree.png │ ├── read_pyobj_old.dat │ ├── read_json_new.dat │ ├── read_json_old.dat │ ├── read_pyobj_new.dat │ └── chep2019-plot.gnuplot ├── small-example.json ├── use-simdjson.cpp ├── awkward-forth-performance │ ├── read-parquet-fast.sh │ ├── fastavro-read-jagged0-avro.py │ ├── fastavro-read-jagged1-avro.py │ ├── fastavro-read-jagged2-avro.py │ ├── fastavro-read-jagged3-avro.py │ ├── uproot-read-jagged0-root.py │ ├── read-parquet.sh │ ├── uproot-read-jagged2-root.py │ ├── uproot-read-jagged3-root.py │ ├── uproot-read-jagged1-root.py │ └── forth-read-jagged0-root.py ├── cuda-kernels │ └── test-cuda-kernels.sh └── templated-LayoutBuilder │ └── test-stuff.cpp ├── docs-img ├── logo │ ├── favicon.ico │ ├── logo-300px.png │ ├── logo-600px.png │ └── logo-300px-white.png ├── panel-doxygen.png ├── panel-sphinx.png ├── panel-developers.png ├── panel-tutorials.png ├── panel-data-analysts.png ├── photos │ └── desire-path.jpg ├── diagrams │ ├── git-strategy.pdf │ ├── git-strategy.png │ ├── awkward-timeline.pdf │ ├── awkward-timeline.png │ ├── cartoon-cartesian.png │ ├── cartoon-schematic.png │ ├── example-hierarchy.png │ ├── example-reduction.png │ ├── awkward-1-0-layers.pdf │ ├── awkward-1-0-layers.png │ ├── cartoon-broadcasting.png │ ├── cartoon-combinations.png │ ├── how-it-works-muons.png │ ├── awkward-uproot-timeline.png │ ├── awkward-uproot-timeline-pip.png │ └── awkward-uproot-timeline-pip-github.png ├── panel-tutorials-alternate.png ├── plots │ ├── awkward-0-popularity.pdf │ └── awkward-0-popularity.png └── screenshots │ └── github-issues-documentation.png ├── tests ├── __init__.py ├── samples │ ├── int_test_data.avro │ ├── array_test_data.avro │ ├── awkward1-strings.pkl │ ├── bool_test_data.avro │ ├── bytes_test_data.avro │ ├── enum_test_data.avro │ ├── fixed_test_data.avro │ ├── float_test_data.avro │ ├── list-depths.parquet │ ├── list-lengths.parquet │ ├── long_test_data.avro │ ├── null_test_data.avro │ ├── awkward1-emptyarray.pkl │ ├── awkward1-numpyarray.pkl │ ├── awkward1-unionarray.pkl │ ├── double_test_data.avro │ ├── int_null_test_data.avro │ ├── nullable-depths.parquet │ ├── nullable-levels.parquet │ ├── record_0_test_data.avro │ ├── record_1_test_data.avro │ ├── record_test_data.avro │ ├── string_test_data.avro │ ├── array_enum_test_data.avro │ ├── awkward1-recordarray.pkl │ ├── awkward1-regulararray.pkl │ ├── enum_null_test_data.avro │ ├── record-primitives.parquet │ ├── array_string_test_data.avro │ ├── awkward1-bytemaskedarray.pkl │ ├── awkward1-listoffsetarray.pkl │ ├── awkward1-unmaskedarray.pkl │ ├── list-depths-records.parquet │ ├── list-depths-simple.parquet │ ├── list-depths-strings.parquet │ ├── nonnullable-depths.parquet │ ├── nullable-list-depths.parquet │ ├── record_null_test_data.avro │ ├── string_null_test_data.avro │ ├── zero-record-batches.parquet │ ├── awkward1-recordarray-tuple.pkl │ ├── int_string_null_test_data.avro │ ├── awkward1-indexedoptionarray.pkl │ ├── list-depths-records-list.parquet │ ├── awkward1-partitioned-numpyarray.pkl │ ├── nullable-record-primitives.parquet │ ├── nullable-list-depths-records.parquet │ ├── nullable-list-depths-strings.parquet │ ├── __init__.py │ ├── nullable-list-depths-records-list.parquet │ ├── nullable-record-primitives-simple.parquet │ ├── test-record-array.json │ ├── test.json │ └── test-nan-inf.json ├── test_1944_to_numpy_empty_record_array.py ├── test_2407_broadcast_no_arrays.py ├── test_2503_deprecate_to_numpyform.py ├── test_2710_pickle_unknown_length.py ├── test_2076_ak_unzip_record.py ├── test_2181_with_name_len.py ├── test_1106_argminmax_axis_None_missing_values.py ├── test_1400_with_name_record.py ├── test_1593_empty_slice_list_record.py ├── test_1978_akRecord_constructor_should_retain_type.py ├── test_2518_datetime_units_as_parameter.py ├── test_2266_fix_nan_to_num.py ├── test_2934_argmin_argmax_bool.py ├── test_2219_flatten_empty.py ├── test_2591_nan_to_num.py ├── test_0758_ak_zip_scallars.py ├── test_2418_union_broadcast_unknown.py ├── test_1991_missed_a_NumpyArray_raw_call_without_underscore.py ├── test_0546_fill_none_replacement_value_type.py ├── test_1305_mixed_awkward_numpy_slicing.py ├── test_2008_ak_type_layout.py ├── test_1644_concatenate_zeros_length.py ├── test_3264_length_one_if_typetracer_with_option_types.py ├── test_1578_to_arrow_empty_recordarray.py ├── test_1735_from_numpy_mask.py ├── test_2765_slice_from_typetracer.py ├── test_2632_unflatten_length.py ├── test_1823_fill_none_axis_none.py ├── test_2294_view_unknown_scalar.py ├── test_2654_divmod.py ├── test_1007_from_buffers_empty_ndarray.py ├── test_2560_minimal_listarray.py ├── test_3033_flatten_bitmaskedarray.py ├── test_2556_jax_tracer_error.py ├── test_2816_public_typetracer_api.py ├── test_3028_mask_bitmaskedarray.py ├── test_1006_packed_regular_array_zero_size.py ├── test_2815_return_scalar_firsts.py ├── test_1403_from_numpy_strings.py ├── test_0903_ArrayView_expects_contiguous_NumpyArrays.py ├── test_0627_behavior_from_dict_of_arrays.py ├── test_0863_is_none_numpy_array.py ├── test_1826_ravel_preserve_none.py ├── test_2304_index_typetracer.py ├── test_0006_deep_iteration.py ├── test_2346_broadcast_depth_limit.py ├── test_0819_issue.py ├── test_2240_merge_union_parameters.py ├── test_2259_run_lengths_typetracer.py ├── test_2327_array_interface.py ├── test_2947_to_list_numpy_integer.py ├── test_3206_generalize_index_ptr.py ├── test_2120_missing_field_error.py ├── test_2051_arraybuilder_behavior_propagation.py ├── test_2104_numpy_merge_option.py ├── test_2246_slice_not_packed.py ├── test_1703_fill_none_typetracer.py ├── test_2678_same_backend.py ├── test_0905_leading_zeros_in_unflatten.py ├── test_1709_ak_array_constructor_behavior.py ├── test_2785_ak_num_typetracer_axis_0.py ├── test_2078_array_function_wrap.py ├── test_2426_is_equal_to.py ├── test_1940_ak_backend.py ├── test_1017_numpyarray_broadcast.py ├── test_1066_to_numpy_masked_structured_array.py ├── test_1685_IndexedArray_project_parameters.py ├── test_2263_to_packed_list.py ├── test_2634_listarray_pad_none.py ├── test_0559_fix_booleans_in_numba.py ├── test_1192_iterables_in___array_function__.py ├── test_2651_parameter_union.py ├── test_2188_values_astype_turns_EmptyArray_into_NumpyArray.py ├── test_1790_reduce_regulararray.py ├── test_2082_broadcast_zero_size.py ├── test_0884_index_and_identifier_refactoring.py ├── test_0339_highlevel_sorting_function.py ├── test_1747_bytemaskedarray_mergemany.py ├── test_2444_minimal_listarray.py ├── test_1764_jax_jacobian.py ├── test_1193_is_none_nested_option.py ├── test_0264_reduce_last_empty.py ├── test_1840_ak_type_to_handle_ndarray_dtype_and_nptypes.py ├── test_2354_ufunc_same_backend.py ├── test_2646_from_parquet_highlevel.py ├── test_0572_numba_array_ndim.py ├── test_2355_to_backend_record.py ├── test_1271_fix_4D_reducers.py ├── test_2023_from_rdataframe.py ├── test_2487_broadcast_list_offsets.py ├── test_1154_arrow_tables_should_preserve_parameters.py ├── test_0835_datetime_type_pandas.py ├── test_1344_broadcast_arrays_depth_limit.py ├── test_0910_unflatten_counts_relation.py ├── test_2226_slice_regulararray_typetracer.py ├── test_2550_validity_error_recursive.py ├── test_0979_where_multidimentional_numpy_array.py ├── test_1453_write_single_records_to_parquet.py ├── test_2631_vectorised_to_numpy_strings.py ├── test_3174_to_parquet_record.py ├── test_0975_mask_multidimensional_numpy_array.py ├── test_0828_arrow_datatype_null.py ├── test_0850_argsort_mask_array.py ├── test_1784_reduce_leading_sublist.py ├── test_1071_mask_identity_false_should_not_return_option_type.py ├── test_2064_fill_none_record.py └── test_2417_bytemasked_singletons.py ├── tests-cuda ├── __init__.py ├── test_2327_array_interface.py └── test_2649_dlpack_support.py ├── .gitmodules ├── requirements-test-minimal.txt ├── requirements-test-ml.txt ├── juliapkg.json ├── header-only ├── examples │ ├── cython │ │ ├── demo │ │ │ └── __init__.py │ │ ├── pyproject.toml │ │ ├── setup.py │ │ ├── demo_impl.pxd │ │ └── include │ │ │ └── demo_impl.h │ └── pybind11 │ │ ├── pyproject.toml │ │ └── README.md ├── README.md └── tests │ └── test_1560-builder-options.cpp ├── codecov.yml ├── .github ├── dependabot.yml ├── ISSUE_TEMPLATE │ └── config.yml ├── workflows │ ├── semantic-pr-title.yml │ └── lint.yml └── matchers │ └── pylint.json ├── .readthedocs.yml ├── requirements-test-full.txt └── cibuildwheel.toml /docs/user-guide/requirements.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/awkward/_meta/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dev/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | -------------------------------------------------------------------------------- /docs/image/favicon.ico: -------------------------------------------------------------------------------- 1 | ../../docs-img/logo/favicon.ico -------------------------------------------------------------------------------- /awkward-cpp/.cmake-format.yaml: -------------------------------------------------------------------------------- 1 | format: 2 | line_width: 99 3 | -------------------------------------------------------------------------------- /docs/image/desire-path.jpg: -------------------------------------------------------------------------------- 1 | ../../docs-img/photos/desire-path.jpg -------------------------------------------------------------------------------- /docs/image/logo-300px.png: -------------------------------------------------------------------------------- 1 | ../../docs-img/logo/logo-300px.png -------------------------------------------------------------------------------- /docs/image/how-it-works.svg: -------------------------------------------------------------------------------- 1 | ../../docs-img/diagrams/how-it-works.svg -------------------------------------------------------------------------------- /docs/requirements-wasm.txt: -------------------------------------------------------------------------------- 1 | pyodide-build==0.23.3 2 | pydantic<2 3 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/.DS_Store -------------------------------------------------------------------------------- /docs/_static/image/logo-300px.png: -------------------------------------------------------------------------------- 1 | ../../../docs-img/logo/logo-300px.png -------------------------------------------------------------------------------- /docs/image/example-array.svg: -------------------------------------------------------------------------------- 1 | ../../docs-img/diagrams/example-array.svg -------------------------------------------------------------------------------- /requirements-test-pypy.txt: -------------------------------------------------------------------------------- 1 | pytest>=6 2 | pytest-cov 3 | pytest-xdist 4 | -------------------------------------------------------------------------------- /docs/image/bikeroutes-scaling.svg: -------------------------------------------------------------------------------- 1 | ../../docs-img/plots/bikeroutes-scaling.svg -------------------------------------------------------------------------------- /docs/_static/image/logo-300px-white.png: -------------------------------------------------------------------------------- 1 | ../../../docs-img/logo/logo-300px-white.png -------------------------------------------------------------------------------- /docs/image/awkward-1-0-layers.svg: -------------------------------------------------------------------------------- 1 | ../../docs-img/diagrams/awkward-1-0-layers.svg -------------------------------------------------------------------------------- /docs/user-guide/cartoon-cartesian.png: -------------------------------------------------------------------------------- 1 | ../../docs-img/diagrams/cartoon-cartesian.png -------------------------------------------------------------------------------- /docs/getting-started/cartoon-cartesian.png: -------------------------------------------------------------------------------- 1 | ../../docs-img/diagrams/cartoon-cartesian.png -------------------------------------------------------------------------------- /docs/image/example-reduction-sum.svg: -------------------------------------------------------------------------------- 1 | ../../docs-img/diagrams/example-reduction-sum.svg -------------------------------------------------------------------------------- /docs/user-guide/cartoon-combinations.png: -------------------------------------------------------------------------------- 1 | ../../docs-img/diagrams/cartoon-combinations.png -------------------------------------------------------------------------------- /docs/getting-started/cartoon-combinations.png: -------------------------------------------------------------------------------- 1 | ../../docs-img/diagrams/cartoon-combinations.png -------------------------------------------------------------------------------- /requirements-test-numpy1.txt: -------------------------------------------------------------------------------- 1 | numpy<2.0.0 2 | pytest>=6 3 | pytest-cov 4 | pytest-xdist 5 | -------------------------------------------------------------------------------- /studies/chep-2019/read_rntuple.dat: -------------------------------------------------------------------------------- 1 | 0 540.276 2 | 1 1257.33 3 | 2 902.673 4 | 3 450.659 5 | -------------------------------------------------------------------------------- /docs/getting-started/example-reduction-sum.svg: -------------------------------------------------------------------------------- 1 | ../../docs-img/diagrams/example-reduction-sum.svg -------------------------------------------------------------------------------- /docs/image/example-reduction-sum-only.svg: -------------------------------------------------------------------------------- 1 | ../../docs-img/diagrams/example-reduction-sum-only.svg -------------------------------------------------------------------------------- /studies/chep-2019/read_ttree_rootnumpy.dat: -------------------------------------------------------------------------------- 1 | 0 13.82373862 2 | 1 11.99450228 3 | 2 13.68735568 4 | -------------------------------------------------------------------------------- /studies/small-example.json: -------------------------------------------------------------------------------- 1 | [[[1.1, 2.2, 3.3], [], [4.4, 5.5]], [], [[6.6, 7.7], [8.8, 9.9]]] 2 | -------------------------------------------------------------------------------- /docs/image/github-issues-documentation.png: -------------------------------------------------------------------------------- 1 | ../../docs-img/screenshots/github-issues-documentation.png -------------------------------------------------------------------------------- /docs-img/logo/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/logo/favicon.ico -------------------------------------------------------------------------------- /docs-img/panel-doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/panel-doxygen.png -------------------------------------------------------------------------------- /docs-img/panel-sphinx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/panel-sphinx.png -------------------------------------------------------------------------------- /studies/chep-2019/read_ttree_new.dat: -------------------------------------------------------------------------------- 1 | 0 226.8612387 2 | 1 61.80874402 3 | 2 49.95179812 4 | 3 20.59638241 5 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | -------------------------------------------------------------------------------- /docs-img/logo/logo-300px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/logo/logo-300px.png -------------------------------------------------------------------------------- /docs-img/logo/logo-600px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/logo/logo-600px.png -------------------------------------------------------------------------------- /docs-img/panel-developers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/panel-developers.png -------------------------------------------------------------------------------- /docs-img/panel-tutorials.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/panel-tutorials.png -------------------------------------------------------------------------------- /studies/chep-2019/read_ttree_old.dat: -------------------------------------------------------------------------------- 1 | 0 226.8612387 2 | 1 24.90447011 3 | 2 0.2915979096 4 | 3 0.3016240853 5 | -------------------------------------------------------------------------------- /tests-cuda/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | -------------------------------------------------------------------------------- /docs-img/panel-data-analysts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/panel-data-analysts.png -------------------------------------------------------------------------------- /docs-img/photos/desire-path.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/photos/desire-path.jpg -------------------------------------------------------------------------------- /docs/samples/Android.head.log.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs/samples/Android.head.log.gz -------------------------------------------------------------------------------- /studies/chep-2019/read_ttree.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/studies/chep-2019/read_ttree.pdf -------------------------------------------------------------------------------- /studies/chep-2019/read_ttree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/studies/chep-2019/read_ttree.png -------------------------------------------------------------------------------- /tests/samples/int_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/int_test_data.avro -------------------------------------------------------------------------------- /docs-img/diagrams/git-strategy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/git-strategy.pdf -------------------------------------------------------------------------------- /docs-img/diagrams/git-strategy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/git-strategy.png -------------------------------------------------------------------------------- /docs-img/logo/logo-300px-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/logo/logo-300px-white.png -------------------------------------------------------------------------------- /src/awkward/_backends/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | -------------------------------------------------------------------------------- /src/awkward/_connect/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | -------------------------------------------------------------------------------- /src/awkward/behaviors/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | -------------------------------------------------------------------------------- /tests/samples/array_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/array_test_data.avro -------------------------------------------------------------------------------- /tests/samples/awkward1-strings.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-strings.pkl -------------------------------------------------------------------------------- /tests/samples/bool_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/bool_test_data.avro -------------------------------------------------------------------------------- /tests/samples/bytes_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/bytes_test_data.avro -------------------------------------------------------------------------------- /tests/samples/enum_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/enum_test_data.avro -------------------------------------------------------------------------------- /tests/samples/fixed_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/fixed_test_data.avro -------------------------------------------------------------------------------- /tests/samples/float_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/float_test_data.avro -------------------------------------------------------------------------------- /tests/samples/list-depths.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/list-depths.parquet -------------------------------------------------------------------------------- /tests/samples/list-lengths.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/list-lengths.parquet -------------------------------------------------------------------------------- /tests/samples/long_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/long_test_data.avro -------------------------------------------------------------------------------- /tests/samples/null_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/null_test_data.avro -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "rapidjson"] 2 | path = awkward-cpp/rapidjson 3 | url = https://github.com/Tencent/rapidjson.git 4 | -------------------------------------------------------------------------------- /docs/getting-started/8-layer_cube.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs/getting-started/8-layer_cube.jpg -------------------------------------------------------------------------------- /src/awkward/_connect/numba/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | -------------------------------------------------------------------------------- /tests/samples/awkward1-emptyarray.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-emptyarray.pkl -------------------------------------------------------------------------------- /tests/samples/awkward1-numpyarray.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-numpyarray.pkl -------------------------------------------------------------------------------- /tests/samples/awkward1-unionarray.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-unionarray.pkl -------------------------------------------------------------------------------- /tests/samples/double_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/double_test_data.avro -------------------------------------------------------------------------------- /tests/samples/int_null_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/int_null_test_data.avro -------------------------------------------------------------------------------- /tests/samples/nullable-depths.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/nullable-depths.parquet -------------------------------------------------------------------------------- /tests/samples/nullable-levels.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/nullable-levels.parquet -------------------------------------------------------------------------------- /tests/samples/record_0_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/record_0_test_data.avro -------------------------------------------------------------------------------- /tests/samples/record_1_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/record_1_test_data.avro -------------------------------------------------------------------------------- /tests/samples/record_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/record_test_data.avro -------------------------------------------------------------------------------- /tests/samples/string_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/string_test_data.avro -------------------------------------------------------------------------------- /docs-img/diagrams/awkward-timeline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/awkward-timeline.pdf -------------------------------------------------------------------------------- /docs-img/diagrams/awkward-timeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/awkward-timeline.png -------------------------------------------------------------------------------- /docs-img/diagrams/cartoon-cartesian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/cartoon-cartesian.png -------------------------------------------------------------------------------- /docs-img/diagrams/cartoon-schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/cartoon-schematic.png -------------------------------------------------------------------------------- /docs-img/diagrams/example-hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/example-hierarchy.png -------------------------------------------------------------------------------- /docs-img/diagrams/example-reduction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/example-reduction.png -------------------------------------------------------------------------------- /docs-img/panel-tutorials-alternate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/panel-tutorials-alternate.png -------------------------------------------------------------------------------- /docs-img/plots/awkward-0-popularity.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/plots/awkward-0-popularity.pdf -------------------------------------------------------------------------------- /docs-img/plots/awkward-0-popularity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/plots/awkward-0-popularity.png -------------------------------------------------------------------------------- /src/awkward/_connect/rdataframe/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | -------------------------------------------------------------------------------- /studies/chep-2019/read_pyobj_old.dat: -------------------------------------------------------------------------------- 1 | 0 0.6758153738223585 2 | 1 0.48330834850132 3 | 2 0.4687868015176278 4 | 3 0.462845896680771 5 | -------------------------------------------------------------------------------- /tests/samples/array_enum_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/array_enum_test_data.avro -------------------------------------------------------------------------------- /tests/samples/awkward1-recordarray.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-recordarray.pkl -------------------------------------------------------------------------------- /tests/samples/awkward1-regulararray.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-regulararray.pkl -------------------------------------------------------------------------------- /tests/samples/enum_null_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/enum_null_test_data.avro -------------------------------------------------------------------------------- /tests/samples/record-primitives.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/record-primitives.parquet -------------------------------------------------------------------------------- /docs-img/diagrams/awkward-1-0-layers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/awkward-1-0-layers.pdf -------------------------------------------------------------------------------- /docs-img/diagrams/awkward-1-0-layers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/awkward-1-0-layers.png -------------------------------------------------------------------------------- /docs-img/diagrams/cartoon-broadcasting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/cartoon-broadcasting.png -------------------------------------------------------------------------------- /docs-img/diagrams/cartoon-combinations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/cartoon-combinations.png -------------------------------------------------------------------------------- /docs-img/diagrams/how-it-works-muons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/how-it-works-muons.png -------------------------------------------------------------------------------- /studies/chep-2019/read_json_new.dat: -------------------------------------------------------------------------------- 1 | 0 14.376991625169566 2 | 1 12.329521232171187 3 | 2 11.059646572719467 4 | 3 10.472477631753778 5 | -------------------------------------------------------------------------------- /studies/chep-2019/read_json_old.dat: -------------------------------------------------------------------------------- 1 | 0 0.5298200665542955 2 | 1 0.4031612656516802 3 | 2 0.3715163987964306 4 | 3 0.3775490542293258 5 | -------------------------------------------------------------------------------- /studies/chep-2019/read_pyobj_new.dat: -------------------------------------------------------------------------------- 1 | 0 3.748414200133741 2 | 1 13.546941380017987 3 | 2 19.87186089758016 4 | 3 19.443585721788086 5 | -------------------------------------------------------------------------------- /tests/samples/array_string_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/array_string_test_data.avro -------------------------------------------------------------------------------- /tests/samples/awkward1-bytemaskedarray.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-bytemaskedarray.pkl -------------------------------------------------------------------------------- /tests/samples/awkward1-listoffsetarray.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-listoffsetarray.pkl -------------------------------------------------------------------------------- /tests/samples/awkward1-unmaskedarray.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-unmaskedarray.pkl -------------------------------------------------------------------------------- /tests/samples/list-depths-records.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/list-depths-records.parquet -------------------------------------------------------------------------------- /tests/samples/list-depths-simple.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/list-depths-simple.parquet -------------------------------------------------------------------------------- /tests/samples/list-depths-strings.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/list-depths-strings.parquet -------------------------------------------------------------------------------- /tests/samples/nonnullable-depths.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/nonnullable-depths.parquet -------------------------------------------------------------------------------- /tests/samples/nullable-list-depths.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/nullable-list-depths.parquet -------------------------------------------------------------------------------- /tests/samples/record_null_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/record_null_test_data.avro -------------------------------------------------------------------------------- /tests/samples/string_null_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/string_null_test_data.avro -------------------------------------------------------------------------------- /tests/samples/zero-record-batches.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/zero-record-batches.parquet -------------------------------------------------------------------------------- /tests/samples/awkward1-recordarray-tuple.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-recordarray-tuple.pkl -------------------------------------------------------------------------------- /tests/samples/int_string_null_test_data.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/int_string_null_test_data.avro -------------------------------------------------------------------------------- /docs-img/diagrams/awkward-uproot-timeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/awkward-uproot-timeline.png -------------------------------------------------------------------------------- /tests/samples/awkward1-indexedoptionarray.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-indexedoptionarray.pkl -------------------------------------------------------------------------------- /tests/samples/list-depths-records-list.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/list-depths-records-list.parquet -------------------------------------------------------------------------------- /docs-img/diagrams/awkward-uproot-timeline-pip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/awkward-uproot-timeline-pip.png -------------------------------------------------------------------------------- /tests/samples/awkward1-partitioned-numpyarray.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/awkward1-partitioned-numpyarray.pkl -------------------------------------------------------------------------------- /tests/samples/nullable-record-primitives.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/nullable-record-primitives.parquet -------------------------------------------------------------------------------- /docs-img/screenshots/github-issues-documentation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/screenshots/github-issues-documentation.png -------------------------------------------------------------------------------- /requirements-test-minimal.txt: -------------------------------------------------------------------------------- 1 | fsspec>=2022.11.0;sys_platform != "win32" 2 | numpy==1.18.0 3 | pyarrow==7.0.0 4 | pytest>=6 5 | pytest-cov 6 | pytest-xdist 7 | -------------------------------------------------------------------------------- /requirements-test-ml.txt: -------------------------------------------------------------------------------- 1 | fsspec>=2022.11.0;sys_platform != "win32" 2 | pytest>=6 3 | pytest-cov 4 | pytest-xdist 5 | tensorflow >= 2.12 6 | torch >= 2.4.0 7 | -------------------------------------------------------------------------------- /tests/samples/nullable-list-depths-records.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/nullable-list-depths-records.parquet -------------------------------------------------------------------------------- /tests/samples/nullable-list-depths-strings.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/nullable-list-depths-strings.parquet -------------------------------------------------------------------------------- /tests/samples/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import absolute_import 4 | -------------------------------------------------------------------------------- /docs-img/diagrams/awkward-uproot-timeline-pip-github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/docs-img/diagrams/awkward-uproot-timeline-pip-github.png -------------------------------------------------------------------------------- /tests/samples/nullable-list-depths-records-list.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/nullable-list-depths-records-list.parquet -------------------------------------------------------------------------------- /tests/samples/nullable-record-primitives-simple.parquet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basnijholt/awkward/main/tests/samples/nullable-record-primitives-simple.parquet -------------------------------------------------------------------------------- /awkward-cpp/README.md: -------------------------------------------------------------------------------- 1 | # `awkward-cpp` 2 | 3 | `awkward-cpp` provides precompiled routines for the `awkward` package. It is not useful on its own, only as a dependency for `awkward `. 4 | -------------------------------------------------------------------------------- /awkward-cpp/.gitignore: -------------------------------------------------------------------------------- 1 | # Doxygen 2 | docs/html 3 | .pyodide-xbuildenv 4 | 5 | # Generated 6 | header-only 7 | include/awkward/kernels.h 8 | src/awkward_cpp/_kernel_signatures.py 9 | 10 | dist 11 | .venv 12 | -------------------------------------------------------------------------------- /tests/samples/test-record-array.json: -------------------------------------------------------------------------------- 1 | {"x": 1.1, "y": []} 2 | {"x": 2.2, "y": [1]} 3 | {"x": 3.3, "y": [1, 2]} 4 | {"x": 4.4, "y": [1, 2, 3]} 5 | {"x": 5.5, "y": [1, 2, 3, 4]} 6 | {"x": 6.6, "y": [1, 2, 3, 4, 5]} 7 | -------------------------------------------------------------------------------- /juliapkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "julia": "1.9", 3 | "packages": { 4 | "AwkwardArray": { 5 | "uuid": "7d259134-7f60-4bf1-aa00-7452e11bde56", 6 | "version": "0.1" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /header-only/examples/cython/demo/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | from ._demo import create_demo_array # noqa: F401 6 | -------------------------------------------------------------------------------- /awkward-cpp/src/libawkward/builder/Builder.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #include "awkward/builder/Builder.h" 4 | 5 | namespace awkward { 6 | Builder::~Builder() = default; 7 | } 8 | -------------------------------------------------------------------------------- /src/awkward/behaviors/categorical.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | from awkward.highlevel import Array 6 | 7 | CategoricalBehavior = Array 8 | -------------------------------------------------------------------------------- /awkward-cpp/src/awkward_cpp/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import awkward_cpp.cpu_kernels 6 | import awkward_cpp.libawkward # noqa: F401 7 | -------------------------------------------------------------------------------- /header-only/examples/cython/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "scikit-build>=0.13", 5 | "cmake>=3.18", 6 | "cython", 7 | "ninja", 8 | "numpy" 9 | ] 10 | build-backend = "setuptools.build_meta" 11 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | require_ci_to_pass: true 3 | 4 | comment: 5 | layout: "files" 6 | 7 | coverage: 8 | status: 9 | project: 10 | default: 11 | target: 20% 12 | patch: false 13 | 14 | github_checks: 15 | annotations: false 16 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Maintain dependencies for GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | groups: 9 | actions: 10 | patterns: 11 | - "*" 12 | -------------------------------------------------------------------------------- /src/awkward/builder.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | from awkward_cpp.lib._ext import ArrayBuilder 6 | 7 | __all__ = ["ArrayBuilder"] 8 | 9 | 10 | def __dir__(): 11 | return __all__ 12 | -------------------------------------------------------------------------------- /tests/test_1944_to_numpy_empty_record_array.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import awkward as ak 6 | 7 | 8 | def test(): 9 | assert ak.to_numpy(ak.Array([{}, {}])).tolist() == [(), ()] 10 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | build: 3 | os: "ubuntu-22.04" 4 | tools: 5 | python: "3.10" 6 | commands: 7 | - mkdir --parents _readthedocs/html/ 8 | - python3 dev/generate-redirects.py docs/redirects.json _readthedocs/html/ 9 | - cp dev/robots.txt _readthedocs/html/robots.txt 10 | -------------------------------------------------------------------------------- /src/awkward/behaviors/string.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | from awkward.highlevel import Array 6 | 7 | ByteBehavior = Array 8 | CharBehavior = Array 9 | ByteStringBehavior = Array 10 | StringBehavior = Array 11 | -------------------------------------------------------------------------------- /tests/test_2407_broadcast_no_arrays.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest # noqa: F401 6 | 7 | import awkward as ak 8 | 9 | 10 | def test(): 11 | result = ak.broadcast_arrays() 12 | assert result == [] 13 | -------------------------------------------------------------------------------- /src/awkward/forth.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | from awkward_cpp.lib._ext import ForthMachine32, ForthMachine64 6 | 7 | __all__ = ["ForthMachine32", "ForthMachine64"] 8 | 9 | 10 | def __dir__(): 11 | return __all__ 12 | -------------------------------------------------------------------------------- /studies/use-simdjson.cpp: -------------------------------------------------------------------------------- 1 | #include "../simdjson/singleheader/simdjson.h" 2 | #include "../simdjson/singleheader/simdjson.cpp" 3 | 4 | using namespace simdjson; 5 | 6 | int main(int argc, char *argv[]) { 7 | padded_string unparsed = get_corpus("small-example.json"); 8 | ParsedJson parsed = build_parsed_json(unparsed); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /docs/lite/jupyter-lite.json: -------------------------------------------------------------------------------- 1 | { 2 | "jupyter-lite-schema-version": 0, 3 | "jupyter-config-data": { 4 | "enableMemoryStorage": true, 5 | "settingsStorageDrivers": ["memoryStorageDriver"], 6 | "contentsStorageDrivers": ["memoryStorageDriver"], 7 | "disabledExtensions": [ 8 | "ipyparallel-labextension" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/awkward/errors.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy 6 | 7 | __all__ = ("FieldNotFoundError", "AxisError") 8 | 9 | 10 | class FieldNotFoundError(IndexError): 11 | pass 12 | 13 | 14 | AxisError = getattr(numpy, "exceptions", numpy).AxisError 15 | -------------------------------------------------------------------------------- /docs/_static/js/awkward.js: -------------------------------------------------------------------------------- 1 | document.addEventListener("DOMContentLoaded", function() { 2 | document.querySelectorAll('a[href="_static/try-it.html"]').forEach(a => { 3 | a.target = "_blank"; 4 | }); 5 | document.querySelectorAll('a[href="https://awkward-array.org/doc/main/_static/try-it.html"]').forEach(a => { 6 | a.target = "_blank"; 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /tests/test_2503_deprecate_to_numpyform.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import awkward as ak 6 | 7 | 8 | def test_primitive(): 9 | form = ak.forms.EmptyForm() 10 | next_form = form.to_NumpyForm(primitive="int64") 11 | assert next_form.primitive == "int64" 12 | -------------------------------------------------------------------------------- /tests/test_2710_pickle_unknown_length.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pickle 6 | 7 | import pytest # noqa: F401 8 | 9 | from awkward._nplikes.shape import unknown_length 10 | 11 | 12 | def test(): 13 | assert pickle.loads(pickle.dumps(unknown_length)) is unknown_length 14 | -------------------------------------------------------------------------------- /header-only/README.md: -------------------------------------------------------------------------------- 1 | # Awkward Header-only Libraries 2 | 3 | This CMake project defined a set of header-only libraries for working with Awkward Array. Use of these libraries is 4 | described in the [documentation](https://awkward-array.org/doc/main/user-guide/). If you are not using CMake, then 5 | ensure that the contents of `builder-options`, `growable-buffer`, `layout-builder` are on the include path. 6 | -------------------------------------------------------------------------------- /header-only/examples/pybind11/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["scikit-build-core[pyproject]", "pybind11"] 3 | build-backend = "scikit_build_core.build" 4 | 5 | [project] 6 | name = "demo" 7 | version = "0.0.1" 8 | 9 | dependencies = [ 10 | 'awkward>=2.0', 11 | "numpy" 12 | ] 13 | 14 | 15 | [tool.scikit-build] 16 | minimum-version = "0.2" 17 | build-dir = "build/{cache_tag}" 18 | -------------------------------------------------------------------------------- /studies/awkward-forth-performance/read-parquet-fast.sh: -------------------------------------------------------------------------------- 1 | for compress in zlib9; do 2 | for jagged in 0; do 3 | for splt in split nosplit; do 4 | python pyarrow-read-jaggedN-parquet.py $compress $jagged $splt; 5 | python pyarrow-read-jaggedN-parquet.py $compress $jagged $splt; 6 | python pyarrow-read-jaggedN-parquet.py $compress $jagged $splt; 7 | done 8 | done 9 | done 10 | -------------------------------------------------------------------------------- /tests/test_2076_ak_unzip_record.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest # noqa: F401 6 | 7 | import awkward as ak 8 | 9 | 10 | def test(): 11 | record = ak.Record({"x": 1, "y": 2, "z": 3}) 12 | assert ak.fields(record) == ["x", "y", "z"] 13 | assert ak.unzip(record) == (1, 2, 3) 14 | -------------------------------------------------------------------------------- /tests/test_2181_with_name_len.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import awkward as ak 6 | 7 | 8 | def test(): 9 | layout = ak.to_layout([{"x": 10}]).to_typetracer(forget_length=True) 10 | named = ak.with_name(layout, "x_like") 11 | assert ak.parameters(named) == {"__record__": "x_like"} 12 | -------------------------------------------------------------------------------- /tests/test_1106_argminmax_axis_None_missing_values.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | x = ak.highlevel.Array([1, 2, 3, None, 4]) 13 | assert ak.operations.argmax(x) == 4 14 | -------------------------------------------------------------------------------- /tests/test_1400_with_name_record.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | record = ak.with_name(ak.Record({"x": 10.0}), "X") 13 | assert ak.parameters(record) == {"__record__": "X"} 14 | -------------------------------------------------------------------------------- /tests/test_1593_empty_slice_list_record.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import awkward as ak 6 | 7 | 8 | def test(): 9 | array = ak.Array([{"x": [[1, 2, 3], [4, 5, 6]]}]) 10 | assert array[:, []].fields == ["x"] 11 | assert ak.to_list(ak.Array([{"x": [[1, 2, 3], [4, 5, 6]]}])[:, []]) == [{"x": []}] 12 | -------------------------------------------------------------------------------- /tests/test_1978_akRecord_constructor_should_retain_type.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | j1 = ak.from_numpy(np.empty(0, np.int32)) 13 | assert str(ak.Record({"d": j1}).type) == "{d: 0 * int32}" 14 | -------------------------------------------------------------------------------- /header-only/tests/test_1560-builder-options.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #include "awkward/BuilderOptions.h" 4 | #include 5 | 6 | int main(int /* argc */, char ** /* argv */) { 7 | 8 | awkward::BuilderOptions options(1024, 1.0); 9 | 10 | assert(options.initial() == 1024); 11 | assert(options.resize() == 1.0); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /tests/test_2518_datetime_units_as_parameter.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | 7 | import awkward as ak 8 | 9 | 10 | def test_false_parameter(): 11 | dtype = np.dtype("datetime64[15us]") 12 | form = ak.forms.numpyform.from_dtype(dtype) 13 | assert form.primitive == "datetime64[15us]" 14 | -------------------------------------------------------------------------------- /tests/test_2266_fix_nan_to_num.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | 7 | import awkward as ak 8 | 9 | 10 | def test(): 11 | array = ak.Array([[2.0, 3.0], [1.0, 9.0, 8.0, np.nan]], backend="typetracer") 12 | result = ak.nan_to_num(array + 3) 13 | assert result.layout.form == array.layout.form 14 | -------------------------------------------------------------------------------- /tests/test_2934_argmin_argmax_bool.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import awkward as ak 6 | 7 | 8 | def test(): 9 | array = ak.Array([[True, False, True], [False, False, True, False], [True, False]]) 10 | 11 | assert ak.argmin(array, axis=1).tolist() == [1, 0, 1] 12 | assert ak.argmax(array, axis=1).tolist() == [0, 2, 0] 13 | -------------------------------------------------------------------------------- /docs/environment.yml.cog: -------------------------------------------------------------------------------- 1 | name: awkward-docs 2 | channels: 3 | - conda-forge 4 | dependencies: 5 | - pip 6 | - cxx-compiler 7 | - root 8 | - ipykernel!=6.18.0 9 | - pip: 10 | # [[[cog 11 | # import cog 12 | # # Inject requirements 13 | # with open("requirements.txt") as f: 14 | # for line in f: 15 | # if line.strip(): 16 | # cog.out(f"- {line}") 17 | # ]]] 18 | # [[[end]]] 19 | 20 | -------------------------------------------------------------------------------- /src/awkward/_connect/jax/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import jax.numpy 6 | 7 | from awkward._connect.jax.reducers import get_jax_reducer # noqa: F401 8 | from awkward._connect.jax.trees import register_pytree_class # noqa: F401 9 | 10 | 11 | def get_jax_ufunc(ufunc): 12 | return getattr(jax.numpy, ufunc.__name__, ufunc) 13 | -------------------------------------------------------------------------------- /requirements-test-full.txt: -------------------------------------------------------------------------------- 1 | fsspec>=2022.11.0;sys_platform != "win32" 2 | jax[cpu]>=0.2.15;sys_platform != "win32" and python_version < "3.13" 3 | numba>=0.50.0;sys_platform != "win32" and python_version < "3.13" 4 | numexpr>=2.7; python_version < "3.13" 5 | pandas>=0.24.0;sys_platform != "win32" and python_version < "3.13" 6 | pyarrow==16.0.0;sys_platform != "win32" and python_version < "3.13" 7 | pytest>=6 8 | pytest-cov 9 | pytest-xdist 10 | uproot>=5 11 | -------------------------------------------------------------------------------- /tests/test_2219_flatten_empty.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest # noqa: F401 6 | 7 | import awkward as ak 8 | 9 | 10 | def test(): 11 | array = ak.Array([[[], [], []], []]) 12 | flattened = ak.flatten(array, axis=None) 13 | assert isinstance(flattened.layout, ak.contents.EmptyArray) 14 | assert len(flattened) == 0 15 | -------------------------------------------------------------------------------- /awkward-cpp/include/awkward/python/io.h: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #ifndef AWKWARDPY_IO_H_ 4 | #define AWKWARDPY_IO_H_ 5 | 6 | #include 7 | 8 | namespace py = pybind11; 9 | 10 | void 11 | make_fromjsonobj(py::module& m, const std::string& name); 12 | 13 | void 14 | make_fromjsonobj_schema(py::module& m, const std::string& name); 15 | 16 | #endif // AWKWARDPY_IO_H_ 17 | -------------------------------------------------------------------------------- /header-only/examples/cython/setup.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | from skbuild import setup # This line replaces 'from setuptools import setup' 6 | 7 | setup( 8 | name="demo", 9 | version="0.0.1", 10 | license="MIT", 11 | packages=["demo"], 12 | python_requires=">=3.7", 13 | install_requires=["awkward>=2.0.0", "numpy"], 14 | ) 15 | -------------------------------------------------------------------------------- /tests/test_2591_nan_to_num.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | 7 | import awkward as ak 8 | 9 | pytest.importorskip("jax") 10 | 11 | ak.jax.register_and_check() 12 | 13 | 14 | def test(): 15 | ak.nan_to_num( 16 | ak.Array([1.1, 2.2, 3.3], backend="jax"), 17 | nan=ak.Array([1.1, 2.2, 3.3], backend="jax"), 18 | ) 19 | -------------------------------------------------------------------------------- /tests/test_0758_ak_zip_scallars.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | to_list = ak.operations.to_list 11 | 12 | 13 | def test(): 14 | assert isinstance( 15 | ak.operations.zip({"x": 1, "y": 0, "z": 0}), 16 | ak.highlevel.Record, 17 | ) 18 | -------------------------------------------------------------------------------- /src/awkward/_ext.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | from awkward.forms import ( 6 | BitMaskedForm, 7 | ByteMaskedForm, 8 | EmptyForm, 9 | Form, 10 | IndexedForm, 11 | IndexedOptionForm, 12 | ListForm, 13 | ListOffsetForm, 14 | NumpyForm, 15 | RecordForm, 16 | RegularForm, 17 | UnionForm, 18 | UnmaskedForm, 19 | ) 20 | -------------------------------------------------------------------------------- /docs/_static/css/try-awkward-array.css: -------------------------------------------------------------------------------- 1 | /*Styles for our try-awkward-array demo*/ 2 | .bd-article { 3 | flex-grow: 1; 4 | /*Allow children to grow*/ 5 | display: flex; 6 | flex-direction: column; 7 | } 8 | 9 | .bd-article > * { 10 | /*Accomodate parent size*/ 11 | flex-grow: 1; 12 | /*Allow children to grow*/ 13 | display: flex; 14 | flex-direction: column; 15 | } 16 | 17 | iframe { 18 | flex-grow: 1; 19 | min-height: 300px; 20 | } 21 | -------------------------------------------------------------------------------- /tests/test_2418_union_broadcast_unknown.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import awkward as ak 6 | 7 | 8 | def test(): 9 | array = ak.Array([1, [2, 3]]) 10 | result = array + array 11 | 12 | array_tt = ak.Array(array.layout.to_typetracer(forget_length=True)) 13 | result_tt = array_tt + array_tt 14 | 15 | assert result_tt.layout.form == result.layout.form 16 | -------------------------------------------------------------------------------- /header-only/examples/cython/demo_impl.pxd: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from libcpp.map cimport map 4 | from libcpp.string cimport string 5 | 6 | # Declare out exported types 7 | cdef extern from "demo_impl.h": 8 | cdef cppclass ArrayBuffers: 9 | map[string, void*] buffers 10 | map[string, size_t] buffer_nbytes 11 | string form 12 | size_t length 13 | 14 | ArrayBuffers create_demo_array() 15 | -------------------------------------------------------------------------------- /tests/test_1991_missed_a_NumpyArray_raw_call_without_underscore.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import awkward as ak 6 | 7 | 8 | def test(): 9 | assert ak.Record({"x": "hello"})["x"] == "hello" 10 | assert ak.Record({"x": b"hello"})["x"] == b"hello" 11 | 12 | assert ak.Array([{"x": "hello"}])[0, "x"] == "hello" 13 | assert ak.Array([{"x": b"hello"}])[0, "x"] == b"hello" 14 | -------------------------------------------------------------------------------- /header-only/examples/cython/include/demo_impl.h: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #include 4 | #include 5 | 6 | 7 | struct ArrayBuffers { 8 | std::map buffers; 9 | std::map buffer_nbytes; 10 | std::string form; 11 | size_t length; 12 | }; 13 | 14 | template 15 | ArrayBuffers snapshot_builder(const T &builder); 16 | 17 | ArrayBuffers create_demo_array(); 18 | -------------------------------------------------------------------------------- /studies/awkward-forth-performance/fastavro-read-jagged0-avro.py: -------------------------------------------------------------------------------- 1 | import time 2 | import fastavro 3 | 4 | begintime = time.time() 5 | 6 | num = 0 7 | next = 1 8 | 9 | for x in fastavro.reader(open("/home/jpivarski/storage/data/chep-2021-jagged-jagged-jagged/zlib0-jagged0.avro", "rb")): 10 | num += 1 11 | if 100.0 * num / 1073741824.0 > next: 12 | print(next) 13 | next += 1 14 | 15 | endtime = time.time() 16 | 17 | print("fastavro zlib0-jagged0", endtime - begintime, "seconds") 18 | -------------------------------------------------------------------------------- /studies/awkward-forth-performance/fastavro-read-jagged1-avro.py: -------------------------------------------------------------------------------- 1 | import time 2 | import fastavro 3 | 4 | begintime = time.time() 5 | 6 | num = 0 7 | next = 1 8 | 9 | for x in fastavro.reader(open("/home/jpivarski/storage/data/chep-2021-jagged-jagged-jagged/zlib0-jagged1.avro", "rb")): 10 | num += 1 11 | if 100.0 * num / 134217728.0 > next: 12 | print(next) 13 | next += 1 14 | 15 | endtime = time.time() 16 | 17 | print("fastavro zlib0-jagged1", endtime - begintime, "seconds") 18 | -------------------------------------------------------------------------------- /studies/awkward-forth-performance/fastavro-read-jagged2-avro.py: -------------------------------------------------------------------------------- 1 | import time 2 | import fastavro 3 | 4 | begintime = time.time() 5 | 6 | num = 0 7 | next = 1 8 | 9 | for x in fastavro.reader(open("/home/jpivarski/storage/data/chep-2021-jagged-jagged-jagged/zlib0-jagged2.avro", "rb")): 10 | num += 1 11 | if 100.0 * num / 16777216.0 > next: 12 | print(next) 13 | next += 1 14 | 15 | endtime = time.time() 16 | 17 | print("fastavro zlib0-jagged2", endtime - begintime, "seconds") 18 | -------------------------------------------------------------------------------- /studies/awkward-forth-performance/fastavro-read-jagged3-avro.py: -------------------------------------------------------------------------------- 1 | import time 2 | import fastavro 3 | 4 | begintime = time.time() 5 | 6 | num = 0 7 | next = 1 8 | 9 | for x in fastavro.reader(open("/home/jpivarski/storage/data/chep-2021-jagged-jagged-jagged/zlib0-jagged3.avro", "rb")): 10 | num += 1 11 | if 100.0 * num / 2097152.0 > next: 12 | print(next) 13 | next += 1 14 | 15 | endtime = time.time() 16 | 17 | print("fastavro zlib0-jagged3", endtime - begintime, "seconds") 18 | -------------------------------------------------------------------------------- /tests/test_0546_fill_none_replacement_value_type.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | array = ak.operations.values_astype( 13 | ak.highlevel.Array([1.1, 2.2, None, 3.3]), np.float32 14 | ) 15 | assert str(ak.operations.fill_none(array, np.float32(0)).type) == "4 * float32" 16 | -------------------------------------------------------------------------------- /tests/test_1305_mixed_awkward_numpy_slicing.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | array = ak.Array([[3.14]]) 13 | first_slice = ak.Array([True, None])[:1] # type is 1 * ?bool 14 | second_slice = 0 15 | with pytest.raises(ValueError): 16 | array[first_slice, second_slice] 17 | -------------------------------------------------------------------------------- /tests/test_2008_ak_type_layout.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import re 6 | 7 | import awkward as ak 8 | 9 | 10 | def test_simple(): 11 | assert re.match(r"3 \* u?int\d+", str(ak.type([1, 2, 3]))) 12 | 13 | 14 | def test_complex(): 15 | assert re.match( 16 | r"2 \* \{x: union\[var \* \?u?int\d+, float\d+\]\}", 17 | str(ak.type([{"x": [None, 10]}, {"x": 40.0}])), 18 | ) 19 | -------------------------------------------------------------------------------- /tests-cuda/test_2327_array_interface.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | 7 | import awkward as ak 8 | 9 | 10 | def test_wrap_index_cupy(): 11 | cp = pytest.importorskip("cupy") 12 | data = cp.arange(10, dtype=cp.int64) 13 | index = ak.index.Index64(data) 14 | other_data = cp.asarray(index) 15 | result = cp.shares_memory(data, other_data) 16 | assert result is True 17 | -------------------------------------------------------------------------------- /tests/test_1644_concatenate_zeros_length.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | x = ak.from_numpy(np.empty((5, 0), dtype=np.float64), regulararray=True) 13 | y = ak.from_numpy(np.empty((8, 0), dtype=np.float64), regulararray=True) 14 | z = ak.concatenate([x, y], axis=0) 15 | assert len(z) == 13 16 | -------------------------------------------------------------------------------- /tests/test_3264_length_one_if_typetracer_with_option_types.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | # ruff: noqa: E402 3 | 4 | from __future__ import annotations 5 | 6 | import awkward as ak 7 | 8 | 9 | def test(): 10 | arr = ak.Array([[1], [2, 3], [1, 2, 4, 5]])[[0, None, 2]] 11 | l1 = ak.typetracer.length_one_if_typetracer(ak.to_backend(arr, "typetracer")) 12 | 13 | assert l1.to_list() == [None] 14 | assert str(l1.type) == "1 * option[var * int64]" 15 | -------------------------------------------------------------------------------- /tests/test_1578_to_arrow_empty_recordarray.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | pytest.importorskip("pyarrow") 11 | 12 | 13 | def test(): 14 | layout = ak.contents.RecordArray([], fields=[], length=3) 15 | struct = ak.to_arrow(layout) 16 | assert len(struct) == len(layout) == 3 17 | assert struct.tolist() == [{}, {}, {}] 18 | -------------------------------------------------------------------------------- /tests/test_1735_from_numpy_mask.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | np_array = np.ma.MaskedArray( 13 | [[1, 2, 3], [4, 5, 6]], mask=[[False, True, False], [True, True, False]] 14 | ) 15 | ak_array = ak.from_numpy(np_array) 16 | 17 | assert ak_array.to_list() == [[1, None, 3], [None, None, 6]] 18 | -------------------------------------------------------------------------------- /tests/test_2765_slice_from_typetracer.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import awkward as ak 4 | 5 | 6 | def test(): 7 | array = ak.typetracer.typetracer_from_form( 8 | ak.forms.from_type( 9 | ak.types.from_datashape("{x: var * {y:int64}}", highlevel=False) 10 | ) 11 | ) 12 | sliced = array[0, "x", 0] 13 | assert sliced.type.is_equal_to( 14 | ak.types.ScalarType( 15 | ak.types.RecordType([ak.types.NumpyType("int64")], ["y"]), None 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: "Start a discussion (GitHub)" 4 | about: "How do I…?" 5 | url: https://github.com/scikit-hep/awkward-1.0/discussions 6 | - name: "StackOverflow: [awkward-array] tag" 7 | about: "How do I…?" 8 | url: https://stackoverflow.com/questions/tagged/awkward-array 9 | - name: "Gitter: Scikit-HEP/awkward-array room" 10 | about: "Getting help in real-time…" 11 | url: https://gitter.im/Scikit-HEP/awkward-array 12 | -------------------------------------------------------------------------------- /awkward-cpp/include/awkward/python/kernel_utils.h: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #ifndef AWKWARD_KERNEL_UTILS_H 4 | #define AWKWARD_KERNEL_UTILS_H 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include "awkward/kernel-dispatch.h" 11 | 12 | namespace py = pybind11; 13 | namespace ak = awkward; 14 | 15 | py::enum_ 16 | make_lib_enum(const py::handle& m, const std::string& name); 17 | 18 | 19 | #endif //AWKWARD_KERNEL_UTILS_H 20 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_localindex.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_localindex( 6 | T* toindex, 7 | int64_t length, 8 | uint64_t invocation_index, 9 | uint64_t* err_code) { 10 | if (err_code[0] == NO_ERROR) { 11 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 12 | if (thread_id < length) { 13 | toindex[thread_id] = thread_id; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/test_2632_unflatten_length.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | x = ak.from_numpy(np.arange(3, dtype=np.int64)) 13 | y = ak.unflatten(x, len(x)) 14 | assert y.to_list() == [[0, 1, 2]] 15 | assert y.type == ak.types.ArrayType( 16 | ak.types.RegularType(ak.types.NumpyType("int64"), 3), 1 17 | ) 18 | -------------------------------------------------------------------------------- /.github/workflows/semantic-pr-title.yml: -------------------------------------------------------------------------------- 1 | name: "Lint PR" 2 | 3 | on: 4 | pull_request: 5 | types: 6 | - opened 7 | - edited 8 | - synchronize 9 | workflow_dispatch: 10 | 11 | concurrency: 12 | group: semantic-pr-title-${{ github.head_ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | main: 17 | name: Validate PR title 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: amannn/action-semantic-pull-request@v5.5.3 21 | env: 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 23 | -------------------------------------------------------------------------------- /tests/samples/test.json: -------------------------------------------------------------------------------- 1 | [1.1, 2.2, 3.3, "inf", "-inf", [4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.10, 11.11], [12.12, 13.13, 14.14, 15.15, 16.16, 17.17], [[[18.18, 19.19, 20.20, 21.21, 22.22], [23.23, 24.24, 25.25, 26.26, 27.27, 28.28, 29.29, 30.30, 31.31, 32.32, 33.33, 34.34, 35.35, 36.36, 37.37], [38.38], [39.39, 40.40, "NaN", "NaN", 41.41, 42.42, 43.43]], [[44.44, 45.45, 46.46, 47.47, 48.48], [49.49, 50.50, 51.51, 52.52, 53.53, 54.54, 55.55, 56.56, 57.57, 58.58, 59.59, 60.60, 61.61, 62.62, 63.63], [64.64], [65.65, 66.66, "NaN", "NaN", 67.67, 68.68, 69.69]]]] 2 | -------------------------------------------------------------------------------- /tests/test_1823_fill_none_axis_none.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | array = ak.Array([None, [1, 2, 3, [None, {"x": [None, 2], "y": [1, 4]}]]]) 13 | 14 | assert ak.fill_none(array, -1.0, axis=None).to_list() == [ 15 | -1.0, 16 | [1, 2, 3, [-1.0, {"x": [-1.0, 2], "y": [1, 4]}]], 17 | ] 18 | -------------------------------------------------------------------------------- /tests/test_2294_view_unknown_scalar.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | scalar = ak.Array(np.arange(5, dtype=np.int64), backend="typetracer")[0] 13 | result = scalar.view(np.float64) 14 | assert result.dtype == np.dtype(np.float64) 15 | assert result.ndim == 0 16 | with pytest.raises(RuntimeError): 17 | int(result) 18 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | pull_request: 5 | workflow_dispatch: 6 | 7 | 8 | concurrency: 9 | group: lint-${{ github.head_ref }} 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | pylint: 14 | name: "Run PyLint" 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | with: 20 | submodules: true 21 | 22 | - name: Run PyLint 23 | run: | 24 | echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json" 25 | pipx run nox -s pylint 26 | -------------------------------------------------------------------------------- /dev/cuda-tests/cuda-tests.timer: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Schedule a CUDA test job every day 3 | # Allow manual starts 4 | RefuseManualStart=no 5 | # Allow manual stops 6 | RefuseManualStop=no 7 | 8 | [Timer] 9 | # Execute job if it missed a run due to machine being off 10 | Persistent=true 11 | # Run 120 seconds after boot for the first time 12 | OnBootSec=240 13 | # Run every day (doesn't matter when due to persistent) 14 | OnCalendar=daily 15 | # File describing job to execute 16 | Unit=cuda-tests.service 17 | 18 | [Install] 19 | WantedBy=timers.target 20 | -------------------------------------------------------------------------------- /tests/test_2654_divmod.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | array = ak.Array([[1, 2, 3, 5, 7, 8, 10], [100000, 20000, 301]]) 13 | quotient, remainder = np.divmod(array, 2) 14 | assert ak.almost_equal(quotient, [[0, 1, 1, 2, 3, 4, 5], [50000, 10000, 150]]) 15 | assert ak.almost_equal(remainder, [[1, 0, 1, 1, 1, 0, 0], [0, 0, 1]]) 16 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_IndexedArray_numnull_unique_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_IndexedArray_numnull_unique.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_IndexedArray_numnull_unique_64( 8 | int64_t* toindex, 9 | int64_t lenindex) { 10 | for (int64_t i = 0; i < lenindex; i++) { 11 | toindex[i] = i; 12 | } 13 | toindex[lenindex] = -1; 14 | return success(); 15 | } 16 | -------------------------------------------------------------------------------- /dev/cuda-tests/cuda-tests.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nvidia/cuda:11.2.2-devel-ubuntu20.04 2 | WORKDIR /app 3 | 4 | ARG DEBIAN_FRONTEND=noninteractive 5 | RUN apt-get update \ 6 | && apt-get install -y python3 python3-pip python3-venv python3-dev python3-wheel g++ git cmake make patch curl nox \ 7 | && curl https://github.com/cli/cli/releases/download/v2.39.1/gh_2.39.1_linux_amd64.deb -L -o /tmp/gh.deb \ 8 | && apt-get install -y /tmp/gh.deb \ 9 | && rm -rf /var/lib/apt/lists/* 10 | 11 | COPY cuda-tests-entrypoint /app/entrypoint 12 | ENTRYPOINT ["/app/entrypoint"] 13 | -------------------------------------------------------------------------------- /tests/samples/test-nan-inf.json: -------------------------------------------------------------------------------- 1 | [1.1, 2.2, 3.3, "inf", "-inf", [4.4, "Infinity", 6.6, 7.7, 8.8, "NaN", 10.10, 11.11], [12.12, 13.13, 14.14, 15.15, 16.16, 17.17], [[[18.18, 19.19, 20.20, 21.21, 22.22], [23.23, 24.24, 25.25, 26.26, 27.27, 28.28, 29.29, 30.30, 31.31, 32.32, 33.33, 34.34, 35.35, 36.36, 37.37], [38.38], [39.39, 40.40, "NaN", "NaN", 41.41, 42.42, 43.43]], [[44.44, 45.45, 46.46, 47.47, 48.48], [49.49, 50.50, 51.51, 52.52, 53.53, 54.54, 55.55, 56.56, 57.57, 58.58, 59.59, 60.60, 61.61, 62.62, 63.63], [64.64], [65.65, 66.66, "NaN", "NaN", 67.67, 68.68, 69.69]]]] 2 | -------------------------------------------------------------------------------- /docs/_templates/redirect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | This page has moved. Redirecting to the new destination ... 10 | 11 | 12 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tests/test_1007_from_buffers_empty_ndarray.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | to_list = ak.operations.to_list 11 | 12 | 13 | def test(): 14 | array = ak.contents.NumpyArray(np.zeros((3, 0), dtype=np.int32)) 15 | buffs = ak.operations.to_buffers(array) 16 | new_array = ak.operations.from_buffers(*buffs) 17 | 18 | assert to_list(new_array) == [[], [], []] 19 | -------------------------------------------------------------------------------- /tests/test_2560_minimal_listarray.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest # noqa: F401 6 | 7 | import awkward as ak 8 | from awkward._nplikes.shape import unknown_length 9 | 10 | 11 | def test(): 12 | layout = ak.to_layout([[1, 2, 3, 4], [5, 6, 7, 8], [4, 5, 6, 9]]).to_typetracer( 13 | forget_length=True 14 | ) 15 | result = layout.to_RegularArray() 16 | assert result.size is unknown_length 17 | assert result.length is unknown_length 18 | -------------------------------------------------------------------------------- /tests/test_3033_flatten_bitmaskedarray.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import numpy as np 4 | 5 | import awkward as ak 6 | 7 | 8 | def test(): 9 | layout = ak.to_layout([[[1, 2, 3], [4]], None]).to_BitMaskedArray( 10 | valid_when=True, lsb_order=True 11 | ) 12 | result = ak.flatten(layout, axis=1, highlevel=False) 13 | assert result.is_equal_to( 14 | ak.contents.ListOffsetArray( 15 | ak.index.Index64([0, 3, 4]), 16 | ak.contents.NumpyArray(np.array([1, 2, 3, 4], dtype=np.int64)), 17 | ) 18 | ) 19 | -------------------------------------------------------------------------------- /awkward-cpp/include/awkward/python/forth.h: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #ifndef AWKWARDPY_FORTH_H_ 4 | #define AWKWARDPY_FORTH_H_ 5 | 6 | #include 7 | 8 | #include "awkward/forth/ForthMachine.h" 9 | 10 | namespace py = pybind11; 11 | namespace ak = awkward; 12 | 13 | template 14 | py::class_, std::shared_ptr>> 15 | make_ForthMachineOf(const py::handle& m, const std::string& name); 16 | 17 | #endif // AWKWARDPY_FORTH_H_ 18 | -------------------------------------------------------------------------------- /docs/user-guide/index.md: -------------------------------------------------------------------------------- 1 | # User guide 2 | 3 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 4 | 5 | If you're looking for documentation on a specific function, see the API reference instead. 6 | 7 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 8 | 9 |




10 | -------------------------------------------------------------------------------- /tests/test_2556_jax_tracer_error.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | from __future__ import annotations 3 | 4 | import pytest 5 | 6 | import awkward as ak 7 | 8 | jax = pytest.importorskip("jax") 9 | 10 | 11 | def test(): 12 | ak.jax.register_and_check() 13 | 14 | arr = ak.Array([[1.0, 2, 3], [5, 6]], backend="jax") 15 | grad_arr = ak.Array([[34.0, 34.0, 34.0], [34.0, 34.0]], backend="jax") 16 | 17 | def f(x): 18 | return ak.sum(ak.sum(x) * x) 19 | 20 | assert ak.all(grad_arr == jax.grad(f)(arr)) 21 | -------------------------------------------------------------------------------- /tests/test_2816_public_typetracer_api.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import numpy as np 4 | 5 | import awkward as ak 6 | 7 | 8 | def test_unknown_scalar(): 9 | scalar = ak.typetracer.create_unknown_scalar(np.int64) 10 | assert scalar.dtype == np.dtype(np.int64) 11 | assert scalar.shape == () 12 | assert ak.typetracer.is_unknown_scalar(scalar) 13 | 14 | scalar = ak.typetracer.create_unknown_scalar("int64") 15 | assert scalar.dtype == np.dtype(np.int64) 16 | assert scalar.shape == () 17 | assert ak.typetracer.is_unknown_scalar(scalar) 18 | -------------------------------------------------------------------------------- /tests/test_3028_mask_bitmaskedarray.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import numpy as np 4 | 5 | import awkward as ak 6 | from awkward.typetracer import unknown_length 7 | 8 | 9 | def test(): 10 | arr = ( 11 | ak.mask([1, 2, 3], [True, False, False], highlevel=False) 12 | .to_BitMaskedArray(valid_when=True, lsb_order=True) 13 | .to_typetracer(forget_length=True) 14 | ) 15 | 16 | result = arr.mask_as_bool() 17 | assert result.dtype == np.dtype("bool") 18 | assert result.ndim == 1 19 | assert result.size is unknown_length 20 | -------------------------------------------------------------------------------- /dev/format-release-prs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from __future__ import annotations 3 | 4 | import argparse 5 | import re 6 | import sys 7 | 8 | 9 | def prefix_key(line): 10 | match = re.match(r"\*\s+([^:]+).*?pull/(\d+)", line) 11 | return match[1], int(match[2]) 12 | 13 | 14 | if __name__ == "__main__": 15 | parser = argparse.ArgumentParser() 16 | parser.add_argument( 17 | "file", type=argparse.FileType("r"), default=sys.stdin, nargs="?" 18 | ) 19 | args = parser.parse_args() 20 | 21 | print("".join(sorted(args.file.readlines(), key=prefix_key))) 22 | -------------------------------------------------------------------------------- /tests/test_1006_packed_regular_array_zero_size.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | to_list = ak.operations.to_list 11 | 12 | 13 | def test(): 14 | array = ak.contents.RegularArray( 15 | ak.contents.NumpyArray(np.empty(0, dtype=np.int32)), 16 | size=0, 17 | zeros_length=1, 18 | ) 19 | packed = ak.operations.to_packed(array) 20 | assert to_list(packed) == [[]] 21 | -------------------------------------------------------------------------------- /tests/test_2815_return_scalar_firsts.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | array = ak.Array([1, 2, 3, 4]) 13 | first = ak.firsts(array, axis=0) 14 | assert isinstance(first, np.int64) and first == 1 15 | 16 | 17 | def test_non_scalar(): 18 | array = ak.Array([[1, 2, 3], [4]]) 19 | first = ak.firsts(array, axis=0) 20 | assert first.to_list() == [1, 2, 3] 21 | -------------------------------------------------------------------------------- /src/awkward/_connect/dlpack.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | from enum import IntEnum 6 | 7 | __all__ = ("DLPackDevice",) 8 | 9 | 10 | class DLPackDevice(IntEnum): 11 | CPU = 1 # CPU 12 | CUDA = 2 # GPU 13 | CUDA_PINNED = 3 # GPU & CPU 14 | OPENCL = 4 # UNSUPPORTED 15 | VULKAN = 7 # UNSUPPORTED 16 | METAL = 8 # UNSUPPORTED 17 | VPI = 9 # UNSUPPORTED 18 | ROCM = 10 # GPU 19 | ROCM_PINNED = 11 # GPU & CPU 20 | CUDA_MANAGED = 13 # GPU & CPU 21 | -------------------------------------------------------------------------------- /tests/test_1403_from_numpy_strings.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test_unicode(): 12 | data = np.array(["this", "that"]) 13 | array = ak.from_numpy(data) 14 | assert array.to_list() == ["this", "that"] 15 | 16 | 17 | def test_bytes(): 18 | data = np.array([b"this", b"that"], dtype="S") 19 | array = ak.from_numpy(data) 20 | assert array.to_list() == [b"this", b"that"] 21 | -------------------------------------------------------------------------------- /tests/test_0903_ArrayView_expects_contiguous_NumpyArrays.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | numba = pytest.importorskip("numba") 11 | 12 | ak.numba.register_and_check() 13 | 14 | 15 | def test(): 16 | @numba.njit 17 | def f1(x): 18 | return x[0], x[1] 19 | 20 | array = ak.highlevel.Array(np.arange(4).reshape(2, 2)[:, 0]) 21 | 22 | assert f1.py_func(array) == (0, 2) 23 | assert f1(array) == (0, 2) 24 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_IndexedArray_numnull_unique_64.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_IndexedArray_numnull_unique_64( 6 | T* toindex, 7 | int64_t lenindex, 8 | uint64_t invocation_index, 9 | uint64_t* err_code) { 10 | if (err_code[0] == NO_ERROR) { 11 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 12 | if (thread_id <= lenindex) { 13 | toindex[thread_id] = (thread_id < lenindex ? thread_id : -1); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /studies/awkward-forth-performance/uproot-read-jagged0-root.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import uproot 4 | 5 | branch = uproot.open("/home/jpivarski/storage/data/chep-2021-jagged-jagged-jagged/zlib9-jagged0.root:tree/branch") 6 | 7 | begintime = time.time() 8 | 9 | for basketid in range(branch.num_baskets): 10 | basket = branch.basket(basketid) 11 | start, stop = branch.basket_entry_start_stop(basketid) 12 | 13 | array1 = branch.array(entry_start=start, entry_stop=stop, library="np") 14 | 15 | endtime = time.time() 16 | print("Uproot zlib9-jagged0", stop, "entries", endtime - begintime, "seconds") 17 | -------------------------------------------------------------------------------- /tests/test_0627_behavior_from_dict_of_arrays.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | simple = {"what": "ever"} 13 | one = ak.Array([[1.1, 2.2, 3.3], [], [4.4, 5.5]], behavior=simple) 14 | two = ak.Array([["one", "two"], ["three"], ["four", "five"]], behavior=simple) 15 | three = ak.operations.cartesian({"one": one, "two": two}) 16 | assert three.behavior == {"what": "ever"} 17 | -------------------------------------------------------------------------------- /tests/test_0863_is_none_numpy_array.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test_numpy_array(): 12 | x = np.arange(12) 13 | y = ak.operations.is_none(x) 14 | 15 | assert y.to_list() == [False] * 12 16 | 17 | 18 | def test_awkward_from_numpy_array(): 19 | x = np.arange(12) 20 | y = ak.operations.from_numpy(x) 21 | z = ak.operations.is_none(y) 22 | 23 | assert z.to_list() == [False] * 12 24 | -------------------------------------------------------------------------------- /tests/test_1826_ravel_preserve_none.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | import awkward._connect.cling 10 | import awkward._lookup 11 | 12 | 13 | def test(): 14 | array = ak.Array([[1, 2, 3, None], [4, 5, 6, 7, 8], [], [9], None, [10]]) 15 | 16 | assert ak.ravel(array).to_list() == [1, 2, 3, None, 4, 5, 6, 7, 8, 9, 10] 17 | assert ak.flatten(array, axis=None).to_list() == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 18 | -------------------------------------------------------------------------------- /tests/test_2304_index_typetracer.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | 7 | import awkward as ak 8 | 9 | 10 | def test(): 11 | array = ak.Array([[1, 2, 3], [4, 5, 6]], backend="typetracer") 12 | 13 | with pytest.raises(IndexError): 14 | array[0, 0, 0] 15 | 16 | with pytest.raises(IndexError): 17 | array[0, :, 0] 18 | 19 | with pytest.raises(IndexError): 20 | array[0, :, ..., 0] 21 | 22 | with pytest.raises(IndexError): 23 | array[0, [0], [0]] 24 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_UnionArray_fillindex_count.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_UnionArray_fillindex_count( 6 | T* toindex, 7 | int64_t toindexoffset, 8 | int64_t length, 9 | uint64_t invocation_index, 10 | uint64_t* err_code) { 11 | if (err_code[0] == NO_ERROR) { 12 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 13 | if (thread_id < length) { 14 | toindex[toindexoffset + thread_id] = (T)thread_id; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /studies/chep-2019/chep2019-plot.gnuplot: -------------------------------------------------------------------------------- 1 | set term svg 2 | set output "read_ttree.svg" 3 | 4 | set nokey 5 | 6 | set size ratio 0.5 7 | 8 | set logscale y 9 | 10 | plot [-0.5:3.5][0.1:2000] "read_rntuple.dat" t "RNTuple + new awkward" with lines, "read_ttree_old.dat" t "TTree in uproot + old awkward" with lines, "read_ttree_new.dat" t "TTree in uproot + new awkward" with lines, "read_pyobj_old.dat" t "Python objects in old awkward" with lines, "read_pyobj_new.dat" t "Python objects in new awkward" with lines, "read_json_old.dat" t "JSON in old awkward" with lines, "read_json_new.dat" t "JSON in new awkward" with lines 11 | -------------------------------------------------------------------------------- /tests/test_0006_deep_iteration.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test_iterator(): 12 | content = ak.contents.NumpyArray(np.array([1.1, 2.2, 3.3])) 13 | offsets = ak.index.Index32(np.array([0, 2, 2, 3], "i4")) 14 | array = ak.contents.ListOffsetArray(offsets, content) 15 | 16 | assert list(content) == [1.1, 2.2, 3.3] 17 | assert [ak.to_numpy(x).tolist() for x in array] == [[1.1, 2.2], [], [3.3]] 18 | -------------------------------------------------------------------------------- /tests/test_2346_broadcast_depth_limit.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest # noqa: F401 6 | 7 | import awkward as ak 8 | 9 | 10 | def test(): 11 | left = ak.Array([0, 4, 5]) 12 | right = ak.Array([[0, 1, 2, 3], [5, 6, 7, 2], [9, 8, 2, 0]]) 13 | 14 | left_result, right_result = ak.broadcast_arrays(left, right, depth_limit=4) 15 | assert left_result.to_list() == [[0, 0, 0, 0], [4, 4, 4, 4], [5, 5, 5, 5]] 16 | assert right_result.to_list() == [[0, 1, 2, 3], [5, 6, 7, 2], [9, 8, 2, 0]] 17 | -------------------------------------------------------------------------------- /studies/awkward-forth-performance/read-parquet.sh: -------------------------------------------------------------------------------- 1 | for compress in zlib1; do # zlib0 2 | for jagged in 0 1 2 3; do 3 | for splt in nosplit; do # split 4 | python pyarrow-read-jaggedN-parquet.py $compress $jagged $splt; 5 | python pyarrow-read-jaggedN-parquet.py $compress $jagged $splt; 6 | python forth-read-jaggedN-parquet.py $compress $jagged $splt; 7 | python forth-read-jaggedN-parquet.py $compress $jagged $splt; 8 | python pyarrow-read-jaggedN-parquet.py $compress $jagged $splt; 9 | python forth-read-jaggedN-parquet.py $compress $jagged $splt; 10 | done 11 | done 12 | done 13 | -------------------------------------------------------------------------------- /tests/test_0819_issue.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | a = ak.Array([[1, 2, 3, 4], [5, 6, 7, 8]]) 13 | assert ak.operations.unflatten(a, [2, 2, 2, 2], axis=1).to_list() == [ 14 | [[1, 2], [3, 4]], 15 | [[5, 6], [7, 8]], 16 | ] 17 | assert ak.operations.unflatten(a, 2, axis=1).to_list() == [ 18 | [[1, 2], [3, 4]], 19 | [[5, 6], [7, 8]], 20 | ] 21 | -------------------------------------------------------------------------------- /tests/test_2240_merge_union_parameters.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | 7 | import awkward as ak 8 | 9 | 10 | def test(): 11 | one = ak.with_parameter([1, 2, [], [3, 4]], "one", "one") 12 | two = ak.with_parameter([100, 200, 300], "two", "two") 13 | three = ak.with_parameter([{"x": 1}, {"x": 2}, 5, 6, 7], "two", "two") 14 | 15 | # No parameter unions should occur here 16 | result = ak.concatenate((two, one, three)) 17 | assert ak.parameters(result) == {} 18 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_UnionArray_filltags_const.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_UnionArray_filltags_const( 6 | T* totags, 7 | int64_t totagsoffset, 8 | int64_t length, 9 | int64_t base, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 14 | if (thread_id < length) { 15 | totags[totagsoffset + thread_id] = (T)base; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/test_2259_run_lengths_typetracer.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | from awkward._nplikes.shape import unknown_length 10 | 11 | 12 | def test(): 13 | array = ak.Array([2, 1, 1, 1, 2, 2, 3, 3, 4], backend="typetracer") 14 | result = ak.run_lengths(array) 15 | assert isinstance(result.layout, ak.contents.NumpyArray) 16 | assert result.layout.length is unknown_length 17 | assert result.layout.dtype == np.dtype("int64") 18 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_reduce_count_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_reduce_count_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_reduce_count_64( 8 | int64_t* toptr, 9 | const int64_t* parents, 10 | int64_t lenparents, 11 | int64_t outlength) { 12 | for (int64_t i = 0; i < outlength; i++) { 13 | toptr[i] = 0; 14 | } 15 | for (int64_t i = 0; i < lenparents; i++) { 16 | toptr[parents[i]]++; 17 | } 18 | return success(); 19 | } 20 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_UnionArray_fillna.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_UnionArray_fillna( 6 | T* toindex, 7 | const C* fromindex, 8 | int64_t length, 9 | uint64_t invocation_index, 10 | uint64_t* err_code) { 11 | if (err_code[0] == NO_ERROR) { 12 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 13 | if (thread_id < length) { 14 | toindex[thread_id] = fromindex[thread_id] >= 0 ? fromindex[thread_id] : 0; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/test_2327_array_interface.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | 7 | import awkward as ak 8 | 9 | 10 | def test_wrap_index_numpy(): 11 | data = np.arange(10, dtype=np.int64) 12 | index = ak.index.Index64(data) 13 | other_data = np.asarray(index) 14 | assert np.shares_memory(data, other_data) 15 | 16 | 17 | def test_wrap_bare_list(): 18 | data = [1, 2, 3, 4, 5] 19 | index = ak.index.Index64(data) 20 | other_data = np.asarray(index) 21 | assert other_data.tolist() == data 22 | -------------------------------------------------------------------------------- /tests/test_2947_to_list_numpy_integer.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | from __future__ import annotations 3 | 4 | import numpy as np 5 | 6 | import awkward as ak 7 | 8 | 9 | def test(): 10 | """Check that to_list() does not break when the array is built from buffers 11 | with a length of type np.int64. 12 | """ 13 | awk = ak.Array(np.ones((7, 0))) 14 | form, length, container = ak.to_buffers(ak.to_packed(awk)) 15 | awk_from_buf = ak.from_buffers(form, np.int64(length), container) 16 | lst = awk_from_buf.to_list() 17 | 18 | assert len(lst) == length 19 | -------------------------------------------------------------------------------- /tests/test_3206_generalize_index_ptr.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | 7 | import awkward as ak 8 | 9 | 10 | def test_1(): 11 | arr = ak.Array([[1, 3, 4], 5]) 12 | tarr = arr.layout.to_typetracer() 13 | 14 | with pytest.raises(ak.errors.AxisError, match="exceeds the depth of this array"): 15 | ak.flatten(tarr) 16 | 17 | 18 | def test_2(): 19 | arr = ak.Array([[[1, 3, 4]], [5]]) 20 | tarr = arr.layout.to_typetracer() 21 | 22 | assert ak.flatten(tarr).type == ak.flatten(arr).type 23 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_ByteMaskedArray_numnull.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_ByteMaskedArray_numnull.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_ByteMaskedArray_numnull( 8 | int64_t* numnull, 9 | const int8_t* mask, 10 | int64_t length, 11 | bool validwhen) { 12 | *numnull = 0; 13 | for (int64_t i = 0; i < length; i++) { 14 | if ((mask[i] != 0) != validwhen) { 15 | *numnull = *numnull + 1; 16 | } 17 | } 18 | return success(); 19 | } 20 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_IndexedArray_fill_count.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_IndexedArray_fill_count( 6 | T* toindex, 7 | int64_t toindexoffset, 8 | int64_t length, 9 | int64_t base, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 14 | if (thread_id < length) { 15 | toindex[(toindexoffset + thread_id)] = (thread_id + base); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /studies/awkward-forth-performance/uproot-read-jagged2-root.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import uproot 4 | 5 | branch = uproot.open("/home/jpivarski/storage/data/chep-2021-jagged-jagged-jagged/zlib9-jagged2.root:tree/branch") 6 | 7 | begintime = time.time() 8 | 9 | for basketid in range(branch.num_baskets): 10 | if basketid == 2: break 11 | 12 | basket = branch.basket(basketid) 13 | start, stop = branch.basket_entry_start_stop(basketid) 14 | 15 | array1 = branch.array(entry_start=start, entry_stop=stop, library="np") 16 | 17 | endtime = time.time() 18 | print("Uproot zlib9-jagged2", stop, "entries", endtime - begintime, "seconds") 19 | -------------------------------------------------------------------------------- /studies/awkward-forth-performance/uproot-read-jagged3-root.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import uproot 4 | 5 | branch = uproot.open("/home/jpivarski/storage/data/chep-2021-jagged-jagged-jagged/zlib9-jagged3.root:tree/branch") 6 | 7 | begintime = time.time() 8 | 9 | for basketid in range(branch.num_baskets): 10 | if basketid == 2: break 11 | 12 | basket = branch.basket(basketid) 13 | start, stop = branch.basket_entry_start_stop(basketid) 14 | 15 | array1 = branch.array(entry_start=start, entry_stop=stop, library="np") 16 | 17 | endtime = time.time() 18 | print("Uproot zlib9-jagged3", stop, "entries", endtime - begintime, "seconds") 19 | -------------------------------------------------------------------------------- /tests/test_2120_missing_field_error.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | 7 | import awkward as ak 8 | 9 | 10 | def test(): 11 | array = ak.Array( 12 | [ 13 | {"x": 100, "y": 200}, 14 | {"x": 300, "y": 400}, 15 | ] 16 | ) 17 | with pytest.raises(ak.errors.FieldNotFoundError): 18 | array["z"] 19 | with pytest.raises(ak.errors.FieldNotFoundError): 20 | array[["z", "k"]] 21 | with pytest.raises(ak.errors.FieldNotFoundError): 22 | array[0, "z"] 23 | -------------------------------------------------------------------------------- /studies/awkward-forth-performance/uproot-read-jagged1-root.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import uproot 4 | 5 | branch = uproot.open("/home/jpivarski/storage/data/chep-2021-jagged-jagged-jagged/zlib9-jagged1.root:tree/branch") 6 | 7 | begintime = time.time() 8 | 9 | for basketid in range(branch.num_baskets): 10 | if basketid == 20: break 11 | 12 | basket = branch.basket(basketid) 13 | start, stop = branch.basket_entry_start_stop(basketid) 14 | 15 | array1 = branch.array(entry_start=start, entry_stop=stop, library="np") 16 | 17 | endtime = time.time() 18 | print("Uproot zlib9-jagged1", stop, "entries", endtime - begintime, "seconds") 19 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_sorting_ranges_length.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_sorting_ranges_length.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_sorting_ranges_length( 8 | int64_t* tolength, 9 | const int64_t* parents, 10 | int64_t parentslength) { 11 | int64_t length = 2; 12 | for (int64_t i = 1; i < parentslength; i++) { 13 | if (parents[i - 1] != parents[i]) { 14 | length++; 15 | } 16 | } 17 | *tolength = length; 18 | return success(); 19 | } 20 | -------------------------------------------------------------------------------- /awkward-cpp/docs/stylesheet.css: -------------------------------------------------------------------------------- 1 | .memtitle { 2 | border: none; 3 | background-color: #ffffffff; 4 | background-image: none; 5 | background-repeat: none; 6 | } 7 | 8 | .memitem { 9 | transition: none; 10 | } 11 | 12 | .memproto { 13 | border: none; 14 | background-color: #ffffffff; 15 | box-shadow: none; 16 | -webkit-box-shadow: none; 17 | } 18 | 19 | .memdoc { 20 | border: none; 21 | background-image: none; 22 | background-repeat: none; 23 | background-color: #fffffff; 24 | box-shadow: none; 25 | -webkit-box-shadow: none; 26 | } 27 | 28 | h2.memtitle span.permalink { 29 | display: none; 30 | } 31 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_localindex.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_localindex.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | template 8 | ERROR awkward_localindex( 9 | T* toindex, 10 | int64_t length) { 11 | for (int64_t i = 0; i < length; i++) { 12 | toindex[i] = i; 13 | } 14 | return success(); 15 | } 16 | ERROR awkward_localindex_64( 17 | int64_t* toindex, 18 | int64_t length) { 19 | return awkward_localindex( 20 | toindex, 21 | length); 22 | } 23 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_UnionArray_fillindex.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_UnionArray_fillindex( 6 | T* toindex, 7 | int64_t toindexoffset, 8 | const C* fromindex, 9 | int64_t length, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 14 | if (thread_id < length) { 15 | toindex[toindexoffset + thread_id] = (T)fromindex[thread_id]; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docs/_templates/funding.html: -------------------------------------------------------------------------------- 1 |

Support for this work was provided by NSF cooperative agreement OAC-1836650 (IRIS-HEP 1), PHY-2323298 (IRIS-HEP 2), grant OAC-1450377 (DIANA/HEP), PHY-1520942 and PHY-2121686 (US-CMS LHC Ops), and OAC-2103945 (Awkward Array).

2 | -------------------------------------------------------------------------------- /tests/test_2051_arraybuilder_behavior_propagation.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import awkward as ak 6 | 7 | 8 | class Point(ak.Array): 9 | def length(self): 10 | raise NotImplementedError 11 | 12 | 13 | def test(): 14 | behavior = {("*", "point"): Point} 15 | builder = ak.ArrayBuilder(behavior=behavior) 16 | with builder.record("point"): 17 | builder.field("x").real(1.0) 18 | builder.field("y").real(2.0) 19 | builder.field("z").real(3.0) 20 | 21 | assert ak.almost_equal(builder, builder.snapshot()) 22 | -------------------------------------------------------------------------------- /tests/test_2104_numpy_merge_option.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | assert ak.almost_equal( 13 | ak.concatenate([ak.Array([1, 2, 3]), ak.Array([1, 2, None])]), 14 | ak.contents.ByteMaskedArray( 15 | ak.index.Index8(np.array([False, False, False, False, False, True])), 16 | ak.contents.NumpyArray(np.array([1, 2, 3, 1, 2, 3], dtype=np.int64)), 17 | valid_when=False, 18 | ), 19 | ) 20 | -------------------------------------------------------------------------------- /tests/test_2246_slice_not_packed.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | 7 | import awkward as ak 8 | 9 | 10 | def test(): 11 | index = ak.Array( 12 | ak.contents.ListOffsetArray( 13 | ak.index.Index64([0, 3, 5]), 14 | ak.contents.NumpyArray( 15 | np.array([True, False, False, True, True, False, False], dtype=np.bool_) 16 | ), 17 | ) 18 | ) 19 | array = ak.Array([[0, 1, 2], [3, 4]]) 20 | result = array[index] 21 | assert result.tolist() == [[0], [3, 4]] 22 | -------------------------------------------------------------------------------- /tests/test_1703_fill_none_typetracer.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | from awkward._nplikes.typetracer import is_unknown_length 10 | 11 | 12 | def test(): 13 | array = ak.Array([1, 2, None]) 14 | result = ak.fill_none(array, 0) 15 | assert result.to_list() == [1, 2, 0] 16 | 17 | array_tt = ak.Array(array.layout.to_typetracer(forget_length=True)) 18 | result_tt = ak.fill_none(array_tt, 0) 19 | assert is_unknown_length(result_tt.layout.length) 20 | -------------------------------------------------------------------------------- /tests/test_2678_same_backend.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | 11 | def test_where(): 12 | result = ak.where( 13 | [True, False, False], ak.to_backend([1, 2, 3], "typetracer"), [4, 5, 6] 14 | ) 15 | assert ak.backend(result) == "typetracer" 16 | 17 | 18 | def test_almost_equal(): 19 | with pytest.raises(NotImplementedError): 20 | ak.almost_equal( 21 | [True, False, False], ak.to_backend([True, False, False], "typetracer") 22 | ) 23 | -------------------------------------------------------------------------------- /tests/test_0905_leading_zeros_in_unflatten.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | array = ak.Array([[1, 2, 3]]) 13 | assert ak.operations.unflatten(array, [2, 1], axis=1).to_list() == [[[1, 2], [3]]] 14 | assert ak.operations.unflatten(array, [0, 2, 1], axis=1).to_list() == [ 15 | [[], [1, 2], [3]] 16 | ] 17 | assert ak.operations.unflatten(array, [0, 0, 2, 1], axis=1).to_list() == [ 18 | [[], [], [1, 2], [3]] 19 | ] 20 | -------------------------------------------------------------------------------- /tests/test_1709_ak_array_constructor_behavior.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest # noqa: F401 6 | 7 | import awkward as ak 8 | from awkward._nplikes.numpy import Numpy 9 | 10 | numpy = Numpy.instance() 11 | 12 | 13 | class MyBehavior(ak.Array): ... 14 | 15 | 16 | def test(): 17 | behavior = {"MyBehavior": MyBehavior} 18 | array = ak.with_parameter([[1, 2, 3]], "__list__", "MyBehavior", behavior=behavior) 19 | assert isinstance(array, MyBehavior) 20 | 21 | shallow_copy = ak.Array(array) 22 | assert isinstance(shallow_copy, MyBehavior) 23 | -------------------------------------------------------------------------------- /tests/test_2785_ak_num_typetracer_axis_0.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import awkward as ak 6 | from awkward._nplikes.typetracer import TypeTracerArray 7 | 8 | 9 | def test_unknown_length(): 10 | array = ak.typetracer.typetracer_from_form(ak.forms.NumpyForm("int64")) 11 | assert isinstance(ak.num(array, axis=0), TypeTracerArray) 12 | 13 | 14 | def test_known_length(): 15 | array = ak.Array([0, 1, 2, 3], backend="typetracer") 16 | # This is now the new behavior - always return typetracers 17 | assert isinstance(ak.num(array, axis=0), TypeTracerArray) 18 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_UnionArray_filltags.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_UnionArray_filltags( 6 | T* totags, 7 | int64_t totagsoffset, 8 | const C* fromtags, 9 | int64_t length, 10 | int64_t base, 11 | uint64_t invocation_index, 12 | uint64_t* err_code) { 13 | if (err_code[0] == NO_ERROR) { 14 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 15 | if (thread_id < length) { 16 | totags[totagsoffset + thread_id] = (T)(fromtags[thread_id] + base); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/test_2078_array_function_wrap.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | left = ak.Array([1, 2, 3]) 13 | right = ak.Array([[1, 2], [4, 5, 6], [None]]) 14 | result = np.broadcast_arrays(left, right) 15 | assert isinstance(result, list) 16 | assert isinstance(result[0], ak.Array) 17 | assert isinstance(result[1], ak.Array) 18 | assert result[0].to_list() == [[1, 1], [2, 2, 2], [None]] 19 | assert result[1].to_list() == [[1, 2], [4, 5, 6], [None]] 20 | -------------------------------------------------------------------------------- /tests/test_2426_is_equal_to.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest # noqa: F401 6 | 7 | import awkward as ak 8 | 9 | 10 | def test_equal_union(): 11 | union_1 = ak.from_iter([1, None, {"x": 2}], highlevel=False) 12 | union_2 = ak.from_iter([1, None, {"x": 2}], highlevel=False) 13 | 14 | assert union_1.is_equal_to(union_2) 15 | 16 | 17 | def test_unequal_union(): 18 | union_1 = ak.from_iter([1, None, {"x": 2}, 3], highlevel=False) 19 | union_2 = ak.from_iter([1, None, {"x": 2}, 2], highlevel=False) 20 | 21 | assert not union_1.is_equal_to(union_2) 22 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_IndexedArray_reduce_next_fix_offsets_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_IndexedArray_reduce_next_fix_offsets_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_IndexedArray_reduce_next_fix_offsets_64( 8 | int64_t* outoffsets, 9 | const int64_t* starts, 10 | int64_t startslength, 11 | int64_t outindexlength) { 12 | for (int64_t i = 0; i < startslength; i++) { 13 | outoffsets[i] = starts[i]; 14 | } 15 | outoffsets[startslength] = outindexlength; 16 | return success(); 17 | } 18 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_index_rpad_and_clip_axis1.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_index_rpad_and_clip_axis1( 6 | T* tostarts, 7 | C* tostops, 8 | int64_t target, 9 | int64_t length, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 14 | if (thread_id < length) { 15 | tostarts[thread_id] = thread_id * target; 16 | tostops[thread_id] = (thread_id + 1) * target; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_IndexedArray_overlay_mask.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_IndexedArray_overlay_mask( 6 | T* toindex, 7 | const C* mask, 8 | const U* fromindex, 9 | int64_t length, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 14 | if (thread_id < length) { 15 | C m = mask[thread_id]; 16 | toindex[thread_id] = (m ? -1 : fromindex[thread_id]); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/test_1940_ak_backend.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test_typetracer(): 12 | array = ak.Array([[0, 1, 2, 3], [8, 9, 10, 11]]) 13 | typetracer = ak.Array(array.layout.to_typetracer()) 14 | 15 | assert ak.backend(typetracer) == "typetracer" 16 | 17 | 18 | def test_to_typetracer(): 19 | array = ak.Array([[0, 1, 2, 3], [8, 9, 10, 11]]) 20 | 21 | assert ak.backend(array) == "cpu" 22 | assert ak.backend(ak.to_backend(array, "typetracer")) == "typetracer" 23 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_RegularArray_localindex.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_RegularArray_localindex( 6 | T* toindex, 7 | int64_t size, 8 | int64_t length, 9 | uint64_t invocation_index, 10 | uint64_t* err_code) { 11 | if (err_code[0] == NO_ERROR) { 12 | int64_t thread_id = (blockIdx.x * blockDim.x + threadIdx.x) / size; 13 | int64_t thready_id = (blockIdx.x * blockDim.x + threadIdx.x) % size; 14 | 15 | if (thread_id < length) { 16 | toindex[((thread_id * size) + thready_id)] = thready_id; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/test_1017_numpyarray_broadcast.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | x = ak.contents.ListOffsetArray( 13 | ak.index.Index64(np.array([0, 2, 2, 4, 6])), 14 | ak.contents.NumpyArray(np.arange(8 * 8).reshape(8, -1)), 15 | ) 16 | y = ak.contents.ListOffsetArray( 17 | ak.index.Index64(np.array([0, 2, 2, 4, 6])), 18 | ak.contents.NumpyArray(np.arange(8)), 19 | ) 20 | u, v = ak.operations.broadcast_arrays(x, y) 21 | assert u.ndim == v.ndim 22 | -------------------------------------------------------------------------------- /tests/test_1066_to_numpy_masked_structured_array.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | a = ak.operations.to_numpy(ak.highlevel.Array({"A": [1, 2, 3], "B": [4, None, 5]})) 13 | assert a["A"].data.tolist() == [1, 2, 3] 14 | assert a["A"].mask.tolist() == [False, False, False] 15 | assert a["B"].data[0] == 4 16 | assert a["B"].data[2] == 5 17 | assert a["A"].mask.tolist() == [False, False, False] 18 | assert a["B"].mask.tolist() == [False, True, False] 19 | -------------------------------------------------------------------------------- /tests/test_1685_IndexedArray_project_parameters.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | layout = ak.contents.IndexedArray( 13 | ak.index.Index64(np.array([0, 1, 2, 3], np.int64)), 14 | ak.contents.NumpyArray( 15 | np.arange(10), parameters={"this": "that", "some": "hidden"} 16 | ), 17 | parameters={"some": "other"}, 18 | ) 19 | assert layout.project().parameter("some") == "other" 20 | assert layout.project().parameter("this") == "that" 21 | -------------------------------------------------------------------------------- /tests/test_2263_to_packed_list.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | from awkward._backends.typetracer import TypeTracerBackend 10 | 11 | 12 | def test(): 13 | backend = TypeTracerBackend.instance() 14 | layout = ak.contents.ListOffsetArray( 15 | ak.index.Index64( 16 | backend.index_nplike.asarray([0, 1, 3, 7], dtype=np.dtype("int64")) 17 | ), 18 | ak.contents.NumpyArray(backend.nplike.asarray([1, 2, 3, 4, 5, 6, 7])), 19 | ) 20 | assert layout.to_packed().length == 3 21 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_reduce_sum_int32_bool_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_reduce_sum_int32_bool_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_reduce_sum_int32_bool_64( 8 | int32_t* toptr, 9 | const bool* fromptr, 10 | const int64_t* parents, 11 | int64_t lenparents, 12 | int64_t outlength) { 13 | for (int64_t i = 0; i < outlength; i++) { 14 | toptr[i] = 0; 15 | } 16 | for (int64_t i = 0; i < lenparents; i++) { 17 | toptr[parents[i]] += (fromptr[i] != 0); 18 | } 19 | return success(); 20 | } 21 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_reduce_sum_int64_bool_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_reduce_sum_int64_bool_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_reduce_sum_int64_bool_64( 8 | int64_t* toptr, 9 | const bool* fromptr, 10 | const int64_t* parents, 11 | int64_t lenparents, 12 | int64_t outlength) { 13 | for (int64_t i = 0; i < outlength; i++) { 14 | toptr[i] = 0; 15 | } 16 | for (int64_t i = 0; i < lenparents; i++) { 17 | toptr[parents[i]] += (fromptr[i] != 0); 18 | } 19 | return success(); 20 | } 21 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_ByteMaskedArray_toIndexedOptionArray.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_ByteMaskedArray_toIndexedOptionArray( 6 | T* toindex, 7 | const C* mask, 8 | int64_t length, 9 | bool validwhen, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 14 | if (thread_id < length) { 15 | toindex[thread_id] = 16 | ((mask[thread_id] != 0) == validwhen ? thread_id : -1); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/awkward/operations/ak_to_cudf.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | from __future__ import annotations 3 | 4 | import awkward as ak 5 | from awkward._dispatch import high_level_function 6 | 7 | __all__ = ("to_cudf",) 8 | 9 | 10 | @high_level_function() 11 | def to_cudf( 12 | array: ak.Array, 13 | ): 14 | """Create a cuDF.Series out of the given ak array 15 | 16 | Buffers that are not already in GPU memory will be transferred, and some 17 | structural reformatting may happen to account for differences in architecture. 18 | """ 19 | import cudf 20 | 21 | return cudf.Series(array.layout._to_cudf(cudf, None, len(array))) 22 | -------------------------------------------------------------------------------- /studies/cuda-kernels/test-cuda-kernels.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Copying files" 4 | 5 | cp standard_parallel_algorithms.h loop-dependent-variable-kernels/manual_*.cu restricted-loop-carried-array-kernels/manual_*.cu ../../src/cuda-kernels/ 6 | cd ../.. 7 | 8 | echo "Running setup" 9 | sudo pip uninstall awkward1_cuda_kernels && sudo ./cuda-build.sh --install 10 | python dev/generate-tests.py 11 | 12 | echo "Testing" 13 | pytest -vvrs tests-cuda-kernels 14 | 15 | echo "Cleaning up" 16 | mv src/cuda-kernels/manual_awkward_ListArray_num.cu src/ 17 | 18 | rm src/cuda-kernels/manual* src/cuda-kernels/standard_parallel_algorithms.h 19 | 20 | mv src/manual_awkward_ListArray_num.cu src/cuda-kernels/ 21 | -------------------------------------------------------------------------------- /tests/test_2634_listarray_pad_none.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | layout = ak.to_layout(["hi", "bye"]) 13 | 14 | def as_32(index): 15 | return ak.index.Index(index.nplike.astype(index.data, np.int32)) 16 | 17 | layout = ak.contents.ListArray( 18 | as_32(layout.starts), 19 | as_32(layout.stops), 20 | layout.content, 21 | parameters=layout._parameters, 22 | ) 23 | assert ak.pad_none(layout, 3, axis=0).tolist() == ["hi", "bye", None] 24 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_NumpyArray_reduce_mask_ByteMaskedArray_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_NumpyArray_reduce_mask_ByteMaskedArray_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_NumpyArray_reduce_mask_ByteMaskedArray_64( 8 | int8_t* toptr, 9 | const int64_t* parents, 10 | int64_t lenparents, 11 | int64_t outlength) { 12 | for (int64_t i = 0; i < outlength; i++) { 13 | toptr[i] = 1; 14 | } 15 | for (int64_t i = 0; i < lenparents; i++) { 16 | toptr[parents[i]] = 0; 17 | } 18 | return success(); 19 | } 20 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_ListOffsetArray_flatten_offsets.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_ListOffsetArray_flatten_offsets( 6 | T* tooffsets, 7 | const C* outeroffsets, 8 | int64_t outeroffsetslen, 9 | const U* inneroffsets, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 14 | if (thread_id < outeroffsetslen) { 15 | tooffsets[thread_id] = inneroffsets[outeroffsets[thread_id]]; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /studies/awkward-forth-performance/forth-read-jagged0-root.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import uproot 4 | import awkward.forth 5 | import awkward as ak 6 | import numpy as np 7 | 8 | branch = uproot.open("/home/jpivarski/storage/data/chep-2021-jagged-jagged-jagged/zlib9-jagged0.root:tree/branch") 9 | 10 | begintime = time.time() 11 | 12 | for basketid in range(branch.num_baskets): 13 | basket = branch.basket(basketid) 14 | start, stop = branch.basket_entry_start_stop(basketid) 15 | 16 | array2 = ak.Array( 17 | ak.layout.NumpyArray(basket.data.astype(np.float32)) 18 | ) 19 | 20 | endtime = time.time() 21 | print("AwkwardForth zlib9-jagged0", stop, "entries", endtime - begintime, "seconds") 22 | -------------------------------------------------------------------------------- /tests/test_0559_fix_booleans_in_numba.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | numba = pytest.importorskip("numba") 11 | 12 | ak.numba.register_and_check() 13 | 14 | 15 | def test(): 16 | @numba.njit 17 | def do_something(array): 18 | out = np.zeros(len(array), np.bool_) 19 | for i, x in enumerate(array): 20 | if x: 21 | out[i] = x 22 | return out 23 | 24 | array = ak.highlevel.Array([True, False, False]) 25 | assert do_something(array).tolist() == [True, False, False] 26 | -------------------------------------------------------------------------------- /tests/test_1192_iterables_in___array_function__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | to_list = ak.operations.to_list 11 | 12 | 13 | def test(): 14 | first = ak.operations.from_numpy(np.array([1, 2, 3])) 15 | deltas = ak.highlevel.Array([[1, 2], [1, 2], [1, 2, 3]]) 16 | assert np.hstack( 17 | ( 18 | first[:, np.newaxis], 19 | ak.operations.fill_none(ak.operations.pad_none(deltas, 3, axis=-1), 999), 20 | ) 21 | ).tolist() == [[1, 1, 2, 999], [2, 1, 2, 999], [3, 1, 2, 3]] 22 | -------------------------------------------------------------------------------- /tests/test_2651_parameter_union.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | layout = ak.contents.IndexedArray( 13 | ak.index.Index64([0, 1, 2]), 14 | ak.contents.NumpyArray(np.array([1, 2, 3], dtype=np.uint32)), 15 | parameters={"foo": {"bar": "baz"}}, 16 | ) 17 | result = layout.project() 18 | assert result.is_equal_to( 19 | ak.contents.NumpyArray( 20 | np.array([1, 2, 3], dtype=np.uint32), parameters={"foo": {"bar": "baz"}} 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/unicode.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/unicode.cpp", line) 4 | 5 | #include "awkward/unicode.h" 6 | 7 | 8 | size_t utf8_codepoint_size(const uint8_t byte) { 9 | if ((byte & UTF8_ONE_BYTE_MASK) == UTF8_ONE_BYTE_BITS) { 10 | return 1; 11 | } 12 | 13 | if ((byte & UTF8_TWO_BYTES_MASK) == UTF8_TWO_BYTES_BITS) { 14 | return 2; 15 | } 16 | 17 | if ((byte & UTF8_THREE_BYTES_MASK) == UTF8_THREE_BYTES_BITS) { 18 | return 3; 19 | } 20 | 21 | if ((byte & UTF8_FOUR_BYTES_MASK) == UTF8_FOUR_BYTES_BITS) { 22 | return 4; 23 | } 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /cibuildwheel.toml: -------------------------------------------------------------------------------- 1 | [tool.cibuildwheel] 2 | build-frontend = "build[uv]" 3 | test-requires = ["pytest>=6", "."] 4 | test-command = """ 5 | pytest {project}/tests \ 6 | {package}/tests-cpu-kernels \ 7 | {package}/tests-cpu-kernels-explicit \ 8 | {package}/tests-spec \ 9 | {package}/tests-spec-explicit 10 | """ 11 | skip = [ 12 | "pp*win*", 13 | "pp*-manylinux_i686", 14 | ] 15 | test-skip = [ 16 | "*universal2:arm64", 17 | "pp*", 18 | "*musllinux*", 19 | ] 20 | build-verbosity = 1 21 | 22 | [tool.cibuildwheel.environment] 23 | PIP_ONLY_BINARY = "cmake,numpy" 24 | 25 | [[tool.cibuildwheel.overrides]] 26 | select = "cp313*" 27 | environment.PYO3_USE_ABI3_FORWARD_COMPATIBILITY = "1" 28 | -------------------------------------------------------------------------------- /awkward-cpp/include/awkward/unicode.h: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | #include 3 | #include 4 | 5 | #ifndef AWKWARD_UNICODE_H_ 6 | #define AWKWARD_UNICODE_H_ 7 | 8 | 9 | #define UTF8_ONE_BYTE_MASK 0x80 10 | #define UTF8_ONE_BYTE_BITS 0 11 | #define UTF8_TWO_BYTES_MASK 0xE0 12 | #define UTF8_TWO_BYTES_BITS 0xC0 13 | #define UTF8_THREE_BYTES_MASK 0xF0 14 | #define UTF8_THREE_BYTES_BITS 0xE0 15 | #define UTF8_FOUR_BYTES_MASK 0xF8 16 | #define UTF8_FOUR_BYTES_BITS 0xF0 17 | #define UTF8_CONTINUATION_MASK 0xC0 18 | #define UTF8_CONTINUATION_BITS 0x80 19 | 20 | 21 | size_t utf8_codepoint_size(const uint8_t byte); 22 | 23 | #endif // AWKWARD_UNICODE_H_ 24 | -------------------------------------------------------------------------------- /tests/test_2188_values_astype_turns_EmptyArray_into_NumpyArray.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | a = ak.Array([]) 13 | 14 | assert a.tolist() == [] 15 | assert str(a.type) == "0 * unknown" 16 | 17 | b = ak.values_astype(a, np.uint16, including_unknown=True) 18 | 19 | assert b.tolist() == [] 20 | assert str(b.type) == "0 * uint16" 21 | 22 | c = ak.values_astype(a, np.uint16, including_unknown=False) 23 | 24 | assert c.tolist() == [] 25 | assert str(c.type) == "0 * unknown" 26 | -------------------------------------------------------------------------------- /tests/test_1790_reduce_regulararray.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | array = ak.Array( 13 | ak.contents.ListOffsetArray( 14 | ak.index.Index64( 15 | np.array( 16 | [0, 2, 4, 4], 17 | dtype=np.int_, 18 | ) 19 | ), 20 | ak.contents.RegularArray(ak.contents.NumpyArray(np.arange(4 * 2)), size=2), 21 | ) 22 | ) 23 | 24 | assert ak.sum(array, axis=1).to_list() == [[2, 4], [10, 12], [0, 0]] 25 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_IndexedArray_fill.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_IndexedArray_fill( 6 | T* toindex, 7 | int64_t toindexoffset, 8 | const C* fromindex, 9 | int64_t length, 10 | int64_t base, 11 | uint64_t invocation_index, 12 | uint64_t* err_code) { 13 | if (err_code[0] == NO_ERROR) { 14 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 15 | if (thread_id < length) { 16 | C fromval = fromindex[thread_id]; 17 | toindex[toindexoffset + thread_id] = fromval < 0 ? (C)-1 : (C)(fromval + base); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_IndexedArray_reduce_next_fix_offsets_64.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_IndexedArray_reduce_next_fix_offsets_64( 6 | T* outoffsets, 7 | const C* starts, 8 | int64_t startslength, 9 | int64_t outindexlength, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 14 | if (thread_id < startslength) { 15 | outoffsets[thread_id] = starts[thread_id]; 16 | } 17 | outoffsets[startslength] = outindexlength; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/test_2082_broadcast_zero_size.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | 11 | @pytest.mark.parametrize("axis", [0, 1, 2]) 12 | def test_axis(axis): 13 | this_slice = (slice(None),) * axis + (slice(0, 0),) + (...,) 14 | that_slice = (slice(None),) * axis + (slice(0, 1),) + (...,) 15 | x = np.arange(3 * 5 * 7).reshape(3, 5, 7) 16 | result = np.broadcast_arrays(x[this_slice], x[that_slice]) 17 | 18 | y = ak.from_numpy(x) 19 | result_ak = ak.broadcast_arrays(y[this_slice], y[that_slice]) 20 | 21 | assert ak.almost_equal(result, result_ak) 22 | -------------------------------------------------------------------------------- /tests/test_0884_index_and_identifier_refactoring.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | from awkward._nplikes.numpy import Numpy 10 | 11 | numpy = Numpy.instance() 12 | 13 | 14 | def test_index32(): 15 | py_array = ak.index.Index.zeros(10, nplike=numpy.instance(), dtype=np.int32) 16 | 17 | assert len(py_array) == 10 18 | assert "i32" == py_array.form 19 | 20 | 21 | def test_index64(): 22 | py_array = ak.index.Index.zeros(10, nplike=numpy.instance(), dtype=np.int64) 23 | 24 | assert len(py_array) == 10 25 | assert "i64" == py_array.form 26 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_NumpyArray_reduce_mask_ByteMaskedArray_64.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_NumpyArray_reduce_mask_ByteMaskedArray_64( 6 | T* toptr, 7 | const C* parents, 8 | int64_t lenparents, 9 | int64_t outlength, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 14 | if (thread_id < outlength) { 15 | toptr[thread_id] = 1; 16 | } 17 | if (thread_id < lenparents) { 18 | toptr[parents[thread_id]] = 0; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /studies/templated-LayoutBuilder/test-stuff.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "LayoutBuilder.h" 4 | 5 | int main(int argc, char** argv) { 6 | std::cout << "BEGIN" << std::endl; 7 | 8 | ListOffsetLayoutBuilder> builder; 9 | 10 | NumpyLayoutBuilder* builder2 = builder.begin_list(); 11 | builder2->append(1.1); 12 | builder2->append(2.2); 13 | builder2->append(3.3); 14 | builder.end_list(); 15 | 16 | builder.begin_list(); 17 | builder.end_list(); 18 | 19 | auto builder3 = builder.begin_list(); 20 | builder3->append(4.4); 21 | builder3->append(5.5); 22 | builder.end_list(); 23 | 24 | builder.dump(""); 25 | 26 | std::cout << "END" << std::endl; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /tests/test_0339_highlevel_sorting_function.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | to_list = ak.operations.to_list 11 | 12 | 13 | def test_sort(): 14 | data = ak.Array([[7, 5, 7], [], [2], [8, 2]]) 15 | assert to_list(ak.operations.sort(data)) == [ 16 | [5, 7, 7], 17 | [], 18 | [2], 19 | [2, 8], 20 | ] 21 | 22 | 23 | def test_argsort(): 24 | data = ak.Array([[7, 5, 7], [], [2], [8, 2]]) 25 | index = ak.operations.argsort(data) 26 | assert to_list(data[index]) == [[5, 7, 7], [], [2], [2, 8]] 27 | -------------------------------------------------------------------------------- /tests/test_1747_bytemaskedarray_mergemany.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | x = ak.contents.ByteMaskedArray( 13 | ak.index.Index8(np.r_[0, 1, 1]), 14 | ak.contents.NumpyArray(np.arange(12)), 15 | valid_when=True, 16 | ) 17 | y = ak.contents.ByteMaskedArray( 18 | ak.index.Index8(np.r_[1, 1, 1, 0, 0]), 19 | ak.contents.NumpyArray(np.arange(12)), 20 | valid_when=True, 21 | ) 22 | z = x._mergemany([y]) 23 | 24 | assert z.to_list() == [None, 1, 2, 0, 1, 2, None, None] 25 | -------------------------------------------------------------------------------- /tests/test_2444_minimal_listarray.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import awkward as ak 6 | 7 | 8 | def test_dict(): 9 | array = ak.Array([{"muon": [{"pt": 1}, {"pt": 4}]}]) 10 | ttarray = ak.to_backend(array, "typetracer") 11 | 12 | array["emptydict"] = {} 13 | ttarray["emptydict"] = {} 14 | 15 | assert ttarray.layout.form == array.layout.form 16 | 17 | 18 | def test_list(): 19 | array = ak.Array([{"muon": [{"pt": 1}, {"pt": 4}]}]) 20 | ttarray = ak.to_backend(array, "typetracer") 21 | 22 | array["emptylist"] = [] 23 | ttarray["emptylist"] = [] 24 | 25 | assert ttarray.layout.form == array.layout.form 26 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_NumpyArray_reduce_adjust_starts_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_NumpyArray_reduce_adjust_starts_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_NumpyArray_reduce_adjust_starts_64( 8 | int64_t* toptr, 9 | int64_t outlength, 10 | const int64_t* parents, 11 | const int64_t* starts) { 12 | for (int64_t k = 0; k < outlength; k++) { 13 | int64_t i = toptr[k]; 14 | if (i >= 0) { 15 | int64_t parent = parents[i]; 16 | int64_t start = starts[parent]; 17 | toptr[k] += -start; 18 | } 19 | } 20 | return success(); 21 | } 22 | -------------------------------------------------------------------------------- /awkward-cpp/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | ColumnLimit: 80 5 | NamespaceIndentation: All 6 | SortIncludes: false 7 | IndentWidth: 2 8 | AccessModifierOffset: -2 9 | PenaltyBreakComment: 30 10 | PenaltyExcessCharacter: 100 11 | AlignAfterOpenBracket: Align 12 | AlignTrailingComments: true 13 | AllowAllArgumentsOnNextLine: true 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AllowShortBlocksOnASingleLine: false 16 | AllowShortIfStatementsOnASingleLine: Never 17 | AllowShortLambdasOnASingleLine: false 18 | AllowShortLoopsOnASingleLine: false 19 | AlwaysBreakAfterReturnType: All 20 | BinPackParameters: false 21 | AlwaysBreakTemplateDeclarations: Yes 22 | ReflowComments: false 23 | BinPackArguments: false 24 | -------------------------------------------------------------------------------- /tests/test_1764_jax_jacobian.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | 7 | import awkward as ak 8 | 9 | jax = pytest.importorskip("jax") 10 | jax.config.update("jax_platform_name", "cpu") 11 | jax.config.update("jax_enable_x64", True) 12 | 13 | ak.jax.register_and_check() 14 | 15 | 16 | @pytest.mark.skip("Jacobian support not implemented") 17 | def test(): 18 | array = ak.Array([[1, 2, 3], [4, 5, 6.0]]) 19 | 20 | def func(x): 21 | return x * 2 - 1 22 | 23 | array_np = ak.to_numpy(array) 24 | jac_np = jax.jacfwd(func)(array_np) 25 | 26 | jac = jax.jacfwd(func)(array) 27 | assert jac.to_list() == jac_np.to_list() 28 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_ListOffsetArray_reduce_nonlocal_nextstarts_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_ListOffsetArray_reduce_nonlocal_nextstarts_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_ListOffsetArray_reduce_nonlocal_nextstarts_64( 8 | int64_t* nextstarts, 9 | const int64_t* nextparents, 10 | int64_t nextlen) { 11 | int64_t lastnextparent = -1; 12 | for (int64_t i = 0; i < nextlen; i++) { 13 | if (nextparents[i] != lastnextparent) { 14 | nextstarts[nextparents[i]] = i; 15 | } 16 | lastnextparent = nextparents[i]; 17 | } 18 | return success(); 19 | } 20 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_sorting_ranges.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_sorting_ranges.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_sorting_ranges( 8 | int64_t* toindex, 9 | int64_t tolength, 10 | const int64_t* parents, 11 | int64_t parentslength) { 12 | int64_t j = 0; 13 | int64_t k = 0; 14 | toindex[0] = k; 15 | k++; j++; 16 | for (int64_t i = 1; i < parentslength; i++) { 17 | if (parents[i - 1] != parents[i]) { 18 | toindex[j] = k; 19 | j++; 20 | } 21 | k++; 22 | } 23 | toindex[tolength - 1] = parentslength; 24 | return success(); 25 | } 26 | -------------------------------------------------------------------------------- /dev/validate-test-names.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 4 | 5 | from __future__ import annotations 6 | 7 | import argparse 8 | import pathlib 9 | import re 10 | 11 | if __name__ == "__main__": 12 | parser = argparse.ArgumentParser() 13 | parser.add_argument("paths", type=pathlib.Path, nargs="*") 14 | args = parser.parse_args() 15 | 16 | for path in args.paths: 17 | if not re.match(r"^[^\d\W]\w*\Z$", path.stem): 18 | raise ValueError( 19 | f"tests must be named according to the pattern " 20 | f"'test_XXXX_some_identifier_here.py'. {path.stem} is " 21 | f"not named correctly." 22 | ) 23 | -------------------------------------------------------------------------------- /tests/test_1193_is_none_nested_option.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | index_of_index = ak.highlevel.Array( 13 | ak.contents.IndexedOptionArray.simplified( 14 | ak.index.Index64(np.r_[0, 1, 2, -1]), 15 | ak.contents.IndexedOptionArray( 16 | ak.index.Index64(np.r_[0, -1, 2, 3]), 17 | ak.contents.NumpyArray(np.r_[1, 2, 3, 4]), 18 | ), 19 | ) 20 | ) 21 | 22 | mask = ak.operations.is_none(index_of_index) 23 | assert mask.to_list() == [False, True, False, True] 24 | -------------------------------------------------------------------------------- /tests/test_0264_reduce_last_empty.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | to_list = ak.operations.to_list 11 | 12 | 13 | def test(): 14 | assert to_list( 15 | ak.operations.prod( 16 | ak.highlevel.Array([[[2, 3, 5]], [[7], [11]], [[]]]), axis=-1 17 | ) 18 | ) == [ 19 | [30], 20 | [7, 11], 21 | [1], 22 | ] 23 | 24 | assert to_list( 25 | ak.operations.prod(ak.highlevel.Array([[[2, 3, 5]], [[7], [11]], []]), axis=-1) 26 | ) == [ 27 | [30], 28 | [7, 11], 29 | [], 30 | ] 31 | -------------------------------------------------------------------------------- /tests/test_1840_ak_type_to_handle_ndarray_dtype_and_nptypes.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test_array(): 12 | array = np.random.random(size=512).astype(dtype=np.float64) 13 | assert ak.type(array) == ak.types.ArrayType(ak.types.NumpyType("float64"), 512) 14 | 15 | 16 | def test_dtype(): 17 | assert ak.type(np.dtype(np.float64)) == ak.types.ScalarType( 18 | ak.types.NumpyType("float64") 19 | ) 20 | 21 | 22 | def test_type_instance(): 23 | assert ak.type(np.float64(10.0)) == ak.types.ScalarType( 24 | ak.types.NumpyType("float64") 25 | ) 26 | -------------------------------------------------------------------------------- /tests/test_2354_ufunc_same_backend.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | array = ak.Array([[0, 1, 2, 3], [8, 9, 10, 11]], backend="typetracer") 13 | other = ak.Array([1, 2], backend="cpu") 14 | result = array + other 15 | assert ak.backend(result) == "typetracer" 16 | 17 | 18 | def test_mixed(): 19 | pytest.importorskip("jax") 20 | ak.jax.register_and_check() 21 | 22 | array = ak.Array([[0, 1, 2, 3], [8, 9, 10, 11]], backend="cpu") 23 | other = ak.Array([1, 2], backend="jax") 24 | with pytest.raises(ValueError): 25 | array + other 26 | -------------------------------------------------------------------------------- /tests/test_2646_from_parquet_highlevel.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | 7 | import awkward as ak 8 | 9 | pytest.importorskip("pyarrow") 10 | 11 | 12 | def test(tmp_path): 13 | ak.to_parquet([1, 2, 3], tmp_path / "test.parquet", extensionarray=True) 14 | ak.to_parquet([1, 2, 3], tmp_path / "test2.parquet", extensionarray=True) 15 | 16 | # Single paths 17 | layout = ak.from_parquet(tmp_path / "test.parquet", highlevel=False) 18 | assert isinstance(layout, ak.contents.Content) 19 | 20 | # Multiple paths 21 | layout = ak.from_parquet(tmp_path / "test*.parquet", highlevel=False) 22 | assert isinstance(layout, ak.contents.Content) 23 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_ByteMaskedArray_overlay_mask.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_ByteMaskedArray_overlay_mask( 6 | T* tomask, 7 | const C* theirmask, 8 | const U* mymask, 9 | int64_t length, 10 | bool validwhen, 11 | uint64_t invocation_index, 12 | uint64_t* err_code) { 13 | if (err_code[0] == NO_ERROR) { 14 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 15 | if (thread_id < length) { 16 | bool theirs = theirmask[thread_id]; 17 | bool mine = (mymask[thread_id] != 0) != validwhen; 18 | tomask[thread_id] = ((theirs | mine) ? 1 : 0); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_ListArray_localindex.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_ListArray_localindex( 6 | T* toindex, 7 | const C* offsets, 8 | int64_t length, 9 | uint64_t invocation_index, 10 | uint64_t* err_code) { 11 | if (err_code[0] == NO_ERROR) { 12 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 13 | if (thread_id < length) { 14 | int64_t start = (int64_t)offsets[thread_id]; 15 | int64_t stop = (int64_t)offsets[thread_id + 1]; 16 | for (int64_t j = start + threadIdx.y; j < stop; j += blockDim.y) { 17 | toindex[j] = j - start; 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_RegularArray_getitem_carry.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_RegularArray_getitem_carry( 6 | T* tocarry, 7 | const C* fromcarry, 8 | int64_t lencarry, 9 | int64_t size, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = (blockIdx.x * blockDim.x + threadIdx.x) / size; 14 | int64_t thready_id = (blockIdx.x * blockDim.x + threadIdx.x) % size; 15 | 16 | if (thread_id < lencarry) { 17 | tocarry[(thread_id * size) + thready_id] = 18 | (fromcarry[thread_id] * size) + thready_id; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_RegularArray_reduce_local_nextparents_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_RegularArray_reduce_local_nextparents_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_RegularArray_reduce_local_nextparents_64( 8 | int64_t* nextparents, 9 | int64_t size, 10 | int64_t length) { 11 | int64_t k = 0; 12 | for (int64_t i=0; i < length; i++) { 13 | for (int64_t j=0; j < size; j++) { 14 | // We're above the reduction, so choose nextparents such that the 15 | // reduction result keeps our row structure 16 | nextparents[k++] = i; 17 | } 18 | } 19 | return success(); 20 | } 21 | -------------------------------------------------------------------------------- /header-only/examples/pybind11/README.md: -------------------------------------------------------------------------------- 1 | # Pybind11 header-only example 2 | 3 | This example demonstrates the use of pybind11 to build Awkward Arrays using `LayoutBuilder` 4 | and return them to a Python caller. The important files are: 5 | 1. `demo.cpp` — an example C++ source file that builds an Awkward Array using `LayoutBuilder`, 6 | and declares a Python extension module. 7 | 8 | The remaining files are associated with Python/CMake configuration, and are not an important part of this example. 9 | 10 | ## Usage 11 | 12 | 1. Install the library 13 | ```bash 14 | pip install . 15 | ``` 16 | 2. Run the demo function and print the returned `ak.Array` 17 | ```python 18 | from demo import create_demo_array 19 | 20 | print( 21 | create_demo_array() 22 | ) 23 | ``` 24 | -------------------------------------------------------------------------------- /tests/test_0572_numba_array_ndim.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | numba = pytest.importorskip("numba") 11 | 12 | ak.numba.register_and_check() 13 | 14 | 15 | def test(): 16 | @numba.njit 17 | def f1(array): 18 | return array.ndim 19 | 20 | assert f1(ak.highlevel.Array([[1, 2, 3], [], [4, 5]])) == 2 21 | assert f1(ak.highlevel.Array([[[1], [2, 3]], [], [[4, 5], []]])) == 3 22 | assert f1(ak.highlevel.Array({"x": [1, 2, 3], "y": [None, None, 4]})) == 1 23 | 24 | with pytest.raises(numba.core.errors.TypingError): 25 | f1(ak.highlevel.Record({"x": [1, 2, 3], "y": [4]})) 26 | -------------------------------------------------------------------------------- /tests/test_2355_to_backend_record.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest 7 | 8 | import awkward as ak 9 | from awkward._backends.numpy import NumpyBackend 10 | from awkward._backends.typetracer import TypeTracerBackend 11 | 12 | 13 | def test(): 14 | layout = ak.to_layout({"x": 1, "y": 1}) 15 | assert ak.backend(layout) == "cpu" 16 | assert layout.backend is NumpyBackend.instance() 17 | 18 | layout_tt = layout.to_backend("typetracer") 19 | assert ak.backend(layout_tt) == "typetracer" 20 | assert layout_tt.backend is TypeTracerBackend.instance() 21 | 22 | with pytest.raises(TypeError): 23 | layout_tt.to_backend("cpu") 24 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_index_rpad_and_clip_axis0.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_index_rpad_and_clip_axis0( 6 | T* toindex, 7 | int64_t target, 8 | int64_t length, 9 | uint64_t invocation_index, 10 | uint64_t* err_code) { 11 | if (err_code[0] == NO_ERROR) { 12 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 13 | if (thread_id < length) { 14 | int64_t shorter = (target < length ? target : length); 15 | if (thread_id < shorter) { 16 | toindex[thread_id] = thread_id; 17 | } else if (thread_id >= shorter && thread_id < target) { 18 | toindex[thread_id] = -1; 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_NumpyArray_reduce_adjust_starts_shifts_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_NumpyArray_reduce_adjust_starts_shifts_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_NumpyArray_reduce_adjust_starts_shifts_64( 8 | int64_t* toptr, 9 | int64_t outlength, 10 | const int64_t* parents, 11 | const int64_t* starts, 12 | const int64_t* shifts) { 13 | for (int64_t k = 0; k < outlength; k++) { 14 | int64_t i = toptr[k]; 15 | if (i >= 0) { 16 | int64_t parent = parents[i]; 17 | int64_t start = starts[parent]; 18 | toptr[k] += shifts[i] - start; 19 | } 20 | } 21 | return success(); 22 | } 23 | -------------------------------------------------------------------------------- /awkward-cpp/include/awkward/kernel-utils.h: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #ifndef AWKWARD_KERNEL_UTILS_H_ 4 | #define AWKWARD_KERNEL_UTILS_H_ 5 | 6 | #include "common.h" 7 | 8 | extern "C" { 9 | 10 | EXPORT_SYMBOL void 11 | awkward_regularize_rangeslice( 12 | int64_t* start, 13 | int64_t* stop, 14 | bool posstep, 15 | bool hasstart, 16 | bool hasstop, 17 | int64_t length 18 | ); 19 | 20 | EXPORT_SYMBOL void 21 | awkward_ListArray_combinations_step_64( 22 | int64_t** tocarry, 23 | int64_t* toindex, 24 | int64_t* fromindex, 25 | int64_t j, 26 | int64_t stop, 27 | int64_t n, 28 | bool replacement 29 | ); 30 | 31 | } 32 | 33 | #endif // AWKWARD_KERNEL_UTILS_H_ 34 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_NumpyArray_reduce_adjust_starts_64.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_NumpyArray_reduce_adjust_starts_64( 6 | T* toptr, 7 | int64_t outlength, 8 | const C* parents, 9 | const U* starts, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 14 | if (thread_id < outlength) { 15 | T i = toptr[thread_id]; 16 | if (i >= 0) { 17 | int64_t parent = parents[i]; 18 | int64_t start = starts[parent]; 19 | toptr[thread_id] += -start; 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_RegularArray_getitem_next_range_spreadadvanced.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_RegularArray_getitem_next_range_spreadadvanced( 6 | T* toadvanced, 7 | const C* fromadvanced, 8 | int64_t length, 9 | int64_t nextsize, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = (blockIdx.x * blockDim.x + threadIdx.x) / nextsize; 14 | int64_t thready_id = (blockIdx.x * blockDim.x + threadIdx.x) % nextsize; 15 | 16 | if (thread_id < length) { 17 | toadvanced[(thread_id * nextsize) + thready_id] = fromadvanced[thread_id]; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/test_1271_fix_4D_reducers.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | akarray = ak.highlevel.Array( 13 | [[[[1], [4]], [[5], [8]]], [[[9], [12]], [[13], [16]]]] 14 | ) 15 | nparray = np.array([[[[1], [4]], [[5], [8]]], [[[9], [12]], [[13], [16]]]]) 16 | 17 | assert ak.sum(akarray, axis=3).to_list() == np.sum(nparray, axis=3).tolist() 18 | assert ak.sum(akarray, axis=2).to_list() == np.sum(nparray, axis=2).tolist() 19 | assert ak.sum(akarray, axis=1).to_list() == np.sum(nparray, axis=1).tolist() 20 | assert ak.sum(akarray, axis=0).to_list() == np.sum(nparray, axis=0).tolist() 21 | -------------------------------------------------------------------------------- /tests/test_2023_from_rdataframe.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest 7 | 8 | import awkward as ak 9 | import awkward._connect.cling 10 | import awkward._lookup 11 | 12 | ROOT = pytest.importorskip("ROOT") 13 | 14 | ROOT.ROOT.EnableImplicitMT(1) 15 | 16 | compiler = ROOT.gInterpreter.Declare 17 | 18 | 19 | def test_rdf_column_of_Long64_t_type(): 20 | data_frame = ROOT.RDataFrame(10).Define("x", "(Long64_t)(gRandom->Rndm()*1000.)") 21 | assert data_frame.GetColumnType("x") == "Long64_t" 22 | 23 | ak_array = ak.from_rdataframe( 24 | data_frame, 25 | columns="x", 26 | ) 27 | assert ak_array.layout.form == ak.forms.NumpyForm("int64") 28 | -------------------------------------------------------------------------------- /tests/test_2487_broadcast_list_offsets.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test_reducer(): 12 | # broadcast_tooffsets64 was changed, and stopped trimming the content 13 | # this test ensures that things still work! 14 | a = ak.Array( 15 | ak.contents.ListOffsetArray( 16 | ak.index.Index64(np.array([1, 2, 3], dtype=np.int64)), 17 | ak.contents.NumpyArray( 18 | np.array([1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5], dtype=np.int64) 19 | ), 20 | ) 21 | ) 22 | # Perform broadcast, check result works! 23 | assert ak.all(a == [[1], [2]]) 24 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_ByteMaskedArray_reduce_next_nonlocal_nextshifts_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_ByteMaskedArray_reduce_next_nonlocal_nextshifts_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_ByteMaskedArray_reduce_next_nonlocal_nextshifts_64( 8 | int64_t* nextshifts, 9 | const int8_t* mask, 10 | int64_t length, 11 | bool valid_when) { 12 | int64_t nullsum = 0; 13 | int64_t k = 0; 14 | for (int64_t i = 0; i < length; i++) { 15 | if ((mask[i] != 0) == (valid_when != 0)) { 16 | nextshifts[k] = nullsum; 17 | k++; 18 | } 19 | else { 20 | nullsum++; 21 | } 22 | } 23 | return success(); 24 | } 25 | -------------------------------------------------------------------------------- /tests/test_1154_arrow_tables_should_preserve_parameters.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | pytest.importorskip("pyarrow") 11 | 12 | 13 | def test(): 14 | a = ak.highlevel.Array( 15 | ak.contents.RecordArray( 16 | [ 17 | ak.contents.NumpyArray(np.array([1.1, 2.2, 3.3])), 18 | ak.contents.NumpyArray(np.array([1, 2, 3])), 19 | ], 20 | ["x", "y"], 21 | parameters={"__record__": "Hello"}, 22 | ) 23 | ) 24 | assert ak.operations.from_arrow( 25 | ak.operations.to_arrow_table(a) 26 | ).type.content.parameters == {"__record__": "Hello"} 27 | -------------------------------------------------------------------------------- /.github/matchers/pylint.json: -------------------------------------------------------------------------------- 1 | { 2 | "problemMatcher": [ 3 | { 4 | "severity": "warning", 5 | "pattern": [ 6 | { 7 | "regexp": "^([^:]+):(\\d+):(\\d+): ([A-DF-Z]\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", 8 | "file": 1, 9 | "line": 2, 10 | "column": 3, 11 | "code": 4, 12 | "message": 5 13 | } 14 | ], 15 | "owner": "pylint-warning" 16 | }, 17 | { 18 | "severity": "error", 19 | "pattern": [ 20 | { 21 | "regexp": "^([^:]+):(\\d+):(\\d+): (E\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", 22 | "file": 1, 23 | "line": 2, 24 | "column": 3, 25 | "code": 4, 26 | "message": 5 27 | } 28 | ], 29 | "owner": "pylint-error" 30 | } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /tests/test_0835_datetime_type_pandas.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | pandas = pytest.importorskip("pandas") 11 | 12 | to_list = ak.operations.to_list 13 | 14 | 15 | def test_from_pandas(): 16 | values = {"time": ["20190902093000", "20190913093000", "20190921200000"]} 17 | df = pandas.DataFrame(values, columns=["time"]) 18 | df["time"] = pandas.to_datetime(df["time"], format="%Y%m%d%H%M%S") 19 | array = ak.contents.NumpyArray(df["time"].values) 20 | assert to_list(array) == df["time"].values.tolist() 21 | array2 = ak.highlevel.Array(df["time"].values) 22 | assert to_list(array2) == df["time"].values.tolist() 23 | -------------------------------------------------------------------------------- /tests/test_1344_broadcast_arrays_depth_limit.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | x = ak.Array([[0, 1], [], [3], [5], [6, 8, 9]]) 13 | y = ak.Array([[0.0, 1.1, 2.2], [], [3.3, 4.4], [5.5], [6.6, 7.7, 8.8, 9.9]]) 14 | 15 | with pytest.raises(ValueError): 16 | ak.broadcast_arrays(x, y, depth_limit=None) 17 | 18 | u, v = ak.broadcast_arrays(x, y, depth_limit=1) 19 | assert ak.to_list(u) == [[0, 1], [], [3], [5], [6, 8, 9]] 20 | assert ak.to_list(v) == [ 21 | [0.0, 1.1, 2.2], 22 | [], 23 | [3.3, 4.4], 24 | [5.5], 25 | [6.6, 7.7, 8.8, 9.9], 26 | ] 27 | -------------------------------------------------------------------------------- /tests/test_0910_unflatten_counts_relation.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | layout = ak.contents.IndexedArray( 13 | ak.index.Index64(np.array([3, 1, 0, 2])), 14 | ak.contents.ListOffsetArray( 15 | ak.index.Index64(np.array([0, 3, 6, 9, 12])), 16 | ak.contents.NumpyArray(np.array([0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 3])), 17 | ), 18 | ) 19 | 20 | assert ak.operations.unflatten( 21 | layout, 22 | ak.operations.flatten(ak.operations.run_lengths(layout)), 23 | axis=1, 24 | ).to_list() == [[[3, 3, 3]], [[1, 1, 1]], [[0, 0, 0]], [[2, 2], [3]]] 25 | -------------------------------------------------------------------------------- /tests/test_2226_slice_regulararray_typetracer.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | from awkward._nplikes.shape import unknown_length 10 | 11 | 12 | def test(): 13 | x = ak.to_regular( 14 | ak.Array([[[-1, 1.0], [-2, 2], [-3, 3]], [[-4, 4]], []], backend="typetracer"), 15 | axis=-1, 16 | ) 17 | result = x[:, :-1] 18 | assert ak.backend(result) == "typetracer" 19 | layout = ak.to_layout(result) 20 | assert layout.length == 3 21 | assert layout.content.length is unknown_length 22 | assert layout.content.content.length is unknown_length 23 | assert layout.content.content.dtype == np.dtype(np.float64) 24 | -------------------------------------------------------------------------------- /tests/test_2550_validity_error_recursive.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | content = ak.contents.ListOffsetArray( 13 | ak.index.Index64([0, 2, 4, 4]), 14 | ak.contents.IndexedArray( 15 | ak.index.Index64([0, 0, 1, 2]), 16 | ak.contents.NumpyArray(np.array([0, 0, 10, 20])), 17 | parameters={"__array__": "categorical"}, 18 | ), 19 | ) 20 | assert ( 21 | ak.validity_error(content) 22 | == 'at highlevel.content (""): __array__ = "categorical" requires contents to be unique' 23 | ) 24 | -------------------------------------------------------------------------------- /dev/cuda-tests/cuda-tests.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Awkward CUDA Tests Service 3 | After=docker.service 4 | Requires=docker.service 5 | After=network-online.target 6 | Requires=network-online.target 7 | 8 | [Service] 9 | TimeoutStartSec=0 10 | Restart=never 11 | Type=oneshot 12 | ExecStartPre=-/usr/bin/docker exec %n stop 13 | ExecStartPre=-/usr/bin/docker rm %n 14 | # Allow pull to fail if the image is e.g. only local (- prefix to this command) 15 | ExecStartPre=-/usr/bin/docker pull agoose77/cuda-tests:latest 16 | ExecStart=/usr/bin/docker run --rm --name %n \ 17 | --runtime=nvidia \ 18 | --gpus all \ 19 | -v "${CREDENTIALS_DIRECTORY}:/creds" \ 20 | -e GH_TOKEN_PATH=/creds/gh-token \ 21 | agoose77/cuda-tests:latest 22 | LoadCredential=gh-token:/etc/cuda-gh-token 23 | 24 | [Install] 25 | WantedBy=default.target 26 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # JupyterLite (kernel requires specific pyodide version) 2 | jupyterlite-pyodide-kernel==0.1.0 3 | jupyterlite[piplite]==0.1.0 4 | jupyterlite-sphinx==0.8.0 5 | 6 | sphinx~=7.0 7 | PyYAML 8 | black 9 | pycparser 10 | lark-parser 11 | sphinx-copybutton 12 | sphinx-design 13 | sphinx-sitemap 14 | pydata-sphinx-theme 15 | myst-nb~=1.0 16 | myst-parser~=2.0 17 | sphinx-external-toc 18 | ipyleaflet 19 | 20 | numpy 21 | scipy 22 | numba>=0.50.0;python_version<"3.11" 23 | pandas>=0.24.0 24 | numexpr 25 | pyarrow>=7.0.0 26 | fsspec 27 | fsspec-xrootd 28 | hist[plot] 29 | particle 30 | hepunits 31 | vector 32 | scikit-hep-testdata 33 | s3fs 34 | h5py 35 | matplotlib 36 | awkward 37 | uproot 38 | jax>=0.2.7;python_version>="3.6" and sys_platform != "win32" 39 | jaxlib>=0.1.57;python_version>="3.6" and sys_platform != "win32" 40 | -------------------------------------------------------------------------------- /tests/test_0979_where_multidimentional_numpy_array.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | array = ak.highlevel.Array( 13 | ak.contents.RegularArray( 14 | ak.contents.NumpyArray(np.r_[1, 2, 3, 4, 5, 6, 7, 8, 9]), 3 15 | ) 16 | ) 17 | condition = ak.highlevel.Array( 18 | ak.contents.NumpyArray( 19 | np.array([[True, True, True], [True, True, False], [True, False, True]]) 20 | ) 21 | ) 22 | 23 | assert ak.operations.where(condition == 2, array, 2 * array).to_list() == [ 24 | [2, 4, 6], 25 | [8, 10, 12], 26 | [14, 16, 18], 27 | ] 28 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_RegularArray_localindex.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_RegularArray_localindex.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | template 8 | ERROR awkward_RegularArray_localindex( 9 | T* toindex, 10 | int64_t size, 11 | int64_t length) { 12 | for (int64_t i = 0; i < length; i++) { 13 | for (int64_t j = 0; j < size; j++) { 14 | toindex[i*size + j] = j; 15 | } 16 | } 17 | return success(); 18 | } 19 | ERROR awkward_RegularArray_localindex_64( 20 | int64_t* toindex, 21 | int64_t size, 22 | int64_t length) { 23 | return awkward_RegularArray_localindex( 24 | toindex, 25 | size, 26 | length); 27 | } 28 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_UnionArray_fillindex_count.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_UnionArray_fillindex_count.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | template 8 | ERROR awkward_UnionArray_fillindex_count( 9 | TO* toindex, 10 | int64_t toindexoffset, 11 | int64_t length) { 12 | for (int64_t i = 0; i < length; i++) { 13 | toindex[toindexoffset + i] = (TO)i; 14 | } 15 | return success(); 16 | } 17 | ERROR awkward_UnionArray_fillindex_to64_count( 18 | int64_t* toindex, 19 | int64_t toindexoffset, 20 | int64_t length) { 21 | return awkward_UnionArray_fillindex_count( 22 | toindex, 23 | toindexoffset, 24 | length); 25 | } 26 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_RegularArray_getitem_next_array_advanced.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_RegularArray_getitem_next_array_advanced( 6 | T* tocarry, 7 | C* toadvanced, 8 | const U* fromadvanced, 9 | const V* fromarray, 10 | int64_t length, 11 | int64_t size, 12 | uint64_t invocation_index, 13 | uint64_t* err_code) { 14 | if (err_code[0] == NO_ERROR) { 15 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 16 | if (thread_id < length) { 17 | tocarry[thread_id] = 18 | (thread_id * size) + fromarray[fromadvanced[thread_id]]; 19 | toadvanced[thread_id] = thread_id; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/test_1453_write_single_records_to_parquet.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import os 6 | 7 | import numpy as np # noqa: F401 8 | import pytest 9 | 10 | import awkward as ak 11 | 12 | pytest.importorskip("pyarrow") 13 | pytest.importorskip("pyarrow.parquet") 14 | 15 | 16 | def test(tmp_path): 17 | filename = os.path.join(tmp_path, "whatever.parquet") 18 | 19 | original = ak.Record({"x": 1, "y": [1, 2, 3], "z": "THREE"}) 20 | 21 | assert ak.from_arrow(ak.to_arrow(original)).to_list() == original.to_list() 22 | 23 | assert ak.from_arrow(ak.to_arrow_table(original)).to_list() == original.to_list() 24 | 25 | ak.to_parquet(original, filename) 26 | assert ak.from_parquet(filename).to_list() == original.to_list() 27 | -------------------------------------------------------------------------------- /tests/test_2631_vectorised_to_numpy_strings.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | 7 | import awkward as ak 8 | 9 | 10 | def test_string(): 11 | source = ak.Array(["abc$¢€", "d¢#", "€e¢", "💰💰"]) 12 | result = source.to_numpy(False) 13 | expected = np.array(["abc$¢€", "d¢#", "€e¢", "💰💰"]) 14 | assert result.dtype == expected.dtype 15 | np.testing.assert_equal(result, expected) 16 | 17 | 18 | def test_bytestring(): 19 | source = ak.Array([b"foo", b"bar", b"catastrophic", b"\x03\x07"]) 20 | result = source.to_numpy(False) 21 | expected = np.array([b"foo", b"bar", b"catastrophic", b"\x03\x07"]) 22 | assert result.dtype == expected.dtype 23 | np.testing.assert_equal(result, expected) 24 | -------------------------------------------------------------------------------- /tests/test_3174_to_parquet_record.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import os 6 | 7 | import pytest 8 | 9 | import awkward as ak 10 | 11 | pytest.importorskip("pyarrow.parquet") 12 | 13 | 14 | def test(tmp_path): 15 | filename = os.path.join(tmp_path, "whatever.parquet") 16 | 17 | px = ak.Array([[1.0, 2.0], [3.0], [], [4.0, 5.0, 6.0]]) 18 | py = ak.Array([[0.5, 1.5], [2.5], [], [3.5, 4.5, 5.5]]) 19 | pz = ak.Array([[0.2, 1.2], [2.2], [], [3.2, 4.2, 5.2]]) 20 | e = ak.Array([[0.1, 1.1], [2.1], [], [3.1, 4.1, 5.1]]) 21 | data = {"px": px, "py": py, "pz": pz, "e": e} # not quite a record 22 | 23 | ak.to_parquet(data, filename) 24 | 25 | assert ak.from_parquet(filename).tolist() == ak.to_list(ak.to_layout(data)) 26 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_ListOffsetArray_reduce_local_outoffsets_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_ListOffsetArray_reduce_local_outoffsets_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_ListOffsetArray_reduce_local_outoffsets_64( 8 | int64_t* outoffsets, 9 | const int64_t* parents, 10 | int64_t lenparents, 11 | int64_t outlength) { 12 | int64_t k = 0; 13 | int64_t last = -1; 14 | for (int64_t i = 0; i < lenparents; i++) { 15 | while (last < parents[i]) { 16 | outoffsets[k] = i; 17 | k++; 18 | last++; 19 | } 20 | } 21 | while (k <= outlength) { 22 | outoffsets[k] = lenparents; 23 | k++; 24 | } 25 | return success(); 26 | } 27 | -------------------------------------------------------------------------------- /tests-cuda/test_2649_dlpack_support.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest 7 | from packaging.version import parse as parse_version 8 | 9 | import awkward as ak 10 | 11 | if parse_version(np.__version__) < parse_version("1.23.0"): 12 | pytest.skip( 13 | "NumPy 1.23 or greater is required for DLPack testing", allow_module_level=True 14 | ) 15 | 16 | 17 | def test_from_dlpack_cupy(): 18 | # This test only checks cupy usage, it doesn't explicitly test GPU & CPU 19 | cp = pytest.importorskip("cupy") 20 | cp_array = cp.arange(2 * 3 * 4 * 5).reshape(2, 3, 4, 5) 21 | array = ak.from_dlpack(cp_array) 22 | cp_from_ak = ak.to_cupy(array) 23 | assert cp.shares_memory(cp_array, cp_from_ak) 24 | -------------------------------------------------------------------------------- /tests/test_0975_mask_multidimensional_numpy_array.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | to_list = ak.operations.to_list 11 | 12 | 13 | def test(): 14 | array = ak.highlevel.Array( 15 | ak.contents.RegularArray( 16 | ak.contents.NumpyArray(np.r_[1, 2, 3, 4, 5, 6, 7, 8, 9]), 3 17 | ) 18 | ) 19 | mask = ak.highlevel.Array( 20 | ak.contents.NumpyArray( 21 | np.array([[True, True, True], [True, True, False], [True, False, True]]) 22 | ) 23 | ) 24 | 25 | assert ak.operations.mask(array, mask).to_list() == [ 26 | [1, 2, 3], 27 | [4, 5, None], 28 | [7, None, 9], 29 | ] 30 | -------------------------------------------------------------------------------- /tests/test_0828_arrow_datatype_null.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest 7 | 8 | import awkward as ak 9 | 10 | pyarrow = pytest.importorskip("pyarrow") 11 | 12 | to_list = ak.operations.to_list 13 | 14 | 15 | def test(): 16 | import awkward._connect.pyarrow 17 | 18 | assert to_list( 19 | awkward._connect.pyarrow.handle_arrow( 20 | pyarrow.Table.from_pydict({"x": [None, None, None]}) 21 | ) 22 | ) == [{"x": None}, {"x": None}, {"x": None}] 23 | assert to_list( 24 | awkward._connect.pyarrow.handle_arrow( 25 | pyarrow.Table.from_pydict({"x": [[None, None], [], [None]]}) 26 | ) 27 | ) == [{"x": [None, None]}, {"x": []}, {"x": [None]}] 28 | -------------------------------------------------------------------------------- /tests/test_0850_argsort_mask_array.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np # noqa: F401 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | array = ak.Array([[0, 1, 2, 3], [3, 3, 3, 2, 1]]) 13 | is_valid = array != 3 14 | 15 | assert ak.operations.mask(array, is_valid).to_list() == [ 16 | [0, 1, 2, None], 17 | [None, None, None, 2, 1], 18 | ] 19 | 20 | assert ak.operations.sort(ak.operations.mask(array, is_valid)).to_list() == [ 21 | [0, 1, 2, None], 22 | [1, 2, None, None, None], 23 | ] 24 | assert ak.operations.argsort(ak.operations.mask(array, is_valid)).to_list() == [ 25 | [0, 1, 2, 3], 26 | [4, 3, 0, 1, 2], 27 | ] 28 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_ListOffsetArray_reduce_nonlocal_maxcount_offsetscopy_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_ListOffsetArray_reduce_nonlocal_maxcount_offsetscopy_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_ListOffsetArray_reduce_nonlocal_maxcount_offsetscopy_64( 8 | int64_t* maxcount, 9 | int64_t* offsetscopy, 10 | const int64_t* offsets, 11 | int64_t length) { 12 | *maxcount = 0; 13 | offsetscopy[0] = offsets[0]; 14 | for (int64_t i = 0; i < length; i++) { 15 | int64_t count = (offsets[i + 1] - offsets[i]); 16 | if (*maxcount < count) { 17 | *maxcount = count; 18 | } 19 | offsetscopy[i + 1] = offsets[i + 1]; 20 | } 21 | return success(); 22 | } 23 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_unique_ranges_bool.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_unique_ranges_bool.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_unique_ranges_bool( 8 | bool* toptr, 9 | const int64_t* fromoffsets, 10 | int64_t offsetslength, 11 | int64_t* tooffsets) { 12 | int64_t m = 0; 13 | for (int64_t i = 0; i < offsetslength - 1; i++) { 14 | tooffsets[i] = m; 15 | toptr[m++] = toptr[fromoffsets[i]]; 16 | for (int64_t k = fromoffsets[i]; k < fromoffsets[i + 1]; k++) { 17 | if ((toptr[m - 1] != 0) != (toptr[k] != 0)) { 18 | toptr[m++] = toptr[k]; 19 | } 20 | } 21 | } 22 | tooffsets[offsetslength - 1] = m; 23 | 24 | return success(); 25 | } 26 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_ListArray_fill.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_ListArray_fill( 6 | T* tostarts, 7 | int64_t tostartsoffset, 8 | C* tostops, 9 | int64_t tostopsoffset, 10 | const U* fromstarts, 11 | const V* fromstops, 12 | int64_t length, 13 | int64_t base, 14 | uint64_t invocation_index, 15 | uint64_t* err_code) { 16 | if (err_code[0] == NO_ERROR) { 17 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 18 | if (thread_id < length) { 19 | tostarts[tostartsoffset + thread_id] = (T)(fromstarts[thread_id] + base); 20 | tostops[tostopsoffset + thread_id] = (C)(fromstops[thread_id] + base); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_RegularArray_getitem_next_range.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_RegularArray_getitem_next_range( 6 | T* tocarry, 7 | int64_t regular_start, 8 | int64_t step, 9 | int64_t length, 10 | int64_t size, 11 | int64_t nextsize, 12 | uint64_t invocation_index, 13 | uint64_t* err_code) { 14 | if (err_code[0] == NO_ERROR) { 15 | int64_t thread_id = (blockIdx.x * blockDim.x + threadIdx.x) / nextsize; 16 | int64_t thready_id = (blockIdx.x * blockDim.x + threadIdx.x) % nextsize; 17 | 18 | if (thread_id < length) { 19 | tocarry[(thread_id * nextsize) + thready_id] = 20 | ((thread_id * size) + regular_start) + (thready_id * step); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_missing_repeat.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_missing_repeat( 6 | T* outindex, 7 | const C* index, 8 | int64_t indexlength, 9 | int64_t repetitions, 10 | int64_t regularsize, 11 | uint64_t invocation_index, 12 | uint64_t* err_code) { 13 | if (err_code[0] == NO_ERROR) { 14 | int64_t thread_id = (blockIdx.x * blockDim.x + threadIdx.x) / indexlength; 15 | int64_t thready_id = (blockIdx.x * blockDim.x + threadIdx.x) % indexlength; 16 | if (thread_id < repetitions) { 17 | T base = index[thready_id]; 18 | outindex[thread_id * indexlength + thready_id] = 19 | base + (base >= 0 ? thread_id * regularsize : 0); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/awkward/_prettyprint.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | # We're renaming awkward._prettyprint to this module, and gently deprecating the 6 | # private submodule. 7 | from awkward.prettyprint import ( 8 | Formatter, 9 | FormatterOptions, 10 | FormatterType, 11 | PlaceholderValue, 12 | alternate, 13 | custom_str, 14 | get_at, 15 | get_field, 16 | half, 17 | is_identifier, 18 | valuestr, 19 | valuestr_horiz, 20 | ) 21 | 22 | __all__ = [ 23 | "Formatter", 24 | "FormatterOptions", 25 | "FormatterType", 26 | "PlaceholderValue", 27 | "alternate", 28 | "custom_str", 29 | "get_at", 30 | "get_field", 31 | "half", 32 | "is_identifier", 33 | "valuestr", 34 | "valuestr_horiz", 35 | ] 36 | -------------------------------------------------------------------------------- /tests/test_1784_reduce_leading_sublist.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | small = ak.Array( 13 | ak.contents.ListOffsetArray( 14 | ak.index.Index64(np.array([0, 0, 2])), 15 | ak.contents.ListOffsetArray( 16 | ak.index.Index64(np.array([0, 2, 4])), 17 | ak.contents.NumpyArray(np.array([1, 2, 3, 4], dtype=np.float32)), 18 | ), 19 | ) 20 | ) 21 | 22 | reduced = ak.sum(small, axis=-2) 23 | assert reduced.to_list() == [[], [4, 6]] 24 | assert np.asarray(reduced.layout.starts).tolist() == [0, 2] 25 | assert np.asarray(reduced.layout.stops).tolist() == [0, 4] 26 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_IndexedArray_fill_count.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_IndexedArray_fill_count.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | template 8 | ERROR awkward_IndexedArray_fill_count( 9 | TO* toindex, 10 | int64_t toindexoffset, 11 | int64_t length, 12 | int64_t base) { 13 | for (int64_t i = 0; i < length; i++) { 14 | toindex[toindexoffset + i] = i + base; 15 | } 16 | return success(); 17 | } 18 | ERROR awkward_IndexedArray_fill_to64_count( 19 | int64_t* toindex, 20 | int64_t toindexoffset, 21 | int64_t length, 22 | int64_t base) { 23 | return awkward_IndexedArray_fill_count( 24 | toindex, 25 | toindexoffset, 26 | length, 27 | base); 28 | } 29 | -------------------------------------------------------------------------------- /docs/user-guide/how-to-math.md: -------------------------------------------------------------------------------- 1 | --- 2 | jupytext: 3 | text_representation: 4 | extension: .md 5 | format_name: myst 6 | format_version: 0.13 7 | jupytext_version: 1.10.3 8 | kernelspec: 9 | display_name: Python 3 10 | language: python 11 | name: python3 12 | --- 13 | 14 | Numerical math 15 | ============== 16 | 17 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 18 | 19 | If you're looking for documentation on a specific function, see the API reference instead. 20 | 21 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 22 | 23 |




24 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_UnionArray_simplify_one.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_UnionArray_simplify_one( 6 | T* totags, 7 | C* toindex, 8 | const U* fromtags, 9 | const V* fromindex, 10 | int64_t towhich, 11 | int64_t fromwhich, 12 | int64_t length, 13 | int64_t base, 14 | uint64_t invocation_index, 15 | uint64_t* err_code) { 16 | if (err_code[0] == NO_ERROR) { 17 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 18 | if (thread_id < length) { 19 | if (fromtags[thread_id] == fromwhich) { 20 | totags[thread_id] = (T)towhich; 21 | toindex[thread_id] = (C)(fromindex[thread_id] + base); 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/awkward/_typetracer.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | """ 4 | Compatibility module for existing users of `_typetracer 5 | """ 6 | 7 | from __future__ import annotations 8 | 9 | from awkward._nplikes.typetracer import MaybeNone, OneOf # noqa: F401 10 | 11 | __all__ = ["UnknownScalar", "UnknownLength"] 12 | 13 | 14 | UnknownLength = None 15 | 16 | 17 | class _UnknownScalarMeta(type): 18 | def __instancecheck__(cls, instance): 19 | from awkward._nplikes.typetracer import is_unknown_scalar 20 | 21 | return is_unknown_scalar(instance) 22 | 23 | 24 | class UnknownScalar(metaclass=_UnknownScalarMeta): 25 | @staticmethod 26 | def __new__(cls, dtype): 27 | from awkward._nplikes.typetracer import TypeTracer 28 | 29 | return TypeTracer.instance().empty((), dtype=dtype) 30 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_ByteMaskedArray_reduce_next_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_ByteMaskedArray_reduce_next_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_ByteMaskedArray_reduce_next_64( 8 | int64_t* nextcarry, 9 | int64_t* nextparents, 10 | int64_t* outindex, 11 | const int8_t* mask, 12 | const int64_t* parents, 13 | int64_t length, 14 | bool validwhen) { 15 | int64_t k = 0; 16 | for (int64_t i = 0; i < length; i++) { 17 | if ((mask[i] != 0) == validwhen) { 18 | nextcarry[k] = i; 19 | nextparents[k] = parents[i]; 20 | outindex[i] = k; 21 | k++; 22 | } 23 | else { 24 | outindex[i] = -1; 25 | } 26 | } 27 | return success(); 28 | } 29 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_UnionArray_filltags_const.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_UnionArray_filltags_const.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | template 8 | ERROR awkward_UnionArray_filltags_const( 9 | TO* totags, 10 | int64_t totagsoffset, 11 | int64_t length, 12 | int64_t base) { 13 | for (int64_t i = 0; i < length; i++) { 14 | totags[totagsoffset + i] = (TO)base; 15 | } 16 | return success(); 17 | } 18 | ERROR awkward_UnionArray_filltags_to8_const( 19 | int8_t* totags, 20 | int64_t totagsoffset, 21 | int64_t length, 22 | int64_t base) { 23 | return awkward_UnionArray_filltags_const( 24 | totags, 25 | totagsoffset, 26 | length, 27 | base); 28 | } 29 | -------------------------------------------------------------------------------- /docs/user-guide/how-to-create.md: -------------------------------------------------------------------------------- 1 | --- 2 | jupytext: 3 | text_representation: 4 | extension: .md 5 | format_name: myst 6 | format_version: 0.13 7 | jupytext_version: 1.10.3 8 | kernelspec: 9 | display_name: Python 3 10 | language: python 11 | name: python3 12 | --- 13 | 14 | Creating arrays 15 | =============== 16 | 17 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 18 | 19 | If you're looking for documentation on a specific function, see the API reference instead. 20 | 21 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 22 | 23 |




24 | -------------------------------------------------------------------------------- /docs/user-guide/how-to-filter.md: -------------------------------------------------------------------------------- 1 | --- 2 | jupytext: 3 | text_representation: 4 | extension: .md 5 | format_name: myst 6 | format_version: 0.13 7 | jupytext_version: 1.10.3 8 | kernelspec: 9 | display_name: Python 3 10 | language: python 11 | name: python3 12 | --- 13 | 14 | Filtering data 15 | ============== 16 | 17 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 18 | 19 | If you're looking for documentation on a specific function, see the API reference instead. 20 | 21 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 22 | 23 |




24 | -------------------------------------------------------------------------------- /docs/user-guide/how-to-specialize.md: -------------------------------------------------------------------------------- 1 | --- 2 | jupytext: 3 | text_representation: 4 | extension: .md 5 | format_name: myst 6 | format_version: 0.13 7 | jupytext_version: 1.10.3 8 | kernelspec: 9 | display_name: Python 3 10 | language: python 11 | name: python3 12 | --- 13 | 14 | Special topics 15 | ============== 16 | 17 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 18 | 19 | If you're looking for documentation on a specific function, see the API reference instead. 20 | 21 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 22 | 23 |




24 | -------------------------------------------------------------------------------- /docs/user-guide/how-to-combinatorics.md: -------------------------------------------------------------------------------- 1 | --- 2 | jupytext: 3 | text_representation: 4 | extension: .md 5 | format_name: myst 6 | format_version: 0.13 7 | jupytext_version: 1.10.3 8 | kernelspec: 9 | display_name: Python 3 10 | language: python 11 | name: python3 12 | --- 13 | 14 | Combinatorics 15 | ============= 16 | 17 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 18 | 19 | If you're looking for documentation on a specific function, see the API reference instead. 20 | 21 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 22 | 23 |




24 | -------------------------------------------------------------------------------- /docs/user-guide/how-to-convert.md: -------------------------------------------------------------------------------- 1 | --- 2 | jupytext: 3 | text_representation: 4 | extension: .md 5 | format_name: myst 6 | format_version: 0.13 7 | jupytext_version: 1.10.3 8 | kernelspec: 9 | display_name: Python 3 10 | language: python 11 | name: python3 12 | --- 13 | 14 | Converting arrays 15 | ================= 16 | 17 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 18 | 19 | If you're looking for documentation on a specific function, see the API reference instead. 20 | 21 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 22 | 23 |




24 | -------------------------------------------------------------------------------- /docs/user-guide/how-to-examine.md: -------------------------------------------------------------------------------- 1 | --- 2 | jupytext: 3 | text_representation: 4 | extension: .md 5 | format_name: myst 6 | format_version: 0.13 7 | jupytext_version: 1.10.3 8 | kernelspec: 9 | display_name: Python 3 10 | language: python 11 | name: python3 12 | --- 13 | 14 | Examining arrays 15 | ================ 16 | 17 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 18 | 19 | If you're looking for documentation on a specific function, see the API reference instead. 20 | 21 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 22 | 23 |




24 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_ListArray_getitem_next_range_spreadadvanced.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_ListArray_getitem_next_range_spreadadvanced( 6 | T* toadvanced, 7 | const C* fromadvanced, 8 | const U* fromoffsets, 9 | int64_t lenstarts, 10 | uint64_t invocation_index, 11 | uint64_t* err_code) { 12 | if (err_code[0] == NO_ERROR) { 13 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 14 | if (thread_id < lenstarts) { 15 | C count = fromoffsets[thread_id + 1] - fromoffsets[thread_id]; 16 | for (int64_t j = threadIdx.y; j < count; j += blockDim.y) { 17 | toadvanced[fromoffsets[thread_id] + j] = fromadvanced[thread_id]; 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_ListOffsetArray_reduce_nonlocal_nextstarts_64.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_ListOffsetArray_reduce_nonlocal_nextstarts_64( 6 | T* nextstarts, 7 | const C* nextparents, 8 | int64_t nextlen, 9 | uint64_t invocation_index, 10 | uint64_t* err_code) { 11 | if (err_code[0] == NO_ERROR) { 12 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 13 | int64_t lastnextparent = -1; 14 | 15 | if (thread_id < nextlen) { 16 | if (thread_id != 0) { 17 | lastnextparent = nextparents[thread_id - 1]; 18 | } 19 | if (nextparents[thread_id] != lastnextparent) { 20 | nextstarts[nextparents[thread_id]] = thread_id; 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/awkward/_connect/cuda/cuda_kernels/awkward_NumpyArray_reduce_adjust_starts_shifts_64.cu: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE 2 | 3 | template 4 | __global__ void 5 | awkward_NumpyArray_reduce_adjust_starts_shifts_64( 6 | T* toptr, 7 | int64_t outlength, 8 | const C* parents, 9 | const U* starts, 10 | const V* shifts, 11 | uint64_t invocation_index, 12 | uint64_t* err_code) { 13 | if (err_code[0] == NO_ERROR) { 14 | int64_t thread_id = blockIdx.x * blockDim.x + threadIdx.x; 15 | if (thread_id < outlength) { 16 | int64_t i = toptr[thread_id]; 17 | if (i >= 0) { 18 | int64_t parent = parents[i]; 19 | int64_t start = starts[parent]; 20 | toptr[thread_id] += (shifts[i] - start); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/test_1071_mask_identity_false_should_not_return_option_type.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import numpy as np 6 | import pytest # noqa: F401 7 | 8 | import awkward as ak 9 | 10 | 11 | def test(): 12 | layout = ak.contents.ListOffsetArray( 13 | ak.index.Index64(np.array([0, 1], dtype=np.int64)), 14 | ak.contents.IndexedArray( 15 | ak.index.Index64(np.array([0, 1, 2, 3], dtype=np.int64)), 16 | ak.contents.RegularArray( 17 | ak.contents.NumpyArray(np.array([1.1, 2.2, 3.3, 4.4])), 4 18 | ), 19 | ), 20 | ) 21 | array = ak.highlevel.Array(layout) 22 | 23 | assert ( 24 | str(ak.operations.min(array, axis=-1, mask_identity=False).type) 25 | == "1 * var * float64" 26 | ) 27 | -------------------------------------------------------------------------------- /tests/test_2064_fill_none_record.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest # noqa: F401 6 | 7 | import awkward as ak 8 | 9 | 10 | def test_axis_none(): 11 | record = ak.zip({"x": [1, None], "y": [2, 3]}) 12 | assert ak.fill_none(record, 0, axis=None).to_list() == [ 13 | {"x": 1, "y": 2}, 14 | {"x": 0, "y": 3}, 15 | ] 16 | 17 | 18 | def test_axis_last(): 19 | record = ak.zip({"x": [1, None], "y": [2, 3]}) 20 | assert ak.fill_none(record, 0, axis=-1).to_list() == [ 21 | {"x": 1, "y": 2}, 22 | {"x": 0, "y": 3}, 23 | ] 24 | 25 | 26 | def test_option_outside_record(): 27 | record = ak.zip({"x": [1, 4], "y": [2, 3]}).mask[[True, False]] 28 | assert ak.fill_none(record, 0, axis=-1).to_list() == [{"x": 1, "y": 2}, 0] 29 | -------------------------------------------------------------------------------- /tests/test_2417_bytemasked_singletons.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import pytest # noqa: F401 6 | 7 | import awkward as ak 8 | 9 | 10 | def test(): 11 | array = ak.Array( 12 | ak.contents.ByteMaskedArray( 13 | mask=ak.index.Index8([1, 1, 0, 0]), 14 | content=ak.contents.NumpyArray([3, 4, 2, 5]), 15 | valid_when=True, 16 | ) 17 | ) 18 | assert ( 19 | ak.singletons(array, highlevel=False).form 20 | == ak.singletons(ak.to_backend(array, "typetracer"), highlevel=False).form 21 | ) 22 | 23 | assert ( 24 | ak.singletons(array, highlevel=False).form 25 | == ak.singletons( 26 | array.layout.to_typetracer(forget_length=True), highlevel=False 27 | ).form 28 | ) 29 | -------------------------------------------------------------------------------- /awkward-cpp/src/python/_ext.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "awkward/python/content.h" 8 | #include "awkward/python/io.h" 9 | #include "awkward/python/forth.h" 10 | 11 | namespace py = pybind11; 12 | PYBIND11_MODULE(_ext, m) { 13 | #ifdef VERSION_INFO 14 | m.attr("__version__") = VERSION_INFO; 15 | #else 16 | m.attr("__version__") = "dev"; 17 | #endif 18 | 19 | ////////// content.h 20 | 21 | make_ArrayBuilder(m, "ArrayBuilder"); 22 | 23 | ////////// io.h 24 | 25 | make_fromjsonobj(m, "fromjsonobj"); 26 | make_fromjsonobj_schema(m, "fromjsonobj_schema"); 27 | 28 | ////////// forth.h 29 | 30 | make_ForthMachineOf(m, "ForthMachine32"); 31 | make_ForthMachineOf(m, "ForthMachine64"); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /docs/user-guide/how-to-array-properties.md: -------------------------------------------------------------------------------- 1 | --- 2 | jupytext: 3 | text_representation: 4 | extension: .md 5 | format_name: myst 6 | format_version: 0.13 7 | jupytext_version: 1.10.3 8 | kernelspec: 9 | display_name: Python 3 10 | language: python 11 | name: python3 12 | --- 13 | 14 | Array properties 15 | ================ 16 | 17 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 18 | 19 | If you're looking for documentation on a specific function, see the API reference instead. 20 | 21 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 22 | 23 |




24 | -------------------------------------------------------------------------------- /docs/user-guide/how-to-restructure.md: -------------------------------------------------------------------------------- 1 | --- 2 | jupytext: 3 | text_representation: 4 | extension: .md 5 | format_name: myst 6 | format_version: 0.13 7 | jupytext_version: 1.10.3 8 | kernelspec: 9 | display_name: Python 3 10 | language: python 11 | name: python3 12 | --- 13 | 14 | Restructuring data 15 | ================== 16 | 17 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 18 | 19 | If you're looking for documentation on a specific function, see the API reference instead. 20 | 21 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 22 | 23 |




24 | -------------------------------------------------------------------------------- /docs/user-guide/how-to-strings.md: -------------------------------------------------------------------------------- 1 | --- 2 | jupytext: 3 | text_representation: 4 | extension: .md 5 | format_name: myst 6 | format_version: 0.13 7 | jupytext_version: 1.10.3 8 | kernelspec: 9 | display_name: Python 3 10 | language: python 11 | name: python3 12 | --- 13 | 14 | Working with strings 15 | ==================== 16 | 17 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 18 | 19 | If you're looking for documentation on a specific function, see the API reference instead. 20 | 21 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 22 | 23 |




24 | -------------------------------------------------------------------------------- /awkward-cpp/src/cpu-kernels/awkward_ByteMaskedArray_reduce_next_nonlocal_nextshifts_fromshifts_64.cpp: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | #define FILENAME(line) FILENAME_FOR_EXCEPTIONS_C("src/cpu-kernels/awkward_ByteMaskedArray_reduce_next_nonlocal_nextshifts_fromshifts_64.cpp", line) 4 | 5 | #include "awkward/kernels.h" 6 | 7 | ERROR awkward_ByteMaskedArray_reduce_next_nonlocal_nextshifts_fromshifts_64( 8 | int64_t* nextshifts, 9 | const int8_t* mask, 10 | int64_t length, 11 | bool valid_when, 12 | const int64_t* shifts) { 13 | int64_t nullsum = 0; 14 | int64_t k = 0; 15 | for (int64_t i = 0; i < length; i++) { 16 | if ((mask[i] != 0) == (valid_when != 0)) { 17 | nextshifts[k] = shifts[i] + nullsum; 18 | k++; 19 | } 20 | else { 21 | nullsum++; 22 | } 23 | } 24 | return success(); 25 | } 26 | -------------------------------------------------------------------------------- /docs/user-guide/how-to-use-in-cpp.md: -------------------------------------------------------------------------------- 1 | --- 2 | jupytext: 3 | text_representation: 4 | extension: .md 5 | format_name: myst 6 | format_version: 0.13 7 | jupytext_version: 1.10.3 8 | kernelspec: 9 | display_name: Python 3 10 | language: python 11 | name: python3 12 | --- 13 | 14 | Using arrays in C++ 15 | ===================== 16 | 17 | The user guide is a collection of "how to..." guides for common tasks. See the left side-bar (or bring it into view by clicking on the upper-left `≡`) to access the guides, grouped by topic. 18 | 19 | If you're looking for documentation on a specific function, see the API reference instead. 20 | 21 | You can test any examples in a new window/tab by clicking on [![Try It! ⭷](https://img.shields.io/badge/-Try%20It%21%20%E2%86%97-orange?style=for-the-badge)](https://awkward-array.org/doc/main/_static/try-it.html). 22 | 23 |




24 | -------------------------------------------------------------------------------- /awkward-cpp/docs/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /awkward-cpp/src/awkward_cpp/cpu_kernels.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE 2 | 3 | from __future__ import annotations 4 | 5 | import ctypes 6 | import platform 7 | import sys 8 | 9 | if sys.version_info < (3, 9): 10 | import importlib_resources 11 | else: 12 | import importlib.resources as importlib_resources 13 | 14 | import awkward_cpp._kernel_signatures 15 | 16 | if platform.system() == "Windows": 17 | name = "awkward-cpu-kernels.dll" 18 | elif platform.system() == "Darwin": 19 | name = "libawkward-cpu-kernels.dylib" 20 | else: 21 | name = "libawkward-cpu-kernels.so" 22 | 23 | libpath_ref = importlib_resources.files(awkward_cpp) / "lib" / name 24 | with importlib_resources.as_file(libpath_ref) as libpath: 25 | lib = ctypes.cdll.LoadLibrary(str(libpath)) 26 | 27 | kernel = awkward_cpp._kernel_signatures.by_signature(lib) 28 | --------------------------------------------------------------------------------