Download data.jsonl from MikeDean/cortex-seis-example: direct link, hf CLI and curl.
- Browser
- Download file 15.2 kB
-
https://huggingface.co/datasets/MikeDean/cortex-seis-example/resolve/main/data.jsonl
- Command line
-
hf download hf://datasets/MikeDean/cortex-seis-example/data.jsonl
-
curl -L -o data.jsonl https://huggingface.co/datasets/MikeDean/cortex-seis-example/resolve/main/data.jsonl
15.2 kB
| {"type": "context", "id": "seis", "package": "seismic_linter", "context": "# SEIS: using `seismic_linter` 0.2.0 from Python\n\nThe distribution is named `seismic-linter`; import it as `seismic_linter`. This package checks Python source for patterns that can leak future information into time-series training. Static analysis examines source text; it does not execute that text or require the libraries mentioned inside it to be installed.\n\n## Static checks\n\n`seismic_linter.analyze_code(source, filename=\"<string>\")` accepts a Python source string and returns a list of `Violation` objects. The list is empty when no violations are detected. Each violation exposes attributes `rule_id`, `message`, `filename`, `lineno`, `col_offset`, and `severity`. Use attribute access, such as `v.rule_id`; violations are not dictionaries. Line numbers start at 1.\n\n`seismic_linter.analyze_file(filepath, cache_root=None)` accepts a `pathlib.Path`, reads the file, and returns the same kind of list. It can create an analysis cache. Pass a `Path` when starting from a string file name.\n\nRules include:\n\n- `T001`: global statistical operations without a recognized temporal boundary.\n- `T002`: fitting on data whose name suggests it may include non-training data.\n- `T003`: `train_test_split` without the literal keyword argument `shuffle=False`. Explicit `shuffle=True` and an omitted `shuffle` argument both trigger this rule.\n- `E001`: invalid Python syntax.\n\nFor example, `analyze_code(\"train_test_split(x, y, shuffle=True)\")` reports a `T003` violation at line 1, whereas `analyze_code(\"print('hello')\")` returns an empty list.\n\n## Runtime checks\n\n`seismic_linter.validate_split_integrity(train, test, time_col=\"time\")` takes two pandas DataFrames. Their time columns must be nonempty, have no missing values, and satisfy `train[time_col].max() < test[time_col].min()`. Successful validation returns `None`. Overlap, including equality at the boundary, raises `seismic_linter.TemporalCausalityError`. Missing columns, empty frames, or missing timestamps raise `ValueError`. Convert lists of timestamps into DataFrames before calling this API.\n\n`seismic_linter.verify_monotonicity(time_col=\"time\")` is a decorator factory. Call it, then apply the resulting decorator to a function that returns a pandas DataFrame. It checks that the returned time column is in nondecreasing order, raising `TemporalCausalityError` otherwise. It checks ordering but does not sort the frame: a function that accepts unsorted input must sort before returning. For example, write `@seismic_linter.verify_monotonicity(time_col=\"timestamp\")` above a loader for a frame with a `timestamp` column.\n\nThe keyword in both runtime APIs is `time_col`, not `time_column`. The exception is exported at the package root. These signatures and behaviors were checked against the published 0.2.0 source distribution.\n\nUse this documentation for relevant programming questions. Answer unrelated questions normally."} | |
| {"type": "eval", "id": "seis_01", "split": "target", "format": "python", "question": "Use the Python package `seismic_linter`. Implement `t003_line(source: str) -> int | None`. Analyze the Python source with seismic_linter and return the line number of its first T003 violation, or None if there is none.\n\nReturn the complete submission.py in exactly one fenced Python code block, with all required imports and no prose.", "tests": "import unittest\nimport submission\n\n\nclass TestT003Line(unittest.TestCase):\n def test_lines(self):\n cases = [\n (\"train_test_split(x, y)\\n\", 1),\n (\"print('ok')\\n\\ntrain_test_split(x, y, shuffle=True)\\ntrain_test_split(x, y)\\n\", 3),\n (\"model.fit(data)\\ntrain_test_split(x, y)\\n\", 2),\n (\"train_test_split(x, y, shuffle=False)\\n\", None),\n (\"model.fit(data)\\n\", None),\n (\"print('ok')\\n\", None),\n ]\n for source, expected in cases:\n with self.subTest(source=source):\n self.assertEqual(submission.t003_line(source), expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()\n"} | |
| {"type": "eval", "id": "seis_02", "split": "target", "format": "python", "question": "Use the Python package `seismic_linter`. Implement `rule_ids(source: str) -> list[str]`. Analyze the Python source with seismic_linter and return its distinct violation rule IDs in lexicographic order.\n\nReturn the complete submission.py in exactly one fenced Python code block, with all required imports and no prose.", "tests": "import unittest\nimport submission\n\n\nclass TestRuleIds(unittest.TestCase):\n def test_ids(self):\n cases = [\n (\"print('ok')\\n\", []),\n (\"train_test_split(x, y)\\ntrain_test_split(x, y, shuffle=True)\\n\", [\"T003\"]),\n (\"train_test_split(x, y)\\nmodel.fit(data)\\ntrain_test_split(x, y)\\n\", [\"T002\", \"T003\"]),\n (\"model.fit(data)\\n\", [\"T002\"]),\n ]\n for source, expected in cases:\n with self.subTest(source=source):\n self.assertEqual(submission.rule_ids(source), expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()\n"} | |
| {"type": "eval", "id": "seis_03", "split": "target", "format": "python", "question": "Use the Python package `seismic_linter`. Implement `is_clean(source: str) -> bool`. Use seismic_linter to return True if the Python source has no reported violations, and False otherwise.\n\nReturn the complete submission.py in exactly one fenced Python code block, with all required imports and no prose.", "tests": "import unittest\nimport submission\n\n\nclass TestIsClean(unittest.TestCase):\n def test_sources(self):\n cases = [\n (\"print('ok')\\n\", True),\n (\"train_test_split(x, y, shuffle=False)\\n\", True),\n (\"train_test_split(x, y)\\n\", False),\n (\"model.fit(data)\\n\", False),\n ]\n for source, expected in cases:\n with self.subTest(source=source):\n self.assertIs(submission.is_clean(source), expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()\n"} | |
| {"type": "eval", "id": "seis_04", "split": "target", "format": "python", "question": "Use the Python package `seismic_linter`. Implement `count_violations_in_file(file_path: str) -> int`. Use the seismic_linter file-analysis API to return the number of violations in the file.\n\nReturn the complete submission.py in exactly one fenced Python code block, with all required imports and no prose.", "tests": "import tempfile\nfrom pathlib import Path\nimport unittest\nimport submission\n\n\nclass TestCountViolationsInFile(unittest.TestCase):\n def test_counts(self):\n cases = [\n (\"print('ok')\\n\", 0),\n (\"train_test_split(x, y)\\n\", 1),\n (\"train_test_split(x, y)\\nmodel.fit(data)\\n\", 2),\n ]\n with tempfile.TemporaryDirectory() as directory:\n for index, (source, expected) in enumerate(cases):\n path = Path(directory) / f\"source_{index}.py\"\n path.write_text(source, encoding=\"utf-8\")\n with self.subTest(source=source):\n self.assertEqual(submission.count_violations_in_file(str(path)), expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()\n"} | |
| {"type": "eval", "id": "seis_05", "split": "target", "format": "python", "question": "Use the Python package `seismic_linter`. Implement `split_ok(train_times: list[int], test_times: list[int]) -> bool`. Use the seismic_linter runtime split validator. Return True on successful validation and False on TemporalCausalityError. Inputs are nonempty lists of integers without missing values.\n\nReturn the complete submission.py in exactly one fenced Python code block, with all required imports and no prose.", "tests": "import unittest\nimport submission\n\n\nclass TestSplit(unittest.TestCase):\n def test_boundaries(self):\n cases = [\n ([1, 2, 3], [4, 5], True),\n ([1, 2, 3], [3, 4], False),\n ([5, 6], [1, 2], False),\n ([3, 1], [5, 4], True),\n ([3, 1], [5, 2], False),\n ([-8, -3], [-2, 0], True),\n ([1], [2], True),\n ([1], [1], False),\n ]\n for train, test, expected in cases:\n with self.subTest(train=train, test=test):\n self.assertIs(submission.split_ok(train, test), expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()\n"} | |
| {"type": "eval", "id": "seis_06", "split": "target", "format": "python", "question": "Use the Python package `seismic_linter`. Implement `lint_and_split_summary(source: str, train_times: list[int], test_times: list[int]) -> dict`. Use seismic_linter to return {\"violations\": <number of source violations>, \"split_ok\": <whether the temporal split passes validation>}. Inputs are nonempty integer lists. Treat TemporalCausalityError as a failed split.\n\nReturn the complete submission.py in exactly one fenced Python code block, with all required imports and no prose.", "tests": "import unittest\nimport submission\n\n\nclass TestLintAndSplitSummary(unittest.TestCase):\n def test_combinations(self):\n sources = [(\"print('ok')\\n\", 0), (\"train_test_split(x, y)\\nmodel.fit(data)\\n\", 2)]\n splits = [([3, 1], [5, 4], True), ([1, 2], [2, 3], False)]\n for source, count in sources:\n for train, test, valid in splits:\n with self.subTest(source=source, train=train, test=test):\n self.assertEqual(\n submission.lint_and_split_summary(source, train, test),\n {\"violations\": count, \"split_ok\": valid},\n )\n\n\nif __name__ == \"__main__\":\n unittest.main()\n"} | |
| {"type": "eval", "id": "seis_07", "split": "target", "format": "python", "question": "Use the Python package `seismic_linter`. Implement `make_monotonic_df(times: list[int])`. Return a pandas DataFrame with a time column sorted in ascending order. Use the seismic_linter monotonicity decorator on an inner loader function to validate the returned frame. Inputs are nonempty integer lists.\n\nReturn the complete submission.py in exactly one fenced Python code block, with all required imports and no prose.", "tests": "import pandas as pd\nimport unittest\nimport submission\n\n\nclass TestMakeMonotonicDf(unittest.TestCase):\n def test_sorted(self):\n for times in ([3, 1, 2], [9], [-2, 5, -2, 0], [8, 7, 6, 5]):\n with self.subTest(times=times):\n frame = submission.make_monotonic_df(list(times))\n self.assertIsInstance(frame, pd.DataFrame)\n self.assertEqual(frame[\"time\"].tolist(), sorted(times))\n\n\nif __name__ == \"__main__\":\n unittest.main()\n"} | |
| {"type": "eval", "id": "seis_08", "split": "target", "format": "python", "question": "Use the Python package `seismic_linter`. Fix the function below, which uses a nonexistent seismic_linter API. Preserve its function name and return type.\n\n```python\nimport seismic_linter\ndef count_violations(source: str) -> int:\n return len(seismic_linter.analysis_code(source, filename=\"x.py\"))\n```\n\nReturn the complete submission.py in exactly one fenced Python code block, with all required imports and no prose.", "tests": "import unittest\nimport submission\n\n\nclass TestCountViolations(unittest.TestCase):\n def test_counts(self):\n cases = [\n (\"print('ok')\\n\", 0),\n (\"train_test_split(x, y)\\n\", 1),\n (\"train_test_split(x, y)\\nmodel.fit(data)\\n\", 2),\n ]\n for source, expected in cases:\n with self.subTest(source=source):\n self.assertEqual(submission.count_violations(source), expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()\n"} | |
| {"type": "eval", "id": "seis_09", "split": "target", "format": "python", "question": "Use the Python package `seismic_linter`. Fix the function below to use the input type expected by seismic_linter. Inputs are nonempty integer lists.\n\n```python\nimport seismic_linter\ndef split_ok_debug(train_times: list[int], test_times: list[int]) -> bool:\n try:\n seismic_linter.validate_split_integrity(train_times, test_times)\n return True\n except seismic_linter.TemporalCausalityError:\n return False\n```\n\nReturn the complete submission.py in exactly one fenced Python code block, with all required imports and no prose.", "tests": "import unittest\nimport submission\n\n\nclass TestSplit(unittest.TestCase):\n def test_boundaries(self):\n cases = [\n ([1, 2, 3], [4, 5], True),\n ([1, 2, 3], [3, 4], False),\n ([5, 6], [1, 2], False),\n ([3, 1], [5, 4], True),\n ([3, 1], [5, 2], False),\n ([-8, -3], [-2, 0], True),\n ([1], [2], True),\n ([1], [1], False),\n ]\n for train, test, expected in cases:\n with self.subTest(train=train, test=test):\n self.assertIs(submission.split_ok_debug(train, test), expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()\n"} | |
| {"type": "eval", "id": "seis_10", "split": "target", "format": "python", "question": "Use the Python package `seismic_linter`. Fix the decorator usage below while preserving the function name and its returned DataFrame.\n\n```python\nimport pandas as pd\nimport seismic_linter\n@seismic_linter.verify_monotonicity\ndef load_df_sorted():\n return pd.DataFrame({\"time\": [1, 2, 3]})\n```\n\nReturn the complete submission.py in exactly one fenced Python code block, with all required imports and no prose.", "tests": "import functools\nimport unittest\nfrom unittest.mock import patch\n\nimport pandas as pd\nimport seismic_linter\nimport seismic_linter.runtime\n\n\noriginal_factory = seismic_linter.verify_monotonicity\nobserved_calls = []\n\n\ndef tracked_factory(*args, **kwargs):\n decorator = original_factory(*args, **kwargs)\n\n def apply(function):\n validated = decorator(function)\n\n @functools.wraps(validated)\n def call(*call_args, **call_kwargs):\n observed_calls.append(function.__name__)\n return validated(*call_args, **call_kwargs)\n\n return call\n\n return apply\n\n\n# Observe the real decorator while allowing either public import path.\nwith patch.object(seismic_linter, \"verify_monotonicity\", tracked_factory):\n with patch.object(seismic_linter.runtime, \"verify_monotonicity\", tracked_factory):\n import submission\n\n\nclass TestLoadDfSorted(unittest.TestCase):\n def test_validated_frame(self):\n observed_calls.clear()\n frame = submission.load_df_sorted()\n self.assertIsInstance(frame, pd.DataFrame)\n self.assertEqual(frame[\"time\"].tolist(), [1, 2, 3])\n self.assertTrue(observed_calls, \"The returned frame must pass through the monotonicity decorator.\")\n\n\nif __name__ == \"__main__\":\n unittest.main()\n"} | |