openJiuwen-ai/sciencediscovery / skills/code-engineer
code-engineer
VerifiedUse this skill when you need to write and execute Python/R code to process, transform, and analyze data, delivering reproducible computational results with complete code-level methodology documentation. Supports statistical analysis, data transformation, visualization, method justification, and structured result output.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.0 KB |
| references/lmfit-conf-interval.md | markdown | 2.3 KB |
| scripts/execute.py | script | 32.5 KB |
| scripts/test_lmfit_conf_interval.py | script | 5.3 KB |
scripts/test_lmfit_conf_interval.py
View on GitHub#!/usr/bin/env python3
"""Hermetic checks for lmfit 1.3.4 conf_interval guidance (issue #589 / #335 S4).
Content tests always run. API tests require lmfit (prefer 1.3.4) and prove
correct patterns succeed while known-wrong patterns still raise real errors —
they must not be swallowed.
"""
from __future__ import annotations
import unittest
from pathlib import Path
SKILL_ROOT = Path(__file__).resolve().parents[1]
REFERENCE = SKILL_ROOT / "references" / "lmfit-conf-interval.md"
SKILL_MD = SKILL_ROOT / "SKILL.md"
try:
import lmfit
from lmfit import Minimizer, Model, Parameters, conf_interval
except ImportError: # pragma: no cover - environment without lmfit
lmfit = None # type: ignore[assignment]
Minimizer = Model = Parameters = conf_interval = None # type: ignore[misc, assignment]
def michaelis_menten(x, Vmax, Km):
return Vmax * x / (Km + x)
def _has_lmfit() -> bool:
return lmfit is not None
@unittest.skipUnless(_has_lmfit(), "lmfit is not installed")
class LmfitConfIntervalApiTests(unittest.TestCase):
"""Exercise correct vs wrong conf_interval calling conventions."""
@classmethod
def setUpClass(cls) -> None:
import numpy as np
version = getattr(lmfit, "__version__", "")
if not str(version).startswith("1.3"):
raise unittest.SkipTest(f"expected lmfit 1.3.x for #589, found {version!r}")
rng = np.random.default_rng(0)
x = np.linspace(0.5, 10.0, 24)
y = michaelis_menten(x, 100.0, 2.5) + rng.normal(0.0, 1.5, size=x.size)
cls.x = x
cls.y = y
def _fit_minimizer(self):
def residual(params):
values = params.valuesdict()
return self.y - michaelis_menten(self.x, values["Vmax"], values["Km"])
params = Parameters()
params.add("Vmax", value=80.0, min=0)
params.add("Km", value=3.0, min=0)
mini = Minimizer(residual, params)
out = mini.minimize()
return mini, out, params
def test_model_result_conf_interval_succeeds(self) -> None:
model = Model(michaelis_menten)
params = model.make_params(Vmax=80.0, Km=3.0)
params["Vmax"].min = 0
params["Km"].min = 0
result = model.fit(self.y, params, x=self.x)
self.assertTrue(result.success)
ci = result.conf_interval()
self.assertIn("Vmax", ci)
self.assertIn("Km", ci)
def test_minimizer_conf_interval_succeeds(self) -> None:
mini, out, _params = self._fit_minimizer()
self.assertTrue(out.success)
ci = conf_interval(mini, out)
self.assertIn("Vmax", ci)
self.assertIn("Km", ci)
def test_wrong_single_argument_still_raises_typeerror(self) -> None:
_mini, out, _params = self._fit_minimizer()
with self.assertRaises(TypeError) as ctx:
conf_interval(out) # type: ignore[arg-type]
self.assertIn("result", str(ctx.exception))
def test_wrong_swapped_arguments_still_raises(self) -> None:
"""Swapped args must fail with a real library error (never a CI dict).
lmfit 1.3.4 typically raises MinimizerException (stderr / params path)
before AttributeError on prepare_fit; either is acceptable — do not
swallow.
"""
mini, out, _params = self._fit_minimizer()
with self.assertRaises(Exception) as ctx:
conf_interval(out, mini) # type: ignore[arg-type]
message = str(ctx.exception)
self.assertTrue(
("prepare_fit" in message)
or ("Confidence Intervals" in message)
or ("stderr" in message.lower())
or type(ctx.exception).__name__ in {"AttributeError", "MinimizerException", "TypeError"},
msg=f"unexpected swapped-arg failure: {type(ctx.exception).__name__}: {message}",
)
def test_unexpected_params_kwarg_still_raises_typeerror(self) -> None:
mini, out, params = self._fit_minimizer()
with self.assertRaises(TypeError) as ctx:
conf_interval(mini, out, params=params) # type: ignore[call-arg]
self.assertIn("params", str(ctx.exception))
class LmfitConfIntervalGuidanceTests(unittest.TestCase):
"""Contract: skill points at the reference and documents correct APIs."""
def test_reference_file_exists(self) -> None:
self.assertTrue(REFERENCE.is_file(), f"missing guidance file: {REFERENCE}")
def test_reference_documents_correct_and_wrong_patterns(self) -> None:
text = REFERENCE.read_text(encoding="utf-8")
self.assertIn("result.conf_interval()", text)
self.assertIn("conf_interval(minimizer, result)", text)
self.assertIn("1.3.4", text)
self.assertIn("prepare_fit", text)
self.assertIn("Do not use", text)
self.assertIn("swallow", text.lower())
def test_skill_md_points_at_reference(self) -> None:
text = SKILL_MD.read_text(encoding="utf-8")
self.assertIn("references/lmfit-conf-interval.md", text)
self.assertIn("conf_interval", text)
def test_reference_is_utf8_markdown(self) -> None:
raw = REFERENCE.read_bytes()
self.assertFalse(raw.startswith(b"\xff\xfe") or raw.startswith(b"\xfe\xff"))
self.assertTrue(REFERENCE.read_text(encoding="utf-8").lstrip().startswith("#"))
if __name__ == "__main__":
unittest.main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 470k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 197k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |