Skip to content

Commit

Permalink
Start development of v1.1
Browse files Browse the repository at this point in the history
- Fix `__version__`  being `"VERSION_INFO"` instead of the version
- Make getting started notebook install v1.0
- Fix failing to compile decoder for empty detector error models
  • Loading branch information
Strilanc committed Dec 14, 2023
1 parent d2e5a8a commit 8d22bdf
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 43 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ if ((${pybind11_FOUND} AND ${Python_FOUND}) OR "$ENV{CMAKE_FORCE_PYBIND_CHROMOBI
target_compile_options(chromobius_pybind PRIVATE -O3 -DNDEBUG)
target_link_libraries(chromobius_pybind PRIVATE libstim libpymatching)
target_link_options(chromobius_pybind PRIVATE -O3)
add_compile_definitions(CHROMOBIUS_VERSION_INFO=${CHROMOBIUS_VERSION_INFO})
else()
message("WARNING: Skipped chromobius_pybind target. `pybind11` not found. To fix, install pybind11. On debian based distributions, the package name is `pybind11-dev`")
endif()
62 changes: 24 additions & 38 deletions doc/getting_started.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def build_extension(self, ext):
ext.sourcedir,
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={pathlib.Path(self.get_ext_fullpath(ext.name)).parent.absolute()}",
f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DVERSION_INFO={__version__}",
f"-DCHROMOBIUS_VERSION_INFO={__version__}",
*osx_cmake_flags,
*[
env_arg_item
Expand All @@ -71,7 +71,7 @@ def build_extension(self, ext):
], cwd=build_temp, env=build_env)


__version__ = '1.0.dev0'
__version__ = '1.1.dev0'

with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()
Expand Down
2 changes: 1 addition & 1 deletion src/chromobius/decode/decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Decoder Decoder::from_dem(const stim::DetectorErrorModel &dem, DecoderConfigOpti
for (const auto &e : remnant_edges) {
result.atomic_errors.emplace(std::move(e));
}
if (!options.include_coords_in_mobius_dem || result.mobius_dem.count_detectors() < result.node_colors.size() * 2) {
if (result.mobius_dem.count_detectors() < result.node_colors.size() * 2) {
// Ensure the number of detectors in the mobius dem is exactly correct.
result.mobius_dem.append_detector_instruction(
{}, stim::DemTarget::relative_detector_id(result.node_colors.size() * 2 - 1));
Expand Down
1 change: 0 additions & 1 deletion src/chromobius/decode/decoder.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ TEST(decoder, from_dem_d5_color_code_x_only) {
error(0.1) D10 D16 ^ D11 D17
error(0.1) D5 D7 ^ D4 D10 ^ D6 D11
error(0.1) D9 D17 ^ D12 D16 ^ D8 D13
detector D17
)DEM");
ASSERT_TRUE(decoder.mobius_dem.approx_equals(expected_mobius_dem, 1e-5));
}
Expand Down
2 changes: 1 addition & 1 deletion src/chromobius/pybind/chromobius.pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct CompiledDecoder {
};

PYBIND11_MODULE(chromobius, m) {
m.attr("__version__") = xstr_literal(VERSION_INFO);
m.attr("__version__") = xstr_literal(CHROMOBIUS_VERSION_INFO);
m.doc() = R"pbdoc(
chromobius: A fast implementation of the mobius color code decoder.
)pbdoc";
Expand Down
5 changes: 5 additions & 0 deletions src/chromobius/pybind/chromobius_pybind_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


def test_version():
assert '.' in chromobius.__version__
assert chromobius.__version__ is not None


Expand Down Expand Up @@ -74,3 +75,7 @@ def test_decoding():
assert np.array_equal(predictions, predictions2)
mistakes = np.count_nonzero(np.any(predictions != obs, axis=1))
assert mistakes < 100


def test_empty():
assert chromobius.compile_decoder_for_dem(stim.DetectorErrorModel()) is not None

0 comments on commit 8d22bdf

Please sign in to comment.