{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Legacy parameter examples\n", "\n", "These are parameters which are no longer used in the modern implementations of QCoDeS but are kept here as examples for applications which still feature them.\n", "\n", "## ArrayParameter\n", "> Note: This is an older base class for array-valued parameters. For any new driver we strongly recommend using `ParameterWithSetpoints` class which is both more flexible and significantly easier to use. Refer to notebook on [writing drivers with ParameterWithSetpoints](Simple-Example-of-ParameterWithSetpoints.ipynb). \n", "\n", "We have kept the documentation shown below of `ArrayParameter` for the legacy purpose.\n", "\n", "While storing the `ArrayParameter` data in the database using `datasaver.add_result()` , be informed that it is stored as BLOB in one row of sqlite database. Where the BLOB in sqlite has a default max length limit set at 1 billion (1,000,000,000) bytes. \n", "\n", "`ArrayParameter` is, for now, only gettable." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "first call: [[0, 1], [2, 3], [4, 5]]\n" ] } ], "source": [ "from qcodes.instrument import ArrayParameter\n", "\n", "\n", "class ArrayCounter(ArrayParameter):\n", " def __init__(self):\n", " # only name and shape are required\n", " # the setpoints I'm giving here are identical to the defaults\n", " # this param would get but I'll give them anyway for\n", " # demonstration purposes\n", " super().__init__('array_counter', shape=(3, 2),\n", " label='Total number of values provided',\n", " unit='',\n", " # first setpoint array is 1D, second is 2D, etc...\n", " setpoints=((0, 1, 2), ((0, 1), (0, 1), (0, 1))),\n", " setpoint_names=('index0', 'index1'),\n", " setpoint_labels=('Outer param index', 'Inner param index'),\n", " docstring='fills a 3x2 array with increasing integers')\n", " self._val = 0\n", "\n", " def get_raw(self):\n", " # here I'm returning a nested list, but any sequence type will do.\n", " # tuple, np.array, DataArray...\n", " out = [[self._val + 2 * i + j for j in range(2)] for i in range(3)]\n", " self._val += 6\n", " return out\n", "\n", "\n", "array_counter = ArrayCounter()\n", "\n", "# simple get\n", "print('first call:', array_counter())" ] }, { "cell_type": "code", "execution_count": null, "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.10.0" } }, "nbformat": 4, "nbformat_minor": 4 }