From 99e0b05cf1a3cafdbcb25e6bb4fd084fa7d1caba Mon Sep 17 00:00:00 2001 From: "Kurt R. Lindberg" <85883737+kurtlindberg@users.noreply.github.com> Date: Mon, 2 Jun 2025 15:31:35 -0700 Subject: [PATCH 1/3] Cat.sleep() duration no longer optional Also fixed missing space in jupyter-execute --- pyCatSim/api/cat.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyCatSim/api/cat.py b/pyCatSim/api/cat.py index 5d90543..849365c 100644 --- a/pyCatSim/api/cat.py +++ b/pyCatSim/api/cat.py @@ -331,7 +331,7 @@ def eat(self): return {"hunger_level": self.hunger_level, "mood": self.mood} - def sleep(self, duration=0): + def sleep(self, duration): """ Simulates the cat getting some sleep. @@ -342,7 +342,7 @@ def sleep(self, duration=0): Parameters ---------- - duration : int or float, optional + duration : int or float Number of hours the cat sleeps. Must be an integer or float. The default is 0. Raises @@ -355,7 +355,7 @@ def sleep(self, duration=0): Examples -------- - ..jupyter-execute:: + .. jupyter-execute:: import pyCatSim as cats nutmeg = cats.Cat(name='Nutmeg', age = 3, color = 'tortoiseshell') From 3260338c2dbe447479cd9ff72c610cf13ba8511b Mon Sep 17 00:00:00 2001 From: "Kurt R. Lindberg" <85883737+kurtlindberg@users.noreply.github.com> Date: Mon, 2 Jun 2025 15:40:56 -0700 Subject: [PATCH 2/3] Additive test for Cat.sleep() --- pyCatSim/tests/test_api_Cat.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyCatSim/tests/test_api_Cat.py b/pyCatSim/tests/test_api_Cat.py index a5b949e..7ee927e 100644 --- a/pyCatSim/tests/test_api_Cat.py +++ b/pyCatSim/tests/test_api_Cat.py @@ -162,7 +162,7 @@ class TestcatCatSleep: [ (0), (1), - (4.4), + (14.4), pytest.param("kitty", marks=pytest.mark.xfail), pytest.param(-1, marks=pytest.mark.xfail), pytest.param(17, marks=pytest.mark.xfail) @@ -175,7 +175,8 @@ def test_sleep_t0(self, duration): if duration < 3: assert cat.energy == 0 - + if (duration >= 12) and (duration < 15): + assert cat.energy == 4 class TestcatCatFact: ''' Test for the give_fact function''' @@ -197,4 +198,4 @@ def test_give_fact_t0(self): "Cats use their whiskers to detect changes in their surroundings.", "The average house cat can run at speeds up to 30 mph.", "Cats meow only to communicate with humans." - ] \ No newline at end of file + ] From b49e5265f0b9d2175ba9ced1ee9ed7a1e0203959 Mon Sep 17 00:00:00 2001 From: "Kurt R. Lindberg" <85883737+kurtlindberg@users.noreply.github.com> Date: Mon, 2 Jun 2025 15:50:35 -0700 Subject: [PATCH 3/3] Possible tab/space fix --- pyCatSim/tests/test_api_Cat.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyCatSim/tests/test_api_Cat.py b/pyCatSim/tests/test_api_Cat.py index 7ee927e..a403f7b 100644 --- a/pyCatSim/tests/test_api_Cat.py +++ b/pyCatSim/tests/test_api_Cat.py @@ -175,6 +175,7 @@ def test_sleep_t0(self, duration): if duration < 3: assert cat.energy == 0 + if (duration >= 12) and (duration < 15): assert cat.energy == 4