Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions ChronoHolographicCipher.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,45 @@
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## UNIT TESTS"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import unittest\n",
"\n",
"class TestChronoHolographicCipher(unittest.TestCase):\n",
" def test_calculate_temporal_echo_simple(self):\n",
" cipher = ChronoHolographicCipher(resonance_factor=2, dimensions=2)\n",
" # dims = 2, R = 2\n",
" # n=1: 2^1 * (10 / 9) = 20/9\n",
" # n=2: 2^2 * (10 / 8) = 40/8 = 5\n",
" # expected = 10 + 20/9 + 5 = 15 + 2.222... = 17.22222222222222\n",
" result = cipher.calculate_temporal_echo(base_state_val=10, current_time=10)\n",
" self.assertAlmostEqual(result, 15 + 20/9, places=7)\n",
"\n",
" def test_calculate_temporal_echo_zero_dims(self):\n",
" cipher = ChronoHolographicCipher(resonance_factor=2, dimensions=0)\n",
" result = cipher.calculate_temporal_echo(base_state_val=10, current_time=10)\n",
" self.assertEqual(result, 10)\n",
"\n",
" def test_calculate_temporal_echo_zero_base(self):\n",
" cipher = ChronoHolographicCipher(resonance_factor=2, dimensions=2)\n",
" result = cipher.calculate_temporal_echo(base_state_val=0, current_time=10)\n",
" self.assertEqual(result, 0)\n",
"\n",
"if __name__ == '__main__':\n",
" unittest.main(argv=[''], exit=False)\n"
]
Comment on lines +375 to +397
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The added tests are a good start for calculate_temporal_echo, but the test suite is missing a check for a critical edge case. The function is vulnerable to a ZeroDivisionError if current_time is an integer that is also in the range of n (from 1 to self.dims), as this would make the denominator current_time - n zero.

Since your tests already use an integer for current_time, it would be valuable to add a test case that specifically checks for this singularity. This would make the test suite more robust and surface a potential bug in the implementation.

I recommend adding the following test method to the TestChronoHolographicCipher class:

    def test_calculate_temporal_echo_singularity(self):
        """Tests for the singularity case where current_time == n."""
        cipher = ChronoHolographicCipher(resonance_factor=2, dimensions=10)
        with self.assertRaises(ZeroDivisionError):
            cipher.calculate_temporal_echo(base_state_val=10, current_time=10)

}
]
}