π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
π Checkpoint: Edit /workspaces/claude-code-flow/test_uncertainty_conversion.py
rUvbc0288894563
diff --git a/.claude/checkpoints/1754583844.json b/.claude/checkpoints/1754583844.jsonnew file mode 100644index 0000000000..732a9c7f49--- /dev/null+++ b/.claude/checkpoints/1754583844.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250807-162404", "file": "/workspaces/claude-code-flow/proposed_patch.py", "timestamp": "2025-08-07T16:24:04Z", "type": "pre-edit", "original_branch": "swe-bench"}diff --git a/.claude/checkpoints/1754583846.json b/.claude/checkpoints/1754583846.jsonnew file mode 100644index 0000000000..2abf656701--- /dev/null+++ b/.claude/checkpoints/1754583846.json@@ -0,0 +1 @@+{"tag": "checkpoint-20250807-162406", "file": "/workspaces/claude-code-flow/proposed_patch.py", "timestamp": "2025-08-07T16:24:06Z", "type": "post-edit", "branch": "swe-bench", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 5308 +++++++++++++++++++++++++++++- .claude-flow/metrics/task-metrics.json | 8 +- .claude/checkpoints/task-1754583520.json | 1 + astropy_fix | 0 proposed_patch.py | 146 + 6 files changed, 5380 insertions(+), 85 deletions(-) "}diff --git a/.claude/checkpoints/1754583881.json b/.claude/checkpoints/1754583881.jsonnew file mode 100644index 0000000000..ce66e73a86--- /dev/null+++ b/.claude/checkpoints/1754583881.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250807-162441", "file": "/workspaces/claude-code-flow/astropy_fix/astropy/nddata/nduncertainty.py", "timestamp": "2025-08-07T16:24:41Z", "type": "pre-edit", "original_branch": "swe-bench"}diff --git a/.claude/checkpoints/1754583884.json b/.claude/checkpoints/1754583884.jsonnew file mode 100644index 0000000000..65ea5287f6--- /dev/null+++ b/.claude/checkpoints/1754583884.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250807-162444", "file": "/workspaces/claude-code-flow/astropy_fix/astropy/nddata/nduncertainty.py", "timestamp": "2025-08-07T16:24:44Z", "type": "pre-edit", "original_branch": "swe-bench"}diff --git a/.claude/checkpoints/1754583904.json b/.claude/checkpoints/1754583904.jsonnew file mode 100644index 0000000000..a2f2a9b548--- /dev/null+++ b/.claude/checkpoints/1754583904.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250807-162504", "file": "/workspaces/claude-code-flow/astropy_fix/astropy/nddata/nduncertainty.py", "timestamp": "2025-08-07T16:25:04Z", "type": "pre-edit", "original_branch": "swe-bench"}diff --git a/test_uncertainty_conversion.py b/test_uncertainty_conversion.pynew file mode 100644index 0000000000..13a97c951a--- /dev/null+++ b/test_uncertainty_conversion.py@@ -0,0 +1,178 @@+"""+Test cases for the new uncertainty conversion helper functions.+"""++import numpy as np+import pytest+++def test_to_stddev():+ """Test conversion to standard deviation uncertainty."""+ from astropy.nddata import VarianceUncertainty, InverseVariance++ # From variance+ var = VarianceUncertainty(np.array([4, 9, 16]))+ std = var.to_stddev()+ assert std.uncertainty_type == 'std'+ np.testing.assert_array_almost_equal(std.array, [2, 3, 4])++ # From inverse variance+ ivar = InverseVariance(np.array([0.25, 1/9, 1/16]))+ std = ivar.to_stddev()+ assert std.uncertainty_type == 'std'+ np.testing.assert_array_almost_equal(std.array, [2, 3, 4])+++def test_to_variance():+ """Test conversion to variance uncertainty."""+ from astropy.nddata import StdDevUncertainty, InverseVariance++ # From standard deviation+ std = StdDevUncertainty(np.array([2, 3, 4]))+ var = std.to_variance()+ assert var.uncertainty_type == 'var'+ np.testing.assert_array_almost_equal(var.array, [4, 9, 16])++ # From inverse variance+ ivar = InverseVariance(np.array([0.25, 1/9, 1/16]))+ var = ivar.to_variance()+ assert var.uncertainty_type == 'var'+ np.testing.assert_array_almost_equal(var.array, [4, 9, 16])+++def test_to_inverse_variance():+ """Test conversion to inverse variance uncertainty."""+ from astropy.nddata import StdDevUncertainty, VarianceUncertainty++ # From standard deviation+ std = StdDevUncertainty(np.array([2, 3, 4]))+ ivar = std.to_inverse_variance()+ assert ivar.uncertainty_type == 'ivar'+ np.testing.assert_array_almost_equal(ivar.array, [0.25, 1/9, 1/16])++ # From variance+ var = VarianceUncertainty(np.array([4, 9, 16]))+ ivar = var.to_inverse_variance()+ assert ivar.uncertainty_type == 'ivar'+ np.testing.assert_array_almost_equal(ivar.array, [0.25, 1/9, 1/16])+++def test_convert_uncertainty_function():+ """Test the standalone convert_uncertainty function."""+ from astropy.nddata import (+ StdDevUncertainty, VarianceUncertainty, InverseVariance,+ convert_uncertainty+ )++ # Test with string target types+ std = StdDevUncertainty(np.array([2, 3, 4]))++ # Convert to variance using string+ var = convert_uncertainty(std, 'variance')+ assert isinstance(var, VarianceUncertainty)+ np.testing.assert_array_almost_equal(var.array, [4, 9, 16])++ # Convert to variance using 'var' alias+ var = convert_uncertainty(std, 'var')+ assert isinstance(var, VarianceUncertainty)+ np.testing.assert_array_almost_equal(var.array, [4, 9, 16])++ # Convert to inverse variance using string+ ivar = convert_uncertainty(std, 'inverse_variance')+ assert isinstance(ivar, InverseVariance)+ np.testing.assert_array_almost_equal(ivar.array, [0.25, 1/9, 1/16])++ # Convert to inverse variance using 'ivar' alias+ ivar = convert_uncertainty(std, 'ivar')+ assert isinstance(ivar, InverseVariance)+ np.testing.assert_array_almost_equal(ivar.array, [0.25, 1/9, 1/16])++ # Test with class target type+ var = convert_uncertainty(std, VarianceUncertainty)+ assert isinstance(var, VarianceUncertainty)+ np.testing.assert_array_almost_equal(var.array, [4, 9, 16])++ # Test invalid string+ with pytest.raises(ValueError, match="Unknown uncertainty type"):+ convert_uncertainty(std, 'invalid')+++def test_round_trip_conversions():+ """Test that round-trip conversions preserve values."""+ from astropy.nddata import StdDevUncertainty++ original = np.array([1, 2, 3, 4, 5])+ std = StdDevUncertainty(original)++ # Round trip through variance+ var = std.to_variance()+ std2 = var.to_stddev()+ np.testing.assert_array_almost_equal(std2.array, original)++ # Round trip through inverse variance+ ivar = std.to_inverse_variance()+ std3 = ivar.to_stddev()+ np.testing.assert_array_almost_equal(std3.array, original)+++def test_conversion_with_units():+ """Test that conversions handle units correctly."""+ from astropy.nddata import StdDevUncertainty, VarianceUncertainty+ from astropy import units as u++ # Standard deviation with unit+ std = StdDevUncertainty(np.array([2, 3, 4]), unit=u.m)++ # Convert to variance - unit should be squared+ var = std.to_variance()+ assert var.array is not None+ np.testing.assert_array_almost_equal(var.array, [4, 9, 16])+ assert var.unit == u.m**2++ # Convert back to std - unit should be m again+ std2 = var.to_stddev()+ np.testing.assert_array_almost_equal(std2.array, [2, 3, 4])+ assert std2.unit == u.m+++def test_unsupported_conversion():+ """Test that unsupported conversions raise appropriate errors."""+ from astropy.nddata import UnknownUncertainty++ # UnknownUncertainty doesn't support conversion+ unk = UnknownUncertainty(np.array([1, 2, 3]))++ with pytest.raises(TypeError, match="does not support conversion"):+ unk.to_variance()++ with pytest.raises(TypeError, match="does not support conversion"):+ unk.to_stddev()++ with pytest.raises(TypeError, match="does not support conversion"):+ unk.to_inverse_variance()+++if __name__ == "__main__":+ # Run the tests+ test_to_stddev()+ print("β test_to_stddev passed")++ test_to_variance()+ print("β test_to_variance passed")++ test_to_inverse_variance()+ print("β test_to_inverse_variance passed")++ test_convert_uncertainty_function()+ print("β test_convert_uncertainty_function passed")++ test_round_trip_conversions()+ print("β test_round_trip_conversions passed")++ test_conversion_with_units()+ print("β test_conversion_with_units passed")++ test_unsupported_conversion()+ print("β test_unsupported_conversion passed")++ print("\nAll tests passed!")\ No newline at end of file