diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07e76ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,117 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# Generated C code +*.c + +# C extensions +*.so + +# Vi +*.swp +*.swo + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# PyCharm +.idea + +# Mac +.DS_Store diff --git a/design_docs/01_rankN_arrays.md b/design_docs/01_rankN_arrays.md new file mode 100644 index 0000000..02048d1 --- /dev/null +++ b/design_docs/01_rankN_arrays.md @@ -0,0 +1,248 @@ + + + + + +
Author Erik Welch (eriknw)
Status Draft
Created Aug 26, 2022
Resolution <url> (Accepted | Rejected | Withdrawn)
+ +## Abstract + +This design document considers what is necessary to support sparse rank N arrays. We will consider a narrow scope and broad scope: +1. how to support rank 1 and 2 arrays in a way that will let us support rank N arrays in the future, and +2. how to fully support rank N arrays + +We use [TACO](http://tensor-compiler.org/) and [MLIR's sparse_tensor dialect](https://mlir.llvm.org/docs/Dialects/SparseTensorOps/) as motivation for sparse rank N arrays (or tensors), and our proposal will be fully compatible with them. + +## Motivation + +We are developing a specification for binary storage of sparse matrices and vectors. The solution will entail saving metadata and storing multiple one-dimensional arrays. Storing rank N arrays need the same things: metadata and one-dimensional arrays. So, why not try to support arrays of arbitrary dimension if it's easy to do so? This will make the binary storage format more capable. + +Many people are already familiar with existing compression schemes for arrays, including COO, CSR (or CRS), DCSC (or HyperCSC), CSF, and more. I think it would be best to reuse these names when possible to increase usability. Doing so will make our documentation clearer, and we want users who only use 1d and 2d arrays to be comfortable. Is this possible with a generic scheme that supports rank N arrays? Let's find out! + +## Detailed description + +### Rank 1 and 2 arrays + +Since we don't yet have specific proposals for how to support rank 1 and 2 arrays, this section will be speculative and constructive. + +#### Names of constituent arrays + +Using names like `rows` and `col_indices` does not scale to arbitrary rank. For example, the two arrays for CSR may typically be called `indptr` and `col_indices`, but we can use names such as `pointers_0` and `indices_1` that can be generalized to arbitrary rank. + +Here's how these arrays would be used for common structures: + +| Type | `indices_0` | `pointers_0` | `indices_1` | `axis_order` | +| -- | :--: | :--: | :--: | :--: | +| **Vector** | Yes | | | `[0]` | +| **CSR** | | Yes | Yes | `[0, 1]` | +| **CSC** | | Yes | Yes | `[1, 0]` | +| **DCSR** | Yes | Yes | Yes | `[0, 1]` | +| **DCSC** | Yes | Yes | Yes | `[1, 0]` | +| **COO** | Yes | | Yes | `[0, 1]` or `[1, 0]` | + +`pointers_i` array is used to group indices of the current dimension to the indices of the next dimension. + + + +#### Row or column orientation + +Observe that CSR and CSC both use `pointers_0` and `indices_1` in the table above, and `axis_order` is used to determine whether the array is row-major or column-major. This is also called `dimOrdering` in [MLIR sparse_tensor](https://mlir.llvm.org/docs/Dialects/SparseTensorOps/#parameters). It is necessary for `axis_order` to be a list or tuple to support different axis ordering in higher dimensions such as `axis_order=[1, 3, 0, 2]`. + +For COO, `axis_order` indicates whether `indices_0` is rows (`axis_order=[0, 1]`) or columns (`axis_order[1, 0]`). + +_Proposal:_ if the compression type (such as CSR) ends in **"R"**, then `axis_order` uses **r**egular ordering `0, 1, ..., N-1`, and if it ends in **"C"**, then `axis_order` uses **c**ontrary ordering `N-1, N-2, ... 1, 0`. + + + +#### Simplifying assumptions + +Traditionally, COO is a common and flexible format. It can often have duplicate indices, and indices may not be sorted. Other storage formats can also allow for duplicate indices or unsorted indices; for example SuiteSparse:GraphBLAS import and export of CSR allows the column indices to be unsorted. + +Let us assume that the _standard_ storage formats that we are designing will have unique indices, and the indices will be sorted lexicographically by `indices_0`, `indices_1`, etc. + +_Remark:_ it would be nice to easily allow extensions to our specification so that e.g. SuiteSparse:GraphBLAS could keep data unsorted. Data readers should fail when reading unknown extensions that break the standard storage format. + +#### Names of compression types + +Indices for a dimension may be compressed in three different ways: like COO, CSR, or DCSR. Let's give these names: + +| Name | Abbv | `indices_i` | `pointers_i` | Like | +| -- | :--: | :--: | :--: | :--: | +| **sparse** | **`S`** | Yes | | COO | +| **compressed** | **`C`** | | Yes | CSR | +| **doubly compressed** | **`DC`** | Yes | Yes | DCSR | + +- **"sparse" (`S`)** dimension indices are aligned to the indices of the following dimension (or values if the final dimension) + - `len(indices_i) == len(indices_{i+1})`, or `len(indices_i) == len(values)` if the final dimension +- **"compressed" (`C`)** dimension allows fast O(1) lookup by the index into the pointers array + - The previous dimension does not need to store `pointers_{i-1}` +- **"doubly compressed" (`DC`)** stores unique index values (so O(1) lookup isn't possible) and pointers to the next dimension + - `len(pointers_i) == len(indices_i) + 1` + +The final dimension must be "sparse" (`S`). The compression schemes for rank 2 arrays are: + +| Dim 0 | Dim 1 | Ordering | Abbv | +| :--: | :--: | :--: | :--: | +| C
compressed | S
sparse | R
`[0, 1]` | CSR | +| C
compressed | S
sparse | C
`[1, 0]` | CSC | +| DC
doubly compressed | S
sparse | R
`[0, 1]` | DCSR | +| DC
doubly compressed | S
sparse | C
`[1, 0]` | DCSC | +| S
sparse | S
sparse | R
`[0, 1]` | SSR | +| S
sparse | S
sparse | C
`[1, 0]` | SSC | + +CSR, CSC, DCSR, and DCSC are familiar and keep their original meanings. + +#### COO + +SSR and SSC in the previous table are new and are instances of COO with sorted indices and no duplicates (according to our simplifying assumptions). SSR indices are lexicographically sorted by row then column, and a backronym could be "sorted sparse rows". Conversely, SSC indices are lexicographically sorted by column then row, and a backronym could be "sorted sparse columns". + +We can consider also keeping COO as a type of compression. COO does not need to be sorted, and metadata can indicate whether or not it may have duplicate indices. + +#### Dense dimensions or multidimensional values array + +Examples of structures with dense dimensions are dense vectors, dense matrices, and sparse vectors where each value is a dense array (so it's actually a matrix). It is an open question if and how we want to handle these. It may be straightforward to support this by allowing the values array to be N-dimensional and have metadata that indicates the shape and layout. + +Per our language, we do not consider CSR to have any dense dimensions. Dense dimensions are those that can be combined into a dense, multidimensional values array. + +#### Multiple value arrays + +It may be reasonable for the same sparse structure to have multiple value arrays. This is another open design question. + +Supporting rank N arrays probably doesn't constrain how we may support having multiple value arrays. A potential complication is when one values array is a scalar per element, and another is an array per element. + +#### Attributes + +It may be useful to store attributes such as `is_symmetric`, `is_structure_symmetric`, `is_upper_triangular`, `ndiag`, etc. It may be more complicated to have attributes like this in a way that generalizes to higher dimensions. + +### Rank N arrays + +#### Names of constituent arrays + +Use `indices_0`, `pointers_0`, `indices_1`, `pointers_1`, ..., `indices_{N-1}`. + +#### Dimension order + +Use `axis_order` with the same semantics as `dimOrdering` in MLIR sparse tensor dialect. + + + +We can reuse "R" to mean regular ordering `axis_order=[0, 1, ..., N-1]` and "C" to mean contrary ordering `axis_order=[N-1, N-2, ..., 1, 0]`. Perhaps we can use "X" to indicate any other ordering. + +#### Compression types + +The last dimension must be "sparse" (`S`). All other dimensions may be sparse (`S`), compressed (`C`), or doubly compressed (`DC`). This fully supports the TACO and MLIR sparse tensor formats. + +For larger dimensions, it is sometimes more clear to separate the abbreviated structure with hyphens. For example, `C-DC-S-S-R` instead of `CDCSSR`. + +**Examples:** + +**`DC-DC-DC-S`** + +![](img/DC-DC-DC-S.svg) + +**`S-C-DC-S`** + +![](img/S-C-DC-S.svg) + +See more examples of different compression types on a rank 4 array here: + +https://nbviewer.org/github/eriknw/binsparse-specification/blob/spz/spz_python/notebooks/Example_Rank4.ipynb + + + +#### COO + +As with rank 2, we can support sorted COO without duplicates as e.g. SSSSSSR. + +We can consider supporting rank N COO that is unsorted and may have duplicates. + +#### Dense dimensions or multidimensional values array + +Probably no change necessary to support rank N. + +This is important to support in order to fully match TACO and MLIR sparse tensor. + +This is also necessary to support semi-COO (sCOO): +- ["Optimizing Sparse Tensor Times Matrix on +Multi-core and Many-core Architectures" by Jiajia Li, et al +](http://fruitfly1026.github.io/static/files/sc16-ia3.pdf) + +#### Multiple value arrays + +Probably no change necessary to support rank N. + +#### Different jargon + +Sparse compression of rank N arrays is an active area of research, and users of that community may prefer the use of different jargon. For example, _modes_ (the order of dimensions), _fibers_, and _slices_. Also, _tensor_ is generally understood to be a multidimensional array, but may have different meanings for physicists, mathematicians, Python users (e.g., a tensor is an N-D array that can use GPUs), etc. + +#### Chunking strategies + +Not determined for ranks 1 and 2 yet, but probably little to no change necessary to support rank N. + +We may want to consider whether our strategy can support HiCOO: +- https://sc17.supercomputing.org/SC17%20Archive/tech_poster/poster_files/post213s2-file3.pdf +- http://fruitfly1026.github.io/static/files/sc18-li.pdf + +### Differences from TACO and MLIR sparse tensor + +Our proposal uses different naming schemes than TACO and MLIR sparse tensor, which use: + +| Type | Dim 0 | Dim 1 | +| -- | :--: | :--: | +| CSR | dense | compressed | +| DCSR | compressed | compressed | +| DCSR (alt) | singleton | compressed | +| COO | singleton | singleton | + +- "dense" dimensions store no arrays +- "compressed" dimension store `pointers_i` and `indices_i` arrays +- "singleton" dimension store `indices_i` arrays + +Note that TACO does not support "singleton" compression, and "singleton" may not be fully supported yet in MLIR sparse tensor. + +The main difference from our proposal is the use of `pointer_i`. In TACO and MLIR sparse tensor, `pointers_i` groups the _previous_ indices to the current indices. In our proposal, `pointers_i` groups the current indices to the _next_ indices. + +In TACO, DCSR is constructed using "compressed", "compressed" dimensions. This results in _two_ `pointers` arrays, which is not standard DCSR. Only one `pointers` array is necessary. In MLIR, there are two ways to specify DCSR arrays. Our proposal only has one way to specify DCSR, and it does not have an extra, unnecessary `pointers` array. + +It is straightforward to convert from our specification to MLIR sparse tensor specification: +1. Increment `pointers` arrays, so e.g. `pointers_0` becomes `mlir_pointers_1` +2. If a dimension has both `mlir_pointers_i` and `indices_i`, then it is MLIR's "compressed" +3. If a dimension has only `indices_i`, then it is MLIR's "singleton" +4. If a dimension does not have `mlir_pointers_i` or `indices_i`, then it is MLIR's "dense" + +### Extensions + +#### Multigraph support + +It would be easy support multigraphs, which can have multiple edges between nodes. This is done by allowing duplicate indices so an index can have multiple values. COO naturally supports this. Other formats can as well. + +Our proposal needs two changes to support multigraphs: +1. Allow the final dimension to be "compressed" (`C`) or "doubly compressed" (`DC`) where the pointers group indices to values +2. Add a flag to the global metadata to indicate whether there may be duplicate indices + +Observe that this is a natural, "obvious" consequence of our proposal, whereas TACO and MLIR sparse tensor cannot support multigraphs like this without adding another dimension. + +This gives us two more compression types for vectors ("compressed" and "doubly compressed"), and 12 more compression types for matrices (`SCR`, `SDCR`, `CCR`, `CDCR`, `DCCR`, `DCDCR` and the columnwise variants). These should only be used for multigraphs. + +#### Unsorted dimensions + +Indices in "sparse" and "doubly compressed" dimensions do not need to be sorted, but `pointers` boundaries must still be respected. For example, import and export in SuiteSparse:GraphBLAS supports unsorted column indices within each row for CSR and DCSR. + +If there are multiple sequential "sparse" dimensions (such as COO), only the first one needs to indicate that it is unsorted. This is because sortedness only applies to indices between pointers; for example, column indices for a given row in CSR are between pointers. Furthermore, if a "sparse" dimension _did_ store pointers, it would be `[0, 1, 2, ..., N]`, which means there is only one index in the next dimension that is grouped between pointers, and sortedness of a single element is extraneous. + +This could be supported by adding a flag to each "sparse" and "doubly compressed" dimension. + +#### Balanced CSF + +This is an extension to "doubly compressed" dimensions based on B-CSF in ["Load-Balanced Sparse MTTKRP on GPUs" by Israt Nisa, et al](https://arxiv.org/pdf/1904.03329.pdf). It allows indices in "doubly compressed" dimensions to be duplicated in order for subtrees to be more comparably sized. + +This could be supported by adding a flag to each "doubly compressed" dimension. + +#### Different sub-tree compressions + +Sometimes compression can be improved by using different compression schemes for different groups of indices. Examples: + +- HB-CSF: https://arxiv.org/pdf/1904.03329.pdf +- MM-CSF: https://par.nsf.gov/servlets/purl/10172913 + +This may be challenging or complicated to support. \ No newline at end of file diff --git a/design_docs/img/DC-DC-DC-S.svg b/design_docs/img/DC-DC-DC-S.svg new file mode 100644 index 0000000..3108232 --- /dev/null +++ b/design_docs/img/DC-DC-DC-S.svg @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + i0 + + i1 + + i2 + + i3 + p0 + p1 + p2 + + + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 2 + 2 + 1 + 0 + 0 + 2 + 2 + 4 + 1 + 0 + 3 + 5 + 1 + 1 + 1 + 0 + 3 + 4 + 1 + 2 + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/design_docs/img/S-C-DC-S.svg b/design_docs/img/S-C-DC-S.svg new file mode 100644 index 0000000..bd3279c --- /dev/null +++ b/design_docs/img/S-C-DC-S.svg @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + i0 + + i1 + + i2 + + i3 + + 0 + + 1 + + 1 + p0 + p1 + p2 + + + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 2 + 2 + 0 + 0 + 0 + 2 + 2 + 4 + 1 + 0 + 1 + 0 + 3 + 3 + 5 + 3 + 1 + 1 + 0 + 4 + 4 + 1 + 2 + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spz_python/.gitattributes b/spz_python/.gitattributes new file mode 100644 index 0000000..637e4c5 --- /dev/null +++ b/spz_python/.gitattributes @@ -0,0 +1 @@ +spz/_version.py export-subst diff --git a/spz_python/LICENSE b/spz_python/LICENSE new file mode 100644 index 0000000..a0cba38 --- /dev/null +++ b/spz_python/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2022, GraphBLAS +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/spz_python/MANIFEST.in b/spz_python/MANIFEST.in new file mode 100644 index 0000000..fa655e9 --- /dev/null +++ b/spz_python/MANIFEST.in @@ -0,0 +1,6 @@ +recursive-include spz *.py +include setup.py +include README.md +include LICENSE +include MANIFEST.in +include versioneer.py diff --git a/spz_python/README.md b/spz_python/README.md new file mode 100644 index 0000000..e69de29 diff --git a/spz_python/conftest.py b/spz_python/conftest.py new file mode 100644 index 0000000..b6f5cc2 --- /dev/null +++ b/spz_python/conftest.py @@ -0,0 +1,2 @@ +def pytest_addoption(parser): + parser.addoption("--runslow", default=None, action="store_true", help="run slow tests") diff --git a/spz_python/notebooks/Example_Rank4.ipynb b/spz_python/notebooks/Example_Rank4.ipynb new file mode 100644 index 0000000..c2f760e --- /dev/null +++ b/spz_python/notebooks/Example_Rank4.ipynb @@ -0,0 +1,18689 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1d023620", + "metadata": {}, + "source": [ + "# Examples for rank 4 array\n", + "\n", + "Pass COO-like data to `SPZ` with one array of indices for each dimension.\n", + "\n", + "The default is to create CSF sparse data structure where all but the last dimension are doubly compressed." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "3f4ad63f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |----|0 |-+--|1 |\n", + "`--' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |----|1 |----|1 |-+--|0 |\n", + "`--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from spz import SPZ\n", + "import itertools\n", + "import IPython\n", + "\n", + "indices = [\n", + " [0, 0, 0, 0, 0, 1, 1, 1],\n", + " [0, 0, 1, 1, 1, 1, 1, 1],\n", + " [0, 0, 0, 0, 1, 1, 1, 1],\n", + " [1, 2, 0, 2, 0, 0, 1, 2],\n", + "]\n", + "sp = SPZ(indices)\n", + "# Display as SVG diagram\n", + "sp" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "833d4e98", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[array([0, 1]),\n", + " array([0, 1, 1]),\n", + " array([0, 0, 1, 1]),\n", + " array([1, 2, 0, 2, 0, 0, 1, 2])]" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.indices" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "e3399807", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[array([0, 2, 3]), array([0, 1, 3, 4]), array([0, 2, 4, 5, 8])]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.pointers" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "e0bdf4f2", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |----|0 |-+--|1 |\n", + "`--' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |----|1 |----|1 |-+--|0 |\n", + "`--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'\n" + ] + } + ], + "source": [ + "# Can also display as ASCII diagram\n", + "print(sp)" + ] + }, + { + "cell_type": "markdown", + "id": "1092fc4b", + "metadata": {}, + "source": [ + "This diagram forms a tree-like structure where the first dimension is on the left and last dimension is on the right.\n", + "\n", + "Index values are in boxes, and pointer values are next to edges.\n", + "\n", + "We can choose how each dimension is compressed:\n", + "- **`S`, \"sparse\"**: like COO; indices are \"aligned\" to the following dimension indices or values.\n", + " - Uses: `indices_i`\n", + "- **`C`, \"compressed sparse\"**: like CSR; fast lookup by index into pointers to the next dimension.\n", + " - Uses: `pointers_i`\n", + " - Makes `pointers_{i-1}` unnecessary\n", + "- **`DC`, \"doubly compressed sparse\"**: like DCSR; store unique index values and pointers to the next dimension.\n", + " - Uses: `pointers_i`, `indices_i`\n", + "\n", + "Currently, the final dimension must be sparse, **`S`**.\n", + "\n", + "Hence, describing the structures of **CSR, CSC, DCSR, and DCSC** give us... CSR, CSC, DCSR, and DCSC (let's address the final \"R\" and \"C\" later)." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "b8253a23", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[doubly_compressed, doubly_compressed, doubly_compressed, sparse]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.structure" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "ec61aa11", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'DC-DC-DC-S'" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.abbreviation" + ] + }, + { + "cell_type": "markdown", + "id": "51842351", + "metadata": {}, + "source": [ + "## Display all sparse structures that are independent of shape\n", + "\n", + "This includes sparse structures that have no \"compressed sparse\" (**`C`**) dimensions.\n", + "\n", + "Hyphonated connecting lines indicate pointers that don't need stored." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "232210ab", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "# `S-S-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 3\n", + " 3\n", + " 3\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 4\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 1\n", + " 1\n", + " 7\n", + " 7\n", + " 7\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |~~~~|0 |~~~~|0 |~~~~|1 |\n", + "`--' 1 `--' 1 `--' 1 `--'\n", + ".--. .--. .--. .--.\n", + "|0 |~~~~|0 |~~~~|0 |~~~~|2 |\n", + "`--' 2 `--' 2 `--' 2 `--'\n", + ".--. .--. .--. .--.\n", + "|0 |~~~~|1 |~~~~|0 |~~~~|0 |\n", + "`--' 3 `--' 3 `--' 3 `--'\n", + ".--. .--. .--. .--.\n", + "|0 |~~~~|1 |~~~~|0 |~~~~|2 |\n", + "`--' 4 `--' 4 `--' 4 `--'\n", + ".--. .--. .--. .--.\n", + "|0 |~~~~|1 |~~~~|1 |~~~~|0 |\n", + "`--' 5 `--' 5 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |~~~~|1 |~~~~|0 |\n", + "`--' 6 `--' 6 `--' 6 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |~~~~|1 |~~~~|1 |\n", + "`--' 7 `--' 7 `--' 7 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |~~~~|1 |~~~~|2 |\n", + "`--' 8 `--' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-S-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |~~~~|0 |~~~~|0 |-+--|1 |\n", + "`--' 1 `--' 1 `--' `--|2 |\n", + ".--. .--. .--. 2 |--|\n", + "|0 |~~~~|1 |~~~~|0 |-+--|0 |\n", + "`--' 2 `--' 2 `--' `--|2 |\n", + ".--. .--. .--. 4 |--|\n", + "|0 |~~~~|1 |~~~~|1 |----|0 |\n", + "`--' 3 `--' 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |~~~~|1 |-+--|0 |\n", + "`--' 4 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-DC-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |~~~~|0 |-+--|0 |~~~~|1 |\n", + "`--' 1 `--' | `--' 1 `--'\n", + " | .--. .--.\n", + " `--|0 |~~~~|2 |\n", + " 2 `--' 2 `--'\n", + ".--. .--. .--. .--.\n", + "|0 |~~~~|1 |-+--|0 |~~~~|0 |\n", + "`--' 2 `--' | `--' 3 `--'\n", + " | .--. .--.\n", + " |--|0 |~~~~|2 |\n", + " | `--' 4 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|0 |\n", + " 5 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |-+--|1 |~~~~|0 |\n", + "`--' 3 `--' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-DC-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |~~~~|0 |----|0 |-+--|1 |\n", + "`--' 1 `--' 1 `--' `--|2 |\n", + ".--. .--. .--. 2 |--|\n", + "|0 |~~~~|1 |-+--|0 |-+--|0 |\n", + "`--' 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |----|1 |-+--|0 |\n", + "`--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-S-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 3\n", + " 3\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 1\n", + " 7\n", + " 7\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |~~~~|0 |~~~~|1 |\n", + "`--' | `--' 1 `--' 1 `--'\n", + " | .--. .--. .--.\n", + " |--|0 |~~~~|0 |~~~~|2 |\n", + " | `--' 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|0 |\n", + " | `--' 3 `--' 3 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|2 |\n", + " | `--' 4 `--' 4 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|0 |\n", + " 5 `--' 5 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |-+--|1 |~~~~|1 |~~~~|0 |\n", + "`--' | `--' 6 `--' 6 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|1 |~~~~|1 |\n", + " | `--' 7 `--' 7 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|2 |\n", + " 8 `--' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-S-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |~~~~|0 |-+--|1 |\n", + "`--' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " |--|1 |~~~~|0 |-+--|0 |\n", + " | `--' 2 `--' `--|2 |\n", + " | .--. .--. 4 |--|\n", + " `--|1 |~~~~|1 |----|0 |\n", + " 3 `--' 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |----|1 |~~~~|1 |-+--|0 |\n", + "`--' 4 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-DC-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |-+--|0 |~~~~|1 |\n", + "`--' | `--' | `--' 1 `--'\n", + " | | .--. .--.\n", + " | `--|0 |~~~~|2 |\n", + " | 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |-+--|0 |~~~~|0 |\n", + " 2 `--' | `--' 3 `--'\n", + " | .--. .--.\n", + " |--|0 |~~~~|2 |\n", + " | `--' 4 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|0 |\n", + " 5 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |----|1 |-+--|1 |~~~~|0 |\n", + "`--' 3 `--' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-DC-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |----|0 |-+--|1 |\n", + "`--' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |----|1 |----|1 |-+--|0 |\n", + "`--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sparsities = [\"S\", \"DC\"]\n", + "for sparsity in itertools.product(sparsities, sparsities, sparsities, [\"S\"]):\n", + " structure = \"-\".join(sparsity)\n", + " IPython.display.display(IPython.display.Markdown(f\"# `{structure}`\"))\n", + " IPython.display.display(SPZ(indices, structure=structure))" + ] + }, + { + "cell_type": "markdown", + "id": "eec6fad5", + "metadata": {}, + "source": [ + "## Display sparse structures, `shape=(2, 2, 2, 3)`\n", + "\n", + "Hyphonated boxes indicate indices that don't need stored.\n", + "\n", + "For compressed sparse dimensions, `C`, some repeated pointer values may be skipped if there is no room" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "c8e1d2a7", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "# S-S-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |~~~~|0 |~~~~┊0 ┊-+--|1 |\n", + "`--' 1 `--' 1 `~~' `--|2 |\n", + ".--. .--. .~~. 2 `--'\n", + "|0 |~~~~|0 |~~~~┊1 ┊)\n", + "`--' 2 `--' 2 `~~'\n", + ".--. .--. .~~. 2 .--.\n", + "|0 |~~~~|1 |~~~~┊0 ┊-+--|0 |\n", + "`--' 3 `--' 3 `~~' `--|2 |\n", + ".--. .--. .~~. 4 |--|\n", + "|0 |~~~~|1 |~~~~┊1 ┊----|0 |\n", + "`--' 4 `--' 4 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|1 |~~~~|1 |~~~~┊0 ┊)\n", + "`--' 5 `--' 5 `~~'\n", + ".--. .--. .~~. 5 .--.\n", + "|1 |~~~~|1 |~~~~┊1 ┊-+--|0 |\n", + "`--' 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# S-C-S-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~~~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`--' 1 `~~' | `--' 1 `--'\n", + " | .--. .--.\n", + " `--|0 |~~~~|2 |\n", + " 2 `--' 2 `--'\n", + ".--. .~~. .--. .--.\n", + "|0 |~~~~┊1 ┊-+--|0 |~~~~|0 |\n", + "`--' 2 `~~' | `--' 3 `--'\n", + ".--. .~~. | .--. .--.\n", + "|1 |~~~~┊0 ┊)|--|0 |~~~~|2 |\n", + "`--' 3 `~~' | `--' 4 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|0 |\n", + " 5 `--' 5 `--'\n", + ".--. .~~. 5 .--. .--.\n", + "|1 |~~~~┊1 ┊-+--|1 |~~~~|0 |\n", + "`--' 4 `~~' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# S-C-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 3\n", + " 1\n", + " 6\n", + " 1\n", + " 0\n", + " 4\n", + " 5\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 5\n", + " 5\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .~~~. .---.\n", + "|i0 |p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`---' `~~~' `~~~' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .~~. 0 .--.\n", + "|0 |~~~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`--' 1 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 2 `--'\n", + " `~~┊1 ┊)\n", + " 2 `~~'\n", + ".--. .~~. .~~. 2 .--.\n", + "|0 |~~~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + "`--' 2 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".--. .~~. .~~.\n", + "|1 |~~~~┊0 ┊~+~~┊0 ┊)\n", + "`--' 3 `~~' ┊ `~~'\n", + " ┊ .~~. 5\n", + " `~~┊1 ┊)\n", + " 6 `~~'\n", + ".--. .~~. .~~. 5\n", + "|1 |~~~~┊1 ┊~+~~┊0 ┊)\n", + "`--' 4 `~~' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 8 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# S-C-DC-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~~~~┊0 ┊----|0 |-+--|1 |\n", + "`--' 1 `~~' 1 `--' `--|2 |\n", + ".--. .~~. .--. 2 |--|\n", + "|0 |~~~~┊1 ┊-+--|0 |-+--|0 |\n", + "`--' 2 `~~' | `--' `--|2 |\n", + ".--. .~~. | .--. 4 |--|\n", + "|1 |~~~~┊0 ┊)`--|1 |----|0 |\n", + "`--' 3 `~~' 3 `--' 5 `--'\n", + ".--. .~~. 3 .--. .--.\n", + "|1 |~~~~┊1 ┊----|1 |-+--|0 |\n", + "`--' 4 `~~' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# S-DC-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |~~~~|0 |~+~~┊0 ┊-+--|1 |\n", + "`--' 1 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 2 `--'\n", + " `~~┊1 ┊)\n", + " 2 `~~'\n", + ".--. .--. .~~. 2 .--.\n", + "|0 |~~~~|1 |~+~~┊0 ┊-+--|0 |\n", + "`--' 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|1 |~~~~|1 |~+~~┊0 ┊)\n", + "`--' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-S-S-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 3\n", + " 3\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 1\n", + " 7\n", + " 7\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~|0 |~~~~|1 |\n", + "`~~' | `--' 1 `--' 1 `--'\n", + " | .--. .--. .--.\n", + " |--|0 |~~~~|0 |~~~~|2 |\n", + " | `--' 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|0 |\n", + " | `--' 3 `--' 3 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|2 |\n", + " | `--' 4 `--' 4 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|0 |\n", + " 5 `--' 5 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊-+--|1 |~~~~|1 |~~~~|0 |\n", + "`~~' | `--' 6 `--' 6 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|1 |~~~~|1 |\n", + " | `--' 7 `--' 7 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|2 |\n", + " 8 `--' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-S-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .~~~. .---.\n", + "┊i0 ┊p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `---' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .~~. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~┊0 ┊-+--|1 |\n", + "`~~' | `--' 1 `~~' `--|2 |\n", + " | .--. .~~. 2 `--'\n", + " |--|0 |~~~~┊1 ┊)\n", + " | `--' 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " |--|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 3 `~~' `--|2 |\n", + " | .--. .~~. 4 |--|\n", + " `--|1 |~~~~┊1 ┊----|0 |\n", + " 4 `--' 4 `~~' 5 `--'\n", + ".~~. .--. .~~.\n", + "┊1 ┊-+--|1 |~~~~┊0 ┊)\n", + "`~~' | `--' 5 `~~'\n", + " | .--. .~~. 5 .--.\n", + " `--|1 |~~~~┊1 ┊-+--|0 |\n", + " 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-S-DC-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~|0 |-+--|1 |\n", + "`~~' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " |--|1 |~~~~|0 |-+--|0 |\n", + " | `--' 2 `--' `--|2 |\n", + " | .--. .--. 4 |--|\n", + " `--|1 |~~~~|1 |----|0 |\n", + " 3 `--' 3 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |~~~~|1 |-+--|0 |\n", + "`~~' 4 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-C-S-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 4\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .~~~. .---. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`~~~' `~~~' `---' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .--. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`~~' ┊ `~~' | `--' 1 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|0 |~~~~|2 |\n", + " ┊ 2 `--' 2 `--'\n", + " ┊ .~~. .--. .--.\n", + " `~~┊1 ┊-+--|0 |~~~~|0 |\n", + " 2 `~~' | `--' 3 `--'\n", + ".~~. .~~. | .--. .--.\n", + "┊1 ┊~+~~┊0 ┊)|--|0 |~~~~|2 |\n", + "`~~' ┊ `~~' | `--' 4 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|1 |~~~~|0 |\n", + " ┊ 5 `--' 5 `--'\n", + " ┊ .~~. 5 .--. .--.\n", + " `~~┊1 ┊-+--|1 |~~~~|0 |\n", + " 4 `~~' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-C-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 0\n", + " 1\n", + " 6\n", + " 0\n", + " 4\n", + " 5\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 5\n", + " 5\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .~~~. .~~~. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `~~~' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .~~. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`~~' ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 2 `--'\n", + " ┊ `~~┊1 ┊)\n", + " ┊ 2 `~~'\n", + " ┊ .~~. .~~. 2 .--.\n", + " `~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + " 2 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".~~. .~~. .~~.\n", + "┊1 ┊~+~~┊0 ┊~+~~┊0 ┊)\n", + "`~~' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ `~~┊1 ┊)\n", + " ┊ 6 `~~'\n", + " ┊ .~~. .~~. 5\n", + " `~~┊1 ┊~+~~┊0 ┊)\n", + " 4 `~~' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 8 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-C-DC-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .~~~. .---. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`~~~' `~~~' `---' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .--. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊----|0 |-+--|1 |\n", + "`~~' ┊ `~~' 1 `--' `--|2 |\n", + " ┊ .~~. .--. 2 |--|\n", + " `~~┊1 ┊-+--|0 |-+--|0 |\n", + " 2 `~~' | `--' `--|2 |\n", + ".~~. .~~. | .--. 4 |--|\n", + "┊1 ┊~+~~┊0 ┊)`--|1 |----|0 |\n", + "`~~' ┊ `~~' 3 `--' 5 `--'\n", + " ┊ .~~. 3 .--. .--.\n", + " `~~┊1 ┊----|1 |-+--|0 |\n", + " 4 `~~' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-DC-S-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |-+--|0 |~~~~|1 |\n", + "`~~' | `--' | `--' 1 `--'\n", + " | | .--. .--.\n", + " | `--|0 |~~~~|2 |\n", + " | 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |-+--|0 |~~~~|0 |\n", + " 2 `--' | `--' 3 `--'\n", + " | .--. .--.\n", + " |--|0 |~~~~|2 |\n", + " | `--' 4 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|0 |\n", + " 5 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |-+--|1 |~~~~|0 |\n", + "`~~' 3 `--' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-DC-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .~~~. .---.\n", + "┊i0 ┊p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `---' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .~~. 0 .--.\n", + "┊0 ┊-+--|0 |~+~~┊0 ┊-+--|1 |\n", + "`~~' | `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | `~~┊1 ┊)\n", + " | 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " `--|1 |~+~~┊0 ┊-+--|0 |\n", + " 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".~~. .--. .~~.\n", + "┊1 ┊----|1 |~+~~┊0 ┊)\n", + "`~~' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-DC-DC-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |----|0 |-+--|1 |\n", + "`~~' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |----|1 |-+--|0 |\n", + "`~~' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# DC-S-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |-+--|0 |~~~~┊0 ┊-+--|1 |\n", + "`--' | `--' 1 `~~' `--|2 |\n", + " | .--. .~~. 2 `--'\n", + " |--|0 |~~~~┊1 ┊)\n", + " | `--' 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " |--|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 3 `~~' `--|2 |\n", + " | .--. .~~. 4 |--|\n", + " `--|1 |~~~~┊1 ┊----|0 |\n", + " 4 `--' 4 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|1 |-+--|1 |~~~~┊0 ┊)\n", + "`--' | `--' 5 `~~'\n", + " | .--. .~~. 5 .--.\n", + " `--|1 |~~~~┊1 ┊-+--|0 |\n", + " 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# DC-C-S-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 4\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~+~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`--' ┊ `~~' | `--' 1 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|0 |~~~~|2 |\n", + " ┊ 2 `--' 2 `--'\n", + " ┊ .~~. .--. .--.\n", + " `~~┊1 ┊-+--|0 |~~~~|0 |\n", + " 2 `~~' | `--' 3 `--'\n", + ".--. .~~. | .--. .--.\n", + "|1 |~+~~┊0 ┊)|--|0 |~~~~|2 |\n", + "`--' ┊ `~~' | `--' 4 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|1 |~~~~|0 |\n", + " ┊ 5 `--' 5 `--'\n", + " ┊ .~~. 5 .--. .--.\n", + " `~~┊1 ┊-+--|1 |~~~~|0 |\n", + " 4 `~~' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# DC-C-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 1\n", + " 6\n", + " 0\n", + " 4\n", + " 5\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 5\n", + " 5\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .~~~. .---.\n", + "|i0 |p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`---' `~~~' `~~~' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .~~. 0 .--.\n", + "|0 |~+~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`--' ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 2 `--'\n", + " ┊ `~~┊1 ┊)\n", + " ┊ 2 `~~'\n", + " ┊ .~~. .~~. 2 .--.\n", + " `~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + " 2 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".--. .~~. .~~.\n", + "|1 |~+~~┊0 ┊~+~~┊0 ┊)\n", + "`--' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ `~~┊1 ┊)\n", + " ┊ 6 `~~'\n", + " ┊ .~~. .~~. 5\n", + " `~~┊1 ┊~+~~┊0 ┊)\n", + " 4 `~~' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 8 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# DC-C-DC-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~+~~┊0 ┊----|0 |-+--|1 |\n", + "`--' ┊ `~~' 1 `--' `--|2 |\n", + " ┊ .~~. .--. 2 |--|\n", + " `~~┊1 ┊-+--|0 |-+--|0 |\n", + " 2 `~~' | `--' `--|2 |\n", + ".--. .~~. | .--. 4 |--|\n", + "|1 |~+~~┊0 ┊)`--|1 |----|0 |\n", + "`--' ┊ `~~' 3 `--' 5 `--'\n", + " ┊ .~~. 3 .--. .--.\n", + " `~~┊1 ┊----|1 |-+--|0 |\n", + " 4 `~~' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# DC-DC-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |-+--|0 |~+~~┊0 ┊-+--|1 |\n", + "`--' | `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | `~~┊1 ┊)\n", + " | 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " `--|1 |~+~~┊0 ┊-+--|0 |\n", + " 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|1 |----|1 |~+~~┊0 ┊)\n", + "`--' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sparsities = [\"S\", \"C\", \"DC\"]\n", + "for sparsity in itertools.product(sparsities, sparsities, sparsities, [\"S\"]):\n", + " if \"C\" not in sparsity:\n", + " continue\n", + " structure = \"-\".join(sparsity)\n", + " IPython.display.display(IPython.display.Markdown(f\"# {structure}\"))\n", + " IPython.display.display(SPZ(indices, shape=(2, 2, 2, 3), structure=structure))" + ] + }, + { + "cell_type": "markdown", + "id": "1131a918", + "metadata": {}, + "source": [ + "## Display sparse structures, `shape=(3, 3, 3, 3)`" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "95577c70", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "# S-S-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 3\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 0\n", + " 1\n", + " 2\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 0\n", + " 7\n", + " 7\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 8\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 5\n", + " 1\n", + " 1\n", + " 2\n", + " 9\n", + " 9\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |~~~~|0 |~~~~┊0 ┊-+--|1 |\n", + "`--' 1 `--' 1 `~~' `--|2 |\n", + ".--. .--. .~~. 2 `--'\n", + "|0 |~~~~|0 |~~~~┊1 ┊)\n", + "`--' 2 `--' 2 `~~'\n", + ".--. .--. .~~. 2\n", + "|0 |~~~~|0 |~~~~┊2 ┊)\n", + "`--' 3 `--' 3 `~~'\n", + ".--. .--. .~~. 2 .--.\n", + "|0 |~~~~|1 |~~~~┊0 ┊-+--|0 |\n", + "`--' 4 `--' 4 `~~' `--|2 |\n", + ".--. .--. .~~. 4 |--|\n", + "|0 |~~~~|1 |~~~~┊1 ┊----|0 |\n", + "`--' 5 `--' 5 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|0 |~~~~|1 |~~~~┊2 ┊)\n", + "`--' 6 `--' 6 `~~'\n", + ".--. .--. .~~. 5\n", + "|1 |~~~~|1 |~~~~┊0 ┊)\n", + "`--' 7 `--' 7 `~~'\n", + ".--. .--. .~~. 5 .--.\n", + "|1 |~~~~|1 |~~~~┊1 ┊-+--|0 |\n", + "`--' 8 `--' 8 `~~' |--|1 |\n", + " `--|2 |\n", + ".--. .--. .~~. 8 `--'\n", + "|1 |~~~~|1 |~~~~┊2 ┊)\n", + "`--' 9 `--' 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# S-C-S-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 0\n", + " 2\n", + " 3\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 4\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 6\n", + " 1\n", + " 2\n", + " 1\n", + " 1\n", + " 6\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~~~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`--' 1 `~~' | `--' 1 `--'\n", + " | .--. .--.\n", + " `--|0 |~~~~|2 |\n", + " 2 `--' 2 `--'\n", + ".--. .~~. .--. .--.\n", + "|0 |~~~~┊1 ┊-+--|0 |~~~~|0 |\n", + "`--' 2 `~~' | `--' 3 `--'\n", + ".--. .~~. | .--. .--.\n", + "|0 |~~~~┊2 ┊)|--|0 |~~~~|2 |\n", + "`--' 3 `~~' | `--' 4 `--'\n", + ".--. .~~. | .--. .--.\n", + "|1 |~~~~┊0 ┊)`--|1 |~~~~|0 |\n", + "`--' 4 `~~' 5 `--' 5 `--'\n", + ".--. .~~. 5 .--. .--.\n", + "|1 |~~~~┊1 ┊-+--|1 |~~~~|0 |\n", + "`--' 5 `~~' | `--' 6 `--'\n", + ".--. .~~. | .--. .--.\n", + "|1 |~~~~┊2 ┊)|--|1 |~~~~|1 |\n", + "`--' 6 `~~' | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# S-C-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 0\n", + " 0\n", + " 3\n", + " \n", + " 1\n", + " 2\n", + " 9\n", + " 1\n", + " 0\n", + " 4\n", + " \n", + " 1\n", + " 2\n", + " 12\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 15\n", + " 1\n", + " 0\n", + " 6\n", + " \n", + " 1\n", + " 2\n", + " 18\n", + " 2\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .~~~. .---.\n", + "|i0 |p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`---' `~~~' `~~~' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .~~. 0 .--.\n", + "|0 |~~~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`--' 1 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 2 `--'\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 2\n", + " `~~┊2 ┊)\n", + " 3 `~~'\n", + ".--. .~~. .~~. 2 .--.\n", + "|0 |~~~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + "`--' 2 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " ┊~~┊1 ┊----|0 |\n", + " ┊ `~~' 5 `--'\n", + " ┊ .~~.\n", + " `~~┊2 ┊)\n", + " 6 `~~'\n", + ".--. .~~. .~~. 5\n", + "|0 |~~~~┊2 ┊~+~~┊0 ┊)\n", + "`--' 3 `~~' ┊ `~~'\n", + " ┊ .~~. 5\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 5\n", + " `~~┊2 ┊)\n", + " 9 `~~'\n", + ".--. .~~. .~~. 5\n", + "|1 |~~~~┊0 ┊~+~~┊0 ┊)\n", + "`--' 4 `~~' ┊ `~~'\n", + " ┊ .~~. 5\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 5\n", + " `~~┊2 ┊)\n", + " 12 `~~'\n", + ".--. .~~. .~~. 5\n", + "|1 |~~~~┊1 ┊~+~~┊0 ┊)\n", + "`--' 5 `~~' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " ┊~~┊1 ┊-+--|0 |\n", + " ┊ `~~' |--|1 |\n", + " ┊ `--|2 |\n", + " ┊ .~~. 8 `--'\n", + " `~~┊2 ┊)\n", + " 15 `~~'\n", + ".--. .~~. .~~. 8\n", + "|1 |~~~~┊2 ┊~+~~┊0 ┊)\n", + "`--' 6 `~~' ┊ `~~'\n", + " ┊ .~~. 8\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 8\n", + " `~~┊2 ┊)\n", + " 18 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# S-C-DC-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 0\n", + " 4\n", + " 3\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 4\n", + " 1\n", + " 2\n", + " 1\n", + " 2\n", + " 8\n", + " 6\n", + " 4\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~~~~┊0 ┊----|0 |-+--|1 |\n", + "`--' 1 `~~' 1 `--' `--|2 |\n", + ".--. .~~. .--. 2 |--|\n", + "|0 |~~~~┊1 ┊-+--|0 |-+--|0 |\n", + "`--' 2 `~~' | `--' `--|2 |\n", + ".--. .~~. | .--. 4 |--|\n", + "|0 |~~~~┊2 ┊)`--|1 |----|0 |\n", + "`--' 3 `~~' 3 `--' 5 `--'\n", + ".--. .~~. 3\n", + "|1 |~~~~┊0 ┊)\n", + "`--' 4 `~~'\n", + ".--. .~~. 3 .--. .--.\n", + "|1 |~~~~┊1 ┊----|1 |-+--|0 |\n", + "`--' 5 `~~' 4 `--' |--|1 |\n", + ".--. .~~. `--|2 |\n", + "|1 |~~~~┊2 ┊) 8 `--'\n", + "`--' 6 `~~' 4" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# S-DC-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 9\n", + " 2\n", + " 5\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |~~~~|0 |~+~~┊0 ┊-+--|1 |\n", + "`--' 1 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 2 `--'\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 2\n", + " `~~┊2 ┊)\n", + " 3 `~~'\n", + ".--. .--. .~~. 2 .--.\n", + "|0 |~~~~|1 |~+~~┊0 ┊-+--|0 |\n", + "`--' 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " ┊~~┊1 ┊----|0 |\n", + " ┊ `~~' 5 `--'\n", + " ┊ .~~.\n", + " `~~┊2 ┊)\n", + " 6 `~~'\n", + ".--. .--. .~~. 5\n", + "|1 |~~~~|1 |~+~~┊0 ┊)\n", + "`--' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " ┊~~┊1 ┊-+--|0 |\n", + " ┊ `~~' |--|1 |\n", + " ┊ `--|2 |\n", + " ┊ .~~. 8 `--'\n", + " `~~┊2 ┊)\n", + " 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-S-S-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 3\n", + " 3\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 2\n", + " 1\n", + " 1\n", + " 1\n", + " 7\n", + " 7\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~|0 |~~~~|1 |\n", + "`~~' | `--' 1 `--' 1 `--'\n", + " | .--. .--. .--.\n", + " |--|0 |~~~~|0 |~~~~|2 |\n", + " | `--' 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|0 |\n", + " | `--' 3 `--' 3 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|2 |\n", + " | `--' 4 `--' 4 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|0 |\n", + " 5 `--' 5 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊-+--|1 |~~~~|1 |~~~~|0 |\n", + "`~~' | `--' 6 `--' 6 `--'\n", + ".~~. | .--. .--. .--.\n", + "┊2 ┊)|--|1 |~~~~|1 |~~~~|1 |\n", + "`~~' | `--' 7 `--' 7 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|2 |\n", + " 8 `--' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-S-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 0\n", + " 2\n", + " 3\n", + " 2\n", + " 1\n", + " 0\n", + " 4\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 2\n", + " 6\n", + " 6\n", + " 1\n", + " 0\n", + " 7\n", + " 5\n", + " 2\n", + " 1\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 1\n", + " 2\n", + " 9\n", + " 9\n", + " 2\n", + " 5\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .~~~. .---.\n", + "┊i0 ┊p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `---' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .~~. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~┊0 ┊-+--|1 |\n", + "`~~' | `--' 1 `~~' `--|2 |\n", + " | .--. .~~. 2 `--'\n", + " |--|0 |~~~~┊1 ┊)\n", + " | `--' 2 `~~'\n", + " | .--. .~~. 2\n", + " |--|0 |~~~~┊2 ┊)\n", + " | `--' 3 `~~'\n", + " | .--. .~~. 2 .--.\n", + " |--|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 4 `~~' `--|2 |\n", + " | .--. .~~. 4 |--|\n", + " |--|1 |~~~~┊1 ┊----|0 |\n", + " | `--' 5 `~~' 5 `--'\n", + " | .--. .~~.\n", + " `--|1 |~~~~┊2 ┊)\n", + " 6 `--' 6 `~~'\n", + ".~~. .--. .~~. 5\n", + "┊1 ┊-+--|1 |~~~~┊0 ┊)\n", + "`~~' | `--' 7 `~~'\n", + ".~~. | .--. .~~. 5 .--.\n", + "┊2 ┊)|--|1 |~~~~┊1 ┊-+--|0 |\n", + "`~~' | `--' 8 `~~' |--|1 |\n", + " | `--|2 |\n", + " | .--. .~~. 8 `--'\n", + " `--|1 |~~~~┊2 ┊)\n", + " 9 `--' 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-S-DC-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 2\n", + " 8\n", + " 4\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~|0 |-+--|1 |\n", + "`~~' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " |--|1 |~~~~|0 |-+--|0 |\n", + " | `--' 2 `--' `--|2 |\n", + " | .--. .--. 4 |--|\n", + " `--|1 |~~~~|1 |----|0 |\n", + " 3 `--' 3 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |~~~~|1 |-+--|0 |\n", + "`~~' 4 `--' 4 `--' |--|1 |\n", + ".~~. `--|2 |\n", + "┊2 ┊) 8 `--'\n", + "`~~' 4" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-C-S-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " \n", + " 0\n", + " 0\n", + " 3\n", + " 2\n", + " 0\n", + " 2\n", + " 3\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " \n", + " 1\n", + " 0\n", + " 6\n", + " 2\n", + " 1\n", + " 1\n", + " 6\n", + " 7\n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " 1\n", + " 2\n", + " 9\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .~~~. .---. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`~~~' `~~~' `---' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .--. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`~~' ┊ `~~' | `--' 1 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|0 |~~~~|2 |\n", + " ┊ 2 `--' 2 `--'\n", + " ┊ .~~. .--. .--.\n", + " ┊~~┊1 ┊-+--|0 |~~~~|0 |\n", + " ┊ `~~' | `--' 3 `--'\n", + " ┊ .~~. | .--. .--.\n", + " `~~┊2 ┊)|--|0 |~~~~|2 |\n", + " 3 `~~' | `--' 4 `--'\n", + ".~~. .~~. | .--. .--.\n", + "┊1 ┊~+~~┊0 ┊)`--|1 |~~~~|0 |\n", + "`~~' ┊ `~~' 5 `--' 5 `--'\n", + " ┊ .~~. 5 .--. .--.\n", + " ┊~~┊1 ┊-+--|1 |~~~~|0 |\n", + " ┊ `~~' | `--' 6 `--'\n", + " ┊ .~~. | .--. .--.\n", + " `~~┊2 ┊)|--|1 |~~~~|1 |\n", + " 6 `~~' | `--' 7 `--'\n", + ".~~. .~~. | .--. .--.\n", + "┊2 ┊~+~~┊0 ┊)`--|1 |~~~~|2 |\n", + "`~~' ┊ `~~' 8 `--' 8 `--'\n", + " ┊ .~~. 8\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 8\n", + " `~~┊2 ┊)\n", + " 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-C-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " 2\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 2\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " \n", + " 0\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 0\n", + " 3\n", + " \n", + " 1\n", + " 2\n", + " 9\n", + " 0\n", + " \n", + " 1\n", + " 2\n", + " 12\n", + " \n", + " 0\n", + " 5\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 15\n", + " 0\n", + " 6\n", + " \n", + " 1\n", + " 2\n", + " 18\n", + " 0\n", + " \n", + " 1\n", + " 2\n", + " 21\n", + " \n", + " 0\n", + " \n", + " 1\n", + " 2\n", + " 24\n", + " 0\n", + " 9\n", + " \n", + " 1\n", + " 2\n", + " 27\n", + " 2\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .~~~. .~~~. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `~~~' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .~~. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`~~' ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 2 `--'\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 2\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 3 `~~'\n", + " ┊ .~~. .~~. 2 .--.\n", + " ┊~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + " ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 4 |--|\n", + " ┊ ┊~~┊1 ┊----|0 |\n", + " ┊ ┊ `~~' 5 `--'\n", + " ┊ ┊ .~~.\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 6 `~~'\n", + " ┊ .~~. .~~. 5\n", + " `~~┊2 ┊~+~~┊0 ┊)\n", + " 3 `~~' ┊ `~~'\n", + " ┊ .~~. 5\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 5\n", + " `~~┊2 ┊)\n", + " 9 `~~'\n", + ".~~. .~~. .~~. 5\n", + "┊1 ┊~+~~┊0 ┊~+~~┊0 ┊)\n", + "`~~' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 12 `~~'\n", + " ┊ .~~. .~~. 5\n", + " ┊~~┊1 ┊~+~~┊0 ┊)\n", + " ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5 .--.\n", + " ┊ ┊~~┊1 ┊-+--|0 |\n", + " ┊ ┊ `~~' |--|1 |\n", + " ┊ ┊ `--|2 |\n", + " ┊ ┊ .~~. 8 `--'\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 15 `~~'\n", + " ┊ .~~. .~~. 8\n", + " `~~┊2 ┊~+~~┊0 ┊)\n", + " 6 `~~' ┊ `~~'\n", + " ┊ .~~. 8\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 8\n", + " `~~┊2 ┊)\n", + " 18 `~~'\n", + ".~~. .~~. .~~. 8\n", + "┊2 ┊~+~~┊0 ┊~+~~┊0 ┊)\n", + "`~~' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 8\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 8\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 21 `~~'\n", + " ┊ .~~. .~~. 8\n", + " ┊~~┊1 ┊~+~~┊0 ┊)\n", + " ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 8\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 8\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 24 `~~'\n", + " ┊ .~~. .~~. 8\n", + " `~~┊2 ┊~+~~┊0 ┊)\n", + " 9 `~~' ┊ `~~'\n", + " ┊ .~~. 8\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 8\n", + " `~~┊2 ┊)\n", + " 27 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-C-DC-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 3\n", + " 0\n", + " 3\n", + " \n", + " 1\n", + " 0\n", + " 4\n", + " 1\n", + " 2\n", + " 2\n", + " 8\n", + " 6\n", + " 0\n", + " \n", + " 1\n", + " 2\n", + " 9\n", + " 4\n", + " 4\n", + " 4\n", + " 4\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .~~~. .---. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`~~~' `~~~' `---' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .--. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊----|0 |-+--|1 |\n", + "`~~' ┊ `~~' 1 `--' `--|2 |\n", + " ┊ .~~. .--. 2 |--|\n", + " ┊~~┊1 ┊-+--|0 |-+--|0 |\n", + " ┊ `~~' | `--' `--|2 |\n", + " ┊ .~~. | .--. 4 |--|\n", + " `~~┊2 ┊)`--|1 |----|0 |\n", + " 3 `~~' 3 `--' 5 `--'\n", + ".~~. .~~. 3\n", + "┊1 ┊~+~~┊0 ┊)\n", + "`~~' ┊ `~~'\n", + " ┊ .~~. 3 .--. .--.\n", + " ┊~~┊1 ┊----|1 |-+--|0 |\n", + " ┊ `~~' 4 `--' |--|1 |\n", + " ┊ .~~. `--|2 |\n", + " `~~┊2 ┊) 8 `--'\n", + " 6 `~~'\n", + ".~~. .~~. 4\n", + "┊2 ┊~+~~┊0 ┊)\n", + "`~~' ┊ `~~'\n", + " ┊ .~~. 4\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 4\n", + " `~~┊2 ┊)\n", + " 9 `~~' 4" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-DC-S-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 6\n", + " 2\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 3\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |-+--|0 |~~~~|1 |\n", + "`~~' | `--' | `--' 1 `--'\n", + " | | .--. .--.\n", + " | `--|0 |~~~~|2 |\n", + " | 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |-+--|0 |~~~~|0 |\n", + " 2 `--' | `--' 3 `--'\n", + " | .--. .--.\n", + " |--|0 |~~~~|2 |\n", + " | `--' 4 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|0 |\n", + " 5 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |-+--|1 |~~~~|0 |\n", + "`~~' 3 `--' | `--' 6 `--'\n", + ".~~. | .--. .--.\n", + "┊2 ┊) |--|1 |~~~~|1 |\n", + "`~~' 3 | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-DC-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 2\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 9\n", + " 2\n", + " 5\n", + " 3\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .~~~. .---.\n", + "┊i0 ┊p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `---' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .~~. 0 .--.\n", + "┊0 ┊-+--|0 |~+~~┊0 ┊-+--|1 |\n", + "`~~' | `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | ┊~~┊1 ┊)\n", + " | ┊ `~~'\n", + " | ┊ .~~. 2\n", + " | `~~┊2 ┊)\n", + " | 3 `~~'\n", + " | .--. .~~. 2 .--.\n", + " `--|1 |~+~~┊0 ┊-+--|0 |\n", + " 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " ┊~~┊1 ┊----|0 |\n", + " ┊ `~~' 5 `--'\n", + " ┊ .~~.\n", + " `~~┊2 ┊)\n", + " 6 `~~'\n", + ".~~. .--. .~~. 5\n", + "┊1 ┊----|1 |~+~~┊0 ┊)\n", + "`~~' 3 `--' ┊ `~~'\n", + ".~~. ┊ .~~. 5 .--.\n", + "┊2 ┊) ┊~~┊1 ┊-+--|0 |\n", + "`~~' 3 ┊ `~~' |--|1 |\n", + " ┊ `--|2 |\n", + " ┊ .~~. 8 `--'\n", + " `~~┊2 ┊)\n", + " 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# C-DC-DC-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 2\n", + " 8\n", + " 3\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |----|0 |-+--|1 |\n", + "`~~' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |----|1 |-+--|0 |\n", + "`~~' 3 `--' 4 `--' |--|1 |\n", + ".~~. `--|2 |\n", + "┊2 ┊) 8 `--'\n", + "`~~' 3" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# DC-S-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 0\n", + " 2\n", + " 3\n", + " 2\n", + " 1\n", + " 0\n", + " 4\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 2\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 0\n", + " 7\n", + " 5\n", + " 1\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 1\n", + " 2\n", + " 9\n", + " 9\n", + " 2\n", + " 5\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |-+--|0 |~~~~┊0 ┊-+--|1 |\n", + "`--' | `--' 1 `~~' `--|2 |\n", + " | .--. .~~. 2 `--'\n", + " |--|0 |~~~~┊1 ┊)\n", + " | `--' 2 `~~'\n", + " | .--. .~~. 2\n", + " |--|0 |~~~~┊2 ┊)\n", + " | `--' 3 `~~'\n", + " | .--. .~~. 2 .--.\n", + " |--|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 4 `~~' `--|2 |\n", + " | .--. .~~. 4 |--|\n", + " |--|1 |~~~~┊1 ┊----|0 |\n", + " | `--' 5 `~~' 5 `--'\n", + " | .--. .~~.\n", + " `--|1 |~~~~┊2 ┊)\n", + " 6 `--' 6 `~~'\n", + ".--. .--. .~~. 5\n", + "|1 |-+--|1 |~~~~┊0 ┊)\n", + "`--' | `--' 7 `~~'\n", + " | .--. .~~. 5 .--.\n", + " |--|1 |~~~~┊1 ┊-+--|0 |\n", + " | `--' 8 `~~' |--|1 |\n", + " | `--|2 |\n", + " | .--. .~~. 8 `--'\n", + " `--|1 |~~~~┊2 ┊)\n", + " 9 `--' 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# DC-C-S-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " \n", + " 0\n", + " 0\n", + " 3\n", + " 2\n", + " 0\n", + " 2\n", + " 3\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " \n", + " 1\n", + " 0\n", + " 6\n", + " 2\n", + " 1\n", + " 1\n", + " 6\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~+~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`--' ┊ `~~' | `--' 1 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|0 |~~~~|2 |\n", + " ┊ 2 `--' 2 `--'\n", + " ┊ .~~. .--. .--.\n", + " ┊~~┊1 ┊-+--|0 |~~~~|0 |\n", + " ┊ `~~' | `--' 3 `--'\n", + " ┊ .~~. | .--. .--.\n", + " `~~┊2 ┊)|--|0 |~~~~|2 |\n", + " 3 `~~' | `--' 4 `--'\n", + ".--. .~~. | .--. .--.\n", + "|1 |~+~~┊0 ┊)`--|1 |~~~~|0 |\n", + "`--' ┊ `~~' 5 `--' 5 `--'\n", + " ┊ .~~. 5 .--. .--.\n", + " ┊~~┊1 ┊-+--|1 |~~~~|0 |\n", + " ┊ `~~' | `--' 6 `--'\n", + " ┊ .~~. | .--. .--.\n", + " `~~┊2 ┊)|--|1 |~~~~|1 |\n", + " 6 `~~' | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# DC-C-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " \n", + " 0\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 0\n", + " 3\n", + " \n", + " 1\n", + " 2\n", + " 9\n", + " 1\n", + " 0\n", + " \n", + " 1\n", + " 2\n", + " 12\n", + " \n", + " 0\n", + " 5\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 15\n", + " 0\n", + " 6\n", + " \n", + " 1\n", + " 2\n", + " 18\n", + " 2\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .~~~. .---.\n", + "|i0 |p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`---' `~~~' `~~~' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .~~. 0 .--.\n", + "|0 |~+~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`--' ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 2 `--'\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 2\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 3 `~~'\n", + " ┊ .~~. .~~. 2 .--.\n", + " ┊~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + " ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 4 |--|\n", + " ┊ ┊~~┊1 ┊----|0 |\n", + " ┊ ┊ `~~' 5 `--'\n", + " ┊ ┊ .~~.\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 6 `~~'\n", + " ┊ .~~. .~~. 5\n", + " `~~┊2 ┊~+~~┊0 ┊)\n", + " 3 `~~' ┊ `~~'\n", + " ┊ .~~. 5\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 5\n", + " `~~┊2 ┊)\n", + " 9 `~~'\n", + ".--. .~~. .~~. 5\n", + "|1 |~+~~┊0 ┊~+~~┊0 ┊)\n", + "`--' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 12 `~~'\n", + " ┊ .~~. .~~. 5\n", + " ┊~~┊1 ┊~+~~┊0 ┊)\n", + " ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5 .--.\n", + " ┊ ┊~~┊1 ┊-+--|0 |\n", + " ┊ ┊ `~~' |--|1 |\n", + " ┊ ┊ `--|2 |\n", + " ┊ ┊ .~~. 8 `--'\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 15 `~~'\n", + " ┊ .~~. .~~. 8\n", + " `~~┊2 ┊~+~~┊0 ┊)\n", + " 6 `~~' ┊ `~~'\n", + " ┊ .~~. 8\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 8\n", + " `~~┊2 ┊)\n", + " 18 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# DC-C-DC-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 0\n", + " 3\n", + " \n", + " 1\n", + " 0\n", + " 4\n", + " 1\n", + " 2\n", + " 2\n", + " 8\n", + " 6\n", + " 4\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~+~~┊0 ┊----|0 |-+--|1 |\n", + "`--' ┊ `~~' 1 `--' `--|2 |\n", + " ┊ .~~. .--. 2 |--|\n", + " ┊~~┊1 ┊-+--|0 |-+--|0 |\n", + " ┊ `~~' | `--' `--|2 |\n", + " ┊ .~~. | .--. 4 |--|\n", + " `~~┊2 ┊)`--|1 |----|0 |\n", + " 3 `~~' 3 `--' 5 `--'\n", + ".--. .~~. 3\n", + "|1 |~+~~┊0 ┊)\n", + "`--' ┊ `~~'\n", + " ┊ .~~. 3 .--. .--.\n", + " ┊~~┊1 ┊----|1 |-+--|0 |\n", + " ┊ `~~' 4 `--' |--|1 |\n", + " ┊ .~~. `--|2 |\n", + " `~~┊2 ┊) 8 `--'\n", + " 6 `~~' 4" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# DC-DC-C-S" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 9\n", + " 2\n", + " 5\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |-+--|0 |~+~~┊0 ┊-+--|1 |\n", + "`--' | `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | ┊~~┊1 ┊)\n", + " | ┊ `~~'\n", + " | ┊ .~~. 2\n", + " | `~~┊2 ┊)\n", + " | 3 `~~'\n", + " | .--. .~~. 2 .--.\n", + " `--|1 |~+~~┊0 ┊-+--|0 |\n", + " 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " ┊~~┊1 ┊----|0 |\n", + " ┊ `~~' 5 `--'\n", + " ┊ .~~.\n", + " `~~┊2 ┊)\n", + " 6 `~~'\n", + ".--. .--. .~~. 5\n", + "|1 |----|1 |~+~~┊0 ┊)\n", + "`--' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " ┊~~┊1 ┊-+--|0 |\n", + " ┊ `~~' |--|1 |\n", + " ┊ `--|2 |\n", + " ┊ .~~. 8 `--'\n", + " `~~┊2 ┊)\n", + " 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "for sparsity in itertools.product(sparsities, sparsities, sparsities, [\"S\"]):\n", + " if \"C\" not in sparsity:\n", + " continue\n", + " structure = \"-\".join(sparsity)\n", + " IPython.display.display(IPython.display.Markdown(f\"# {structure}\"))\n", + " IPython.display.display(SPZ(indices, (3, 3, 3, 3), structure))" + ] + }, + { + "cell_type": "markdown", + "id": "07f40f47", + "metadata": {}, + "source": [ + "# voilà!" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/spz_python/pyproject.toml b/spz_python/pyproject.toml new file mode 100644 index 0000000..90ccf9c --- /dev/null +++ b/spz_python/pyproject.toml @@ -0,0 +1,5 @@ +[build-system] +requires = ["setuptools", "wheel"] + +[tool.black] +line-length = 100 diff --git a/spz_python/requirements.txt b/spz_python/requirements.txt new file mode 100644 index 0000000..5da331c --- /dev/null +++ b/spz_python/requirements.txt @@ -0,0 +1,2 @@ +numpy +pandas diff --git a/spz_python/setup.cfg b/spz_python/setup.cfg new file mode 100644 index 0000000..ba9a677 --- /dev/null +++ b/spz_python/setup.cfg @@ -0,0 +1,56 @@ +[aliases] +test=pytest + +[flake8] +max-line-length = 100 +inline-quotes = " +exclude = + versioneer.py, +ignore = + E203, # whitespace before ':' + E231, # Multiple spaces around "," + W503, # line break before binary operator + B020 +per-file-ignores = + __init__.py:F401 + +[isort] +sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER +profile = black +skip_gitignore = true +float_to_top = true +default_section = THIRDPARTY +known_first_party = spz +line_length = 100 + +[versioneer] +VCS = git +style = pep440 +versionfile_source = spz/_version.py +versionfile_build = spz/_version.py +tag_prefix= +parentdir_prefix=spz- + +[tool:pytest] +testpaths = spz/tests +markers: + slow: Skipped unless --runslow passed + +[coverage:run] +source = spz +omit = + spz/_version.py + +[coverage:report] +# Regexes for lines to exclude from consideration +exclude_lines = + pragma: no cover + + raise AssertionError + raise NotImplementedError + +ignore_errors = True +precision = 1 +fail_under = 0 +skip_covered = True +skip_empty = True diff --git a/spz_python/setup.py b/spz_python/setup.py new file mode 100644 index 0000000..f7d263c --- /dev/null +++ b/spz_python/setup.py @@ -0,0 +1,47 @@ +from setuptools import find_packages, setup + +import versioneer + +install_requires = open("requirements.txt").read().strip().split("\n") +extras_require = { + "test": ["pytest"], + "viz": ["sphinxcontrib-svgbob"], +} +extras_require["complete"] = sorted({v for req in extras_require.values() for v in req}) + +with open("README.md") as f: + long_description = f.read() + +setup( + name="spz", + version=versioneer.get_version(), + cmdclass=versioneer.get_cmdclass(), + description="Explore multidimensional sparse data structures", + long_description=long_description, + long_description_content_type="text/markdown", + author="Erik Welch", + author_email="erik.n.welch@gmail.com", + url="https://github.com/GraphBLAS/binsparse-specification", + packages=find_packages(), + license="BSD", + python_requires=">=3.8", + setup_requires=[], + install_requires=install_requires, + extras_require=extras_require, + include_package_data=True, + classifiers=[ + "Development Status :: 3 - Alpha" "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3 :: Only", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Mathematics", + ], + zip_safe=False, +) diff --git a/spz_python/spz/__init__.py b/spz_python/spz/__init__.py new file mode 100644 index 0000000..fb234b1 --- /dev/null +++ b/spz_python/spz/__init__.py @@ -0,0 +1,5 @@ +from . import _version +from ._core import SPZ +from .sparsetype import DC, C, S, compressed, doubly_compressed, sparse + +__version__ = _version.get_versions()["version"] diff --git a/spz_python/spz/_core.py b/spz_python/spz/_core.py new file mode 100644 index 0000000..129a0f3 --- /dev/null +++ b/spz_python/spz/_core.py @@ -0,0 +1,293 @@ +import numpy as np +import pandas as pd + +from .sparsetype import DC, C, S, abbreviate, unabbreviate + + +def repeatrange(repeat, *args): + """e.g., [0, 1, 2, 0, 1, 2]""" + return np.repeat(np.arange(*args)[None, :], repeat, axis=0).ravel() + + +def issorted(array): + return np.all(array[:-1] <= array[1:]) + + +class SPZ: + def __init__(self, arrays, shape=None, structure=None): + if not isinstance(arrays, (list, tuple)): + raise TypeError("arrays argument must be a list or tuple of numpy arrays") + if not arrays: + raise ValueError("At least one array must be given") + arrays = [np.array(array) for array in arrays] + if not all(array.ndim == 1 for array in arrays): + raise ValueError("arrays must be a single dimension") + size = arrays[0].size + if not all(array.size == size for array in arrays): + raise ValueError("arrays must be the same size") + if not all(np.issubdtype(array.dtype, np.integer) for array in arrays): + raise ValueError("arrays must be integer dtype") + if not all((array >= 0).all() for array in arrays): + raise ValueError("array values must be positive") + + if shape is not None: + self._shape = tuple(shape) + if not all(dimsize > 0 for dimsize in self._shape): + raise ValueError("Dimension sizes must be greater than 0") + if len(self._shape) != len(arrays): + raise ValueError("shape must be the same length as arrays") + if not all((array < dimsize).all() for array, dimsize in zip(arrays, self._shape)): + raise ValueError("index in array is out of bounds") + else: + self._shape = tuple(int(array.max()) + 1 for array in arrays) + shape = self._shape + + if structure is None: # Assume CSF + self._structure = [DC] * (len(arrays) - 1) + [S] + elif isinstance(structure, str): + self._structure = unabbreviate(structure) + else: + self._structure = unabbreviate(abbreviate(*structure)) + if len(self._structure) != len(arrays): + raise ValueError("structure must be the same length as arrays") + if self._structure[-1] != S: + # C as the final dimension means "dense" + raise ValueError("The final dimension must be sparse structural type") + + # Now the fun part! Generate the compressed structure from COO + df = pd.DataFrame(arrays).T.sort_values(list(range(self.ndim))) + if df.duplicated().any(): + raise ValueError("Duplicate indices found!") + + # First create indices + indices = [] + cols = list(df.columns) + num_s_levels = 0 + prev = None + for sparsity, level in zip(self._structure, range(df.shape[-1])): + if sparsity == S: + num_s_levels += 1 + elif sparsity == DC: + subdf = df[cols[: level + 1]].drop_duplicates() + for i in range(-num_s_levels - 1, 0): + indices.append(subdf.iloc[:, i].values) + num_s_levels = 0 + elif sparsity == C: + if level == 0: + indices.append(np.arange(shape[level])) + elif prev == DC: + subdf = df[cols[:level]].drop_duplicates() + indices.append(repeatrange(len(subdf), shape[level])) + elif prev == S: + subdf = df[cols[:level]].drop_duplicates() + subdf = subdf.join( + pd.DataFrame({cols[level]: range(shape[level])}), how="cross" + ) + for i in range(-num_s_levels - 1, 0): + indices.append(subdf.iloc[:, i].values) + num_s_levels = 0 + else: # prev == C + indices.append(repeatrange(indices[-1].size, shape[level])) + prev = sparsity + for i in range(-num_s_levels, 0): + indices.append(df.iloc[:, i].values) + self._indices = indices + + # Now create pointers + pointers = [] + for sparsity, level in zip(self._structure[:-1], range(df.shape[-1] - 1)): + if sparsity == S: + ptr = np.arange(indices[level].size + 1) + elif self._structure[level + 1] == C: + ptr = np.arange(len(indices[level]) + 1) * shape[level + 1] + if sparsity == C: + # Update subdf to use later + if level == 0: + subdf = pd.DataFrame({cols[level]: range(shape[level])}) + elif self._structure[level - 1] == C: + subdf = subdf.join( + pd.DataFrame({cols[level]: range(shape[level])}), how="cross" + ) + else: + subdf = df[cols[:level]].drop_duplicates() + subdf = subdf.join( + pd.DataFrame({cols[level]: range(shape[level])}), how="cross" + ) + elif sparsity == DC: + if self._structure[level + 1] == DC: + subdf = df[cols[: level + 2]].drop_duplicates() + else: # sparsity[level + 1] == S + # number of "S" immediately after this level + nums = 0 + for item in self._structure[level + 1 :]: + if item == S: + nums += 1 + else: + break + subdf = df[cols[: level + nums + 1]].drop_duplicates() + if len(self._structure) > level + nums + 1: + if self._structure[level + nums + 1] == C: + subdf = subdf.join( + pd.DataFrame( + {cols[level + nums + 1]: range(shape[level + nums + 1])} + ), + how="cross", + ) + elif self._structure[level + nums + 1] == DC: + subdf = df[cols[: level + nums + 2]].drop_duplicates() + ptr = np.zeros(indices[level].size + 1, int) + ptr[1:] = subdf.groupby(cols[: level + 1])[cols[level + 1]].count().cumsum() + elif sparsity == C: + if level > 0: + if self._structure[level - 1] == C: + subdf1 = subdf + else: + subdf1 = df[cols[:level]].drop_duplicates() + subdf = pd.DataFrame({cols[level]: range(shape[level])}) + if level > 0: + subdf = subdf1.join(subdf, how="cross") + if self._structure[level + 1] == DC: + subdf2 = df[cols[: level + 2]].drop_duplicates() + else: # sparsity[level + 1] == S + # number of "S" immediately after this level + nums = 0 + for item in self._structure[level + 1 :]: + if item == S: + nums += 1 + else: + break + subdf2 = df[cols[: level + nums + 1]].drop_duplicates() + if len(self._structure) > level + nums + 1: + if self._structure[level + nums + 1] == C: + subdf2 = subdf2.join( + pd.DataFrame( + {cols[level + nums + 1]: range(shape[level + nums + 1])} + ), + how="cross", + ) + elif self._structure[level + nums + 1] == DC: + subdf2 = df[cols[: level + nums + 2]].drop_duplicates() + subdf3 = subdf.merge(subdf2, how="left") + subdf3[level + 1] = subdf3[level + 1].notnull() + ptr = np.zeros(indices[level].size + 1, int) + ptr[1:] = subdf3.groupby(cols[: level + 1])[level + 1].sum().cumsum() + pointers.append(ptr) + self._pointers = pointers + # TODO: can we detect and change sparsity type to be more efficient? + # For example, so we don't need to store a pointers or indices. + + def _validate(self): + indices = self._indices + pointers = self._pointers + structure = self._structure + ndim = self.ndim + shape = self.shape + assert len(indices) == len(pointers) + 1 == ndim + for idx in indices: + assert idx.dtype == int + for ptr in pointers: + assert ptr.dtype == int + for idx, ptr in zip(indices[:-1], pointers): + assert len(ptr) == len(idx) + 1 + for idx, ptr in zip(indices[1:], pointers): + assert ptr[0] == 0 + assert ptr[-1] == len(idx) + for ptr in pointers: + assert issorted(ptr) + assert issorted(indices[0]) + assert indices[0][0] >= 0 + assert indices[0][-1] < shape[0] + for i, (idx, ptr) in enumerate(zip(indices[1:], pointers), 1): + for start, stop in zip(ptr[:-1], ptr[1:]): + assert issorted(idx[start:stop]) + if start < stop: + assert idx[start] >= 0 + assert idx[stop - 1] < shape[i] + assert structure[-1] == S + for i, (sparsity, idx, ptr) in enumerate(zip(structure[:-1], indices, pointers[:-1])): + if sparsity == C: + if i == 0: + assert len(idx) == shape[0] + elif structure[i - 1] != S: + assert len(idx) == len(self._indices[i - 1]) * shape[i] + elif sparsity == S: + assert len(idx) == len(indices[i + 1]) + elif sparsity == DC: + if i == 0: + assert len(idx) == len(set(idx)) + assert len(ptr) == len(set(ptr)) + else: # pragma: no cover + raise AssertionError() + + def as_structure(self, structure): + return SPZ(self.arrays, self.shape, structure) + + def get_index(self, dim): + return self._indices[dim] + + def get_pointers(self, dim): + return self._pointers[dim] + + @property + def indices(self): + rv = list(self._indices) + for i, sparsity in enumerate(self._structure): + if sparsity == C: + rv[i] = None + return rv + + @property + def pointers(self): + rv = list(self._pointers) + for i, sparsity in enumerate(self._structure[:-1]): + if sparsity == S: + rv[i] = None + elif sparsity == C and i > 0: + rv[i - 1] = None + return rv + + @property + def ndim(self): + return len(self._shape) + + @property + def shape(self): + return self._shape + + @property + def structure(self): + return self._structure + + @property + def abbreviation(self): + return abbreviate(self._structure) + + @property + def arrays(self): + return [np.array(array) for array in zip(*_to_coo(self._indices, self._pointers))] + + def _repr_svg_(self): + try: + from ._formatting import to_svg + except ImportError: + return + return to_svg(self) + + def __repr__(self): + from ._formatting import to_text + + return to_text(self) + + +def _to_coo(indices, pointers, start=0, stop=None): + index, *indices = indices + if stop is None: + stop = len(index) + if not indices: + for idx in index[start:stop]: + yield (idx,) + return + ptrs, *pointers = pointers + for idx, start, stop in zip(index[start:stop], ptrs[start:stop], ptrs[start + 1 : stop + 1]): + for indexes in _to_coo(indices, pointers, start, stop): + yield (idx,) + indexes diff --git a/spz_python/spz/_formatting.py b/spz_python/spz/_formatting.py new file mode 100644 index 0000000..7892adb --- /dev/null +++ b/spz_python/spz/_formatting.py @@ -0,0 +1,301 @@ +import itertools + +import numpy as np + +concat = itertools.chain.from_iterable + + +def _to_level(indices, pointers, level=0, start=0, stop=None): + index, *indices = indices + if stop is None: + stop = len(index) + if not indices: + for _ in range(start, stop): + yield level + level += 1 + return + ptrs, *pointers = pointers + for start, stop in zip(ptrs[start:stop], ptrs[start + 1 : stop + 1]): + levels = list(_to_level(indices, pointers, level, start, stop)) + yield [level, levels] + maxlevel = level + while levels: + vals = [val for val in levels if not isinstance(val, list)] + if vals: + maxlevel = max(maxlevel, max(vals)) + levels = list(concat(val for val in levels if isinstance(val, list))) + level = maxlevel + 1 + + +def index_levels(self): + levels = list(_to_level(self._indices, self._pointers)) + if self.ndim == 1: + return [levels] + rv = [] + rv.append([x for x, _ in levels]) + for _ in range(len(self._pointers) - 1): + levels = list(concat(y for _, y in levels)) + rv.append([x for x, _ in levels]) + rv.append(list(concat(y for _, y in levels))) + return rv + + +def _to_group(indices, pointers, group=None, start=0, stop=None): + index, *indices = indices + if stop is None: + stop = len(index) + if not indices: + for i in range(start, stop): + if group is None: + yield i + else: + yield group + return + ptrs, *pointers = pointers + for i, (start, stop) in enumerate(zip(ptrs[start:stop], ptrs[start + 1 : stop + 1])): + cur_group = i if group is None else group + groups = list(_to_group(indices, pointers, cur_group, start, stop)) + yield [cur_group, groups] + + +def index_groups(self): + groups = list(_to_group(self._indices, self._pointers)) + if self.ndim == 1: + return [groups] + rv = [] + rv.append([x for x, _ in groups]) + for _ in range(len(self._pointers) - 1): + groups = list(concat(y for _, y in groups)) + rv.append([x for x, _ in groups]) + rv.append(list(concat(y for _, y in groups))) + return rv + + +def get_layout(self, *, squared=False): + indices = self._indices + pointers = self._pointers + + # Xs is easy + index_widths = [2 + max(2, len(str(index.max()))) for index in indices] + pointers_widths = [max(4, len(str(ptr.max()))) for ptr in pointers] + index_widths = [2 + max(2, len(str(index.max()))) for index in indices] + pointers_widths = [max(4, len(str(ptr.max()))) for ptr in pointers] + widths = [0] + for ws in zip(index_widths[:-1], pointers_widths): + widths.extend(ws) + xoffsets = np.cumsum(widths) + + # Now we need to determins Ys. Get initial guesses. + groups = index_groups(self) + if self.ndim > 1: + yoffsets = [list(np.arange(len(index)) * 3) for index in indices[:-2]] + last_in_group = np.diff(np.pad(groups[-1], (0, 1)))[ + [min(x, len(groups[-1]) - 1) for x in pointers[-1][:-2]] + ].astype(bool) + diffed = np.diff(pointers[-1])[:-1] + yoffsets.append( + np.pad((np.maximum(2, diffed + last_in_group) + 1 + squared).cumsum(), (1, 0)).tolist() + ) + yoffsets.append(list(range(len(indices[-1])))) # We handle constraints in the line above + else: + yoffsets = [list(range(len(indices[-1])))] + + # Now update by matching level ys + levels = index_levels(self) + inplay = set(zip(concat(levels), concat(yoffsets))) + for level in sorted({x for x, _ in inplay}): + heights = sorted({y for x, y in inplay if x == level}) + if len(heights) == 1: + continue + max_height = max(heights) + new_yoffsets = [] + for ys, cur_levels in zip(yoffsets, levels): + if level not in cur_levels or ys[cur_levels.index(level)] == max_height: + new_yoffsets.append(ys) + continue + diff = max_height - ys[cur_levels.index(level)] + new_yoffsets.append([y if lvl < level else y + diff for y, lvl in zip(ys, cur_levels)]) + yoffsets = new_yoffsets + inplay = set(zip(concat(levels), concat(yoffsets))) + + return index_widths, pointers_widths, xoffsets, yoffsets + + +def autoexpand(func): + """Make the canvas larger if there is an IndexError""" + + def inner(canvas, *args, **kwargs): + for _ in range(1000): + try: + return func(canvas, *args, **kwargs) + except IndexError: + for row in canvas: + row.append(" ") + canvas.append([" "] * len(canvas[0])) + + return inner + + +@autoexpand +def draw_box(canvas, x, y, width, val, *, dashed=False, square=False, cap_right=False): + h = "~" if dashed else "-" + v = "┊" if dashed else "|" + canvas[y][x] = "+" if square else "." + canvas[y + 1][x] = v + canvas[y + 2][x] = "+" if square else "`" + canvas[y][x + width - 1] = "+" if square else "." + canvas[y + 1][x + width - 1] = v + canvas[y + 2][x + width - 1] = "+" if square else "'" + for w in range(1, width - 1): + canvas[y][x + w] = h + canvas[y + 2][x + w] = h + sval = str(val).center(width - 2) + for c, w in zip(sval, range(1, width - 1)): + canvas[y + 1][x + w] = c + if cap_right: + canvas[y + 1][x + width] = ")" + + +@autoexpand +def draw_final_boxes(canvas, x, ys, width, index, *, square=False): + prev_y = -999 + for y, idx in zip(ys, index): + if y - prev_y > 2: + canvas[y][x] = "+" if square else "." + for w in range(1, width - 1): + canvas[y][x + w] = "-" + canvas[y][x + width - 1] = "+" if square else "." + # Close previous box + if prev_y >= 0: + canvas[prev_y + 2][x] = "+" if square else "`" + for w in range(1, width - 1): + canvas[prev_y + 2][x + w] = "-" + canvas[prev_y + 2][x + width - 1] = "+" if square else "'" + elif y - prev_y == 2: + # Connected, but separate by horizontal line + canvas[y][x] = "|" + for w in range(1, width - 1): + canvas[y][x + w] = "-" + canvas[y][x + width - 1] = "|" + canvas[y + 1][x] = "|" + sval = str(idx).center(width - 2) + for c, w in zip(sval, range(1, width - 1)): + canvas[y + 1][x + w] = c + canvas[y + 1][x + width - 1] = "|" + prev_y = y + # Close last box + canvas[prev_y + 2][x] = "+" if square else "`" + for w in range(1, width - 1): + canvas[prev_y + 2][x + w] = "-" + canvas[prev_y + 2][x + width - 1] = "+" if square else "'" + + +@autoexpand +def draw_line(canvas, x, y, w, *, dashed=False, double=False, chain=False): + c = "~" if dashed else "-" + if double: + c = "=" + for i in range(w): + if dashed and double and i % 2: + continue + if chain: + c = "=" if i % 2 else "-" + canvas[y][x + i] = c + + +@autoexpand +def draw_bendy_line(canvas, x, y1, y2, w, *, dashed=False, squared=False): + h = "~" if dashed else "-" + v = "┊" if dashed else "|" + for i in range(w - 2, w): + canvas[y2][x + i] = h + for i in range(y1 + 1, y2): + canvas[i][x + w - 3] = v + canvas[y1][x + w - 3] = "+" + canvas[y2][x + w - 3] = "+" if squared else "`" + + +@autoexpand +def draw_pointer(canvas, x, y, w, ptr, *, center_right=False, skip_if_nonempty=False): + if center_right and w % 2 != len(str(ptr)) % 2: + sptr = str(ptr).center(w + 1)[:-1] + else: + sptr = str(ptr).center(w) + if skip_if_nonempty: + for i in range(len(sptr)): + if canvas[y][x + i] != " ": + return + for i, c in enumerate(sptr): + canvas[y][x + i] = c + + +def to_text(self, *, squared=False): + indices = self._indices + pointers = self._pointers + index_widths, pointers_widths, xoffsets, yoffsets = get_layout(self, squared=squared) + # Doesn't need to be perfect: we'll expand the canvas as needed + xmax = max(xoffsets) + 1 + ymax = max(concat(yoffsets)) + 1 + canvas = [[" "] * xmax for _ in range(ymax)] + # Draw boxes of indices + for i, (width, x, ys, index, ptrs) in enumerate( + zip(index_widths[:-1], xoffsets[::2], yoffsets, indices[:-1], pointers) + ): + dashed = self.indices[i] is None + for y, idx, start, stop in zip(ys, index, ptrs[:-1], ptrs[1:]): + cap_right = start == stop + draw_box(canvas, x, y, width, idx, dashed=dashed, square=squared, cap_right=cap_right) + draw_final_boxes( + canvas, xoffsets[-1], yoffsets[-1], index_widths[-1], indices[-1], square=squared + ) + + # Draw lines for pointers + for i, (x, w) in enumerate(zip(xoffsets[1::2], pointers_widths)): + dashed = self.pointers[i] is None + prev_start = 0 + for j, (yinit, start, stop) in enumerate( + zip(yoffsets[i], pointers[i][:-1], pointers[i][1:]) + ): + if j == 0 or prev_start == start: + draw_pointer(canvas, x, yinit, w, start, center_right=True, skip_if_nonempty=True) + for y in yoffsets[i + 1][start:stop]: + if y == yinit: + draw_line(canvas, x, y + 1, w, dashed=dashed) + else: + draw_bendy_line(canvas, x, yinit + 1, y + 1, w, dashed=dashed, squared=squared) + draw_pointer(canvas, x, y + 2, w, stop, center_right=True) + prev_start = start + if start == stop: + draw_pointer( + canvas, + xoffsets[2 * i + 1], + yoffsets[i][-1] + 2, + w, + start, + center_right=True, + skip_if_nonempty=True, + ) + + # Draw header + header = [[" "] * xmax for _ in range(4)] + for i, (x, w, index) in enumerate(zip(xoffsets[::2], index_widths, self.indices)): + draw_box(header, x, 0, w + 1, f"i{i} ", square=squared, dashed=index is None) + for i, (x, w) in enumerate(zip(xoffsets[1::2], pointers_widths)): + draw_pointer(header, x + 1, 1, w - 2, f"p{i}", center_right=False) + draw_line(header, 0, 3, len("".join(header[0]).rstrip()), double=True) + + # Strip extra white space + hrows = ["".join(row).rstrip() for row in header] + while hrows and not hrows[-1]: + hrows.pop() + rows = ["".join(row).rstrip() for row in canvas] + while rows and not rows[-1]: + rows.pop() + return "\n".join(hrows + rows) + + +def to_svg(self): + from sphinxcontrib.svgbob._svgbob import to_svg as _to_svg + + text = to_text(self) + return _to_svg(text) diff --git a/spz_python/spz/_version.py b/spz_python/spz/_version.py new file mode 100644 index 0000000..b47e5cd --- /dev/null +++ b/spz_python/spz/_version.py @@ -0,0 +1,689 @@ +# This file helps to compute a version number in source trees obtained from +# git-archive tarball (such as those provided by githubs download-from-tag +# feature). Distribution tarballs (built by setup.py sdist) and build +# directories (produced by setup.py build) will contain a much shorter file +# that just contains the computed version number. + +# This file is released into the public domain. Generated by +# versioneer-0.23 (https://github.com/python-versioneer/python-versioneer) + +"""Git implementation of _version.py.""" + +import errno +import functools +import os +import re +import subprocess +import sys +from typing import Callable, Dict + + +def get_keywords(): + """Get the keywords needed to look up the version information.""" + # these strings will be replaced by git during git-archive. + # setup.py/versioneer.py will grep for the variable names, so they must + # each be defined on a line of their own. _version.py will just call + # get_keywords(). + git_refnames = "$Format:%d$" + git_full = "$Format:%H$" + git_date = "$Format:%ci$" + keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} + return keywords + + +class VersioneerConfig: + """Container for Versioneer configuration parameters.""" + + +def get_config(): + """Create, populate and return the VersioneerConfig() object.""" + # these strings are filled in when 'setup.py versioneer' creates + # _version.py + cfg = VersioneerConfig() + cfg.VCS = "git" + cfg.style = "pep440" + cfg.tag_prefix = "" + cfg.parentdir_prefix = "spz-" + cfg.versionfile_source = "spz/_version.py" + cfg.verbose = False + return cfg + + +class NotThisMethod(Exception): + """Exception raised if a method is not valid for the current scenario.""" + + +LONG_VERSION_PY: Dict[str, str] = {} +HANDLERS: Dict[str, Dict[str, Callable]] = {} + + +def register_vcs_handler(vcs, method): # decorator + """Create decorator to mark a method as the handler of a VCS.""" + + def decorate(f): + """Store f in HANDLERS[vcs][method].""" + if vcs not in HANDLERS: + HANDLERS[vcs] = {} + HANDLERS[vcs][method] = f + return f + + return decorate + + +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None): + """Call the given command(s).""" + assert isinstance(commands, list) + process = None + + popen_kwargs = {} + if sys.platform == "win32": + # This hides the console window if pythonw.exe is used + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + popen_kwargs["startupinfo"] = startupinfo + + for command in commands: + try: + dispcmd = str([command] + args) + # remember shell=False, so use git.cmd on windows, not just git + process = subprocess.Popen( + [command] + args, + cwd=cwd, + env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr else None), + **popen_kwargs, + ) + break + except OSError: + e = sys.exc_info()[1] + if e.errno == errno.ENOENT: + continue + if verbose: + print("unable to run %s" % dispcmd) + print(e) + return None, None + else: + if verbose: + print("unable to find command, tried %s" % (commands,)) + return None, None + stdout = process.communicate()[0].strip().decode() + if process.returncode != 0: + if verbose: + print("unable to run %s (error)" % dispcmd) + print("stdout was %s" % stdout) + return None, process.returncode + return stdout, process.returncode + + +def versions_from_parentdir(parentdir_prefix, root, verbose): + """Try to determine the version from the parent directory name. + + Source tarballs conventionally unpack into a directory that includes both + the project name and a version string. We will also support searching up + two directory levels for an appropriately named parent directory + """ + rootdirs = [] + + for _ in range(3): + dirname = os.path.basename(root) + if dirname.startswith(parentdir_prefix): + return { + "version": dirname[len(parentdir_prefix) :], + "full-revisionid": None, + "dirty": False, + "error": None, + "date": None, + } + rootdirs.append(root) + root = os.path.dirname(root) # up a level + + if verbose: + print( + "Tried directories %s but none started with prefix %s" + % (str(rootdirs), parentdir_prefix) + ) + raise NotThisMethod("rootdir doesn't start with parentdir_prefix") + + +@register_vcs_handler("git", "get_keywords") +def git_get_keywords(versionfile_abs): + """Extract version information from the given file.""" + # the code embedded in _version.py can just fetch the value of these + # keywords. When used from setup.py, we don't want to import _version.py, + # so we do it with a regexp instead. This function is not used from + # _version.py. + keywords = {} + try: + with open(versionfile_abs, "r") as fobj: + for line in fobj: + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + except OSError: + pass + return keywords + + +@register_vcs_handler("git", "keywords") +def git_versions_from_keywords(keywords, tag_prefix, verbose): + """Get version information from git keywords.""" + if "refnames" not in keywords: + raise NotThisMethod("Short version file found") + date = keywords.get("date") + if date is not None: + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + + # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant + # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 + # -like" string, which we must then edit to make compliant), because + # it's been around since git-1.5.3, and it's too difficult to + # discover which version we're using, or to work around using an + # older one. + date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + refnames = keywords["refnames"].strip() + if refnames.startswith("$Format"): + if verbose: + print("keywords are unexpanded, not using") + raise NotThisMethod("unexpanded keywords, not a git-archive tarball") + refs = {r.strip() for r in refnames.strip("()").split(",")} + # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of + # just "foo-1.0". If we see a "tag: " prefix, prefer those. + TAG = "tag: " + tags = {r[len(TAG) :] for r in refs if r.startswith(TAG)} + if not tags: + # Either we're using git < 1.8.3, or there really are no tags. We use + # a heuristic: assume all version tags have a digit. The old git %d + # expansion behaves like git log --decorate=short and strips out the + # refs/heads/ and refs/tags/ prefixes that would let us distinguish + # between branches and tags. By ignoring refnames without digits, we + # filter out many common branch names like "release" and + # "stabilization", as well as "HEAD" and "master". + tags = {r for r in refs if re.search(r"\d", r)} + if verbose: + print("discarding '%s', no digits" % ",".join(refs - tags)) + if verbose: + print("likely tags: %s" % ",".join(sorted(tags))) + for ref in sorted(tags): + # sorting will prefer e.g. "2.0" over "2.0rc1" + if ref.startswith(tag_prefix): + r = ref[len(tag_prefix) :] + # Filter out refs that exactly match prefix or that don't start + # with a number once the prefix is stripped (mostly a concern + # when prefix is '') + if not re.match(r"\d", r): + continue + if verbose: + print("picking %s" % r) + return { + "version": r, + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": None, + "date": date, + } + # no suitable tags, so version is "0+unknown", but full hex is still there + if verbose: + print("no suitable tags, using unknown + full revision id") + return { + "version": "0+unknown", + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": "no suitable tags", + "date": None, + } + + +@register_vcs_handler("git", "pieces_from_vcs") +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): + """Get version from 'git describe' in the root of the source tree. + + This only gets called if the git-archive 'subst' keywords were *not* + expanded, and _version.py hasn't already been rewritten with a short + version string, meaning we're inside a checked out source tree. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + + # GIT_DIR can interfere with correct operation of Versioneer. + # It may be intended to be passed to the Versioneer-versioned project, + # but that should not change where we get our version from. + env = os.environ.copy() + env.pop("GIT_DIR", None) + runner = functools.partial(runner, env=env) + + _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True) + if rc != 0: + if verbose: + print("Directory %s not under git control" % root) + raise NotThisMethod("'git rev-parse --git-dir' returned error") + + # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] + # if there isn't one, this yields HEX[-dirty] (no NUM) + describe_out, rc = runner( + GITS, + [ + "describe", + "--tags", + "--dirty", + "--always", + "--long", + "--match", + f"{tag_prefix}[[:digit:]]*", + ], + cwd=root, + ) + # --long was added in git-1.5.5 + if describe_out is None: + raise NotThisMethod("'git describe' failed") + describe_out = describe_out.strip() + full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) + if full_out is None: + raise NotThisMethod("'git rev-parse' failed") + full_out = full_out.strip() + + pieces = {} + pieces["long"] = full_out + pieces["short"] = full_out[:7] # maybe improved later + pieces["error"] = None + + branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], cwd=root) + # --abbrev-ref was added in git-1.6.3 + if rc != 0 or branch_name is None: + raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") + branch_name = branch_name.strip() + + if branch_name == "HEAD": + # If we aren't exactly on a branch, pick a branch which represents + # the current commit. If all else fails, we are on a branchless + # commit. + branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) + # --contains was added in git-1.5.4 + if rc != 0 or branches is None: + raise NotThisMethod("'git branch --contains' returned error") + branches = branches.split("\n") + + # Remove the first line if we're running detached + if "(" in branches[0]: + branches.pop(0) + + # Strip off the leading "* " from the list of branches. + branches = [branch[2:] for branch in branches] + if "master" in branches: + branch_name = "master" + elif not branches: + branch_name = None + else: + # Pick the first branch that is returned. Good or bad. + branch_name = branches[0] + + pieces["branch"] = branch_name + + # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] + # TAG might have hyphens. + git_describe = describe_out + + # look for -dirty suffix + dirty = git_describe.endswith("-dirty") + pieces["dirty"] = dirty + if dirty: + git_describe = git_describe[: git_describe.rindex("-dirty")] + + # now we have TAG-NUM-gHEX or HEX + + if "-" in git_describe: + # TAG-NUM-gHEX + mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) + if not mo: + # unparsable. Maybe git-describe is misbehaving? + pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out + return pieces + + # tag + full_tag = mo.group(1) + if not full_tag.startswith(tag_prefix): + if verbose: + fmt = "tag '%s' doesn't start with prefix '%s'" + print(fmt % (full_tag, tag_prefix)) + pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % (full_tag, tag_prefix) + return pieces + pieces["closest-tag"] = full_tag[len(tag_prefix) :] + + # distance: number of commits since tag + pieces["distance"] = int(mo.group(2)) + + # commit: short hex revision ID + pieces["short"] = mo.group(3) + + else: + # HEX: no tags + pieces["closest-tag"] = None + out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) + pieces["distance"] = len(out.split()) # total number of commits + + # commit date: see ISO-8601 comment in git_versions_from_keywords() + date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip() + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + + return pieces + + +def plus_or_dot(pieces): + """Return a + if we don't already have one, else return a .""" + if "+" in pieces.get("closest-tag", ""): + return "." + return "+" + + +def render_pep440(pieces): + """Build up version string, with post-release "local version identifier". + + Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you + get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty + + Exceptions: + 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_branch(pieces): + """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . + + The ".dev0" means not master branch. Note that .dev0 sorts backwards + (a feature branch will appear "older" than the master branch). + + Exceptions: + 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0" + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def pep440_split_post(ver): + """Split pep440 version string at the post-release segment. + + Returns the release segments before the post-release and the + post-release version number (or -1 if no post-release segment is present). + """ + vc = str.split(ver, ".post") + return vc[0], int(vc[1] or 0) if len(vc) == 2 else None + + +def render_pep440_pre(pieces): + """TAG[.postN.devDISTANCE] -- No -dirty. + + Exceptions: + 1: no tags. 0.post0.devDISTANCE + """ + if pieces["closest-tag"]: + if pieces["distance"]: + # update the post release segment + tag_version, post_version = pep440_split_post(pieces["closest-tag"]) + rendered = tag_version + if post_version is not None: + rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"]) + else: + rendered += ".post0.dev%d" % (pieces["distance"]) + else: + # no commits, use the tag as the version + rendered = pieces["closest-tag"] + else: + # exception #1 + rendered = "0.post0.dev%d" % pieces["distance"] + return rendered + + +def render_pep440_post(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX] . + + The ".dev0" means dirty. Note that .dev0 sorts backwards + (a dirty tree will appear "older" than the corresponding clean one), + but you shouldn't be releasing software with -dirty anyways. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + return rendered + + +def render_pep440_post_branch(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . + + The ".dev0" means not master branch. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_old(pieces): + """TAG[.postDISTANCE[.dev0]] . + + The ".dev0" means dirty. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + return rendered + + +def render_git_describe(pieces): + """TAG[-DISTANCE-gHEX][-dirty]. + + Like 'git describe --tags --dirty --always'. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"]: + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render_git_describe_long(pieces): + """TAG-DISTANCE-gHEX[-dirty]. + + Like 'git describe --tags --dirty --always -long'. + The distance/hash is unconditional. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render(pieces, style): + """Render the given version pieces into the requested style.""" + if pieces["error"]: + return { + "version": "unknown", + "full-revisionid": pieces.get("long"), + "dirty": None, + "error": pieces["error"], + "date": None, + } + + if not style or style == "default": + style = "pep440" # the default + + if style == "pep440": + rendered = render_pep440(pieces) + elif style == "pep440-branch": + rendered = render_pep440_branch(pieces) + elif style == "pep440-pre": + rendered = render_pep440_pre(pieces) + elif style == "pep440-post": + rendered = render_pep440_post(pieces) + elif style == "pep440-post-branch": + rendered = render_pep440_post_branch(pieces) + elif style == "pep440-old": + rendered = render_pep440_old(pieces) + elif style == "git-describe": + rendered = render_git_describe(pieces) + elif style == "git-describe-long": + rendered = render_git_describe_long(pieces) + else: + raise ValueError("unknown style '%s'" % style) + + return { + "version": rendered, + "full-revisionid": pieces["long"], + "dirty": pieces["dirty"], + "error": None, + "date": pieces.get("date"), + } + + +def get_versions(): + """Get version information or return default if unable to do so.""" + # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have + # __file__, we can work backwards from there to the root. Some + # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which + # case we can only use expanded keywords. + + cfg = get_config() + verbose = cfg.verbose + + try: + return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, verbose) + except NotThisMethod: + pass + + try: + root = os.path.realpath(__file__) + # versionfile_source is the relative path from the top of the source + # tree (where the .git directory might live) to this file. Invert + # this to find the root from __file__. + for _ in cfg.versionfile_source.split("/"): + root = os.path.dirname(root) + except NameError: + return { + "version": "0+unknown", + "full-revisionid": None, + "dirty": None, + "error": "unable to find root of source tree", + "date": None, + } + + try: + pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) + return render(pieces, cfg.style) + except NotThisMethod: + pass + + try: + if cfg.parentdir_prefix: + return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) + except NotThisMethod: + pass + + return { + "version": "0+unknown", + "full-revisionid": None, + "dirty": None, + "error": "unable to compute version", + "date": None, + } diff --git a/spz_python/spz/sparsetype.py b/spz_python/spz/sparsetype.py new file mode 100644 index 0000000..ebc655e --- /dev/null +++ b/spz_python/spz/sparsetype.py @@ -0,0 +1,75 @@ +class StructureType: + def __repr__(self): + return self.name + + def __eq__(self, other): + return self.name == to_type(other).name + + def __hash__(self): + return hash(self.name) + + def __reduce__(self): + return self.name + + +# Singletons +class sparse(StructureType): + name = "sparse" + abbreviation = "S" + + +class compressed(StructureType): + name = "compressed" + abbreviation = "C" + + +class doubly_compressed(StructureType): + name = "doubly_compressed" + abbreviation = "DC" + + +S = sparse = sparse() +C = compressed = compressed() +DC = doubly_compressed = doubly_compressed() + +_STR_TO_TYPE = { + "s": S, + "sparse": S, + "singleton": S, + "c": C, + "compressed": C, + "dc": DC, + "d": DC, + "doubly_compressed": DC, + "doubly compressed": DC, + "doublycompressed": DC, +} + + +def to_type(x): + """Convert a string to a StructureType""" + if isinstance(x, StructureType): + return x + return _STR_TO_TYPE[x.lower()] + + +def to_str(x): + return to_type(x).name + + +def abbreviate(*types): + if len(types) == 1 and not isinstance(types[0], (StructureType, str)): + types = types[0] + abbvs = [to_type(x).abbreviation for x in types] + sep = "-" if "DC" in abbvs else "" + return sep.join(abbvs) + + +def unabbreviate(abbr): + rv = [] + for sub in abbr.replace("D-", "DC-").replace("-", "").split("DC"): + for c in sub: + rv.append(to_type(c)) + rv.append(DC) + rv.pop() # One extra DC + return rv diff --git a/spz_python/spz/tests/__init__.py b/spz_python/spz/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/spz_python/spz/tests/conftest.py b/spz_python/spz/tests/conftest.py new file mode 100644 index 0000000..2d716ad --- /dev/null +++ b/spz_python/spz/tests/conftest.py @@ -0,0 +1,18 @@ +import pytest + + +@pytest.fixture(scope="session", autouse=True) +def ic(): + """Make `ic` available everywhere for easier debugging""" + try: + import icecream + except ImportError: + return + icecream.install() + # icecream.ic.disable() # do ic.enable() to re-enable + return icecream.ic + + +def pytest_runtest_setup(item): + if "slow" in item.keywords and not item.config.getoption("--runslow"): + pytest.skip("need --runslow option to run") diff --git a/spz_python/spz/tests/test_sparsetype.py b/spz_python/spz/tests/test_sparsetype.py new file mode 100644 index 0000000..50324d7 --- /dev/null +++ b/spz_python/spz/tests/test_sparsetype.py @@ -0,0 +1,16 @@ +from spz.sparsetype import DC, C, S, abbreviate, unabbreviate + + +def test_abbreviate(): + expected = "S-C-S-DC-C-S" + assert abbreviate([S, C, S, DC, C, S]) == expected + assert abbreviate(S, C, S, DC, C, S) == expected + assert abbreviate("S", "C", "S", "DC", "C", "S") == expected + assert abbreviate(["S", "c", "Sparse", "D", "compressed", "sparse"]) == expected + + +def test_unabbreviate(): + expected = [S, C, S, DC, C, S] + assert unabbreviate("S-C-S-DC-C-S") == expected + assert unabbreviate("SCSDCCS") == expected + assert unabbreviate("SC-S-D-C-S") == expected diff --git a/spz_python/spz/tests/test_spz.py b/spz_python/spz/tests/test_spz.py new file mode 100644 index 0000000..b6dfd63 --- /dev/null +++ b/spz_python/spz/tests/test_spz.py @@ -0,0 +1,135 @@ +import itertools +import random + +import numpy as np +import pandas as pd +import pytest + +from spz import SPZ + + +@pytest.fixture +def indices1(): + return [ + [0, 0, 0, 0, 0, 1, 1, 1], + [0, 0, 1, 1, 1, 1, 1, 1], + [0, 0, 0, 0, 1, 1, 1, 1], + [1, 2, 0, 2, 0, 0, 1, 2], + ] + + +@pytest.mark.parametrize("shape", [[2, 2, 2, 3], [5, 6, 7, 8], [8, 7, 6, 5]]) +def test_indices1(indices1, shape): + df = pd.DataFrame(indices1).T.sort_values([0, 1, 2, 3]) + sparsities = ["S", "C", "DC"] + for sparsity in itertools.product(sparsities, sparsities, sparsities): + structure = "".join(sparsity) + "S" + spz = SPZ(indices1, shape, structure) + spz._validate() + # spz._repr_svg_() + df2 = pd.DataFrame(spz.arrays).T + pd.testing.assert_frame_equal(df, df2) + + +def test_rank1(): + for size in range(1, 4): + for num in range(1, size + 1): + for array in itertools.combinations(range(size), num): + array = np.array(array) + spz = SPZ([array], (size,), "S") + spz._validate() + # spz._repr_svg_() + [index] = spz.arrays + assert np.array_equal(array, index) + + +@pytest.mark.slow +def test_rank2(): + for nrows in range(1, 4): + for ncols in range(1, 4): + size = nrows * ncols + for num in range(1, size + 1): + for array in itertools.combinations(range(size), num): + array = np.array(array) + x = array // ncols + y = array % ncols + for sparsity in ["S", "C", "DC"]: + spz = SPZ([x, y], (nrows, ncols), sparsity + "S") + spz._validate() + # spz._repr_svg_() + rows, cols = spz.arrays + assert np.array_equal(x, rows) + assert np.array_equal(y, cols) + + +@pytest.mark.slow +def test_rank3(): + for nx in range(1, 3): + for ny in range(1, 3): + for nz in range(1, 3): + size = nx * ny * nz + for num in range(1, size + 1): + for array in itertools.combinations(range(size), num): + array = np.array(array) + x = array // (ny * nz) + y = array // nz % ny + z = array % nz + for sparsity in itertools.product(["S", "C", "DC"], ["S", "C", "DC"]): + if random.random() < 2 / 3: + # Randomly skip two thirds of cases to speed up testing + continue + structure = "".join(sparsity) + "S" + spz = SPZ([x, y, z], (nx, ny, nz), structure) + spz._validate() + # spz._repr_svg_() + x2, y2, z2 = spz.arrays + assert np.array_equal(x, x2) + assert np.array_equal(y, y2) + assert np.array_equal(z, z2) + + +@pytest.mark.slow +@pytest.mark.parametrize("N", range(1, 7)) +def test_rankN(N): + sparsities = [["S", "C", "DC"]] * (N - 1) + for sparsity in itertools.product(*sparsities): + structure = "".join(sparsity) + "S" + # For each structure, randomly choose each dimension to be size 1, 2, 3, or 4 + shape = tuple(random.randint(1, 4) for _ in range(N)) + size = np.multiply.reduce(shape) + # Randomly choose the number of elements + num = random.randint(1, size) + # Randomly add indices for the elements + flat_idx = set() + while len(flat_idx) < num: + flat_idx.add(random.randrange(size)) + array = np.array(sorted(flat_idx)) + if N == 1: + indices = [] + else: + indices = [array // int(np.multiply.reduce(shape[1:]))] + for i in range(1, N - 1): + indices.append(array // np.multiply.reduce(shape[i + 1 :]) % shape[i]) + indices.append(array % shape[-1]) + try: + spz = SPZ(indices, shape, structure) + except Exception: # pragma: no cover + print("N:", N) + print("array:", array) + print("structure:", structure) + print("shape:", shape) + print("indices:", indices) + raise + try: + spz._validate() + except Exception: # pragma: no cover + print("structure:", spz.structure) + print("shape:", spz.shape) + print("indices:", spz._indices) + print("pointers:", spz._pointers) + print(spz) + raise + # spz._repr_svg_() + arrays = spz.arrays + for index, arr in zip(indices, arrays): + assert np.array_equal(index, arr) diff --git a/spz_python/versioneer.py b/spz_python/versioneer.py new file mode 100644 index 0000000..8db5abd --- /dev/null +++ b/spz_python/versioneer.py @@ -0,0 +1,2193 @@ +# Version: 0.23 + +"""The Versioneer - like a rocketeer, but for versions. + +The Versioneer +============== + +* like a rocketeer, but for versions! +* https://github.com/python-versioneer/python-versioneer +* Brian Warner +* License: Public Domain (CC0-1.0) +* Compatible with: Python 3.7, 3.8, 3.9, 3.10 and pypy3 +* [![Latest Version][pypi-image]][pypi-url] +* [![Build Status][travis-image]][travis-url] + +This is a tool for managing a recorded version number in distutils/setuptools-based +python projects. The goal is to remove the tedious and error-prone "update +the embedded version string" step from your release process. Making a new +release should be as easy as recording a new tag in your version-control +system, and maybe making new tarballs. + + +## Quick Install + +* `pip install versioneer` to somewhere in your $PATH +* add a `[versioneer]` section to your setup.cfg (see [Install](INSTALL.md)) +* run `versioneer install` in your source tree, commit the results +* Verify version information with `python setup.py version` + +## Version Identifiers + +Source trees come from a variety of places: + +* a version-control system checkout (mostly used by developers) +* a nightly tarball, produced by build automation +* a snapshot tarball, produced by a web-based VCS browser, like github's + "tarball from tag" feature +* a release tarball, produced by "setup.py sdist", distributed through PyPI + +Within each source tree, the version identifier (either a string or a number, +this tool is format-agnostic) can come from a variety of places: + +* ask the VCS tool itself, e.g. "git describe" (for checkouts), which knows + about recent "tags" and an absolute revision-id +* the name of the directory into which the tarball was unpacked +* an expanded VCS keyword ($Id$, etc) +* a `_version.py` created by some earlier build step + +For released software, the version identifier is closely related to a VCS +tag. Some projects use tag names that include more than just the version +string (e.g. "myproject-1.2" instead of just "1.2"), in which case the tool +needs to strip the tag prefix to extract the version identifier. For +unreleased software (between tags), the version identifier should provide +enough information to help developers recreate the same tree, while also +giving them an idea of roughly how old the tree is (after version 1.2, before +version 1.3). Many VCS systems can report a description that captures this, +for example `git describe --tags --dirty --always` reports things like +"0.7-1-g574ab98-dirty" to indicate that the checkout is one revision past the +0.7 tag, has a unique revision id of "574ab98", and is "dirty" (it has +uncommitted changes). + +The version identifier is used for multiple purposes: + +* to allow the module to self-identify its version: `myproject.__version__` +* to choose a name and prefix for a 'setup.py sdist' tarball + +## Theory of Operation + +Versioneer works by adding a special `_version.py` file into your source +tree, where your `__init__.py` can import it. This `_version.py` knows how to +dynamically ask the VCS tool for version information at import time. + +`_version.py` also contains `$Revision$` markers, and the installation +process marks `_version.py` to have this marker rewritten with a tag name +during the `git archive` command. As a result, generated tarballs will +contain enough information to get the proper version. + +To allow `setup.py` to compute a version too, a `versioneer.py` is added to +the top level of your source tree, next to `setup.py` and the `setup.cfg` +that configures it. This overrides several distutils/setuptools commands to +compute the version when invoked, and changes `setup.py build` and `setup.py +sdist` to replace `_version.py` with a small static file that contains just +the generated version data. + +## Installation + +See [INSTALL.md](./INSTALL.md) for detailed installation instructions. + +## Version-String Flavors + +Code which uses Versioneer can learn about its version string at runtime by +importing `_version` from your main `__init__.py` file and running the +`get_versions()` function. From the "outside" (e.g. in `setup.py`), you can +import the top-level `versioneer.py` and run `get_versions()`. + +Both functions return a dictionary with different flavors of version +information: + +* `['version']`: A condensed version string, rendered using the selected + style. This is the most commonly used value for the project's version + string. The default "pep440" style yields strings like `0.11`, + `0.11+2.g1076c97`, or `0.11+2.g1076c97.dirty`. See the "Styles" section + below for alternative styles. + +* `['full-revisionid']`: detailed revision identifier. For Git, this is the + full SHA1 commit id, e.g. "1076c978a8d3cfc70f408fe5974aa6c092c949ac". + +* `['date']`: Date and time of the latest `HEAD` commit. For Git, it is the + commit date in ISO 8601 format. This will be None if the date is not + available. + +* `['dirty']`: a boolean, True if the tree has uncommitted changes. Note that + this is only accurate if run in a VCS checkout, otherwise it is likely to + be False or None + +* `['error']`: if the version string could not be computed, this will be set + to a string describing the problem, otherwise it will be None. It may be + useful to throw an exception in setup.py if this is set, to avoid e.g. + creating tarballs with a version string of "unknown". + +Some variants are more useful than others. Including `full-revisionid` in a +bug report should allow developers to reconstruct the exact code being tested +(or indicate the presence of local changes that should be shared with the +developers). `version` is suitable for display in an "about" box or a CLI +`--version` output: it can be easily compared against release notes and lists +of bugs fixed in various releases. + +The installer adds the following text to your `__init__.py` to place a basic +version in `YOURPROJECT.__version__`: + + from ._version import get_versions + __version__ = get_versions()['version'] + del get_versions + +## Styles + +The setup.cfg `style=` configuration controls how the VCS information is +rendered into a version string. + +The default style, "pep440", produces a PEP440-compliant string, equal to the +un-prefixed tag name for actual releases, and containing an additional "local +version" section with more detail for in-between builds. For Git, this is +TAG[+DISTANCE.gHEX[.dirty]] , using information from `git describe --tags +--dirty --always`. For example "0.11+2.g1076c97.dirty" indicates that the +tree is like the "1076c97" commit but has uncommitted changes (".dirty"), and +that this commit is two revisions ("+2") beyond the "0.11" tag. For released +software (exactly equal to a known tag), the identifier will only contain the +stripped tag, e.g. "0.11". + +Other styles are available. See [details.md](details.md) in the Versioneer +source tree for descriptions. + +## Debugging + +Versioneer tries to avoid fatal errors: if something goes wrong, it will tend +to return a version of "0+unknown". To investigate the problem, run `setup.py +version`, which will run the version-lookup code in a verbose mode, and will +display the full contents of `get_versions()` (including the `error` string, +which may help identify what went wrong). + +## Known Limitations + +Some situations are known to cause problems for Versioneer. This details the +most significant ones. More can be found on Github +[issues page](https://github.com/python-versioneer/python-versioneer/issues). + +### Subprojects + +Versioneer has limited support for source trees in which `setup.py` is not in +the root directory (e.g. `setup.py` and `.git/` are *not* siblings). The are +two common reasons why `setup.py` might not be in the root: + +* Source trees which contain multiple subprojects, such as + [Buildbot](https://github.com/buildbot/buildbot), which contains both + "master" and "slave" subprojects, each with their own `setup.py`, + `setup.cfg`, and `tox.ini`. Projects like these produce multiple PyPI + distributions (and upload multiple independently-installable tarballs). +* Source trees whose main purpose is to contain a C library, but which also + provide bindings to Python (and perhaps other languages) in subdirectories. + +Versioneer will look for `.git` in parent directories, and most operations +should get the right version string. However `pip` and `setuptools` have bugs +and implementation details which frequently cause `pip install .` from a +subproject directory to fail to find a correct version string (so it usually +defaults to `0+unknown`). + +`pip install --editable .` should work correctly. `setup.py install` might +work too. + +Pip-8.1.1 is known to have this problem, but hopefully it will get fixed in +some later version. + +[Bug #38](https://github.com/python-versioneer/python-versioneer/issues/38) is tracking +this issue. The discussion in +[PR #61](https://github.com/python-versioneer/python-versioneer/pull/61) describes the +issue from the Versioneer side in more detail. +[pip PR#3176](https://github.com/pypa/pip/pull/3176) and +[pip PR#3615](https://github.com/pypa/pip/pull/3615) contain work to improve +pip to let Versioneer work correctly. + +Versioneer-0.16 and earlier only looked for a `.git` directory next to the +`setup.cfg`, so subprojects were completely unsupported with those releases. + +### Editable installs with setuptools <= 18.5 + +`setup.py develop` and `pip install --editable .` allow you to install a +project into a virtualenv once, then continue editing the source code (and +test) without re-installing after every change. + +"Entry-point scripts" (`setup(entry_points={"console_scripts": ..})`) are a +convenient way to specify executable scripts that should be installed along +with the python package. + +These both work as expected when using modern setuptools. When using +setuptools-18.5 or earlier, however, certain operations will cause +`pkg_resources.DistributionNotFound` errors when running the entrypoint +script, which must be resolved by re-installing the package. This happens +when the install happens with one version, then the egg_info data is +regenerated while a different version is checked out. Many setup.py commands +cause egg_info to be rebuilt (including `sdist`, `wheel`, and installing into +a different virtualenv), so this can be surprising. + +[Bug #83](https://github.com/python-versioneer/python-versioneer/issues/83) describes +this one, but upgrading to a newer version of setuptools should probably +resolve it. + + +## Updating Versioneer + +To upgrade your project to a new release of Versioneer, do the following: + +* install the new Versioneer (`pip install -U versioneer` or equivalent) +* edit `setup.cfg`, if necessary, to include any new configuration settings + indicated by the release notes. See [UPGRADING](./UPGRADING.md) for details. +* re-run `versioneer install` in your source tree, to replace + `SRC/_version.py` +* commit any changed files + +## Future Directions + +This tool is designed to make it easily extended to other version-control +systems: all VCS-specific components are in separate directories like +src/git/ . The top-level `versioneer.py` script is assembled from these +components by running make-versioneer.py . In the future, make-versioneer.py +will take a VCS name as an argument, and will construct a version of +`versioneer.py` that is specific to the given VCS. It might also take the +configuration arguments that are currently provided manually during +installation by editing setup.py . Alternatively, it might go the other +direction and include code from all supported VCS systems, reducing the +number of intermediate scripts. + +## Similar projects + +* [setuptools_scm](https://github.com/pypa/setuptools_scm/) - a non-vendored build-time + dependency +* [minver](https://github.com/jbweston/miniver) - a lightweight reimplementation of + versioneer +* [versioningit](https://github.com/jwodder/versioningit) - a PEP 518-based setuptools + plugin + +## License + +To make Versioneer easier to embed, all its code is dedicated to the public +domain. The `_version.py` that it creates is also in the public domain. +Specifically, both are released under the Creative Commons "Public Domain +Dedication" license (CC0-1.0), as described in +https://creativecommons.org/publicdomain/zero/1.0/ . + +[pypi-image]: https://img.shields.io/pypi/v/versioneer.svg +[pypi-url]: https://pypi.python.org/pypi/versioneer/ +[travis-image]: +https://img.shields.io/travis/com/python-versioneer/python-versioneer.svg +[travis-url]: https://travis-ci.com/github/python-versioneer/python-versioneer + +""" +# pylint:disable=invalid-name,import-outside-toplevel,missing-function-docstring +# pylint:disable=missing-class-docstring,too-many-branches,too-many-statements +# pylint:disable=raise-missing-from,too-many-lines,too-many-locals,import-error +# pylint:disable=too-few-public-methods,redefined-outer-name,consider-using-with +# pylint:disable=attribute-defined-outside-init,too-many-arguments + +import configparser +import errno +import functools +import json +import os +import re +import subprocess +import sys +from typing import Callable, Dict + + +class VersioneerConfig: + """Container for Versioneer configuration parameters.""" + + +def get_root(): + """Get the project root directory. + + We require that all commands are run from the project root, i.e. the + directory that contains setup.py, setup.cfg, and versioneer.py . + """ + root = os.path.realpath(os.path.abspath(os.getcwd())) + setup_py = os.path.join(root, "setup.py") + versioneer_py = os.path.join(root, "versioneer.py") + if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): + # allow 'python path/to/setup.py COMMAND' + root = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0]))) + setup_py = os.path.join(root, "setup.py") + versioneer_py = os.path.join(root, "versioneer.py") + if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): + err = ( + "Versioneer was unable to run the project root directory. " + "Versioneer requires setup.py to be executed from " + "its immediate directory (like 'python setup.py COMMAND'), " + "or in a way that lets it use sys.argv[0] to find the root " + "(like 'python path/to/setup.py COMMAND')." + ) + raise VersioneerBadRootError(err) + try: + # Certain runtime workflows (setup.py install/develop in a setuptools + # tree) execute all dependencies in a single python process, so + # "versioneer" may be imported multiple times, and python's shared + # module-import table will cache the first one. So we can't use + # os.path.dirname(__file__), as that will find whichever + # versioneer.py was first imported, even in later projects. + my_path = os.path.realpath(os.path.abspath(__file__)) + me_dir = os.path.normcase(os.path.splitext(my_path)[0]) + vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0]) + if me_dir != vsr_dir: + print( + "Warning: build in %s is using versioneer.py from %s" + % (os.path.dirname(my_path), versioneer_py) + ) + except NameError: + pass + return root + + +def get_config_from_root(root): + """Read the project setup.cfg file to determine Versioneer config.""" + # This might raise OSError (if setup.cfg is missing), or + # configparser.NoSectionError (if it lacks a [versioneer] section), or + # configparser.NoOptionError (if it lacks "VCS="). See the docstring at + # the top of versioneer.py for instructions on writing your setup.cfg . + setup_cfg = os.path.join(root, "setup.cfg") + parser = configparser.ConfigParser() + with open(setup_cfg, "r") as cfg_file: + parser.read_file(cfg_file) + VCS = parser.get("versioneer", "VCS") # mandatory + + # Dict-like interface for non-mandatory entries + section = parser["versioneer"] + + cfg = VersioneerConfig() + cfg.VCS = VCS + cfg.style = section.get("style", "") + cfg.versionfile_source = section.get("versionfile_source") + cfg.versionfile_build = section.get("versionfile_build") + cfg.tag_prefix = section.get("tag_prefix") + if cfg.tag_prefix in ("''", '""', None): + cfg.tag_prefix = "" + cfg.parentdir_prefix = section.get("parentdir_prefix") + cfg.verbose = section.get("verbose") + return cfg + + +class NotThisMethod(Exception): + """Exception raised if a method is not valid for the current scenario.""" + + +# these dictionaries contain VCS-specific tools +LONG_VERSION_PY: Dict[str, str] = {} +HANDLERS: Dict[str, Dict[str, Callable]] = {} + + +def register_vcs_handler(vcs, method): # decorator + """Create decorator to mark a method as the handler of a VCS.""" + + def decorate(f): + """Store f in HANDLERS[vcs][method].""" + HANDLERS.setdefault(vcs, {})[method] = f + return f + + return decorate + + +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None): + """Call the given command(s).""" + assert isinstance(commands, list) + process = None + + popen_kwargs = {} + if sys.platform == "win32": + # This hides the console window if pythonw.exe is used + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + popen_kwargs["startupinfo"] = startupinfo + + for command in commands: + try: + dispcmd = str([command] + args) + # remember shell=False, so use git.cmd on windows, not just git + process = subprocess.Popen( + [command] + args, + cwd=cwd, + env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr else None), + **popen_kwargs, + ) + break + except OSError: + e = sys.exc_info()[1] + if e.errno == errno.ENOENT: + continue + if verbose: + print("unable to run %s" % dispcmd) + print(e) + return None, None + else: + if verbose: + print("unable to find command, tried %s" % (commands,)) + return None, None + stdout = process.communicate()[0].strip().decode() + if process.returncode != 0: + if verbose: + print("unable to run %s (error)" % dispcmd) + print("stdout was %s" % stdout) + return None, process.returncode + return stdout, process.returncode + + +LONG_VERSION_PY[ + "git" +] = r''' +# This file helps to compute a version number in source trees obtained from +# git-archive tarball (such as those provided by githubs download-from-tag +# feature). Distribution tarballs (built by setup.py sdist) and build +# directories (produced by setup.py build) will contain a much shorter file +# that just contains the computed version number. + +# This file is released into the public domain. Generated by +# versioneer-0.23 (https://github.com/python-versioneer/python-versioneer) + +"""Git implementation of _version.py.""" + +import errno +import os +import re +import subprocess +import sys +from typing import Callable, Dict +import functools + + +def get_keywords(): + """Get the keywords needed to look up the version information.""" + # these strings will be replaced by git during git-archive. + # setup.py/versioneer.py will grep for the variable names, so they must + # each be defined on a line of their own. _version.py will just call + # get_keywords(). + git_refnames = "%(DOLLAR)sFormat:%%d%(DOLLAR)s" + git_full = "%(DOLLAR)sFormat:%%H%(DOLLAR)s" + git_date = "%(DOLLAR)sFormat:%%ci%(DOLLAR)s" + keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} + return keywords + + +class VersioneerConfig: + """Container for Versioneer configuration parameters.""" + + +def get_config(): + """Create, populate and return the VersioneerConfig() object.""" + # these strings are filled in when 'setup.py versioneer' creates + # _version.py + cfg = VersioneerConfig() + cfg.VCS = "git" + cfg.style = "%(STYLE)s" + cfg.tag_prefix = "%(TAG_PREFIX)s" + cfg.parentdir_prefix = "%(PARENTDIR_PREFIX)s" + cfg.versionfile_source = "%(VERSIONFILE_SOURCE)s" + cfg.verbose = False + return cfg + + +class NotThisMethod(Exception): + """Exception raised if a method is not valid for the current scenario.""" + + +LONG_VERSION_PY: Dict[str, str] = {} +HANDLERS: Dict[str, Dict[str, Callable]] = {} + + +def register_vcs_handler(vcs, method): # decorator + """Create decorator to mark a method as the handler of a VCS.""" + def decorate(f): + """Store f in HANDLERS[vcs][method].""" + if vcs not in HANDLERS: + HANDLERS[vcs] = {} + HANDLERS[vcs][method] = f + return f + return decorate + + +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, + env=None): + """Call the given command(s).""" + assert isinstance(commands, list) + process = None + + popen_kwargs = {} + if sys.platform == "win32": + # This hides the console window if pythonw.exe is used + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + popen_kwargs["startupinfo"] = startupinfo + + for command in commands: + try: + dispcmd = str([command] + args) + # remember shell=False, so use git.cmd on windows, not just git + process = subprocess.Popen([command] + args, cwd=cwd, env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr + else None), **popen_kwargs) + break + except OSError: + e = sys.exc_info()[1] + if e.errno == errno.ENOENT: + continue + if verbose: + print("unable to run %%s" %% dispcmd) + print(e) + return None, None + else: + if verbose: + print("unable to find command, tried %%s" %% (commands,)) + return None, None + stdout = process.communicate()[0].strip().decode() + if process.returncode != 0: + if verbose: + print("unable to run %%s (error)" %% dispcmd) + print("stdout was %%s" %% stdout) + return None, process.returncode + return stdout, process.returncode + + +def versions_from_parentdir(parentdir_prefix, root, verbose): + """Try to determine the version from the parent directory name. + + Source tarballs conventionally unpack into a directory that includes both + the project name and a version string. We will also support searching up + two directory levels for an appropriately named parent directory + """ + rootdirs = [] + + for _ in range(3): + dirname = os.path.basename(root) + if dirname.startswith(parentdir_prefix): + return {"version": dirname[len(parentdir_prefix):], + "full-revisionid": None, + "dirty": False, "error": None, "date": None} + rootdirs.append(root) + root = os.path.dirname(root) # up a level + + if verbose: + print("Tried directories %%s but none started with prefix %%s" %% + (str(rootdirs), parentdir_prefix)) + raise NotThisMethod("rootdir doesn't start with parentdir_prefix") + + +@register_vcs_handler("git", "get_keywords") +def git_get_keywords(versionfile_abs): + """Extract version information from the given file.""" + # the code embedded in _version.py can just fetch the value of these + # keywords. When used from setup.py, we don't want to import _version.py, + # so we do it with a regexp instead. This function is not used from + # _version.py. + keywords = {} + try: + with open(versionfile_abs, "r") as fobj: + for line in fobj: + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + except OSError: + pass + return keywords + + +@register_vcs_handler("git", "keywords") +def git_versions_from_keywords(keywords, tag_prefix, verbose): + """Get version information from git keywords.""" + if "refnames" not in keywords: + raise NotThisMethod("Short version file found") + date = keywords.get("date") + if date is not None: + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + + # git-2.2.0 added "%%cI", which expands to an ISO-8601 -compliant + # datestamp. However we prefer "%%ci" (which expands to an "ISO-8601 + # -like" string, which we must then edit to make compliant), because + # it's been around since git-1.5.3, and it's too difficult to + # discover which version we're using, or to work around using an + # older one. + date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + refnames = keywords["refnames"].strip() + if refnames.startswith("$Format"): + if verbose: + print("keywords are unexpanded, not using") + raise NotThisMethod("unexpanded keywords, not a git-archive tarball") + refs = {r.strip() for r in refnames.strip("()").split(",")} + # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of + # just "foo-1.0". If we see a "tag: " prefix, prefer those. + TAG = "tag: " + tags = {r[len(TAG):] for r in refs if r.startswith(TAG)} + if not tags: + # Either we're using git < 1.8.3, or there really are no tags. We use + # a heuristic: assume all version tags have a digit. The old git %%d + # expansion behaves like git log --decorate=short and strips out the + # refs/heads/ and refs/tags/ prefixes that would let us distinguish + # between branches and tags. By ignoring refnames without digits, we + # filter out many common branch names like "release" and + # "stabilization", as well as "HEAD" and "master". + tags = {r for r in refs if re.search(r'\d', r)} + if verbose: + print("discarding '%%s', no digits" %% ",".join(refs - tags)) + if verbose: + print("likely tags: %%s" %% ",".join(sorted(tags))) + for ref in sorted(tags): + # sorting will prefer e.g. "2.0" over "2.0rc1" + if ref.startswith(tag_prefix): + r = ref[len(tag_prefix):] + # Filter out refs that exactly match prefix or that don't start + # with a number once the prefix is stripped (mostly a concern + # when prefix is '') + if not re.match(r'\d', r): + continue + if verbose: + print("picking %%s" %% r) + return {"version": r, + "full-revisionid": keywords["full"].strip(), + "dirty": False, "error": None, + "date": date} + # no suitable tags, so version is "0+unknown", but full hex is still there + if verbose: + print("no suitable tags, using unknown + full revision id") + return {"version": "0+unknown", + "full-revisionid": keywords["full"].strip(), + "dirty": False, "error": "no suitable tags", "date": None} + + +@register_vcs_handler("git", "pieces_from_vcs") +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): + """Get version from 'git describe' in the root of the source tree. + + This only gets called if the git-archive 'subst' keywords were *not* + expanded, and _version.py hasn't already been rewritten with a short + version string, meaning we're inside a checked out source tree. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + + # GIT_DIR can interfere with correct operation of Versioneer. + # It may be intended to be passed to the Versioneer-versioned project, + # but that should not change where we get our version from. + env = os.environ.copy() + env.pop("GIT_DIR", None) + runner = functools.partial(runner, env=env) + + _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, + hide_stderr=True) + if rc != 0: + if verbose: + print("Directory %%s not under git control" %% root) + raise NotThisMethod("'git rev-parse --git-dir' returned error") + + # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] + # if there isn't one, this yields HEX[-dirty] (no NUM) + describe_out, rc = runner(GITS, [ + "describe", "--tags", "--dirty", "--always", "--long", + "--match", f"{tag_prefix}[[:digit:]]*" + ], cwd=root) + # --long was added in git-1.5.5 + if describe_out is None: + raise NotThisMethod("'git describe' failed") + describe_out = describe_out.strip() + full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) + if full_out is None: + raise NotThisMethod("'git rev-parse' failed") + full_out = full_out.strip() + + pieces = {} + pieces["long"] = full_out + pieces["short"] = full_out[:7] # maybe improved later + pieces["error"] = None + + branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], + cwd=root) + # --abbrev-ref was added in git-1.6.3 + if rc != 0 or branch_name is None: + raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") + branch_name = branch_name.strip() + + if branch_name == "HEAD": + # If we aren't exactly on a branch, pick a branch which represents + # the current commit. If all else fails, we are on a branchless + # commit. + branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) + # --contains was added in git-1.5.4 + if rc != 0 or branches is None: + raise NotThisMethod("'git branch --contains' returned error") + branches = branches.split("\n") + + # Remove the first line if we're running detached + if "(" in branches[0]: + branches.pop(0) + + # Strip off the leading "* " from the list of branches. + branches = [branch[2:] for branch in branches] + if "master" in branches: + branch_name = "master" + elif not branches: + branch_name = None + else: + # Pick the first branch that is returned. Good or bad. + branch_name = branches[0] + + pieces["branch"] = branch_name + + # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] + # TAG might have hyphens. + git_describe = describe_out + + # look for -dirty suffix + dirty = git_describe.endswith("-dirty") + pieces["dirty"] = dirty + if dirty: + git_describe = git_describe[:git_describe.rindex("-dirty")] + + # now we have TAG-NUM-gHEX or HEX + + if "-" in git_describe: + # TAG-NUM-gHEX + mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) + if not mo: + # unparsable. Maybe git-describe is misbehaving? + pieces["error"] = ("unable to parse git-describe output: '%%s'" + %% describe_out) + return pieces + + # tag + full_tag = mo.group(1) + if not full_tag.startswith(tag_prefix): + if verbose: + fmt = "tag '%%s' doesn't start with prefix '%%s'" + print(fmt %% (full_tag, tag_prefix)) + pieces["error"] = ("tag '%%s' doesn't start with prefix '%%s'" + %% (full_tag, tag_prefix)) + return pieces + pieces["closest-tag"] = full_tag[len(tag_prefix):] + + # distance: number of commits since tag + pieces["distance"] = int(mo.group(2)) + + # commit: short hex revision ID + pieces["short"] = mo.group(3) + + else: + # HEX: no tags + pieces["closest-tag"] = None + out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) + pieces["distance"] = len(out.split()) # total number of commits + + # commit date: see ISO-8601 comment in git_versions_from_keywords() + date = runner(GITS, ["show", "-s", "--format=%%ci", "HEAD"], cwd=root)[0].strip() + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + + return pieces + + +def plus_or_dot(pieces): + """Return a + if we don't already have one, else return a .""" + if "+" in pieces.get("closest-tag", ""): + return "." + return "+" + + +def render_pep440(pieces): + """Build up version string, with post-release "local version identifier". + + Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you + get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty + + Exceptions: + 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += plus_or_dot(pieces) + rendered += "%%d.g%%s" %% (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0+untagged.%%d.g%%s" %% (pieces["distance"], + pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_branch(pieces): + """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . + + The ".dev0" means not master branch. Note that .dev0 sorts backwards + (a feature branch will appear "older" than the master branch). + + Exceptions: + 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "%%d.g%%s" %% (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0" + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+untagged.%%d.g%%s" %% (pieces["distance"], + pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def pep440_split_post(ver): + """Split pep440 version string at the post-release segment. + + Returns the release segments before the post-release and the + post-release version number (or -1 if no post-release segment is present). + """ + vc = str.split(ver, ".post") + return vc[0], int(vc[1] or 0) if len(vc) == 2 else None + + +def render_pep440_pre(pieces): + """TAG[.postN.devDISTANCE] -- No -dirty. + + Exceptions: + 1: no tags. 0.post0.devDISTANCE + """ + if pieces["closest-tag"]: + if pieces["distance"]: + # update the post release segment + tag_version, post_version = pep440_split_post(pieces["closest-tag"]) + rendered = tag_version + if post_version is not None: + rendered += ".post%%d.dev%%d" %% (post_version + 1, pieces["distance"]) + else: + rendered += ".post0.dev%%d" %% (pieces["distance"]) + else: + # no commits, use the tag as the version + rendered = pieces["closest-tag"] + else: + # exception #1 + rendered = "0.post0.dev%%d" %% pieces["distance"] + return rendered + + +def render_pep440_post(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX] . + + The ".dev0" means dirty. Note that .dev0 sorts backwards + (a dirty tree will appear "older" than the corresponding clean one), + but you shouldn't be releasing software with -dirty anyways. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%%s" %% pieces["short"] + else: + # exception #1 + rendered = "0.post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += "+g%%s" %% pieces["short"] + return rendered + + +def render_pep440_post_branch(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . + + The ".dev0" means not master branch. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%%d" %% pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%%s" %% pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0.post%%d" %% pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+g%%s" %% pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_old(pieces): + """TAG[.postDISTANCE[.dev0]] . + + The ".dev0" means dirty. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + else: + # exception #1 + rendered = "0.post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + return rendered + + +def render_git_describe(pieces): + """TAG[-DISTANCE-gHEX][-dirty]. + + Like 'git describe --tags --dirty --always'. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"]: + rendered += "-%%d-g%%s" %% (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render_git_describe_long(pieces): + """TAG-DISTANCE-gHEX[-dirty]. + + Like 'git describe --tags --dirty --always -long'. + The distance/hash is unconditional. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + rendered += "-%%d-g%%s" %% (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render(pieces, style): + """Render the given version pieces into the requested style.""" + if pieces["error"]: + return {"version": "unknown", + "full-revisionid": pieces.get("long"), + "dirty": None, + "error": pieces["error"], + "date": None} + + if not style or style == "default": + style = "pep440" # the default + + if style == "pep440": + rendered = render_pep440(pieces) + elif style == "pep440-branch": + rendered = render_pep440_branch(pieces) + elif style == "pep440-pre": + rendered = render_pep440_pre(pieces) + elif style == "pep440-post": + rendered = render_pep440_post(pieces) + elif style == "pep440-post-branch": + rendered = render_pep440_post_branch(pieces) + elif style == "pep440-old": + rendered = render_pep440_old(pieces) + elif style == "git-describe": + rendered = render_git_describe(pieces) + elif style == "git-describe-long": + rendered = render_git_describe_long(pieces) + else: + raise ValueError("unknown style '%%s'" %% style) + + return {"version": rendered, "full-revisionid": pieces["long"], + "dirty": pieces["dirty"], "error": None, + "date": pieces.get("date")} + + +def get_versions(): + """Get version information or return default if unable to do so.""" + # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have + # __file__, we can work backwards from there to the root. Some + # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which + # case we can only use expanded keywords. + + cfg = get_config() + verbose = cfg.verbose + + try: + return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, + verbose) + except NotThisMethod: + pass + + try: + root = os.path.realpath(__file__) + # versionfile_source is the relative path from the top of the source + # tree (where the .git directory might live) to this file. Invert + # this to find the root from __file__. + for _ in cfg.versionfile_source.split('/'): + root = os.path.dirname(root) + except NameError: + return {"version": "0+unknown", "full-revisionid": None, + "dirty": None, + "error": "unable to find root of source tree", + "date": None} + + try: + pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) + return render(pieces, cfg.style) + except NotThisMethod: + pass + + try: + if cfg.parentdir_prefix: + return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) + except NotThisMethod: + pass + + return {"version": "0+unknown", "full-revisionid": None, + "dirty": None, + "error": "unable to compute version", "date": None} +''' + + +@register_vcs_handler("git", "get_keywords") +def git_get_keywords(versionfile_abs): + """Extract version information from the given file.""" + # the code embedded in _version.py can just fetch the value of these + # keywords. When used from setup.py, we don't want to import _version.py, + # so we do it with a regexp instead. This function is not used from + # _version.py. + keywords = {} + try: + with open(versionfile_abs, "r") as fobj: + for line in fobj: + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + except OSError: + pass + return keywords + + +@register_vcs_handler("git", "keywords") +def git_versions_from_keywords(keywords, tag_prefix, verbose): + """Get version information from git keywords.""" + if "refnames" not in keywords: + raise NotThisMethod("Short version file found") + date = keywords.get("date") + if date is not None: + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + + # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant + # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 + # -like" string, which we must then edit to make compliant), because + # it's been around since git-1.5.3, and it's too difficult to + # discover which version we're using, or to work around using an + # older one. + date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + refnames = keywords["refnames"].strip() + if refnames.startswith("$Format"): + if verbose: + print("keywords are unexpanded, not using") + raise NotThisMethod("unexpanded keywords, not a git-archive tarball") + refs = {r.strip() for r in refnames.strip("()").split(",")} + # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of + # just "foo-1.0". If we see a "tag: " prefix, prefer those. + TAG = "tag: " + tags = {r[len(TAG) :] for r in refs if r.startswith(TAG)} + if not tags: + # Either we're using git < 1.8.3, or there really are no tags. We use + # a heuristic: assume all version tags have a digit. The old git %d + # expansion behaves like git log --decorate=short and strips out the + # refs/heads/ and refs/tags/ prefixes that would let us distinguish + # between branches and tags. By ignoring refnames without digits, we + # filter out many common branch names like "release" and + # "stabilization", as well as "HEAD" and "master". + tags = {r for r in refs if re.search(r"\d", r)} + if verbose: + print("discarding '%s', no digits" % ",".join(refs - tags)) + if verbose: + print("likely tags: %s" % ",".join(sorted(tags))) + for ref in sorted(tags): + # sorting will prefer e.g. "2.0" over "2.0rc1" + if ref.startswith(tag_prefix): + r = ref[len(tag_prefix) :] + # Filter out refs that exactly match prefix or that don't start + # with a number once the prefix is stripped (mostly a concern + # when prefix is '') + if not re.match(r"\d", r): + continue + if verbose: + print("picking %s" % r) + return { + "version": r, + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": None, + "date": date, + } + # no suitable tags, so version is "0+unknown", but full hex is still there + if verbose: + print("no suitable tags, using unknown + full revision id") + return { + "version": "0+unknown", + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": "no suitable tags", + "date": None, + } + + +@register_vcs_handler("git", "pieces_from_vcs") +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): + """Get version from 'git describe' in the root of the source tree. + + This only gets called if the git-archive 'subst' keywords were *not* + expanded, and _version.py hasn't already been rewritten with a short + version string, meaning we're inside a checked out source tree. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + + # GIT_DIR can interfere with correct operation of Versioneer. + # It may be intended to be passed to the Versioneer-versioned project, + # but that should not change where we get our version from. + env = os.environ.copy() + env.pop("GIT_DIR", None) + runner = functools.partial(runner, env=env) + + _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True) + if rc != 0: + if verbose: + print("Directory %s not under git control" % root) + raise NotThisMethod("'git rev-parse --git-dir' returned error") + + # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] + # if there isn't one, this yields HEX[-dirty] (no NUM) + describe_out, rc = runner( + GITS, + [ + "describe", + "--tags", + "--dirty", + "--always", + "--long", + "--match", + f"{tag_prefix}[[:digit:]]*", + ], + cwd=root, + ) + # --long was added in git-1.5.5 + if describe_out is None: + raise NotThisMethod("'git describe' failed") + describe_out = describe_out.strip() + full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) + if full_out is None: + raise NotThisMethod("'git rev-parse' failed") + full_out = full_out.strip() + + pieces = {} + pieces["long"] = full_out + pieces["short"] = full_out[:7] # maybe improved later + pieces["error"] = None + + branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], cwd=root) + # --abbrev-ref was added in git-1.6.3 + if rc != 0 or branch_name is None: + raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") + branch_name = branch_name.strip() + + if branch_name == "HEAD": + # If we aren't exactly on a branch, pick a branch which represents + # the current commit. If all else fails, we are on a branchless + # commit. + branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) + # --contains was added in git-1.5.4 + if rc != 0 or branches is None: + raise NotThisMethod("'git branch --contains' returned error") + branches = branches.split("\n") + + # Remove the first line if we're running detached + if "(" in branches[0]: + branches.pop(0) + + # Strip off the leading "* " from the list of branches. + branches = [branch[2:] for branch in branches] + if "master" in branches: + branch_name = "master" + elif not branches: + branch_name = None + else: + # Pick the first branch that is returned. Good or bad. + branch_name = branches[0] + + pieces["branch"] = branch_name + + # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] + # TAG might have hyphens. + git_describe = describe_out + + # look for -dirty suffix + dirty = git_describe.endswith("-dirty") + pieces["dirty"] = dirty + if dirty: + git_describe = git_describe[: git_describe.rindex("-dirty")] + + # now we have TAG-NUM-gHEX or HEX + + if "-" in git_describe: + # TAG-NUM-gHEX + mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) + if not mo: + # unparsable. Maybe git-describe is misbehaving? + pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out + return pieces + + # tag + full_tag = mo.group(1) + if not full_tag.startswith(tag_prefix): + if verbose: + fmt = "tag '%s' doesn't start with prefix '%s'" + print(fmt % (full_tag, tag_prefix)) + pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % (full_tag, tag_prefix) + return pieces + pieces["closest-tag"] = full_tag[len(tag_prefix) :] + + # distance: number of commits since tag + pieces["distance"] = int(mo.group(2)) + + # commit: short hex revision ID + pieces["short"] = mo.group(3) + + else: + # HEX: no tags + pieces["closest-tag"] = None + out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) + pieces["distance"] = len(out.split()) # total number of commits + + # commit date: see ISO-8601 comment in git_versions_from_keywords() + date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip() + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + + return pieces + + +def do_vcs_install(versionfile_source, ipy): + """Git-specific installation logic for Versioneer. + + For Git, this means creating/changing .gitattributes to mark _version.py + for export-subst keyword substitution. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + files = [versionfile_source] + if ipy: + files.append(ipy) + try: + my_path = __file__ + if my_path.endswith(".pyc") or my_path.endswith(".pyo"): + my_path = os.path.splitext(my_path)[0] + ".py" + versioneer_file = os.path.relpath(my_path) + except NameError: + versioneer_file = "versioneer.py" + files.append(versioneer_file) + present = False + try: + with open(".gitattributes", "r") as fobj: + for line in fobj: + if line.strip().startswith(versionfile_source): + if "export-subst" in line.strip().split()[1:]: + present = True + break + except OSError: + pass + if not present: + with open(".gitattributes", "a+") as fobj: + fobj.write(f"{versionfile_source} export-subst\n") + files.append(".gitattributes") + run_command(GITS, ["add", "--"] + files) + + +def versions_from_parentdir(parentdir_prefix, root, verbose): + """Try to determine the version from the parent directory name. + + Source tarballs conventionally unpack into a directory that includes both + the project name and a version string. We will also support searching up + two directory levels for an appropriately named parent directory + """ + rootdirs = [] + + for _ in range(3): + dirname = os.path.basename(root) + if dirname.startswith(parentdir_prefix): + return { + "version": dirname[len(parentdir_prefix) :], + "full-revisionid": None, + "dirty": False, + "error": None, + "date": None, + } + rootdirs.append(root) + root = os.path.dirname(root) # up a level + + if verbose: + print( + "Tried directories %s but none started with prefix %s" + % (str(rootdirs), parentdir_prefix) + ) + raise NotThisMethod("rootdir doesn't start with parentdir_prefix") + + +SHORT_VERSION_PY = """ +# This file was generated by 'versioneer.py' (0.23) from +# revision-control system data, or from the parent directory name of an +# unpacked source archive. Distribution tarballs contain a pre-generated copy +# of this file. + +import json + +version_json = ''' +%s +''' # END VERSION_JSON + + +def get_versions(): + return json.loads(version_json) +""" + + +def versions_from_file(filename): + """Try to determine the version from _version.py if present.""" + try: + with open(filename) as f: + contents = f.read() + except OSError: + raise NotThisMethod("unable to read _version.py") + mo = re.search(r"version_json = '''\n(.*)''' # END VERSION_JSON", contents, re.M | re.S) + if not mo: + mo = re.search(r"version_json = '''\r\n(.*)''' # END VERSION_JSON", contents, re.M | re.S) + if not mo: + raise NotThisMethod("no version_json in _version.py") + return json.loads(mo.group(1)) + + +def write_to_version_file(filename, versions): + """Write the given version number to the given _version.py file.""" + os.unlink(filename) + contents = json.dumps(versions, sort_keys=True, indent=1, separators=(",", ": ")) + with open(filename, "w") as f: + f.write(SHORT_VERSION_PY % contents) + + print("set %s to '%s'" % (filename, versions["version"])) + + +def plus_or_dot(pieces): + """Return a + if we don't already have one, else return a .""" + if "+" in pieces.get("closest-tag", ""): + return "." + return "+" + + +def render_pep440(pieces): + """Build up version string, with post-release "local version identifier". + + Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you + get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty + + Exceptions: + 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_branch(pieces): + """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . + + The ".dev0" means not master branch. Note that .dev0 sorts backwards + (a feature branch will appear "older" than the master branch). + + Exceptions: + 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0" + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def pep440_split_post(ver): + """Split pep440 version string at the post-release segment. + + Returns the release segments before the post-release and the + post-release version number (or -1 if no post-release segment is present). + """ + vc = str.split(ver, ".post") + return vc[0], int(vc[1] or 0) if len(vc) == 2 else None + + +def render_pep440_pre(pieces): + """TAG[.postN.devDISTANCE] -- No -dirty. + + Exceptions: + 1: no tags. 0.post0.devDISTANCE + """ + if pieces["closest-tag"]: + if pieces["distance"]: + # update the post release segment + tag_version, post_version = pep440_split_post(pieces["closest-tag"]) + rendered = tag_version + if post_version is not None: + rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"]) + else: + rendered += ".post0.dev%d" % (pieces["distance"]) + else: + # no commits, use the tag as the version + rendered = pieces["closest-tag"] + else: + # exception #1 + rendered = "0.post0.dev%d" % pieces["distance"] + return rendered + + +def render_pep440_post(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX] . + + The ".dev0" means dirty. Note that .dev0 sorts backwards + (a dirty tree will appear "older" than the corresponding clean one), + but you shouldn't be releasing software with -dirty anyways. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + return rendered + + +def render_pep440_post_branch(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . + + The ".dev0" means not master branch. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_old(pieces): + """TAG[.postDISTANCE[.dev0]] . + + The ".dev0" means dirty. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + return rendered + + +def render_git_describe(pieces): + """TAG[-DISTANCE-gHEX][-dirty]. + + Like 'git describe --tags --dirty --always'. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"]: + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render_git_describe_long(pieces): + """TAG-DISTANCE-gHEX[-dirty]. + + Like 'git describe --tags --dirty --always -long'. + The distance/hash is unconditional. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render(pieces, style): + """Render the given version pieces into the requested style.""" + if pieces["error"]: + return { + "version": "unknown", + "full-revisionid": pieces.get("long"), + "dirty": None, + "error": pieces["error"], + "date": None, + } + + if not style or style == "default": + style = "pep440" # the default + + if style == "pep440": + rendered = render_pep440(pieces) + elif style == "pep440-branch": + rendered = render_pep440_branch(pieces) + elif style == "pep440-pre": + rendered = render_pep440_pre(pieces) + elif style == "pep440-post": + rendered = render_pep440_post(pieces) + elif style == "pep440-post-branch": + rendered = render_pep440_post_branch(pieces) + elif style == "pep440-old": + rendered = render_pep440_old(pieces) + elif style == "git-describe": + rendered = render_git_describe(pieces) + elif style == "git-describe-long": + rendered = render_git_describe_long(pieces) + else: + raise ValueError("unknown style '%s'" % style) + + return { + "version": rendered, + "full-revisionid": pieces["long"], + "dirty": pieces["dirty"], + "error": None, + "date": pieces.get("date"), + } + + +class VersioneerBadRootError(Exception): + """The project root directory is unknown or missing key files.""" + + +def get_versions(verbose=False): + """Get the project version from whatever source is available. + + Returns dict with two keys: 'version' and 'full'. + """ + if "versioneer" in sys.modules: + # see the discussion in cmdclass.py:get_cmdclass() + del sys.modules["versioneer"] + + root = get_root() + cfg = get_config_from_root(root) + + assert cfg.VCS is not None, "please set [versioneer]VCS= in setup.cfg" + handlers = HANDLERS.get(cfg.VCS) + assert handlers, "unrecognized VCS '%s'" % cfg.VCS + verbose = verbose or cfg.verbose + assert cfg.versionfile_source is not None, "please set versioneer.versionfile_source" + assert cfg.tag_prefix is not None, "please set versioneer.tag_prefix" + + versionfile_abs = os.path.join(root, cfg.versionfile_source) + + # extract version from first of: _version.py, VCS command (e.g. 'git + # describe'), parentdir. This is meant to work for developers using a + # source checkout, for users of a tarball created by 'setup.py sdist', + # and for users of a tarball/zipball created by 'git archive' or github's + # download-from-tag feature or the equivalent in other VCSes. + + get_keywords_f = handlers.get("get_keywords") + from_keywords_f = handlers.get("keywords") + if get_keywords_f and from_keywords_f: + try: + keywords = get_keywords_f(versionfile_abs) + ver = from_keywords_f(keywords, cfg.tag_prefix, verbose) + if verbose: + print("got version from expanded keyword %s" % ver) + return ver + except NotThisMethod: + pass + + try: + ver = versions_from_file(versionfile_abs) + if verbose: + print("got version from file %s %s" % (versionfile_abs, ver)) + return ver + except NotThisMethod: + pass + + from_vcs_f = handlers.get("pieces_from_vcs") + if from_vcs_f: + try: + pieces = from_vcs_f(cfg.tag_prefix, root, verbose) + ver = render(pieces, cfg.style) + if verbose: + print("got version from VCS %s" % ver) + return ver + except NotThisMethod: + pass + + try: + if cfg.parentdir_prefix: + ver = versions_from_parentdir(cfg.parentdir_prefix, root, verbose) + if verbose: + print("got version from parentdir %s" % ver) + return ver + except NotThisMethod: + pass + + if verbose: + print("unable to compute version") + + return { + "version": "0+unknown", + "full-revisionid": None, + "dirty": None, + "error": "unable to compute version", + "date": None, + } + + +def get_version(): + """Get the short version string for this project.""" + return get_versions()["version"] + + +def get_cmdclass(cmdclass=None): + """Get the custom setuptools subclasses used by Versioneer. + + If the package uses a different cmdclass (e.g. one from numpy), it + should be provide as an argument. + """ + if "versioneer" in sys.modules: + del sys.modules["versioneer"] + # this fixes the "python setup.py develop" case (also 'install' and + # 'easy_install .'), in which subdependencies of the main project are + # built (using setup.py bdist_egg) in the same python process. Assume + # a main project A and a dependency B, which use different versions + # of Versioneer. A's setup.py imports A's Versioneer, leaving it in + # sys.modules by the time B's setup.py is executed, causing B to run + # with the wrong versioneer. Setuptools wraps the sub-dep builds in a + # sandbox that restores sys.modules to it's pre-build state, so the + # parent is protected against the child's "import versioneer". By + # removing ourselves from sys.modules here, before the child build + # happens, we protect the child from the parent's versioneer too. + # Also see https://github.com/python-versioneer/python-versioneer/issues/52 + + cmds = {} if cmdclass is None else cmdclass.copy() + + # we add "version" to setuptools + from setuptools import Command + + class cmd_version(Command): + description = "report generated version string" + user_options = [] + boolean_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + vers = get_versions(verbose=True) + print("Version: %s" % vers["version"]) + print(" full-revisionid: %s" % vers.get("full-revisionid")) + print(" dirty: %s" % vers.get("dirty")) + print(" date: %s" % vers.get("date")) + if vers["error"]: + print(" error: %s" % vers["error"]) + + cmds["version"] = cmd_version + + # we override "build_py" in setuptools + # + # most invocation pathways end up running build_py: + # distutils/build -> build_py + # distutils/install -> distutils/build ->.. + # setuptools/bdist_wheel -> distutils/install ->.. + # setuptools/bdist_egg -> distutils/install_lib -> build_py + # setuptools/install -> bdist_egg ->.. + # setuptools/develop -> ? + # pip install: + # copies source tree to a tempdir before running egg_info/etc + # if .git isn't copied too, 'git describe' will fail + # then does setup.py bdist_wheel, or sometimes setup.py install + # setup.py egg_info -> ? + + # pip install -e . and setuptool/editable_wheel will invoke build_py + # but the build_py command is not expected to copy any files. + + # we override different "build_py" commands for both environments + if "build_py" in cmds: + _build_py = cmds["build_py"] + else: + from setuptools.command.build_py import build_py as _build_py + + class cmd_build_py(_build_py): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + _build_py.run(self) + if getattr(self, "editable_mode", False): + # During editable installs `.py` and data files are + # not copied to build_lib + return + # now locate _version.py in the new build/ directory and replace + # it with an updated value + if cfg.versionfile_build: + target_versionfile = os.path.join(self.build_lib, cfg.versionfile_build) + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + cmds["build_py"] = cmd_build_py + + if "build_ext" in cmds: + _build_ext = cmds["build_ext"] + else: + from setuptools.command.build_ext import build_ext as _build_ext + + class cmd_build_ext(_build_ext): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + _build_ext.run(self) + if self.inplace: + # build_ext --inplace will only build extensions in + # build/lib<..> dir with no _version.py to write to. + # As in place builds will already have a _version.py + # in the module dir, we do not need to write one. + return + # now locate _version.py in the new build/ directory and replace + # it with an updated value + target_versionfile = os.path.join(self.build_lib, cfg.versionfile_build) + if not os.path.exists(target_versionfile): + print( + f"Warning: {target_versionfile} does not exist, skipping " + "version update. This can happen if you are running build_ext " + "without first running build_py." + ) + return + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + cmds["build_ext"] = cmd_build_ext + + if "cx_Freeze" in sys.modules: # cx_freeze enabled? + from cx_Freeze.dist import build_exe as _build_exe + + # nczeczulin reports that py2exe won't like the pep440-style string + # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g. + # setup(console=[{ + # "version": versioneer.get_version().split("+", 1)[0], # FILEVERSION + # "product_version": versioneer.get_version(), + # ... + + class cmd_build_exe(_build_exe): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + target_versionfile = cfg.versionfile_source + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + _build_exe.run(self) + os.unlink(target_versionfile) + with open(cfg.versionfile_source, "w") as f: + LONG = LONG_VERSION_PY[cfg.VCS] + f.write( + LONG + % { + "DOLLAR": "$", + "STYLE": cfg.style, + "TAG_PREFIX": cfg.tag_prefix, + "PARENTDIR_PREFIX": cfg.parentdir_prefix, + "VERSIONFILE_SOURCE": cfg.versionfile_source, + } + ) + + cmds["build_exe"] = cmd_build_exe + del cmds["build_py"] + + if "py2exe" in sys.modules: # py2exe enabled? + from py2exe.distutils_buildexe import py2exe as _py2exe + + class cmd_py2exe(_py2exe): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + target_versionfile = cfg.versionfile_source + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + _py2exe.run(self) + os.unlink(target_versionfile) + with open(cfg.versionfile_source, "w") as f: + LONG = LONG_VERSION_PY[cfg.VCS] + f.write( + LONG + % { + "DOLLAR": "$", + "STYLE": cfg.style, + "TAG_PREFIX": cfg.tag_prefix, + "PARENTDIR_PREFIX": cfg.parentdir_prefix, + "VERSIONFILE_SOURCE": cfg.versionfile_source, + } + ) + + cmds["py2exe"] = cmd_py2exe + + # sdist farms its file list building out to egg_info + if "egg_info" in cmds: + _sdist = cmds["egg_info"] + else: + from setuptools.command.egg_info import egg_info as _egg_info + + class cmd_egg_info(_egg_info): + def find_sources(self): + # egg_info.find_sources builds the manifest list and writes it + # in one shot + super().find_sources() + + # Modify the filelist and normalize it + root = get_root() + cfg = get_config_from_root(root) + self.filelist.append("versioneer.py") + if cfg.versionfile_source: + # There are rare cases where versionfile_source might not be + # included by default, so we must be explicit + self.filelist.append(cfg.versionfile_source) + self.filelist.sort() + self.filelist.remove_duplicates() + + # The write method is hidden in the manifest_maker instance that + # generated the filelist and was thrown away + # We will instead replicate their final normalization (to unicode, + # and POSIX-style paths) + from setuptools import unicode_utils + + normalized = [ + unicode_utils.filesys_decode(f).replace(os.sep, "/") for f in self.filelist.files + ] + + manifest_filename = os.path.join(self.egg_info, "SOURCES.txt") + with open(manifest_filename, "w") as fobj: + fobj.write("\n".join(normalized)) + + cmds["egg_info"] = cmd_egg_info + + # we override different "sdist" commands for both environments + if "sdist" in cmds: + _sdist = cmds["sdist"] + else: + from setuptools.command.sdist import sdist as _sdist + + class cmd_sdist(_sdist): + def run(self): + versions = get_versions() + self._versioneer_generated_versions = versions + # unless we update this, the command will keep using the old + # version + self.distribution.metadata.version = versions["version"] + return _sdist.run(self) + + def make_release_tree(self, base_dir, files): + root = get_root() + cfg = get_config_from_root(root) + _sdist.make_release_tree(self, base_dir, files) + # now locate _version.py in the new base_dir directory + # (remembering that it may be a hardlink) and replace it with an + # updated value + target_versionfile = os.path.join(base_dir, cfg.versionfile_source) + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, self._versioneer_generated_versions) + + cmds["sdist"] = cmd_sdist + + return cmds + + +CONFIG_ERROR = """ +setup.cfg is missing the necessary Versioneer configuration. You need +a section like: + + [versioneer] + VCS = git + style = pep440 + versionfile_source = src/myproject/_version.py + versionfile_build = myproject/_version.py + tag_prefix = + parentdir_prefix = myproject- + +You will also need to edit your setup.py to use the results: + + import versioneer + setup(version=versioneer.get_version(), + cmdclass=versioneer.get_cmdclass(), ...) + +Please read the docstring in ./versioneer.py for configuration instructions, +edit setup.cfg, and re-run the installer or 'python versioneer.py setup'. +""" + +SAMPLE_CONFIG = """ +# See the docstring in versioneer.py for instructions. Note that you must +# re-run 'versioneer.py setup' after changing this section, and commit the +# resulting files. + +[versioneer] +#VCS = git +#style = pep440 +#versionfile_source = +#versionfile_build = +#tag_prefix = +#parentdir_prefix = + +""" + +OLD_SNIPPET = """ +from ._version import get_versions +__version__ = get_versions()['version'] +del get_versions +""" + +INIT_PY_SNIPPET = """ +from . import {0} +__version__ = {0}.get_versions()['version'] +""" + + +def do_setup(): + """Do main VCS-independent setup function for installing Versioneer.""" + root = get_root() + try: + cfg = get_config_from_root(root) + except (OSError, configparser.NoSectionError, configparser.NoOptionError) as e: + if isinstance(e, (OSError, configparser.NoSectionError)): + print("Adding sample versioneer config to setup.cfg", file=sys.stderr) + with open(os.path.join(root, "setup.cfg"), "a") as f: + f.write(SAMPLE_CONFIG) + print(CONFIG_ERROR, file=sys.stderr) + return 1 + + print(" creating %s" % cfg.versionfile_source) + with open(cfg.versionfile_source, "w") as f: + LONG = LONG_VERSION_PY[cfg.VCS] + f.write( + LONG + % { + "DOLLAR": "$", + "STYLE": cfg.style, + "TAG_PREFIX": cfg.tag_prefix, + "PARENTDIR_PREFIX": cfg.parentdir_prefix, + "VERSIONFILE_SOURCE": cfg.versionfile_source, + } + ) + + ipy = os.path.join(os.path.dirname(cfg.versionfile_source), "__init__.py") + if os.path.exists(ipy): + try: + with open(ipy, "r") as f: + old = f.read() + except OSError: + old = "" + module = os.path.splitext(os.path.basename(cfg.versionfile_source))[0] + snippet = INIT_PY_SNIPPET.format(module) + if OLD_SNIPPET in old: + print(" replacing boilerplate in %s" % ipy) + with open(ipy, "w") as f: + f.write(old.replace(OLD_SNIPPET, snippet)) + elif snippet not in old: + print(" appending to %s" % ipy) + with open(ipy, "a") as f: + f.write(snippet) + else: + print(" %s unmodified" % ipy) + else: + print(" %s doesn't exist, ok" % ipy) + ipy = None + + # Make VCS-specific changes. For git, this means creating/changing + # .gitattributes to mark _version.py for export-subst keyword + # substitution. + do_vcs_install(cfg.versionfile_source, ipy) + return 0 + + +def scan_setup_py(): + """Validate the contents of setup.py against Versioneer's expectations.""" + found = set() + setters = False + errors = 0 + with open("setup.py", "r") as f: + for line in f.readlines(): + if "import versioneer" in line: + found.add("import") + if "versioneer.get_cmdclass()" in line: + found.add("cmdclass") + if "versioneer.get_version()" in line: + found.add("get_version") + if "versioneer.VCS" in line: + setters = True + if "versioneer.versionfile_source" in line: + setters = True + if len(found) != 3: + print("") + print("Your setup.py appears to be missing some important items") + print("(but I might be wrong). Please make sure it has something") + print("roughly like the following:") + print("") + print(" import versioneer") + print(" setup( version=versioneer.get_version(),") + print(" cmdclass=versioneer.get_cmdclass(), ...)") + print("") + errors += 1 + if setters: + print("You should remove lines like 'versioneer.VCS = ' and") + print("'versioneer.versionfile_source = ' . This configuration") + print("now lives in setup.cfg, and should be removed from setup.py") + print("") + errors += 1 + return errors + + +if __name__ == "__main__": + cmd = sys.argv[1] + if cmd == "setup": + errors = do_setup() + errors += scan_setup_py() + if errors: + sys.exit(1)