diff --git a/docs/source/tutorial/basics.rst b/docs/source/tutorial/basics.rst index 1ee6f79cd3b4ea0636c8c9cb36c61285fade6d4e..6d56caf46c4d6242b8e81742f5a4dc21bb5d4e7b 100644 --- a/docs/source/tutorial/basics.rst +++ b/docs/source/tutorial/basics.rst @@ -213,20 +213,23 @@ and :ref:`tutorial_kekule`. Saving and loading Qsymm models ------------------------------------------------- -We can save and load Qsymm models. +Qsymm models and identified symmetries don't guarantee consistent ordering and basis selection +across multiple runs. To avoid irrerproducible results you may use the ``Model.tosympy`` method +and serialize the resulting sympy expression as shown below. To save we do: .. jupyter-execute:: - H2D_str = str(H2D.tosympy(nsimplify=True)) + H2D_sympy = H2D.tosympy() - file = open("H2D.txt", "w") - file.write(H2D_str) - file.close() + with open("H2D.txt", "w") as f: + f.write(str(H2D)) To load we do: .. jupyter-execute:: - f = open('H2D.txt','r').read() + with open("H2D.txt") as f: + data = f.read() + loaded_H2D = qsymm.Model(sympy.parsing.sympy_parser.parse_expr(f), momenta=['k_x', 'k_z']) diff --git a/pytest.ini b/pytest.ini index 8d1014e75cf529cbbd04eb038825077c3d0a1761..4fa8ee76f6731854d8c6b94d968c4b5b884d1b02 100644 --- a/pytest.ini +++ b/pytest.ini @@ -9,4 +9,4 @@ filterwarnings = # Remove once this does not need to be ignored ignore:np\.asscalar\(a\) is deprecated since NumPy v1\.16, use a\.item\(\) instead:DeprecationWarning # Remove once setuptools figures it out - ignore:lib2to3:PendingDeprecationWarning \ No newline at end of file + ignore:lib2to3:PendingDeprecationWarning