Skip to content

Commit

Permalink
Slightly improve datatypes viewers notebook.
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha committed Oct 9, 2023
1 parent 43a6776 commit ec9b553
Showing 1 changed file with 12 additions and 28 deletions.
40 changes: 12 additions & 28 deletions notebooks/aiida_datatypes_viewers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"load_profile()\n",
"import io\n",
"from os import path\n",
"from aiida.plugins import DataFactory\n",
"from ase import build\n",
"from aiida import engine, orm, plugins\n",
"from aiidalab_widgets_base import viewer"
]
},
Expand All @@ -34,7 +35,7 @@
"metadata": {},
"outputs": [],
"source": [
"Dict = DataFactory('core.dict')\n",
"Dict = plugins.DataFactory('core.dict')\n",
"p = Dict(dict={\n",
" 'Parameter' :'super long string '*4,\n",
" 'parameter 2' :'value 2',\n",
Expand All @@ -52,12 +53,11 @@
"outputs": [],
"source": [
"# create molecule\n",
"from ase.build import molecule, bulk\n",
"m = molecule('H2O')\n",
"m = build.molecule('H2O')\n",
"m.center(vacuum=2.0)\n",
"#\n",
"# create bulk Pt\n",
"pt = bulk('Pt', cubic = True)"
"pt = build.bulk('Pt', cubic = True)"
]
},
{
Expand All @@ -73,7 +73,7 @@
"metadata": {},
"outputs": [],
"source": [
"CifData = DataFactory('core.cif')\n",
"CifData = plugins.DataFactory('core.cif')\n",
"s = CifData(ase=pt)\n",
"vwr = viewer(s.store(), configuration_tabs=['Selection', 'Appearance', 'Cell', 'Download'])\n",
"display(vwr)"
Expand All @@ -92,7 +92,7 @@
"metadata": {},
"outputs": [],
"source": [
"StructureData = DataFactory('core.structure')\n",
"StructureData = plugins.DataFactory('core.structure')\n",
"s = StructureData(ase=m)\n",
"vwr = viewer(s.store())\n",
"display(vwr)"
Expand All @@ -112,7 +112,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"BandsData = DataFactory('core.array.bands')\n",
"BandsData = plugins.DataFactory('core.array.bands')\n",
"bs = BandsData()\n",
"kpoints = np.array([[0. , 0. , 0. ], # array shape is 12 * 3\n",
" [0.1 , 0. , 0.1 ],\n",
Expand Down Expand Up @@ -164,7 +164,7 @@
"metadata": {},
"outputs": [],
"source": [
"FolderData = DataFactory('core.folder')\n",
"FolderData = plugins.DataFactory('core.folder')\n",
"fd = FolderData()\n",
"with io.StringIO('content of test1 filelike') as fobj:\n",
" fd.put_object_from_filelike(fobj, path='test1.txt')\n",
Expand All @@ -189,9 +189,7 @@
"metadata": {},
"outputs": [],
"source": [
"from aiida.workflows.arithmetic.add_multiply import add, add_multiply\n",
"from aiida.engine import run_get_node\n",
"from aiida.orm import Int"
"from aiida.workflows.arithmetic.add_multiply import add, add_multiply"
]
},
{
Expand All @@ -200,7 +198,7 @@
"metadata": {},
"outputs": [],
"source": [
"result, workfunction = run_get_node(add_multiply, Int(3), Int(4), Int(5))\n",
"result, workfunction = engine.run_get_node(add_multiply, orm.Int(3), orm.Int(4), orm.Int(5))\n",
"display(viewer(workfunction))"
]
},
Expand All @@ -210,23 +208,9 @@
"metadata": {},
"outputs": [],
"source": [
"result, calcfunction = run_get_node(add, Int(3), Int(4))\n",
"result, calcfunction = engine.run_get_node(add, Int(3), Int(4))\n",
"display(viewer(calcfunction))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit ec9b553

Please sign in to comment.