Skip to content

Commit

Permalink
Add logging for cognition progress and improve reporting of areas nee…
Browse files Browse the repository at this point in the history
…ding improvement; update tests for new functionality
  • Loading branch information
kasinadhsarma committed Dec 26, 2024
1 parent d48a25f commit a8c2714
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
Binary file modified models/__pycache__/consciousness_model.cpython-310.pyc
Binary file not shown.
25 changes: 17 additions & 8 deletions models/consciousness_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ def calculate_cognition_progress(self, metrics):
'breakdown': scores
})

self.logger.debug(f"Cognition Progress: {cognition_percentage}%")

end_time = time.time() # End profiling
self.logger.debug(f"calculate_cognition_progress took {end_time - start_time:.6f} seconds")

Expand All @@ -267,16 +269,23 @@ def report_cognition_progress(self):
f"- Adaptability: {latest['breakdown']['adaptability']*100:.2f}%",
f"- Memory Retention: {latest['breakdown']['memory_retention']*100:.2f}%",
f"- Emotional Coherence: {latest['breakdown']['emotional_coherence']*100:.2f}%",
f"- Decision Making Efficiency: {latest['breakdown']['decision_making_efficiency']*100:.2f}%\n",
"Areas Needing Improvement:"
f"- Decision Making Efficiency: {latest['breakdown']['decision_making_efficiency']*100:.2f}%\n"
]

# Identify areas below target threshold
threshold = self.target_cognition_percentage / 100 # Convert to fraction
areas_needing_improvement = [
metric.replace('_', ' ').title()
for metric, value in latest['breakdown'].items()
if value < threshold
]

# Identify areas below target threshold (e.g., 70%)
threshold = 70.0
for metric, value in latest['breakdown'].items():
if value * 100 < threshold:
readable_metric = metric.replace('_', ' ').title()
report.append(f"- {readable_metric}: {value*100:.2f}%")
if areas_needing_improvement:
report.append("Areas Needing Improvement:")
for area in areas_needing_improvement:
report.append(f"- {area}")
else:
report.append("No areas need improvement.")

return "\n".join(report)

Expand Down
Binary file not shown.
22 changes: 20 additions & 2 deletions tests/unit/test_cognition_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,24 @@ def test_report_cognition_progress_no_improvement_needed(self, model):
report = model.report_cognition_progress()
assert "Current Cognition Progress: 81.00%" in report
assert "Target Cognition Progress: 70.00%" in report
assert "Areas Needing Improvement:" in report
assert "No areas need improvement." in report
# No areas should be listed as needing improvement
assert not any(metric in report for metric in []), "No metrics should need improvement"
assert "Areas Needing Improvement:" not in report

def test_achieve_90_percent_cognition(self, model):
model.target_cognition_percentage = 90.0
metrics = {
'phi': 0.9,
'coherence': 0.9,
'stability': 0.9,
'adaptability': 0.9,
'memory_retention': 0.9,
'emotional_coherence': 0.9,
'decision_making_efficiency': 0.9
}
progress = model.calculate_cognition_progress(metrics)
report = model.report_cognition_progress()
assert "Current Cognition Progress: 90.00%" in report
assert "Target Cognition Progress: 90.00%" in report
assert "Areas Needing Improvement:" not in report
assert progress == pytest.approx(90.0)

0 comments on commit a8c2714

Please sign in to comment.