From 717ad2082c9f98218928c399b6a14e5eb1b833f6 Mon Sep 17 00:00:00 2001 From: Tyler Howe Date: Fri, 4 Apr 2025 17:54:22 -0600 Subject: [PATCH] Added verbose flag to both checkerboard functions. --- build/lib/CheckmateSample/generator.py | 22 +++-- example_notebooks/example_notebook.ipynb | 25 ++--- src/CheckmateSample.egg-info/PKG-INFO | 5 +- .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 257 bytes .../__pycache__/_version.cpython-312.pyc | Bin 0 -> 1455 bytes .../__pycache__/generator.cpython-312.pyc | Bin 0 -> 7542 bytes src/CheckmateSample/generator.py | 22 +++-- ..._checkerboard.cpython-312-pytest-7.4.4.pyc | Bin 0 -> 15522 bytes tests/test_make_checkerboard.py | 92 +++++++++++++----- 9 files changed, 115 insertions(+), 51 deletions(-) create mode 100644 src/CheckmateSample/__pycache__/__init__.cpython-312.pyc create mode 100644 src/CheckmateSample/__pycache__/_version.cpython-312.pyc create mode 100644 src/CheckmateSample/__pycache__/generator.cpython-312.pyc create mode 100644 tests/__pycache__/test_make_checkerboard.cpython-312-pytest-7.4.4.pyc diff --git a/build/lib/CheckmateSample/generator.py b/build/lib/CheckmateSample/generator.py index 09ea085..e76ba53 100644 --- a/build/lib/CheckmateSample/generator.py +++ b/build/lib/CheckmateSample/generator.py @@ -7,6 +7,7 @@ def make_checkerboard( square_size: tuple[int, int], separation_size: int = None, validation: bool = False, + verbose: bool = False, ) -> np.ndarray: """ Create a checkerboard pattern. @@ -33,7 +34,7 @@ def make_checkerboard( raise ValueError("Separation size must be a non-negative, non-zero integer") # Add warning if inputs are not the same - if rows != cols or sq_rows != sq_cols: + if verbose and (rows != cols or sq_rows != sq_cols): print( "Warning: The inputs for board_size or square_size are not the same. This may result in a non-square checkerboard." ) @@ -71,6 +72,7 @@ def make_checkerboard_xr( keep_pattern: int = 1, validation: bool = False, dim_names: dict = None, + verbose: bool = False, ) -> xr.DataArray: """ Apply a checkerboard pattern to an existing xarray DataArray. @@ -95,9 +97,13 @@ def make_checkerboard_xr( if sq_y <= 0 or sq_x <= 0: raise ValueError("Square size dimensions must be positive integers.") if validation and keep_pattern not in [0, 1, 2]: - raise ValueError("For validation (ternary pattern), keep_pattern must be 0, 1, or 2.") + raise ValueError( + "For validation (ternary pattern), keep_pattern must be 0, 1, or 2." + ) elif not validation and keep_pattern not in [0, 1]: - raise ValueError("For non-validation (binary pattern), keep_pattern must be 0 or 1.") + raise ValueError( + "For non-validation (binary pattern), keep_pattern must be 0 or 1." + ) if sep and sep < 0: raise ValueError("Separation size must be a non-negative, non-zero integer") @@ -111,7 +117,9 @@ def make_checkerboard_xr( x_dim = next((dim for dim in da.dims if dim in possible_x_dims), None) if y_dim is None or x_dim is None: - raise ValueError("Could not automatically detect x and y dimensions. Please specify using dim_names.") + raise ValueError( + "Could not automatically detect x and y dimensions. Please specify using dim_names." + ) else: y_dim = dim_names.get("y") x_dim = dim_names.get("x") @@ -120,12 +128,14 @@ def make_checkerboard_xr( raise ValueError("Both 'x' and 'y' must be specified in dim_names.") if y_dim not in da.dims or x_dim not in da.dims: - raise ValueError(f"Specified dimensions {y_dim} and {x_dim} not found in DataArray.") + raise ValueError( + f"Specified dimensions {y_dim} and {x_dim} not found in DataArray." + ) y_size, x_size = da.sizes[y_dim], da.sizes[x_dim] # Add warning if inputs are not the same - if y_size != x_size or sq_y != sq_x: + if verbose and (y_size != x_size or sq_y != sq_x): print( "Warning: The inputs for board_size or square_size are not the same. This may result in a non-square checkerboard." ) diff --git a/example_notebooks/example_notebook.ipynb b/example_notebooks/example_notebook.ipynb index b1fe84c..cf760c5 100644 --- a/example_notebooks/example_notebook.ipynb +++ b/example_notebooks/example_notebook.ipynb @@ -93,7 +93,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -109,13 +109,13 @@ ], "source": [ "# Plot original 0-1 pattern\n", - "checkerboard_01 = make_checkerboard(board_size=(74,74), square_size=(10,10), separation_size=2)\n", + "checkerboard_01 = make_checkerboard(board_size=(74,74), square_size=(10,10), separation_size=2, verbose=True)\n", "plot_checkerboard(checkerboard_01, \"Checkerboard Pattern (0-1)\")" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -131,7 +131,7 @@ ], "source": [ "# Plot new 0-1-2 pattern\n", - "checkerboard_012 = make_checkerboard(board_size=(71,71), square_size=(10,10), separation_size=5, validation=True)\n", + "checkerboard_012 = make_checkerboard(board_size=(71,71), square_size=(10,10), separation_size=5, validation=True, verbose=True)\n", "plot_checkerboard(checkerboard_012, \"Checkerboard Pattern (0-1-2)\")" ] }, @@ -173,7 +173,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -204,6 +204,7 @@ " square_size=(50, 50), # adjust this size to make pattern more/less visible\n", " separation_size=10,\n", " validation=False,\n", + " verbose=True\n", ")\n", "\n", "# Create figure with three subplots\n", @@ -246,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -306,9 +307,9 @@ "\n", "# Apply the checkerboard pattern for all three parts of the ternary pattern\n", "square_size = (5, 5) # 5x5 pixel squares\n", - "checkerboard_temp_0 = make_checkerboard_xr(air_temp, square_size, keep_pattern=0, validation=True)\n", - "checkerboard_temp_1 = make_checkerboard_xr(air_temp, square_size, keep_pattern=1, validation=True)\n", - "checkerboard_temp_2 = make_checkerboard_xr(air_temp, square_size, keep_pattern=2, validation=True)\n", + "checkerboard_temp_0 = make_checkerboard_xr(air_temp, square_size, keep_pattern=0, validation=True, verbose=True)\n", + "checkerboard_temp_1 = make_checkerboard_xr(air_temp, square_size, keep_pattern=1, validation=True, verbose=True))\n", + "checkerboard_temp_2 = make_checkerboard_xr(air_temp, square_size, keep_pattern=2, validation=True, verbose=True))\n", "\n", "# Plotting\n", "fig, axs = plt.subplots(2, 2, figsize=(15, 15))\n", @@ -352,7 +353,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -413,8 +414,8 @@ "\n", "# Apply the checkerboard pattern for both parts of the binary pattern\n", "square_size = (7, 5) # 7x5 pixel squares\n", - "checkerboard_temp_0 = make_checkerboard_xr(air_temp, square_size, separation_size=3, keep_pattern=0, validation=False)\n", - "checkerboard_temp_1 = make_checkerboard_xr(air_temp, square_size, separation_size=3, keep_pattern=1, validation=False)\n", + "checkerboard_temp_0 = make_checkerboard_xr(air_temp, square_size, separation_size=3, keep_pattern=0, validation=False, verbose=True))\n", + "checkerboard_temp_1 = make_checkerboard_xr(air_temp, square_size, separation_size=3, keep_pattern=1, validation=False, verbose=True))\n", "\n", "# Plotting\n", "fig, axs = plt.subplots(1, 3, figsize=(20, 6))\n", diff --git a/src/CheckmateSample.egg-info/PKG-INFO b/src/CheckmateSample.egg-info/PKG-INFO index 769c603..1d2a93e 100644 --- a/src/CheckmateSample.egg-info/PKG-INFO +++ b/src/CheckmateSample.egg-info/PKG-INFO @@ -1,6 +1,6 @@ -Metadata-Version: 2.1 +Metadata-Version: 2.4 Name: CheckmateSample -Version: 0.0.post1 +Version: 0.0.post154 Summary: A sample project with checkerboard functionality Author-email: Thomas Martin Project-URL: Homepage, https://github.com/ThomasMGeo/CheckmateSample @@ -13,6 +13,7 @@ Provides-Extra: dev Requires-Dist: pytest>=7.4.0; extra == "dev" Requires-Dist: ruff>=0.1.3; extra == "dev" Requires-Dist: setuptools_scm>=8.1; extra == "dev" +Dynamic: license-file # CheckmateSample diff --git a/src/CheckmateSample/__pycache__/__init__.cpython-312.pyc b/src/CheckmateSample/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ee8f3be1b004c13cc6dab72d80461dd8300a5372 GIT binary patch literal 257 zcmX@j%ge<81V?f|q}K!K#~=<2FhLog6@ZNC3@HpLj5!Rsj8Tk?3``8EjH{v2QB2W{ zl}wtx_>~NwL5BSD($C1x zP1P^S$S+UTcgasK%}vcKDb^3qFUr<;&PYwp&P^;y4NlB0$Vt^NE=tA_i;vID%PfhH y*DI*J#bJ}1pHiBWYFESwG#cclVj&>$ftit!@hOAiLq5sw+y?HOEc`|6Kw$v6_(j_Q literal 0 HcmV?d00001 diff --git a/src/CheckmateSample/__pycache__/_version.cpython-312.pyc b/src/CheckmateSample/__pycache__/_version.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0a1173dd42abc7a549e563c9bcaf62a4ef2597eb GIT binary patch literal 1455 zcmZ`(O>7%Q6rSSs)vdbH$x7Q%7r&;Zxac4t9|q4y*J-` z^XAR`GCZ6@K#%<1>KOx}-_;}{JP`IrK-feMT1F235-sDkSYBJteM+gv%?f4aZNj)q z12Xb8nn2MOgB($*kgH`a;Oh9d3Z=xC8g z8+SFv0Z;dguHMmW!-rmx)OqFIH9AHu8|e>6$8gbBtUv!xdpwHAE{3s^-FPQn8#_dZ zBr*OJIkYkETmE< z&=pry2{Tv0!4+nOQQvIX<+{B}OrHqbv4#D%3CBNhXmV(P2*NDWKrrf=ZU7zP+XDK- zbSojQ9hk&%g}vetFmqvhUT80b)<4uX^D&umTrQZq(o{?3_>F$#MJle+X5d_5jI#Bt z<1$hfR+D*!8mGacOoGNzF=aA}k;gI(DO!UrT{jAaVxh2}X;3cCGvX1Ole{K%MyZf# zP(U)bi6y8U87#4Qxk`K@6Q2e3fVP7Cs66KS4a$V)t`wqLFdY(SaEXviTh^dbmL-Q6 zu^mg0wvf6?QW_q$9WFIUN~Tnuzyv@t$(xM^Bb>|hhaq~nNtynb(t5MepNw!Knhl|@ z9%SXSqzad`tcvRqh?N**oKGIfMpu=T@qVq?s9K?i$D%qpMBoZW9l4^H*Nau^lcK27 z7Aan)<)%*p!Hb_$Rxd78Nx2TkNtSHC;gKR|<$vj-N*5YyA$rKveda#``vM(gkZ~3F z^qg`0x9rrnAMIslHuPQ`O}xH&>)x%M(--z~vpeb84aJ^iUIWYcr@kxgWzRmzp4-iydvN`6_PuALCl!kMBsa60n|V0(L;crW>G}BFi>bFB zTzfRRvs`^V|KPQp~Zfm}US5EbJ;GYC)b$4}tn%mm#(zjJg% literal 0 HcmV?d00001 diff --git a/src/CheckmateSample/__pycache__/generator.cpython-312.pyc b/src/CheckmateSample/__pycache__/generator.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f1d77aa5ff504de4f79f86f4596d7a5bb204111b GIT binary patch literal 7542 zcmb_gU2q%Mb>7AQ{~tkulqq@jXAv?9{>YYWN|8;AqN+%uRZ$6T*$!ukU6LR{EOd84 z66n&Q(qs%})G?W~71U0qkf$@IqIAkMnTa3!)=c|Cn4K8e@Ih_zP`$yG9%8?==j>vE z1qnv(&th=*-gD16_wSs$-#P!{^|~l{R#TPf*5@edx7g61V72n(pP_P>;wX+zQa5Pz zZMtE0QuyP%oQb#aR^B>g>Ht2@+|Ys^&dS?38~p7&J?qnz*WXhf&hcIA4Tq*r)#>A$ zym>ZM=h16Tw7aS!xOrD~l%|qX0nP)XxU+QB{}|PcDy~U^CESFV$nlC>yqRGMuQmK4 zpJoXwC4`hla4oRO1g8=d`vOlU1(8>5gqJcT6}Re>gSQR-X81pO!-QKVQ}4oi*}80# zX|-lwcF3k>r)=fuxqTER`ej?S=92BznpJjaHR6_NT{mZXSgn7DmYpOZJAnsuH}IGZ zJQmU_TV>naDHz2n+hqsVfE#D0KAc78rYX<}QkHp`yW{{MxnU6X|s zzb?6T{TvN@Px3y>75Z4 zdnBP}o}J@+*dF5qdlIRhRAxS%b!jsMx0>f+#^Rvb#)Z|rkm-^#=_LP7A|-V*P`no% zWX8Zd8DWZ%W_XPgIv64>iVU0Ln7EM4%%?4*ya|{tnAVP2 z)h`QXo)zbqNnTpy`BYWCVQ%$Hgz1_Tge2&>IK^Bi8NM6Oi0SKQ`r#z>Gd;~DrkD{n zDH^)V1*VG%xu$QTHEXA>eu-QT8ToXHCSlBmaG&6rS%cyMH&Ji#&D%U%dOu}xY zGZMok=J}L}XUxoJL9JXc@M0z@ zff`sF4plu^qaD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WacXn$+Gb#^VWhV9yKk+%Rp8eqijyDD+@D#` z+!yjAD3+{GiXVq1B$;-exjeAf0-sqLkWYg=uv z00rzP@Znpx-&z&cJ4eAZt6)Uu1kJ~ybcC3N>v{sy0b5Xuf1*Jio z&GEsFTQ{C~u{CT$hQ?0si gG`CvyP=Rp8t5$tDvZ}Naz@gv0_3qOk_Nbfi-|ii*_y7O^ literal 0 HcmV?d00001 diff --git a/src/CheckmateSample/generator.py b/src/CheckmateSample/generator.py index 09ea085..e76ba53 100644 --- a/src/CheckmateSample/generator.py +++ b/src/CheckmateSample/generator.py @@ -7,6 +7,7 @@ def make_checkerboard( square_size: tuple[int, int], separation_size: int = None, validation: bool = False, + verbose: bool = False, ) -> np.ndarray: """ Create a checkerboard pattern. @@ -33,7 +34,7 @@ def make_checkerboard( raise ValueError("Separation size must be a non-negative, non-zero integer") # Add warning if inputs are not the same - if rows != cols or sq_rows != sq_cols: + if verbose and (rows != cols or sq_rows != sq_cols): print( "Warning: The inputs for board_size or square_size are not the same. This may result in a non-square checkerboard." ) @@ -71,6 +72,7 @@ def make_checkerboard_xr( keep_pattern: int = 1, validation: bool = False, dim_names: dict = None, + verbose: bool = False, ) -> xr.DataArray: """ Apply a checkerboard pattern to an existing xarray DataArray. @@ -95,9 +97,13 @@ def make_checkerboard_xr( if sq_y <= 0 or sq_x <= 0: raise ValueError("Square size dimensions must be positive integers.") if validation and keep_pattern not in [0, 1, 2]: - raise ValueError("For validation (ternary pattern), keep_pattern must be 0, 1, or 2.") + raise ValueError( + "For validation (ternary pattern), keep_pattern must be 0, 1, or 2." + ) elif not validation and keep_pattern not in [0, 1]: - raise ValueError("For non-validation (binary pattern), keep_pattern must be 0 or 1.") + raise ValueError( + "For non-validation (binary pattern), keep_pattern must be 0 or 1." + ) if sep and sep < 0: raise ValueError("Separation size must be a non-negative, non-zero integer") @@ -111,7 +117,9 @@ def make_checkerboard_xr( x_dim = next((dim for dim in da.dims if dim in possible_x_dims), None) if y_dim is None or x_dim is None: - raise ValueError("Could not automatically detect x and y dimensions. Please specify using dim_names.") + raise ValueError( + "Could not automatically detect x and y dimensions. Please specify using dim_names." + ) else: y_dim = dim_names.get("y") x_dim = dim_names.get("x") @@ -120,12 +128,14 @@ def make_checkerboard_xr( raise ValueError("Both 'x' and 'y' must be specified in dim_names.") if y_dim not in da.dims or x_dim not in da.dims: - raise ValueError(f"Specified dimensions {y_dim} and {x_dim} not found in DataArray.") + raise ValueError( + f"Specified dimensions {y_dim} and {x_dim} not found in DataArray." + ) y_size, x_size = da.sizes[y_dim], da.sizes[x_dim] # Add warning if inputs are not the same - if y_size != x_size or sq_y != sq_x: + if verbose and (y_size != x_size or sq_y != sq_x): print( "Warning: The inputs for board_size or square_size are not the same. This may result in a non-square checkerboard." ) diff --git a/tests/__pycache__/test_make_checkerboard.cpython-312-pytest-7.4.4.pyc b/tests/__pycache__/test_make_checkerboard.cpython-312-pytest-7.4.4.pyc new file mode 100644 index 0000000000000000000000000000000000000000..008bf6e27ff48dac6a9d793c372c91628a82af25 GIT binary patch literal 15522 zcmeHOYiu0Hec!#?+k5c%rbN`fKq0zTMQmLJa6bqF3X~z02+)`I z_n+Cv+;RD6EunUj!R>!%XXmvu^MC*EpPHLf3etDR=ZEzkMfneU@KVgpEdDDpZ!3mk zs3m1U<@d-~bTFbSW7szboxh0>Byf+El4GfX6y8N&R|c944KQuQ0GkaRu*HZ2 zwi*e*HX{kxZlnM^j3&TNBMsPP>LWY6$prV2T|wT<8O_6r(ejRZIU-7o*4LHG?#qF0 zqYb_F80~<)MhD;nMknBgNj2Mbi)x+Bs!sb@VbshIo-qeUO?J9cV8)=^0lzf?MsY39 zX?!u%8a}e7+NxKns#H}YdPTcTwUBBN+ntP}jG#?pszs&udgEKP*Nj*#R*h6+qucSM z8+t8{r#OE~M3kyl)vF2bgKJ5YM61cm?tE&gYU<61rQ1ob=Mlcq-jlc+@v1(g8VMR@ zD011IrIECoy?P@pUM{$M3wu_v)=B-h1vR`}HR8>O$u&E?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XM5p0vmOjDEw&5v>E=8!>!L;80XA~5n}N# zoDpax7+K=Uv5GNKGM{4K$9uvw>ve$nsH&iQx}uS&hzX-sz-ft;ef8{3mpK91UT~l4}nS6m;e9( literal 0 HcmV?d00001 diff --git a/tests/test_make_checkerboard.py b/tests/test_make_checkerboard.py index ea5c6df..703ba0f 100644 --- a/tests/test_make_checkerboard.py +++ b/tests/test_make_checkerboard.py @@ -6,32 +6,40 @@ def test_checkerboard_values_zero_one(): board_size = (10, 10) square_size = (2, 2) - checkerboard = make_checkerboard(board_size, square_size) - assert np.all(np.logical_or(checkerboard == 0, checkerboard == 1)), "Checkerboard should only contain 0 and 1" + checkerboard = make_checkerboard(board_size, square_size, verbose=True) + assert np.all( + np.logical_or(checkerboard == 0, checkerboard == 1) + ), "Checkerboard should only contain 0 and 1" def test_masked_checkerboard_values_minusone_zero_one(): board_size = (10, 10) square_size = (2, 2) separation_size = 1 - checkerboard = make_checkerboard(board_size, square_size, separation_size) + checkerboard = make_checkerboard( + board_size, square_size, separation_size, verbose=True + ) # Use logical_or.reduce for multiple conditions - valid_values = np.logical_or.reduce([checkerboard == -1, checkerboard == 0, checkerboard == 1]) + valid_values = np.logical_or.reduce( + [checkerboard == -1, checkerboard == 0, checkerboard == 1] + ) assert np.all(valid_values), "Checkerboard should only contain -1, 0 and 1" def test_checkerboard_shape(): board_size = (8, 8) square_size = (1, 1) - checkerboard = make_checkerboard(board_size, square_size) + checkerboard = make_checkerboard(board_size, square_size, verbose=True) assert checkerboard.shape == board_size def test_checkerboard_values(): board_size = (4, 4) square_size = (1, 1) - checkerboard = make_checkerboard(board_size, square_size) - expected = np.array([[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]], dtype="float32") + checkerboard = make_checkerboard(board_size, square_size, verbose=True) + expected = np.array( + [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]], dtype="float32" + ) np.testing.assert_array_equal(checkerboard, expected) @@ -39,15 +47,20 @@ def test_masked_checkerboard_values(): board_size = (4, 4) square_size = (1, 1) setparation_size = 1 - checkerboard = make_checkerboard(board_size, square_size, setparation_size) - expected = np.array([[0, -1, 1, -1], [-1, -1, -1, -1], [1, -1, 0, -1], [-1, -1, -1, -1]], dtype="float32") + checkerboard = make_checkerboard( + board_size, square_size, setparation_size, verbose=True + ) + expected = np.array( + [[0, -1, 1, -1], [-1, -1, -1, -1], [1, -1, 0, -1], [-1, -1, -1, -1]], + dtype="float32", + ) np.testing.assert_array_equal(checkerboard, expected) def test_checkerboard_larger_squares(): board_size = (6, 6) square_size = (2, 2) - checkerboard = make_checkerboard(board_size, square_size) + checkerboard = make_checkerboard(board_size, square_size, verbose=True) expected = np.array( [ [0, 0, 1, 1, 0, 0], @@ -66,7 +79,9 @@ def test_masked_checkerboard_larger_squares(): board_size = (6, 6) square_size = (2, 2) separation_size = 1 - checkerboard = make_checkerboard(board_size, square_size, separation_size) + checkerboard = make_checkerboard( + board_size, square_size, separation_size, verbose=True + ) # Update expected to match the actual implementation pattern expected = np.array( [ @@ -85,9 +100,17 @@ def test_masked_checkerboard_larger_squares(): def test_checkerboard_rectangular(): board_size = (6, 4) square_size = (2, 1) - checkerboard = make_checkerboard(board_size, square_size) + checkerboard = make_checkerboard(board_size, square_size, verbose=True) expected = np.array( - [[0, 1, 0, 1], [0, 1, 0, 1], [1, 0, 1, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 1, 0, 1]], dtype="float32" + [ + [0, 1, 0, 1], + [0, 1, 0, 1], + [1, 0, 1, 0], + [1, 0, 1, 0], + [0, 1, 0, 1], + [0, 1, 0, 1], + ], + dtype="float32", ) np.testing.assert_array_equal(checkerboard, expected) @@ -96,9 +119,18 @@ def test_masked_checkerboard_rectangular(): board_size = (6, 4) square_size = (2, 1) setparation_size = 1 - checkerboard = make_checkerboard(board_size, square_size, setparation_size) + checkerboard = make_checkerboard( + board_size, square_size, setparation_size, verbose=True + ) expected = np.array( - [[0, -1, 1, -1], [0, -1, 1, -1], [-1, -1, -1, -1], [1, -1, 0, -1], [1, -1, 0, -1], [-1, -1, -1, -1]], + [ + [0, -1, 1, -1], + [0, -1, 1, -1], + [-1, -1, -1, -1], + [1, -1, 0, -1], + [1, -1, 0, -1], + [-1, -1, -1, -1], + ], dtype="float32", ) np.testing.assert_array_equal(checkerboard, expected) @@ -107,22 +139,23 @@ def test_masked_checkerboard_rectangular(): def test_checkerboard_dtype(): board_size = (4, 4) square_size = (1, 1) - checkerboard = make_checkerboard(board_size, square_size) + checkerboard = make_checkerboard(board_size, square_size, verbose=True) assert checkerboard.dtype == np.float32 @pytest.mark.parametrize( - "board_size,square_size", [((0, 0), (1, 1)), ((5, 5), (0, 0)), ((-1, 5), (1, 1)), ((5, 5), (-1, 1))] + "board_size,square_size", + [((0, 0), (1, 1)), ((5, 5), (0, 0)), ((-1, 5), (1, 1)), ((5, 5), (-1, 1))], ) def test_invalid_inputs(board_size, square_size): with pytest.raises((ValueError, ZeroDivisionError)): - make_checkerboard(board_size, square_size) + make_checkerboard(board_size, square_size, verbose=True) def test_make_checkerboard_validation_true(): board_size = (6, 6) square_size = (2, 2) - result = make_checkerboard(board_size, square_size, validation=True) + result = make_checkerboard(board_size, square_size, validation=True, verbose=True) # Check if the result contains only 0, 1, and 2 assert np.all(np.isin(result, [0, 1, 2])) @@ -147,18 +180,27 @@ def test_make_checkerboard_validation_true(): def test_make_checkerboard_warning_non_square_board(capsys): - make_checkerboard((5, 6), (2, 2)) + make_checkerboard((5, 6), (2, 2), verbose=True) captured = capsys.readouterr() - assert "Warning: The inputs for board_size or square_size are not the same" in captured.out + assert ( + "Warning: The inputs for board_size or square_size are not the same" + in captured.out + ) def test_make_checkerboard_warning_non_square_squares(capsys): - make_checkerboard((6, 6), (2, 3)) + make_checkerboard((6, 6), (2, 3), verbose=True) captured = capsys.readouterr() - assert "Warning: The inputs for board_size or square_size are not the same" in captured.out + assert ( + "Warning: The inputs for board_size or square_size are not the same" + in captured.out + ) def test_make_checkerboard_warning_both_non_square(capsys): - make_checkerboard((5, 6), (2, 3)) + make_checkerboard((5, 6), (2, 3), verbose=True) captured = capsys.readouterr() - assert "Warning: The inputs for board_size or square_size are not the same" in captured.out + assert ( + "Warning: The inputs for board_size or square_size are not the same" + in captured.out + )