cefast 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cefast-0.2.0 → cefast-0.2.2}/PKG-INFO +2 -2
- {cefast-0.2.0 → cefast-0.2.2}/README.md +1 -1
- {cefast-0.2.0 → cefast-0.2.2}/docs/cpp.rst +2 -2
- {cefast-0.2.0 → cefast-0.2.2}/docs/history.rst +14 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/reading.rst +1 -1
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/data/records.hpp +10 -22
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/model.hpp +3 -3
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/values.hpp +4 -6
- {cefast-0.2.0 → cefast-0.2.2}/meson.build +1 -1
- {cefast-0.2.0 → cefast-0.2.2}/pycefast/_cefast.cpp +16 -10
- {cefast-0.2.0 → cefast-0.2.2}/tests/cpp/test_corpus.cpp +6 -6
- {cefast-0.2.0 → cefast-0.2.2}/tests/cpp/test_records.cpp +19 -2
- {cefast-0.2.0 → cefast-0.2.2}/tests/cpp/test_values.cpp +15 -4
- {cefast-0.2.0 → cefast-0.2.2}/tests/python/test_cefast.py +33 -4
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/csa_manifest.json +70 -70
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/reference_records.hpp +11 -16
- {cefast-0.2.0 → cefast-0.2.2}/.clang-format +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/.github/dependabot.yml +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/.github/workflows/tests.yml +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/.github/workflows/wheels.yml +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/.gitignore +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/.readthedocs.yaml +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/COPYING +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/cefast/__init__.py +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/cefast/_repr.py +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/cefast/_version.py.in +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/cefast/meson.build +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/_static/playground.css +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/_static/playground.js +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/accepted-deviations.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/api.rst +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/cef.rst +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/check_examples.py +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/conf.py +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/contributing.rst +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/cookbook.rst +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/deviations.rst +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/faq.rst +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/images/cefast_logo.png +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/index.rst +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/installation.rst +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/perf/2026-11-round1-profile.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/perf/2026-11-round5-parallel.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/perf/2026-11-round6-small-files.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/perf/2026-11-round7.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/performance.rst +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/quickstart.rst +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/requirements.txt +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/plans/2026-11-05-cefast-reader.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/plans/2026-11-05-cefast-speed-round2.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/plans/2026-11-05-cefast-speed-round3.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/plans/2026-11-05-cefast-speed.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/plans/2026-11-05-cpp-utils-python.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/plans/2026-11-05-plan-review-opencode.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/plans/2026-11-06-cefast-speed-round4.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/plans/2026-11-06-cefast-speed-round5.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/plans/2026-11-06-cefast-speed-round6.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/plans/2026-11-06-cefast-speed-round7.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/specs/2026-11-05-cef-facts.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/specs/2026-11-05-cefast-design.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/docs/superpowers/specs/2026-11-05-csa-cef-probe.md +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/cefast.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/data/parallel.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/data/structural.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/data/workers.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/errors.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/gzip.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/header/attributes.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/header/lexer.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/header/parser.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/input.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/include/cefast/time.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/meson_options.txt +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/pycefast/meson.build +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/pyproject.toml +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/subprojects/catch2.wrap +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/subprojects/cpp_utils.wrap +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/subprojects/fast_float.wrap +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/subprojects/hedley.wrap +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/subprojects/pybind11.wrap +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/subprojects/zlib.wrap +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/cpp/test_header.cpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/cpp/test_input.cpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/cpp/test_lexer.cpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/cpp/test_time.cpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/meson.build +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/python/test_vs_ceflib.py +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/codif-header.cef +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/hello.cef +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/hello.cef.gz +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/include/broken.cef +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/include/broken.ceh +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/include/common.ceh +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/include/cycle-a.cef +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/include/cycle-b.ceh +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/include/main.cef +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/include/nested.ceh +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/trailing_zeros.cef.gz +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/truncated.cef.gz +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/two_members.cef.gz +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/fixtures/whi-header.cef +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/resources/make_gz.py +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tests/wheel/test_wheel.py +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/bench/bench_load.cpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/bench/meson.build +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/ceflib/benchmark.py +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/ceflib/build_ceflib.sh +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fetch_csa_corpus.py +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/cef.dict +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/compare.hpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/fuzz_float.cpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/fuzz_lexer.cpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/fuzz_lexer_diff.cpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/fuzz_load.cpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/fuzz_records_diff.cpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/fuzz_time.cpp +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/make_corpus.py +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/meson.build +0 -0
- {cefast-0.2.0 → cefast-0.2.2}/tools/fuzz/reference_lexer.hpp +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cefast
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Fast reader for ESA's Cluster Exchange Format (CEF 2.0)
|
|
5
5
|
Author-Email: Alexis Jeandet <alexis.jeandet@member.fsf.org>
|
|
6
6
|
License: MIT License
|
|
@@ -143,7 +143,7 @@ declared shape.
|
|
|
143
143
|
| --- | --- |
|
|
144
144
|
| FLOAT | float32 |
|
|
145
145
|
| DOUBLE | float64 |
|
|
146
|
-
| INT |
|
|
146
|
+
| INT | int64 |
|
|
147
147
|
| BYTE | uint8 |
|
|
148
148
|
| CHAR | numpy unicode string, copied |
|
|
149
149
|
| ISO_TIME | datetime64[ns] |
|
|
@@ -16,7 +16,7 @@ Put this wrap file in your ``subprojects/`` directory, as ``subprojects/cefast.w
|
|
|
16
16
|
|
|
17
17
|
[wrap-git]
|
|
18
18
|
url = https://github.com/SciQLop/CEFast.git
|
|
19
|
-
revision = v0.2.
|
|
19
|
+
revision = v0.2.2
|
|
20
20
|
depth = 1
|
|
21
21
|
|
|
22
22
|
[provide]
|
|
@@ -106,7 +106,7 @@ varies fastest.
|
|
|
106
106
|
=================== ===================================================
|
|
107
107
|
``FLOAT`` ``float``
|
|
108
108
|
``DOUBLE`` ``double``
|
|
109
|
-
``INT`` ``std::
|
|
109
|
+
``INT`` ``std::int64_t``
|
|
110
110
|
``BYTE`` ``std::uint8_t``
|
|
111
111
|
``ISO_TIME`` ``std::int64_t``, nanoseconds since 1970-01-01 UTC
|
|
112
112
|
``ISO_TIME_RANGE`` ``std::int64_t``, start and stop one after the other
|
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
History
|
|
3
3
|
=======
|
|
4
4
|
|
|
5
|
+
0.2.2 (2026-11-19)
|
|
6
|
+
==================
|
|
7
|
+
|
|
8
|
+
- ``INT`` values are read as 64-bit integers. CSA writes ``INT`` values that do not fit in
|
|
9
|
+
32 bits (``C3_CP_PEA_MOMENTS`` stores calibration versions like ``20122350000``), and one
|
|
10
|
+
such value made the whole file fail to load. ``INT`` arrays are now ``int64``, not ``int32``.
|
|
11
|
+
|
|
12
|
+
0.2.1 (2026-11-08)
|
|
13
|
+
==================
|
|
14
|
+
|
|
15
|
+
- A key that is not text is missing, as in a :class:`dict`: ``None in f`` is false,
|
|
16
|
+
``f.get(None)`` returns the default and ``f[None]`` raises :class:`KeyError`. They used to
|
|
17
|
+
raise :class:`TypeError`.
|
|
18
|
+
|
|
5
19
|
0.2.0 (2026-11-08)
|
|
6
20
|
==================
|
|
7
21
|
|
|
@@ -129,7 +129,7 @@ CEF ``VALUE_TYPE`` numpy dtype Notes
|
|
|
129
129
|
=================== =================================== ===================================
|
|
130
130
|
``FLOAT`` ``float32``
|
|
131
131
|
``DOUBLE`` ``float64``
|
|
132
|
-
``INT`` ``int32
|
|
132
|
+
``INT`` ``int64`` CSA writes values beyond int32
|
|
133
133
|
``BYTE`` ``uint8`` 0 to 255
|
|
134
134
|
``ISO_TIME`` ``datetime64[ns]`` UTC
|
|
135
135
|
``ISO_TIME_RANGE`` ``datetime64[ns]`` last axis: start, stop
|
|
@@ -164,8 +164,8 @@ namespace detail
|
|
|
164
164
|
set_cursor<double>(state, 0);
|
|
165
165
|
break;
|
|
166
166
|
case value_type::INT:
|
|
167
|
-
typed<std::
|
|
168
|
-
set_cursor<std::
|
|
167
|
+
typed<std::int64_t>(*state.values).resize(total);
|
|
168
|
+
set_cursor<std::int64_t>(state, 0);
|
|
169
169
|
break;
|
|
170
170
|
case value_type::BYTE:
|
|
171
171
|
typed<std::uint8_t>(*state.values).resize(total);
|
|
@@ -193,7 +193,7 @@ namespace detail
|
|
|
193
193
|
typed<double>(*state.values).resize(total);
|
|
194
194
|
break;
|
|
195
195
|
case value_type::INT:
|
|
196
|
-
typed<std::
|
|
196
|
+
typed<std::int64_t>(*state.values).resize(total);
|
|
197
197
|
break;
|
|
198
198
|
case value_type::BYTE:
|
|
199
199
|
typed<std::uint8_t>(*state.values).resize(total);
|
|
@@ -245,9 +245,7 @@ namespace detail
|
|
|
245
245
|
case value_type::INT:
|
|
246
246
|
{
|
|
247
247
|
std::int64_t value = 0;
|
|
248
|
-
state.has_fill = parse_int(state.fillval, value)
|
|
249
|
-
&& value >= std::numeric_limits<std::int32_t>::min()
|
|
250
|
-
&& value <= std::numeric_limits<std::int32_t>::max();
|
|
248
|
+
state.has_fill = parse_int(state.fillval, value);
|
|
251
249
|
state.fill_integer = value;
|
|
252
250
|
break;
|
|
253
251
|
}
|
|
@@ -297,7 +295,7 @@ namespace detail
|
|
|
297
295
|
put(state, state.fill_number);
|
|
298
296
|
return true;
|
|
299
297
|
case value_type::INT:
|
|
300
|
-
put(state,
|
|
298
|
+
put(state, state.fill_integer);
|
|
301
299
|
return true;
|
|
302
300
|
case value_type::BYTE:
|
|
303
301
|
put(state, static_cast<std::uint8_t>(state.fill_integer));
|
|
@@ -342,10 +340,9 @@ namespace detail
|
|
|
342
340
|
case value_type::INT:
|
|
343
341
|
{
|
|
344
342
|
std::int64_t value = 0;
|
|
345
|
-
if (!parse_int(token, value)
|
|
346
|
-
|| value > std::numeric_limits<std::int32_t>::max())
|
|
343
|
+
if (!parse_int(token, value))
|
|
347
344
|
return false;
|
|
348
|
-
put(state,
|
|
345
|
+
put(state, value);
|
|
349
346
|
return true;
|
|
350
347
|
}
|
|
351
348
|
case value_type::BYTE:
|
|
@@ -395,7 +392,7 @@ namespace detail
|
|
|
395
392
|
set_cursor<double>(state, total);
|
|
396
393
|
break;
|
|
397
394
|
case value_type::INT:
|
|
398
|
-
set_cursor<std::
|
|
395
|
+
set_cursor<std::int64_t>(state, total);
|
|
399
396
|
break;
|
|
400
397
|
case value_type::BYTE:
|
|
401
398
|
set_cursor<std::uint8_t>(state, total);
|
|
@@ -720,17 +717,8 @@ namespace detail
|
|
|
720
717
|
[this](std::size_t& at, double& value) { return parse_float_at(at, value); },
|
|
721
718
|
count, ends_record, position, local_line, multi_line);
|
|
722
719
|
case value_type::INT:
|
|
723
|
-
return fast_column(target,
|
|
724
|
-
[this](std::size_t& at, std::
|
|
725
|
-
{
|
|
726
|
-
std::int64_t wide = 0;
|
|
727
|
-
if (!parse_int_at(at, wide)
|
|
728
|
-
|| wide < std::numeric_limits<std::int32_t>::min()
|
|
729
|
-
|| wide > std::numeric_limits<std::int32_t>::max())
|
|
730
|
-
return false;
|
|
731
|
-
value = static_cast<std::int32_t>(wide);
|
|
732
|
-
return true;
|
|
733
|
-
},
|
|
720
|
+
return fast_column(target, target.fill_integer,
|
|
721
|
+
[this](std::size_t& at, std::int64_t& value) { return parse_int_at(at, value); },
|
|
734
722
|
count, ends_record, position, local_line, multi_line);
|
|
735
723
|
case value_type::BYTE:
|
|
736
724
|
return fast_column(target, static_cast<std::uint8_t>(target.fill_integer),
|
|
@@ -43,11 +43,11 @@ struct attribute
|
|
|
43
43
|
|
|
44
44
|
using attributes = std::vector<attribute>;
|
|
45
45
|
|
|
46
|
-
// One buffer per value type: INT is
|
|
47
|
-
// ISO_TIME and ISO_TIME_RANGE share int64 (a
|
|
46
|
+
// One buffer per value type: INT is int64 (CEF says 4 bytes, but CSA writes wider values such as
|
|
47
|
+
// 20122350000), BYTE is unsigned (0-255), and INT, ISO_TIME and ISO_TIME_RANGE share int64 (a
|
|
48
|
+
// range stores its start/stop pairs interleaved).
|
|
48
49
|
using column = std::variant<cpp_utils::containers::no_init_vector<float>,
|
|
49
50
|
cpp_utils::containers::no_init_vector<double>,
|
|
50
|
-
cpp_utils::containers::no_init_vector<std::int32_t>,
|
|
51
51
|
cpp_utils::containers::no_init_vector<std::int64_t>,
|
|
52
52
|
cpp_utils::containers::no_init_vector<std::uint8_t>, std::vector<std::string>>;
|
|
53
53
|
|
|
@@ -54,7 +54,7 @@ namespace detail
|
|
|
54
54
|
return true;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
// CEF writes signed samples, and INT already takes the '+'
|
|
57
|
+
// CEF writes signed samples, and INT already takes the '+' spelling, so the floating
|
|
58
58
|
// types must too: fast_float only accepts it when asked.
|
|
59
59
|
constexpr fast_float::chars_format float_format
|
|
60
60
|
= fast_float::chars_format::general | fast_float::chars_format::allow_leading_plus;
|
|
@@ -197,7 +197,7 @@ namespace detail
|
|
|
197
197
|
case value_type::DOUBLE:
|
|
198
198
|
return no_init_vector<double> { };
|
|
199
199
|
case value_type::INT:
|
|
200
|
-
return no_init_vector<std::
|
|
200
|
+
return no_init_vector<std::int64_t> { };
|
|
201
201
|
case value_type::BYTE:
|
|
202
202
|
return no_init_vector<std::uint8_t> { };
|
|
203
203
|
case value_type::ISO_TIME:
|
|
@@ -236,11 +236,9 @@ namespace detail
|
|
|
236
236
|
case value_type::INT:
|
|
237
237
|
{
|
|
238
238
|
std::int64_t value = 0;
|
|
239
|
-
if (!detail::parse_int(token, value)
|
|
240
|
-
|| value > std::numeric_limits<std::int32_t>::max())
|
|
239
|
+
if (!detail::parse_int(token, value))
|
|
241
240
|
return false;
|
|
242
|
-
std::get<no_init_vector<std::
|
|
243
|
-
static_cast<std::int32_t>(value));
|
|
241
|
+
std::get<no_init_vector<std::int64_t>>(values).push_back(value);
|
|
244
242
|
return true;
|
|
245
243
|
}
|
|
246
244
|
case value_type::BYTE:
|
|
@@ -146,7 +146,7 @@ template <typename Container>
|
|
|
146
146
|
case cefast::value_type::DOUBLE:
|
|
147
147
|
return view_of(std::get<no_init_vector<double>>(var.values), shape, owner);
|
|
148
148
|
case cefast::value_type::INT:
|
|
149
|
-
return view_of(std::get<no_init_vector<std::
|
|
149
|
+
return view_of(std::get<no_init_vector<std::int64_t>>(var.values), shape, owner);
|
|
150
150
|
case cefast::value_type::BYTE:
|
|
151
151
|
return view_of(std::get<no_init_vector<std::uint8_t>>(var.values), shape, owner);
|
|
152
152
|
case cefast::value_type::ISO_TIME:
|
|
@@ -193,22 +193,28 @@ struct py_cef
|
|
|
193
193
|
{
|
|
194
194
|
std::shared_ptr<cefast::cef_file> file;
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
// Keys of any type, like a dict: a key that is not text is simply not there.
|
|
197
|
+
[[nodiscard]] std::optional<std::size_t> find(const py::handle& key) const
|
|
197
198
|
{
|
|
199
|
+
if (!py::isinstance<py::str>(key))
|
|
200
|
+
return std::nullopt;
|
|
201
|
+
const auto name = key.cast<std::string>();
|
|
198
202
|
for (std::size_t index = 0; index < file->variables.size(); ++index)
|
|
199
203
|
if (file->variables[index].name == name)
|
|
200
|
-
return
|
|
201
|
-
|
|
204
|
+
return index;
|
|
205
|
+
return std::nullopt;
|
|
202
206
|
}
|
|
203
207
|
|
|
204
|
-
[[nodiscard]]
|
|
208
|
+
[[nodiscard]] py_variable getitem(const py::object& key) const
|
|
205
209
|
{
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
+
if (const auto index = find(key))
|
|
211
|
+
return py_variable { file, *index };
|
|
212
|
+
PyErr_SetObject(PyExc_KeyError, key.ptr());
|
|
213
|
+
throw py::error_already_set();
|
|
210
214
|
}
|
|
211
215
|
|
|
216
|
+
[[nodiscard]] bool contains(const py::object& key) const { return find(key).has_value(); }
|
|
217
|
+
|
|
212
218
|
[[nodiscard]] std::size_t len() const { return file->variables.size(); }
|
|
213
219
|
[[nodiscard]] py::dict attributes() const { return attributes_of(file->globals); }
|
|
214
220
|
|
|
@@ -377,7 +383,7 @@ of 2 (start, stop).
|
|
|
377
383
|
================== ======================================
|
|
378
384
|
``FLOAT`` ``float32``
|
|
379
385
|
``DOUBLE`` ``float64``
|
|
380
|
-
``INT`` ``
|
|
386
|
+
``INT`` ``int64``
|
|
381
387
|
``BYTE`` ``uint8``
|
|
382
388
|
``ISO_TIME`` ``datetime64[ns]``
|
|
383
389
|
``ISO_TIME_RANGE`` ``datetime64[ns]``
|
|
@@ -179,7 +179,7 @@ TEST_CASE("corpus: WHI last record matches the file text")
|
|
|
179
179
|
CHECK(strings_of(spectrum).back() == "A");
|
|
180
180
|
|
|
181
181
|
const auto& quality = variable_named(file, "Quality__C1_CP_WHI_ELECTRON_DENSITY");
|
|
182
|
-
CHECK(values_of<std::
|
|
182
|
+
CHECK(values_of<std::int64_t>(quality).back() == 3);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
TEST_CASE("corpus: CODIF 3d_ions keeps its multidim C layout")
|
|
@@ -223,7 +223,7 @@ TEST_CASE("corpus: EFW L3 microsecond time tags keep their six digits")
|
|
|
223
223
|
CHECK(values_of<float>(sigma).front() == 0.178f);
|
|
224
224
|
|
|
225
225
|
const auto& bitmask = variable_named(file, "E_bitmask__C1_CP_EFW_L3_E");
|
|
226
|
-
CHECK(values_of<std::
|
|
226
|
+
CHECK(values_of<std::int64_t>(bitmask).front() == 4096);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
TEST_CASE("corpus: sub-millisecond time tags are not rounded away")
|
|
@@ -242,12 +242,12 @@ TEST_CASE("corpus: an ISO_TIME_RANGE variable keeps both ends")
|
|
|
242
242
|
const auto& time = variable_named(file, "time_tags__C3_CT_AUX_GRMB");
|
|
243
243
|
REQUIRE(time.type == cefast::value_type::ISO_TIME_RANGE);
|
|
244
244
|
REQUIRE(time.is_nrv == false);
|
|
245
|
-
REQUIRE(time.records ==
|
|
245
|
+
REQUIRE(time.records == 633);
|
|
246
246
|
const auto& values = values_of<std::int64_t>(time);
|
|
247
|
-
REQUIRE(values.size() ==
|
|
248
|
-
// 2004-12-31T21:04:12Z/2005-01-01T03:
|
|
247
|
+
REQUIRE(values.size() == 633UL * 2);
|
|
248
|
+
// 2004-12-31T21:04:12Z/2005-01-01T03:05:00Z
|
|
249
249
|
CHECK(values[0] == 1'104'527'052'000'000'000);
|
|
250
|
-
CHECK(values[1] == 1'104'548'
|
|
250
|
+
CHECK(values[1] == 1'104'548'700'000'000'000);
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
TEST_CASE("corpus: a gzipped file loads exactly like its plain version")
|
|
@@ -377,7 +377,7 @@ TEST_CASE("records: a hint shorter than the file still stores every value", "[re
|
|
|
377
377
|
// The hint sizes the column up front; a file with more records than that must grow it.
|
|
378
378
|
const auto result
|
|
379
379
|
= load(header("", three_ints) + "!RECORDS= 1\n1,2,3\n4,5,6\n7,8,9\nEND_DATA\n");
|
|
380
|
-
const auto& values = std::get<cpp_utils::containers::no_init_vector<std::
|
|
380
|
+
const auto& values = std::get<cpp_utils::containers::no_init_vector<std::int64_t>>(
|
|
381
381
|
result.file.variables[0].values);
|
|
382
382
|
REQUIRE(values.size() == 9);
|
|
383
383
|
CHECK(values[0] == 1);
|
|
@@ -385,10 +385,27 @@ TEST_CASE("records: a hint shorter than the file still stores every value", "[re
|
|
|
385
385
|
CHECK(values[8] == 9);
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
+
TEST_CASE("records: INT values and fill beyond int32 are stored", "[records]")
|
|
389
|
+
{
|
|
390
|
+
constexpr std::string_view wide_ints = R"(START_VARIABLE = i
|
|
391
|
+
VALUE_TYPE = INT
|
|
392
|
+
SIZES = 3
|
|
393
|
+
FILLVAL = 99999999999
|
|
394
|
+
END_VARIABLE = i)";
|
|
395
|
+
const auto result = load(header("", wide_ints)
|
|
396
|
+
+ "20122350000,-3000000000,1\n99999999999,2,3\nEND_DATA\n");
|
|
397
|
+
const auto& values = std::get<cpp_utils::containers::no_init_vector<std::int64_t>>(
|
|
398
|
+
result.file.variables[0].values);
|
|
399
|
+
REQUIRE(values.size() == 6);
|
|
400
|
+
CHECK(values[0] == 20122350000);
|
|
401
|
+
CHECK(values[1] == -3000000000);
|
|
402
|
+
CHECK(values[3] == 99999999999);
|
|
403
|
+
}
|
|
404
|
+
|
|
388
405
|
TEST_CASE("records: a hint longer than the file trims the column", "[records]")
|
|
389
406
|
{
|
|
390
407
|
const auto result = load(header("", three_ints) + "!RECORDS= 50\n1,2,3\n4,5,6\nEND_DATA\n");
|
|
391
|
-
const auto& values = std::get<cpp_utils::containers::no_init_vector<std::
|
|
408
|
+
const auto& values = std::get<cpp_utils::containers::no_init_vector<std::int64_t>>(
|
|
392
409
|
result.file.variables[0].values);
|
|
393
410
|
REQUIRE(values.size() == 6);
|
|
394
411
|
CHECK(values[5] == 6);
|
|
@@ -77,7 +77,7 @@ TEST_CASE("values: INT accepts leading zero and plus", "[values]")
|
|
|
77
77
|
column values = make_column(value_type::INT);
|
|
78
78
|
REQUIRE(append_value(values, value_type::INT, "05", ""));
|
|
79
79
|
REQUIRE(append_value(values, value_type::INT, "+7", ""));
|
|
80
|
-
const auto& ints = std::get<cpp_utils::containers::no_init_vector<std::
|
|
80
|
+
const auto& ints = std::get<cpp_utils::containers::no_init_vector<std::int64_t>>(values);
|
|
81
81
|
REQUIRE(ints.size() == 2);
|
|
82
82
|
CHECK(ints[0] == 5);
|
|
83
83
|
CHECK(ints[1] == 7);
|
|
@@ -110,10 +110,21 @@ TEST_CASE("values: INT rejects garbage", "[values]")
|
|
|
110
110
|
CHECK_FALSE(append_value(values, value_type::INT, "5x", ""));
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
TEST_CASE("values: INT
|
|
113
|
+
TEST_CASE("values: INT keeps values beyond int32", "[values]")
|
|
114
|
+
{
|
|
115
|
+
// CSA's C3_CP_PEA_MOMENTS writes calibration versions such as 20122350000 as INT.
|
|
116
|
+
column values = make_column(value_type::INT);
|
|
117
|
+
REQUIRE(append_value(values, value_type::INT, "20122350000", ""));
|
|
118
|
+
REQUIRE(append_value(values, value_type::INT, "-3000000000", ""));
|
|
119
|
+
const auto& ints = std::get<cpp_utils::containers::no_init_vector<std::int64_t>>(values);
|
|
120
|
+
CHECK(ints[0] == 20122350000);
|
|
121
|
+
CHECK(ints[1] == -3000000000);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
TEST_CASE("values: INT rejects values outside int64", "[values]")
|
|
114
125
|
{
|
|
115
126
|
column values = make_column(value_type::INT);
|
|
116
|
-
CHECK_FALSE(append_value(values, value_type::INT, "
|
|
127
|
+
CHECK_FALSE(append_value(values, value_type::INT, "9223372036854775808", ""));
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
TEST_CASE("values: BYTE accepts 0..255", "[values]")
|
|
@@ -201,7 +212,7 @@ TEST_CASE("values: NRV scalar keeps its single element", "[values]")
|
|
|
201
212
|
{
|
|
202
213
|
const auto result = parse(one_variable(value_type::INT, " SIZES = 1\n", "7"));
|
|
203
214
|
CHECK(result.file.variables[0].sizes == std::vector<std::size_t> { 1 });
|
|
204
|
-
CHECK(std::get<cpp_utils::containers::no_init_vector<std::
|
|
215
|
+
CHECK(std::get<cpp_utils::containers::no_init_vector<std::int64_t>>(
|
|
205
216
|
result.file.variables[0].values)
|
|
206
217
|
.size()
|
|
207
218
|
== 1);
|
|
@@ -41,6 +41,17 @@ DATA_UNTIL = END_DATA
|
|
|
41
41
|
END_DATA
|
|
42
42
|
"""
|
|
43
43
|
|
|
44
|
+
WIDE_INT_FILE = b"""FILE_NAME = "wide.cef"
|
|
45
|
+
FILE_FORMAT_VERSION = "CEF-2.0"
|
|
46
|
+
START_VARIABLE = i
|
|
47
|
+
VALUE_TYPE = INT
|
|
48
|
+
END_VARIABLE = i
|
|
49
|
+
DATA_UNTIL = END_DATA
|
|
50
|
+
20122350000
|
|
51
|
+
-3000000000
|
|
52
|
+
END_DATA
|
|
53
|
+
"""
|
|
54
|
+
|
|
44
55
|
|
|
45
56
|
class TestLoad(unittest.TestCase):
|
|
46
57
|
def test_load_path_and_bytes_equal(self):
|
|
@@ -169,10 +180,10 @@ class TestVariables(unittest.TestCase):
|
|
|
169
180
|
values = cefast.load(corpus_file("C3_CT_AUX_GRMB"))[
|
|
170
181
|
"time_tags__C3_CT_AUX_GRMB"
|
|
171
182
|
].values
|
|
172
|
-
self.assertEqual(values.shape, (
|
|
183
|
+
self.assertEqual(values.shape, (633, 2))
|
|
173
184
|
self.assertEqual(values.dtype, np.dtype("datetime64[ns]"))
|
|
174
185
|
self.assertEqual(values[0, 0], np.datetime64("2004-12-31T21:04:12"))
|
|
175
|
-
self.assertEqual(values[0, 1], np.datetime64("2005-01-01T03:
|
|
186
|
+
self.assertEqual(values[0, 1], np.datetime64("2005-01-01T03:05:00"))
|
|
176
187
|
|
|
177
188
|
def test_dtypes(self):
|
|
178
189
|
whi = self.whi
|
|
@@ -180,7 +191,7 @@ class TestVariables(unittest.TestCase):
|
|
|
180
191
|
whi["Delta_Time__C1_CP_WHI_ELECTRON_DENSITY"].values.dtype, np.float32
|
|
181
192
|
)
|
|
182
193
|
self.assertEqual(
|
|
183
|
-
whi["Quality__C1_CP_WHI_ELECTRON_DENSITY"].values.dtype, np.
|
|
194
|
+
whi["Quality__C1_CP_WHI_ELECTRON_DENSITY"].values.dtype, np.int64
|
|
184
195
|
)
|
|
185
196
|
self.assertEqual(
|
|
186
197
|
whi["time_tags__C1_CP_WHI_ELECTRON_DENSITY"].values.dtype,
|
|
@@ -190,7 +201,7 @@ class TestVariables(unittest.TestCase):
|
|
|
190
201
|
self.assertEqual(edi.value_type, "DOUBLE")
|
|
191
202
|
self.assertEqual(edi.values.dtype, np.float64)
|
|
192
203
|
efw = cefast.load(corpus_file("C1_CP_EFW_L3_E"))
|
|
193
|
-
self.assertEqual(efw["E_bitmask__C1_CP_EFW_L3_E"].values.dtype, np.
|
|
204
|
+
self.assertEqual(efw["E_bitmask__C1_CP_EFW_L3_E"].values.dtype, np.int64)
|
|
194
205
|
|
|
195
206
|
def test_fill_time_is_nat(self):
|
|
196
207
|
values = cefast.load(FILL_TIME_FILE)["t"].values
|
|
@@ -198,6 +209,11 @@ class TestVariables(unittest.TestCase):
|
|
|
198
209
|
self.assertTrue(np.isnat(values[0]))
|
|
199
210
|
self.assertEqual(values[1], np.datetime64("2000-01-01T00:00:00"))
|
|
200
211
|
|
|
212
|
+
def test_int_beyond_int32(self):
|
|
213
|
+
values = cefast.load(WIDE_INT_FILE)["i"].values
|
|
214
|
+
self.assertEqual(values.dtype, np.int64)
|
|
215
|
+
np.testing.assert_array_equal(values, [20122350000, -3000000000])
|
|
216
|
+
|
|
201
217
|
def test_attributes_plain_values(self):
|
|
202
218
|
self.assertEqual(self.whi.attributes["MISSION"], "Cluster")
|
|
203
219
|
regions = self.whi.attributes["MISSION_REGION"]
|
|
@@ -340,6 +356,19 @@ class TestMapping(unittest.TestCase):
|
|
|
340
356
|
def test_dict_conversion(self):
|
|
341
357
|
self.assertEqual(list(dict(self.f)), ["time_tags", "B_vec", "label"])
|
|
342
358
|
|
|
359
|
+
def test_keys_that_are_not_text_are_missing_like_in_a_dict(self):
|
|
360
|
+
for key in (None, 1, b"B_vec"):
|
|
361
|
+
self.assertNotIn(key, self.f)
|
|
362
|
+
self.assertIsNone(self.f.get(key))
|
|
363
|
+
self.assertEqual(self.f.get(key, 42), 42)
|
|
364
|
+
with self.assertRaises(KeyError):
|
|
365
|
+
self.f[key]
|
|
366
|
+
|
|
367
|
+
def test_missing_key_error_holds_the_key(self):
|
|
368
|
+
with self.assertRaises(KeyError) as caught:
|
|
369
|
+
self.f["missing"]
|
|
370
|
+
self.assertEqual(caught.exception.args, ("missing",))
|
|
371
|
+
|
|
343
372
|
def test_still_read_only(self):
|
|
344
373
|
with self.assertRaises(TypeError):
|
|
345
374
|
self.f["x"] = None
|