Skip to content

Commit 83fd6e2

Browse files
0.24.30
1 parent 07912ee commit 83fd6e2

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotpython"
10-
version = "0.24.29"
10+
version = "0.24.30"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotpython/utils/compare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def check_identical_columns_and_rows(df, remove=False, verbosity=1) -> tuple:
8686
identical_columns = []
8787
for i in range(len(df.columns)):
8888
for j in range(i + 1, len(df.columns)):
89-
if df.iloc[:, i].equals(df.iloc[:, j]):
89+
if df.iloc[:, i].equals(df.iloc[:, j]): # Ensure entire columns are compared
9090
identical_columns.append((df.columns[i], df.columns[j]))
9191

9292
if identical_columns and verbosity > 0:
@@ -101,7 +101,7 @@ def check_identical_columns_and_rows(df, remove=False, verbosity=1) -> tuple:
101101
identical_rows = []
102102
for i in range(len(df.index)):
103103
for j in range(i + 1, len(df.index)):
104-
if df.iloc[i, :].equals(df.iloc[j, :]):
104+
if df.iloc[i, :].equals(df.iloc[j, :]): # Ensure entire rows are compared
105105
identical_rows.append((df.index[i], df.index[j]))
106106

107107
if identical_rows and verbosity > 0:

test/test_check_identical_columns_and_rows.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from spotpython.utils.compare import check_identical_columns_and_rows, check_identical_columns_and_rows_with_tol
44

55
def test_check_exact_identical_columns_and_rows_remove_true():
6+
# Test DataFrame with exact duplicate columns
67
df1 = pd.DataFrame({
78
"A": [1, 2, 3],
89
"B": [1, 2, 3],
@@ -15,6 +16,7 @@ def test_check_exact_identical_columns_and_rows_remove_true():
1516
assert identical_rows == [], "Incorrectly identified duplicate rows where none exist"
1617

1718
def test_check_exact_identical_columns_and_rows_remove_false():
19+
# Test DataFrame checks presence of duplicates without removing
1820
df1 = pd.DataFrame({
1921
"A": [1, 2, 3],
2022
"B": [1, 2, 3],
@@ -27,6 +29,7 @@ def test_check_exact_identical_columns_and_rows_remove_false():
2729
assert identical_rows == [], "Incorrectly found duplicate rows"
2830

2931
def test_check_identical_columns_and_rows_with_tol_remove_true():
32+
# Test DataFrame with near-duplicate tolerance checks for columns
3033
df1 = pd.DataFrame({
3134
"A": [1.00, 2.01, 3.00],
3235
"B": [1.01, 2.00, 3.01],
@@ -39,6 +42,7 @@ def test_check_identical_columns_and_rows_with_tol_remove_true():
3942
assert identical_rows == [], "Incorrectly found duplicate rows"
4043

4144
def test_check_identical_columns_and_rows_with_tol_remove_false():
45+
# Test DataFrame with tolerance execution, no removal
4246
df1 = pd.DataFrame({
4347
"A": [1.00, 2.01, 3.00],
4448
"B": [1.01, 2.00, 3.01],
@@ -51,6 +55,7 @@ def test_check_identical_columns_and_rows_with_tol_remove_false():
5155
assert identical_rows == [], "Incorrectly found duplicate rows"
5256

5357
def test_with_no_duplicates():
58+
# Tests scenarios where there are no duplicate columns or rows present
5459
df = pd.DataFrame({
5560
"X": [1, 2, 3],
5661
"Y": [4, 5, 6],

0 commit comments

Comments
 (0)