{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import chemcoord as cc" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Settings" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Settings can be seen here:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'defaults': {'atomic_radius_data': 'atomic_radius_cc',\n", " 'use_lookup': False,\n", " 'viewer': 'gv.exe'}}" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cc.configuration.settings" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A configuration file can be written with:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "cc.configuration.write_configuration_file('./example_configuration_file', overwrite=True)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "%less example_configuration_file" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is read automatically during startup from ``'~/.chemcoordrc'``.\n", "Otherwise it is possible to explicitly call ``cc.configuration.read_configuration_file(...)``" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "!rm example_configuration_file" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Inheritance\n", "\n", "You can safely inherit from the classes in this module" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [], "source": [ "class my_tailored_class(cc.Cartesian):\n", " def my_number_one_method(self):\n", " return 1" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "chemcoord.cartesian_coordinates.cartesian_class_main.Cartesian" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "molecule = cc.Cartesian.read_xyz('MIL53_small.xyz')\n", "type(molecule)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice how all old methods from Cartesian return an object of your tailored class" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "__main__.my_tailored_class" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_molecule = my_tailored_class.read_xyz('MIL53_small.xyz')\n", "type(my_molecule)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "__main__.my_tailored_class" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(my_molecule.get_inertia()['transformed_Cartesian'])" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_molecule.get_inertia()['transformed_Cartesian'].my_number_one_method()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python [conda root]", "language": "python", "name": "conda-root-py" }, "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.6.2" } }, "nbformat": 4, "nbformat_minor": 2 }