Skip to content

Commit 751aaf6

Browse files
committed
Update web pages for Intel/Mac updates
1 parent e871920 commit 751aaf6

File tree

3 files changed

+278
-81
lines changed

3 files changed

+278
-81
lines changed

webdocs/developers.rst

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,87 @@ web page, which discusses changing the origin to your forked copy of GSAS-II.
4848
Developing GSAS-II inside VSCode
4949
----------------------------------------------------------
5050

51-
Visual Studio Code (VSCode) is a free code development environment that is available on all major platforms where GSAS-II runs. Yuanpeng Zhang (ORNL) has written some notes on how to
51+
Visual Studio Code (VSCode) is a code development environment that is
52+
freely distributed on all major platforms where GSAS-II runs.
53+
Yuanpeng Zhang (ORNL) has written some notes on how to
5254
`make GSAS-II run in the VSCode debugger <https://iris2020.net/2025-04-21-gsasii_dev_new/>`_.
5355

5456
Note that if you have used the gsas2main installer to place GSAS-II at ``~/g2main`` then you can use the Python installation there (examples:
5557
Mac/Linux, ``/Users/toby/G2/g2main/bin/python``;
5658
Windows, ``c:\Users\toby\g2main\python.exe``)
57-
to run the debugger rather than install a new conda environment as he does.
59+
to run the debugger, rather than install a new conda environment as he does.
5860

5961
----------------------------------------------------------
60-
IPython Code development tip
62+
Debug mode/IPython Code development
6163
----------------------------------------------------------
6264

63-
One nice trick for working with GSAS-II is that if you locate a place where you want to insert code into the program, you can run commands in that environment. To do this, two prerequisite steps are needed. First, use the conda command to install iPython (this assumes you have already used the activate command, as above)::
65+
One nice trick for working with GSAS-II is that if you locate a place
66+
where you want to insert code into the program, you can run commands
67+
in that namespace environment. To do this, two prerequisite steps are
68+
needed. First, use the conda command to install iPython (this assumes
69+
you have already used the activate command, as above)::
6470

6571
conda install ipython
6672

67-
Then run GSAS-II and use the Preferences command (File menu or on MacOs on the first menu, named GSAS-II or python) and `set the debug option to True`. One can then place a
68-
``breakpoint()`` statement into GSAS-II at a location where one wants to develop code. When that statement is executed, GSAS-II will enter iPython but in the local environment where your code will be executed, so you can see what variables and functions are defined and try running code that can then be placed into GSAS-II. Remember to remove the breakpoint statement when you are done.
73+
Then run GSAS-II and use the Preferences command (File menu or on
74+
MacOs on the first menu, named GSAS-II or python) and `set the debug
75+
option to True`. One can then place a ``breakpoint()`` statement into
76+
GSAS-II at a location where one wants to develop code. When that
77+
statement is executed, GSAS-II will enter iPython but in the local
78+
environment where your code will be executed, so you can see what
79+
variables and functions are defined and try running code that can then
80+
be placed into GSAS-II. Remember to remove the breakpoint statement
81+
when you are done.
82+
83+
Note that when the ``debug`` configuration setting is set to True, that
84+
also turns on some potentially useful print statements.
85+
86+
---------------------------------------------------
87+
Testing code without restarting
88+
---------------------------------------------------
89+
90+
One trick that can sometimes be used to test new GSAS-II routines without restarting GSAS-II is to insert code like this::
91+
92+
from importlib import reload
93+
reload(G2mod)
94+
print('Reloading',G2mod)
95+
G2mod.NewRoutine()
96+
97+
into the location where a module is being called. This will cause the
98+
GSAS-II module "``G2mod``" (for example ``G2sc`` for GSASIIscriptable
99+
or ``G2G`` for GSASIIctrlGUI, etc.) to be reread from its Python file
100+
just before it is run. In this way, code can be modified, saved and
101+
tested without even needing to restart GSAS-II. Where this is not
102+
possible (usually because one is testing with an object or because
103+
global variables inside the module are reset by the reload), it is
104+
still often quick to restart and retest development code.
105+
106+
It should be noted that this can occasionally cause problems in that
107+
anything saved in that module (for example global variables) will be
108+
reset to initial values when the module is reloaded.
109+
110+
For safety, just in case one forgets to remove this, it is best to
111+
have this code be executed only in debug mode::
112+
113+
if GSASIIpath.GetConfigValue('debug'):
114+
print('Debug: reloading',G2gr, G2pwpl)
115+
from importlib import reload
116+
reload(G2pwpl)
117+
reload(G2gr)
118+
G2gr.UpdateGroup(G2frame,item)
119+
120+
---------------------------------------------------
121+
Adding startup commands
122+
---------------------------------------------------
123+
124+
When doing repetitive testing, it can be time consuming to have to run
125+
the same commands from the GUI each time that GSAS-II is started. In
126+
debug mode, GSAS-II can run specific code when the program is started
127+
by creating a file named ``debug_setup.py`` that is placed in the
128+
directory with the rest of the GSAS-II files. As an example::
129+
130+
import wx
131+
G2frame = wx.App.GetMainTopWindow()
132+
G2frame.OnRefine(None)
133+
134+

0 commit comments

Comments
 (0)