{
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.10"
    }
  },
  "cells": [
    {
      "id": "scope",
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# sway reproduction check\n",
        "Run in the extracted bundle folder. Read README.md for provenance, prerequisites, and limitations. This is not full-paper replication.\n"
      ]
    },
    {
      "id": "check",
      "cell_type": "code",
      "metadata": {},
      "execution_count": null,
      "outputs": [],
      "source": [
        "\"\"\"Check transcribed postural-sway statistics. No force-plate file is read.\"\"\"\n",
        "import json\n",
        "import math\n",
        "from pathlib import Path\n",
        "\n",
        "ROOT = Path(__file__).resolve().parent if \"__file__\" in globals() else Path.cwd()\n",
        "ABSTRACT_FAMILIES = {\n",
        "    \"music\": \"supported\",\n",
        "    \"interaction\": \"unsupported\",\n",
        "    \"nonlinear\": \"null\",\n",
        "    \"spectral\": \"null\",\n",
        "    \"surrogate\": \"failed\",\n",
        "    \"classifier\": \"chance\",\n",
        "}\n",
        "\n",
        "\n",
        "def reproduce():\n",
        "    source = json.loads((ROOT / \"source.json\").read_text(encoding=\"utf-8\"))\n",
        "    low, high = source[\"interval\"]\n",
        "    ratio = source[\"ratio\"]\n",
        "    return {\n",
        "        \"ratio\": ratio,\n",
        "        \"low\": low,\n",
        "        \"high\": high,\n",
        "        \"ratio_inside_interval\": low <= ratio <= high,\n",
        "        \"interval_excludes_one\": low > 1 or high < 1,\n",
        "        \"families_match_abstract\": source[\"families\"] == ABSTRACT_FAMILIES,\n",
        "    }\n",
        "\n",
        "\n",
        "if __name__ == \"__main__\":\n",
        "    result = reproduce()\n",
        "    expected = json.loads((ROOT / \"expected.json\").read_text(encoding=\"utf-8\"))\n",
        "    for key, value in expected.items():\n",
        "        if isinstance(value, float):\n",
        "            assert math.isclose(result[key], value, rel_tol=0, abs_tol=1e-12), key\n",
        "        else:\n",
        "            assert result[key] is value or result[key] == value, key\n",
        "    assert result[\"ratio_inside_interval\"] and result[\"interval_excludes_one\"]\n",
        "    assert result[\"families_match_abstract\"]\n",
        "    print(json.dumps(result, indent=2))\n",
        "    print(\"PASS: transcribed sway statistics checked; no trial reanalyzed.\")\n"
      ]
    }
  ]
}
