From 4d9dee3f24afa3eec052f2bdcb4569b539f75e8a Mon Sep 17 00:00:00 2001 From: Najib Ishaq Date: Sat, 30 Nov 2024 15:58:48 -0500 Subject: [PATCH] chore: fixed lots of lints and other issues --- Cargo.toml | 1 - crates/abd-clam/Cargo.toml | 4 +- .../src/cakes/cluster/permuted_ball.rs | 4 +- crates/abd-clam/src/cakes/mod.rs | 6 +- .../src/cakes/search/knn_breadth_first.rs | 8 +- .../src/cakes/search/knn_depth_first.rs | 8 +- .../src/cakes/search/knn_repeated_rnn.rs | 8 +- .../src/cakes/search/rnn_clustered.rs | 8 +- crates/abd-clam/src/core/cluster/ball.rs | 12 +- pypi/results/cakes/.github/workflows/CI.yml | 120 ------------------ pypi/results/cakes/.gitignore | 72 ----------- pypi/results/cakes/Cargo.toml | 12 -- pypi/results/cakes/pyproject.toml | 32 ----- .../results/cakes/python/py_cakes/__init__.py | 6 - .../results/cakes/python/py_cakes/__main__.py | 52 -------- pypi/results/cakes/python/py_cakes/tables.py | 96 -------------- .../cakes/python/py_cakes/wrangling_logs.py | 72 ----------- pypi/results/cakes/python/tests/__init__.py | 1 - pypi/results/cakes/python/tests/test_all.py | 5 - pypi/results/cakes/src/lib.rs | 14 -- pyproject.toml | 1 - requirements-dev.lock | 74 +++++------ requirements.lock | 33 +---- 23 files changed, 50 insertions(+), 599 deletions(-) delete mode 100644 pypi/results/cakes/.github/workflows/CI.yml delete mode 100644 pypi/results/cakes/.gitignore delete mode 100644 pypi/results/cakes/Cargo.toml delete mode 100644 pypi/results/cakes/pyproject.toml delete mode 100644 pypi/results/cakes/python/py_cakes/__init__.py delete mode 100644 pypi/results/cakes/python/py_cakes/__main__.py delete mode 100644 pypi/results/cakes/python/py_cakes/tables.py delete mode 100644 pypi/results/cakes/python/py_cakes/wrangling_logs.py delete mode 100644 pypi/results/cakes/python/tests/__init__.py delete mode 100644 pypi/results/cakes/python/tests/test_all.py delete mode 100644 pypi/results/cakes/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index f3f83cf7c..6bc5f9e22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ members = [ # "crates/results/rite-solutions", "crates/results/msa", "pypi/distances", - "pypi/results/cakes", ] resolver = "2" diff --git a/crates/abd-clam/Cargo.toml b/crates/abd-clam/Cargo.toml index a44988bde..a6b3d7c61 100644 --- a/crates/abd-clam/Cargo.toml +++ b/crates/abd-clam/Cargo.toml @@ -10,7 +10,7 @@ authors = [ "Oliver McLaughlin ", ] edition = "2021" -rust-version = "1.83" +rust-version = "1.81" # using: `total_cmp` description = "Clustering, Learning and Approximation with Manifolds" license = "MIT" readme = "./README.md" @@ -82,4 +82,4 @@ required-features = ["msa"] [[bench]] name = "ann_benchmarks" harness = false -required-features = ["ndarray-bindings"] +required-features = ["disk-io"] diff --git a/crates/abd-clam/src/cakes/cluster/permuted_ball.rs b/crates/abd-clam/src/cakes/cluster/permuted_ball.rs index aead65d81..0b8c8f362 100644 --- a/crates/abd-clam/src/cakes/cluster/permuted_ball.rs +++ b/crates/abd-clam/src/cakes/cluster/permuted_ball.rs @@ -333,7 +333,7 @@ mod tests { } #[test] - fn permutation() -> Result<(), String> { + fn permutation() { let data = gen_tiny_data(); let metric = Manhattan; @@ -347,7 +347,5 @@ mod tests { let (root, perm_data) = PermutedBall::par_from_ball_tree(ball, data, &metric); assert!(check_permutation(&root, &perm_data, &metric)); - - Ok(()) } } diff --git a/crates/abd-clam/src/cakes/mod.rs b/crates/abd-clam/src/cakes/mod.rs index 96e0a6b16..bcdc78be5 100644 --- a/crates/abd-clam/src/cakes/mod.rs +++ b/crates/abd-clam/src/cakes/mod.rs @@ -143,7 +143,7 @@ pub mod tests { #[test_case(10_000, 10)] #[test_case(1_000, 100)] #[test_case(10_000, 100)] - fn vectors(car: usize, dim: usize) -> Result<(), String> { + fn vectors(car: usize, dim: usize) { let mut algs: Algs, f32, usize> = vec![]; for radius in [0.1, 1.0] { algs.push((Algorithm::RnnClustered(radius), check_search_by_index)); @@ -180,8 +180,6 @@ pub mod tests { "par_off_ball", &per_perm_data, ); - - Ok(()) } #[test_case::test_case(16, 16, 2)] @@ -232,7 +230,7 @@ pub mod tests { let (perm_ball, perm_data) = PermutedBall::from_ball_tree(ball.clone(), data.clone(), &metric); check_search(&algs, &perm_data, &metric, &perm_ball, query, "off_ball", &perm_data); - let (par_perm_ball, par_perm_data) = PermutedBall::par_from_ball_tree(ball.clone(), data.clone(), &metric); + let (par_perm_ball, par_perm_data) = PermutedBall::par_from_ball_tree(ball, data, &metric); check_search( &algs, &par_perm_data, diff --git a/crates/abd-clam/src/cakes/search/knn_breadth_first.rs b/crates/abd-clam/src/cakes/search/knn_breadth_first.rs index b828e1dfb..c353f5303 100644 --- a/crates/abd-clam/src/cakes/search/knn_breadth_first.rs +++ b/crates/abd-clam/src/cakes/search/knn_breadth_first.rs @@ -227,7 +227,7 @@ mod tests { }; #[test] - fn line() -> Result<(), String> { + fn line() { let data = gen_line_data(10); let metric = AbsoluteDifference; let query = &0; @@ -244,12 +244,10 @@ mod tests { for k in [1, 4, 8] { assert!(check_knn(&off_ball, &perm_data, &metric, query, k)); } - - Ok(()) } #[test] - fn grid() -> Result<(), String> { + fn grid() { let data = gen_grid_data(10); let metric = Hypotenuse; let query = &(0.0, 0.0); @@ -266,7 +264,5 @@ mod tests { for k in [1, 4, 8] { assert!(check_knn(&off_ball, &perm_data, &metric, query, k)); } - - Ok(()) } } diff --git a/crates/abd-clam/src/cakes/search/knn_depth_first.rs b/crates/abd-clam/src/cakes/search/knn_depth_first.rs index 430ee3896..b5946fb2e 100644 --- a/crates/abd-clam/src/cakes/search/knn_depth_first.rs +++ b/crates/abd-clam/src/cakes/search/knn_depth_first.rs @@ -224,7 +224,7 @@ pub mod tests { } #[test] - fn line() -> Result<(), String> { + fn line() { let data = gen_line_data(10); let metric = AbsoluteDifference; let query = &0; @@ -241,12 +241,10 @@ pub mod tests { for k in [1, 4, 8] { assert!(check_knn(&off_ball, &perm_data, &metric, query, k)); } - - Ok(()) } #[test] - fn grid() -> Result<(), String> { + fn grid() { let data = gen_grid_data(10); let metric = Hypotenuse; let query = &(0.0, 0.0); @@ -263,7 +261,5 @@ pub mod tests { for k in [1, 4, 8] { assert!(check_knn(&off_ball, &perm_data, &metric, query, k)); } - - Ok(()) } } diff --git a/crates/abd-clam/src/cakes/search/knn_repeated_rnn.rs b/crates/abd-clam/src/cakes/search/knn_repeated_rnn.rs index dd7280fcb..596d2c34e 100644 --- a/crates/abd-clam/src/cakes/search/knn_repeated_rnn.rs +++ b/crates/abd-clam/src/cakes/search/knn_repeated_rnn.rs @@ -162,7 +162,7 @@ mod tests { } #[test] - fn line() -> Result<(), String> { + fn line() { let data = gen_line_data(10); let metric = AbsoluteDifference; let query = &0; @@ -180,12 +180,10 @@ mod tests { for k in [1, 4, 8] { assert!(check_knn(&off_ball, &perm_data, &metric, query, k, max_multiplier)); } - - Ok(()) } #[test] - fn grid() -> Result<(), String> { + fn grid() { let data = gen_grid_data(10); let metric = Hypotenuse; let query = &(0.0, 0.0); @@ -203,7 +201,5 @@ mod tests { for k in [1, 4, 8, 16, 32] { assert!(check_knn(&off_ball, &perm_data, &metric, query, k, max_multiplier)); } - - Ok(()) } } diff --git a/crates/abd-clam/src/cakes/search/rnn_clustered.rs b/crates/abd-clam/src/cakes/search/rnn_clustered.rs index 7dedf0bba..a6624ab20 100644 --- a/crates/abd-clam/src/cakes/search/rnn_clustered.rs +++ b/crates/abd-clam/src/cakes/search/rnn_clustered.rs @@ -236,7 +236,7 @@ mod tests { } #[test] - fn line() -> Result<(), String> { + fn line() { let data = gen_line_data(10); let metric = AbsoluteDifference; let query = &0; @@ -253,12 +253,10 @@ mod tests { for radius in 0..=4 { assert!(check_rnn(&off_ball, &perm_data, &metric, query, radius)); } - - Ok(()) } #[test] - fn grid() -> Result<(), String> { + fn grid() { let data = gen_grid_data(10); let metric = Hypotenuse; let query = &(0.0, 0.0); @@ -275,7 +273,5 @@ mod tests { for radius in [1.0, 4.0, 8.0, 16.0, 32.0] { assert!(check_rnn(&off_ball, &perm_data, &metric, query, radius)); } - - Ok(()) } } diff --git a/crates/abd-clam/src/core/cluster/ball.rs b/crates/abd-clam/src/core/cluster/ball.rs index 3c26926a1..8a65b6f9f 100644 --- a/crates/abd-clam/src/core/cluster/ball.rs +++ b/crates/abd-clam/src/core/cluster/ball.rs @@ -337,7 +337,7 @@ mod tests { } #[test] - fn new() -> Result<(), String> { + fn new() { let data = gen_tiny_data(); let metric = Manhattan; @@ -366,8 +366,6 @@ mod tests { assert_eq!(root.arg_radial(), arg_r); assert!(root.children().is_empty()); assert_eq!(root.indices().collect::>(), indices); - - Ok(()) } fn check_partition(root: &Ball) -> bool { @@ -399,7 +397,7 @@ mod tests { } #[test] - fn tree() -> Result<(), String> { + fn tree() { let data = gen_tiny_data(); let metric = Manhattan; @@ -413,12 +411,10 @@ mod tests { let root = Ball::par_new_tree(&data, &metric, &criteria, seed); assert_eq!(root.indices().count(), data.cardinality()); assert!(check_partition(&root)); - - Ok(()) } #[test] - fn partition_further() -> Result<(), String> { + fn partition_further() { let data = gen_tiny_data(); let metric = Manhattan; @@ -443,8 +439,6 @@ mod tests { for leaf in root.leaves() { assert_eq!(leaf.depth(), 2); } - - Ok(()) } #[test] diff --git a/pypi/results/cakes/.github/workflows/CI.yml b/pypi/results/cakes/.github/workflows/CI.yml deleted file mode 100644 index 1bae4be43..000000000 --- a/pypi/results/cakes/.github/workflows/CI.yml +++ /dev/null @@ -1,120 +0,0 @@ -# This file is autogenerated by maturin v1.4.0 -# To update, run -# -# maturin generate-ci github -# -name: CI - -on: - push: - branches: - - main - - master - tags: - - '*' - pull_request: - workflow_dispatch: - -permissions: - contents: read - -jobs: - linux: - runs-on: ubuntu-latest - strategy: - matrix: - target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - args: --release --out dist --find-interpreter - sccache: 'true' - manylinux: auto - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist - - windows: - runs-on: windows-latest - strategy: - matrix: - target: [x64, x86] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - architecture: ${{ matrix.target }} - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - args: --release --out dist --find-interpreter - sccache: 'true' - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist - - macos: - runs-on: macos-latest - strategy: - matrix: - target: [x86_64, aarch64] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - args: --release --out dist --find-interpreter - sccache: 'true' - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist - - sdist: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Build sdist - uses: PyO3/maturin-action@v1 - with: - command: sdist - args: --out dist - - name: Upload sdist - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist - - release: - name: Release - runs-on: ubuntu-latest - if: "startsWith(github.ref, 'refs/tags/')" - needs: [linux, windows, macos, sdist] - steps: - - uses: actions/download-artifact@v3 - with: - name: wheels - - name: Publish to PyPI - uses: PyO3/maturin-action@v1 - env: - MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} - with: - command: upload - args: --non-interactive --skip-existing * diff --git a/pypi/results/cakes/.gitignore b/pypi/results/cakes/.gitignore deleted file mode 100644 index c8f044299..000000000 --- a/pypi/results/cakes/.gitignore +++ /dev/null @@ -1,72 +0,0 @@ -/target - -# Byte-compiled / optimized / DLL files -__pycache__/ -.pytest_cache/ -*.py[cod] - -# C extensions -*.so - -# Distribution / packaging -.Python -.venv/ -env/ -bin/ -build/ -develop-eggs/ -dist/ -eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -include/ -man/ -venv/ -*.egg-info/ -.installed.cfg -*.egg - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt -pip-selfcheck.json - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.cache -nosetests.xml -coverage.xml - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# Rope -.ropeproject - -# Django stuff: -*.log -*.pot - -.DS_Store - -# Sphinx documentation -docs/_build/ - -# PyCharm -.idea/ - -# VSCode -.vscode/ - -# Pyenv -.python-version diff --git a/pypi/results/cakes/Cargo.toml b/pypi/results/cakes/Cargo.toml deleted file mode 100644 index 4497198a4..000000000 --- a/pypi/results/cakes/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "py-cakes" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -name = "py_cakes" -crate-type = ["cdylib"] - -[dependencies] -pyo3 = { workspace = true } diff --git a/pypi/results/cakes/pyproject.toml b/pypi/results/cakes/pyproject.toml deleted file mode 100644 index 4d766c3a2..000000000 --- a/pypi/results/cakes/pyproject.toml +++ /dev/null @@ -1,32 +0,0 @@ -[build-system] -requires = ["maturin>=1.4,<2.0"] -build-backend = "maturin" - -[project] -name = "py-cakes" -version = "0.1.0" -description = "A Python library for benchmarks with CAKES." -requires-python = ">=3.9" -classifiers = [ - "Programming Language :: Rust", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", -] -dependencies = [ - "numpy<=2.0.0", - "typer>=0.12.4,<0.13", - "pandas>=2.2.2,<3.0", -] - -[tool.rye] -dev-dependencies = [ - "seaborn>=0.13.2", - "editdistance>=0.8.1", - "scipy>=1.13.1", - "tqdm>=4.66.4", -] - -[tool.maturin] -python-source = "python" -features = ["pyo3/extension-module"] -profile = "release" diff --git a/pypi/results/cakes/python/py_cakes/__init__.py b/pypi/results/cakes/python/py_cakes/__init__.py deleted file mode 100644 index e639e685d..000000000 --- a/pypi/results/cakes/python/py_cakes/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -"""Wrangling the results for CAKES and PanCAKES.""" - -from . import tables -from . import wrangling_logs - -__all__ = ["tables", "wrangling_logs"] diff --git a/pypi/results/cakes/python/py_cakes/__main__.py b/pypi/results/cakes/python/py_cakes/__main__.py deleted file mode 100644 index 4b9c4e9e9..000000000 --- a/pypi/results/cakes/python/py_cakes/__main__.py +++ /dev/null @@ -1,52 +0,0 @@ -"""CLI for the package.""" - -import logging -import pathlib - -import typer - -from py_cakes import tables -from py_cakes.wrangling_logs import wrangle_logs - -logger = logging.getLogger("py_cakes") -logger.setLevel(logging.INFO) -logging.basicConfig( - format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", - datefmt="%Y-%m-%d %H:%M:%S", -) - - -app = typer.Typer() - - -@app.command() -def main( - pre_trim_path: pathlib.Path = typer.Option( # noqa: B008 - ..., - help="Path to the file to analyze.", - exists=True, - file_okay=True, - dir_okay=False, - readable=True, - resolve_path=True, - ), - post_trim_path: pathlib.Path = typer.Option( # noqa: B008 - ..., - help="Path to the file to analyze.", - exists=True, - file_okay=True, - dir_okay=False, - readable=True, - resolve_path=True, - ), -) -> None: - """Main entry point.""" - if "logs" in str(pre_trim_path): - wrangle_logs(pre_trim_path) - - if "csv" in str(pre_trim_path) and "csv" in str(post_trim_path): - tables.draw_plots(pre_trim_path, post_trim_path) - - -if __name__ == "__main__": - app() diff --git a/pypi/results/cakes/python/py_cakes/tables.py b/pypi/results/cakes/python/py_cakes/tables.py deleted file mode 100644 index b2cf1bb88..000000000 --- a/pypi/results/cakes/python/py_cakes/tables.py +++ /dev/null @@ -1,96 +0,0 @@ -"""Reading the tables from Rust and making plots.""" - -import pathlib - -import matplotlib.pyplot as plt -import numpy -import pandas - -BALL_TYPES = { - "depth": numpy.uint32, - "cardinality": numpy.uint64, - "radius": numpy.uint32, - "lfd": numpy.float32, - "arg_center": numpy.uint64, - "arg_radial": numpy.uint64, -} - -SQUISHY_BALL_TYPES = { - **BALL_TYPES, - "offset": numpy.uint64, - "unitary_cost": numpy.uint32, - "recursive_cost": numpy.uint32, -} - - -def draw_plots( - pre_trim_path: pathlib.Path, - post_trim_path: pathlib.Path, -) -> None: - """Read the ball table from the csv file.""" - # Read the pre-trim and post-trim dataframes from the csv files. - pre_trim_df = pandas.read_csv(pre_trim_path, dtype=SQUISHY_BALL_TYPES) - post_trim_df = pandas.read_csv(post_trim_path, dtype=SQUISHY_BALL_TYPES) - - # Drop all rows where "recursive_cost" is not positive. - pre_trim_df = pre_trim_df[pre_trim_df["recursive_cost"] > 0] - post_trim_df = post_trim_df[post_trim_df["recursive_cost"] > 0] - - # Drop all rows where "cardinality" is too small. - min_cardinality = 1 - pre_trim_df = pre_trim_df[pre_trim_df["cardinality"] >= min_cardinality] - post_trim_df = post_trim_df[post_trim_df["cardinality"] >= min_cardinality] - - # Create a new column called "ratio" that is the ratio of "recursive_cost" to "unitary_cost" - pre_trim_df["ratio"] = pre_trim_df["recursive_cost"] / pre_trim_df["unitary_cost"] - post_trim_df["ratio"] = post_trim_df["recursive_cost"] / post_trim_df["unitary_cost"] - - # Calculate the maximum values of some columns. - max_ratio = numpy.ceil(max(pre_trim_df["ratio"].max(), post_trim_df["ratio"].max())) # noqa: F841 - max_lfd = max(pre_trim_df["lfd"].max(), post_trim_df["lfd"].max()) - max_depth = max(pre_trim_df["depth"].max(), post_trim_df["depth"].max()) - max_radius = max(pre_trim_df["radius"].max(), post_trim_df["radius"].max()) # noqa: F841 - - dfs = { - "pre_trim": pre_trim_df, - "post_trim": post_trim_df, - } - - cmap = "cool" - for name, df in dfs.items(): - # Make a scatter plot with "depth" on the x-axis, "ratio" on the y-axis, - # and "lfd" as the color. - df["color"], mean, std = normalized_color_scale(df["lfd"]) - ax = df.plot.scatter( - x="depth", - y="lfd", - s=0.2, - c="ratio", - cmap=cmap, - vmin=0, - vmax=numpy.ceil(max_lfd), - ) - # Set the minimum and maximum values of the y-axis. - ax.set_xlim(0, max_depth) - ax.set_ylim(1, numpy.ceil(max_lfd)) - - # Set the title of the plot to be the name of the dataframe. - title = f"Recursive / Unitary ratio for {pre_trim_path.stem}" - ax.set_title(title) - - # Save the plot to a file with the name of the dataframe. - plot_path = pre_trim_path.parent / f"{pre_trim_path.stem}-{name}-ratio.png" - plt.savefig(plot_path, dpi=300) - - # Close the plots. - plt.close("all") - - -def normalized_color_scale(values: numpy.ndarray) -> tuple[numpy.ndarray, float, float]: - """Apply Gaussian normalization to the values and return the result.""" - # Calculate the mean and standard deviation of the values. - mean = values.mean() - std = values.std() - - # Apply Gaussian normalization to the values. - return (values - mean) / std, mean, std diff --git a/pypi/results/cakes/python/py_cakes/wrangling_logs.py b/pypi/results/cakes/python/py_cakes/wrangling_logs.py deleted file mode 100644 index cd5747dc7..000000000 --- a/pypi/results/cakes/python/py_cakes/wrangling_logs.py +++ /dev/null @@ -1,72 +0,0 @@ -"""Exploring the logs of long Clustering runs.""" - -import logging -import pathlib -import re - -logger = logging.getLogger(__name__) - - -def count_clusters(file_path: pathlib.Path) -> list[tuple[bool, int, int]]: - """Count the number of lines in a file that contain information about clusters.""" - pattern = re.compile( - r"^(?PStarting|Finished) `par_partition` of a cluster at depth (?P\d+), with (?P\d+) instances\.$", # noqa: E501 - ) - - cluster_counts = [] - - with file_path.open("r") as file: - for line in file: - if match := pattern.match(line.strip()): - status = match.group("status") == "Finished" - depth = int(match.group("depth")) - cardinality = int(match.group("cardinality")) - cluster_counts.append((status, depth, cardinality)) - - msg = f"Found {len(cluster_counts)} clusters in {file_path}." - logger.info(msg) - - return cluster_counts - - -def clusters_by_depth( - clusters: list[tuple[bool, int, int]], -) -> list[tuple[int, tuple[tuple[int, int], tuple[int, int]]]]: - """Count the number of clusters by depth.""" - depth_counts: dict[int, tuple[tuple[int, int], tuple[int, int]]] = {} - - for status, depth, cardinality in clusters: - (s_freq, s_count), (f_freq, f_count) = depth_counts.get(depth, ((0, 0), (0, 0))) - if status: - f_freq += 1 - f_count += cardinality - else: - s_freq += 1 - s_count += cardinality - depth_counts[depth] = (s_freq, s_count), (f_freq, f_count) - - return sorted(depth_counts.items()) - - -def wrangle_logs(log_path: pathlib.Path) -> None: - """Wrangle the logs of long Clustering runs.""" - msg = f"Analyzing {log_path}..." - logger.info(msg) - - clusters = count_clusters(log_path) - progress = clusters_by_depth(clusters) - - gg_car = 989_002 - for depth, ((s_freq, s_card), (f_freq, f_card)) in progress: - if depth % 256 < 50: - lines = [ - "", - f"Depth {depth:4d}:", - f"Clusters: Started {s_freq:7d}, finished {f_freq:7d}. {100 * f_freq / s_freq:3.2f}%).", # noqa: E501 - f"Instances: Started {s_card:7d}, finished {f_card:7d}. {100 * f_card / s_card:3.2f}% of started, {100 * f_card / gg_car:3.2f}% of total.", # noqa: E501 - ] - msg = "\n".join(lines) - logger.info(msg) - - msg = f"Built (or building) tree with {len(progress)} depth." - logger.info(msg) diff --git a/pypi/results/cakes/python/tests/__init__.py b/pypi/results/cakes/python/tests/__init__.py deleted file mode 100644 index 005c965f7..000000000 --- a/pypi/results/cakes/python/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Tests for the package.""" diff --git a/pypi/results/cakes/python/tests/test_all.py b/pypi/results/cakes/python/tests/test_all.py deleted file mode 100644 index a10761bfa..000000000 --- a/pypi/results/cakes/python/tests/test_all.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Tests for the package.""" - - -def test_hello(): - pass diff --git a/pypi/results/cakes/src/lib.rs b/pypi/results/cakes/src/lib.rs deleted file mode 100644 index 65c17ba4c..000000000 --- a/pypi/results/cakes/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -use pyo3::prelude::*; - -/// Formats the sum of two numbers as string. -#[pyfunction] -fn sum_as_string(a: usize, b: usize) -> PyResult { - Ok((a + b).to_string()) -} - -/// A Python module implemented in Rust. -#[pymodule] -fn py_cakes(m: &Bound<'_, PyModule>) -> PyResult<()> { - m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; - Ok(()) -} diff --git a/pyproject.toml b/pyproject.toml index 3a750c06d..131c6f441 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,5 +28,4 @@ dev-dependencies = [ [tool.rye.workspace] members = [ "pypi/distances", - "pypi/results/cakes", ] diff --git a/requirements-dev.lock b/requirements-dev.lock index 91b2f3337..7d141be82 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -4,115 +4,105 @@ # last locked with the following flags: # pre: false # features: [] -# all-features: true +# all-features: false # with-sources: false -e file:pypi/distances --e file:pypi/results/cakes bump2version==1.0.1 cfgv==3.4.0 # via pre-commit -click==8.1.7 - # via typer -contourpy==1.2.0 +contourpy==1.3.0 # via matplotlib -coverage==7.4.3 +coverage==7.6.8 # via coverage # via pytest-cov cycler==0.12.1 # via matplotlib -distlib==0.3.8 +distlib==0.3.9 # via virtualenv editdistance==0.8.1 -exceptiongroup==1.2.0 +exceptiongroup==1.2.2 # via pytest execnet==2.1.1 # via pytest-xdist -filelock==3.15.4 +filelock==3.16.1 # via virtualenv -fonttools==4.49.0 +fonttools==4.55.0 # via matplotlib -identify==2.6.0 +identify==2.6.3 # via pre-commit -importlib-resources==6.1.3 +importlib-resources==6.4.5 # via matplotlib iniconfig==2.0.0 # via pytest -kiwisolver==1.4.5 +kiwisolver==1.4.7 # via matplotlib markdown-it-py==3.0.0 # via rich -matplotlib==3.8.3 +matplotlib==3.9.3 # via seaborn mdurl==0.1.2 # via markdown-it-py nodeenv==1.9.1 # via pre-commit -numpy==1.26.4 +numpy==2.0.2 # via abd-distances # via contourpy # via matplotlib # via pandas - # via py-cakes # via scipy # via seaborn -packaging==23.2 +packaging==24.2 # via matplotlib # via pytest # via pytest-sugar -pandas==2.2.2 - # via py-cakes +pandas==2.2.3 # via seaborn -pillow==10.2.0 +pillow==11.0.0 # via matplotlib -platformdirs==4.2.2 +platformdirs==4.3.6 # via virtualenv pluggy==1.5.0 # via pytest -pre-commit==3.7.1 -pygments==2.17.2 +pre-commit==4.0.1 +pygments==2.18.0 # via rich -pyinstrument==4.6.2 +pyinstrument==5.0.0 # via richbench -pyparsing==3.1.2 +pyparsing==3.2.0 # via matplotlib -pytest==8.2.2 +pytest==8.3.3 # via pytest-cov # via pytest-sugar # via pytest-xdist -pytest-cov==5.0.0 +pytest-cov==6.0.0 pytest-sugar==1.0.0 pytest-xdist==3.6.1 python-dateutil==2.9.0.post0 # via matplotlib # via pandas -pytz==2024.1 +pytz==2024.2 # via pandas -pyyaml==6.0.1 +pyyaml==6.0.2 # via pre-commit -rich==13.7.1 +rich==13.9.4 # via richbench - # via typer richbench==1.0.3 scipy==1.13.1 seaborn==0.13.2 -shellingham==1.5.4 - # via typer six==1.16.0 # via python-dateutil -termcolor==2.4.0 +termcolor==2.5.0 # via pytest-sugar -tomli==2.0.1 +tomli==2.2.1 # via coverage # via pytest -tqdm==4.66.4 -typer==0.12.4 - # via py-cakes +tqdm==4.67.1 typing-extensions==4.12.2 - # via typer -tzdata==2024.1 + # via rich +tzdata==2024.2 # via pandas -virtualenv==20.26.3 +virtualenv==20.28.0 # via pre-commit -zipp==3.17.0 +zipp==3.21.0 # via importlib-resources diff --git a/requirements.lock b/requirements.lock index 166a0c137..76efe07e8 100644 --- a/requirements.lock +++ b/requirements.lock @@ -4,38 +4,9 @@ # last locked with the following flags: # pre: false # features: [] -# all-features: true +# all-features: false # with-sources: false -e file:pypi/distances --e file:pypi/results/cakes -click==8.1.7 - # via typer -markdown-it-py==3.0.0 - # via rich -mdurl==0.1.2 - # via markdown-it-py -numpy==2.0.0 +numpy==2.0.2 # via abd-distances - # via pandas - # via py-cakes -pandas==2.2.2 - # via py-cakes -pygments==2.18.0 - # via rich -python-dateutil==2.9.0.post0 - # via pandas -pytz==2024.1 - # via pandas -rich==13.7.1 - # via typer -shellingham==1.5.4 - # via typer -six==1.16.0 - # via python-dateutil -typer==0.12.4 - # via py-cakes -typing-extensions==4.12.2 - # via typer -tzdata==2024.1 - # via pandas