Skip to content

Commit 70a673d

Browse files
committed
Apply the suggestion from copilot
1 parent 741fc49 commit 70a673d

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

libCacheSim-python/src/pylibcachesim.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ struct ReaderDeleter {
164164
}
165165
};
166166

167-
namespace py = pybind11;
168-
169167
PYBIND11_MODULE(_libcachesim, m) { // NOLINT(readability-named-parameter)
170168
m.doc() = R"pbdoc(
171169
libCacheSim Python bindings
@@ -617,7 +615,8 @@ PYBIND11_MODULE(_libcachesim, m) { // NOLINT(readability-named-parameter)
617615
/**
618616
* @brief Create a TinyLFU cache instance.
619617
*/
620-
// mark evivtion parsing need change
618+
// TODO: Review and update the eviction parsing logic in TinyLFU_init if
619+
// necessary.
621620
m.def(
622621
"TinyLFU_init",
623622
[](uint64_t cache_size, std::string main_cache, double window_size) {

libCacheSim-python/tests/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ def get_reference_data(eviction_algo, cache_size_ratio):
99
)
1010
with open(data_file, "r") as f: # noqa: PTH123
1111
lines = f.readlines()
12+
key = "3LCache" if eviction_algo == "ThreeLCache" else eviction_algo
1213
for line in lines:
13-
if eviction_algo == "ThreeLCache":
14-
eviction_algo = "3LCache"
15-
if line.startswith(f"{eviction_algo},{cache_size_ratio}"):
14+
if line.startswith(f"{key},{cache_size_ratio}"):
1615
return float(line.split(",")[-1])
1716
return None

scripts/install_python.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -euo pipefail
23

34
# Build the main libCacheSim C++ library first
45
echo "Building main libCacheSim library..."

scripts/sync_python_version.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ def update_pyproject_toml(version):
5151
pyproject_data = f.read()
5252

5353
# Update the version line in pyproject.toml, make it can match any version in version.txt, like "0.3.1" or "dev"
54-
current_version = re.search(r"version = \"(dev|[0-9]+\.[0-9]+\.[0-9]+)\"", pyproject_data).group(1)
54+
match = re.search(r"version = \"(dev|[0-9]+\.[0-9]+\.[0-9]+)\"", pyproject_data)
55+
if not match:
56+
print("Error: Could not find a valid version line in pyproject.toml", file=sys.stderr)
57+
return False
58+
current_version = match.group(1)
5559
if current_version == version:
5660
print(f"Python binding version already up to date: {version}")
5761
return False
@@ -77,9 +81,9 @@ def main():
7781
updated = update_pyproject_toml(main_version)
7882

7983
if updated:
80-
print("Python binding version synchronized successfully")
84+
print("Python binding version synchronized successfully")
8185
else:
82-
print("No changes needed")
86+
print("No changes needed")
8387
except Exception as e:
8488
print(f"Error: {e}", file=sys.stderr)
8589
sys.exit(1)

0 commit comments

Comments
 (0)