k-wave-python
k-wave-python copied to clipboard
Avoid setting p0 to None during assignment
Fixed #468
Not sure why we even have a logic to assign p0 to None. Could not find any reason.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 73.16%. Comparing base (
2dfa811) to head (364d9f7). Report is 34 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #543 +/- ##
==========================================
+ Coverage 73.11% 73.16% +0.04%
==========================================
Files 46 46
Lines 6830 6830
Branches 1308 1308
==========================================
+ Hits 4994 4997 +3
+ Misses 1286 1284 -2
+ Partials 550 549 -1
| Flag | Coverage Δ | |
|---|---|---|
| 3.10 | 73.16% <100.00%> (+0.04%) |
:arrow_up: |
| 3.11 | 73.16% <100.00%> (+0.04%) |
:arrow_up: |
| 3.12 | 73.16% <100.00%> (+0.04%) |
:arrow_up: |
| 3.13 | 73.16% <100.00%> (+0.04%) |
:arrow_up: |
| macos-latest | 73.13% <100.00%> (+0.04%) |
:arrow_up: |
| ubuntu-latest | 73.13% <100.00%> (+0.04%) |
:arrow_up: |
| windows-latest | 73.14% <100.00%> (+0.04%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
import unittest
import numpy as np
from kwave.ksource import kSource
class TestKSource(unittest.TestCase):
def setUp(self):
self.source = kSource()
def test_p0_setter_empty_array(self):
"""Test that p0 is set to None when given an empty array"""
self.source.p0 = np.array([])
self.assertIsNone(self.source.p0)
def test_p0_setter_non_empty_array(self):
"""Test that p0 is set correctly for non-empty array"""
test_array = np.array([1.0, 2.0, 3.0])
self.source.p0 = test_array
np.testing.assert_array_equal(self.source.p0, test_array)
def test_p0_setter_zero_array(self):
"""Test that p0 is set correctly for array of zeros (should not be set to None)"""
test_array = np.zeros(5)
self.source.p0 = test_array
np.testing.assert_array_equal(self.source.p0, test_array)
def test_is_p0_empty(self):
"""Test the is_p0_empty method"""
# Test with None
self.assertTrue(self.source.is_p0_empty())
# Test with empty array
self.source.p0 = np.array([])
self.assertTrue(self.source.is_p0_empty())
# Test with non-empty array
self.source.p0 = np.array([1.0, 2.0])
self.assertFalse(self.source.is_p0_empty())
# Test with zero array
self.source.p0 = np.zeros(5)
self.assertTrue(self.source.is_p0_empty())