{ "cells": [ { "cell_type": "markdown", "id": "bced5706-02de-4ebb-a116-443f2378e513", "metadata": {}, "source": [ "# Interface and Methods" ] }, { "cell_type": "markdown", "id": "645ed634-4bf5-4449-b1ed-d472c76a7bcc", "metadata": {}, "source": [ "Each unit is an instance of class `Physical`, as in \"physical quantity\".\n", "\n", "Instances of `Physical` are not typically created through the class constructor but by through multiplication with either numbers (`int` or `float`) or other `Physical` instances.\n", "\n", "When the library is imported, and also when an environment is loaded, the namespace is auto-populated with variables representing units, all of which are instances of the `Physical` class.\n", "\n", "Instances of the `Physical` class are _immutable_ and most operations on a `Physical` instance produce a new instance." ] }, { "cell_type": "code", "execution_count": 18, "id": "aefeb3e8-90e2-4474-9e46-6f1dbf2caaa2", "metadata": {}, "outputs": [], "source": [ "import forallpeople as si\n", "si.environment('default')" ] }, { "cell_type": "markdown", "id": "d33a5ca7-a3c8-4f39-907e-1b62c7668967", "metadata": {}, "source": [ "## API\n", "\n", "The methods defined on `Physical` allow you to have some control on the representation of the instance." ] }, { "cell_type": "raw", "id": "5af6dfd1-e49d-4674-9146-9174ab62f6e6", "metadata": { "raw_mimetype": "text/restructuredtext", "tags": [] }, "source": [ ".. autoclass:: forallpeople.Physical\n", " :members: repr, html, latex, prefix, to, split" ] } ], "metadata": { "kernelspec": { "display_name": "forallpeople", "language": "python", "name": "forallpeople" }, "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.12.4" } }, "nbformat": 4, "nbformat_minor": 5 }