Skip to content

Commit

Permalink
changes to __init__.py to include the table plotting functions
Browse files Browse the repository at this point in the history
  • Loading branch information
philipposk committed Feb 25, 2024
1 parent 7279cde commit eee045e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions mcstasscript/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@
from .helper.optimizer_helper import plot_2d
from .helper.optimizer_helper import plot_3d_scatter
from .helper.optimizer_helper import plot_3d_surface
from .helper.optimizer_helper import print_optimal_table
from .helper.optimizer_helper import print_history_table
24 changes: 19 additions & 5 deletions tutorial/Union_tutorial_1_processes_and_materials.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'xopt' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mmcstasscript\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mms\u001b[39;00m\n",
"File \u001b[0;32m~/Downloads/OptimizerSpace/McStasScript/mcstasscript/__init__.py:24\u001b[0m\n\u001b[1;32m 20\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtools\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcryostat_builder\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Cryostat\n\u001b[1;32m 22\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01minstrument_diagnostics\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mbeam_diagnostics\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m BeamDiagnostics \u001b[38;5;28;01mas\u001b[39;00m Diagnostics\n\u001b[0;32m---> 24\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mhelper\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01moptimizer_helper\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m optimizer\n\u001b[1;32m 25\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mhelper\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01moptimizer_helper\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m plot_2d\n\u001b[1;32m 26\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mhelper\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01moptimizer_helper\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m plot_3d_scatter\n",
"File \u001b[0;32m~/Downloads/OptimizerSpace/McStasScript/mcstasscript/helper/optimizer_helper.py:306\u001b[0m\n\u001b[1;32m 303\u001b[0m \u001b[38;5;66;03m# Print bottom border\u001b[39;00m\n\u001b[1;32m 304\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m└\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m─\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m─\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;241m*\u001b[39m (width \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m2\u001b[39m) \u001b[38;5;28;01mfor\u001b[39;00m width \u001b[38;5;129;01min\u001b[39;00m column_widths) \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m┘\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m--> 306\u001b[0m print_optimal_table(\u001b[43mxopt\u001b[49m, fopt, [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mz_width\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmosaic\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124my_height\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n",
"\u001b[0;31mNameError\u001b[0m: name 'xopt' is not defined"
]
}
],
"source": [
"import mcstasscript as ms"
]
Expand Down Expand Up @@ -431,7 +445,7 @@
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -445,7 +459,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit eee045e

Please sign in to comment.