{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "4af828e3",
   "metadata": {},
   "source": [
    "# Example TuningResult"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "dependent-assistant",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Logging hadn't been started.\n",
      "Activating auto-logging. Current session state plus future input saved.\n",
      "Filename       : /Users/jana/.qcodes/logs/command_history.log\n",
      "Mode           : append\n",
      "Output logging : True\n",
      "Raw input log  : False\n",
      "Timestamping   : True\n",
      "State          : active\n",
      "Qcodes Logfile : /Users/jana/.qcodes/logs/210816-15278-qcodes.log\n"
     ]
    }
   ],
   "source": [
    "import nanotune as nt\n",
    "from nanotune.device_tuner.tuningresult import TuningResult, MeasurementHistory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "assisted-geography",
   "metadata": {},
   "outputs": [],
   "source": [
    "result = TuningResult(\n",
    "    'gatecharacterization',\n",
    "    True,\n",
    "    guids=['aaaaaaaa-0000-0000-0000-000000000000'],\n",
    "    data_ids=[1],\n",
    "    db_name='test_po.db',\n",
    "    ml_result={'low_voltage': -0.4,\n",
    "              'high_voltage': -0.6,\n",
    "              'transition_voltage': -0.5,\n",
    "             }\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "static-rouge",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result.success"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "protected-management",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stage': 'gatecharacterization',\n",
       " 'success': True,\n",
       " 'guids': ['aaaaaaaa-0000-0000-0000-000000000000'],\n",
       " 'ml_result': {'low_voltage': -0.4,\n",
       "  'high_voltage': -0.6,\n",
       "  'transition_voltage': -0.5},\n",
       " 'data_ids': [1],\n",
       " 'db_name': 'test_po.db',\n",
       " 'db_folder': '',\n",
       " 'termination_reasons': [],\n",
       " 'comment': '',\n",
       " 'timestamp': '',\n",
       " 'status': {}}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result.to_dict()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "forty-compiler",
   "metadata": {},
   "outputs": [],
   "source": [
    "ms = MeasurementHistory('doubledot_test')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "minor-river",
   "metadata": {},
   "outputs": [],
   "source": [
    "ms.add_result(result, 'gate1_characterization')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "stylish-drama",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'low_voltage': -0.4, 'high_voltage': -0.6, 'transition_voltage': -0.5}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ms.tuningresults['gate1_characterization'].ml_result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "single-energy",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "friendly-burning",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "manufactured-springer",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "controlling-finance",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}