# Configure Editor

PoPy is script driven, so it is very important to have a suitable editor installed on your system.

We recommended that you use Notepad++ to edit PoPy text files.

Note

It is especially important that you follow the advice in Configure Notepad++ Tabs.

## Notepad++

Notepad++ is a text editor that uses tabs and context highlighting, both of which are helpful when editing PoPy script files.

### Install Notepad++

Download it from:-

https://notepad-plus-plus.org/download/

If you install the 64bit binary installer the default install directory is:-

    C:\Program Files\Notepad++

But you may install Notepad++ at another location.

### Configure Notepad++ Tabs

PoPy is written in Python, and Python does not like tabs. It is essential that you set this from within Notepad++:-

    Settings->Preferences->Language->Replace by space

The default tab size is 4, which is a sensible choice.

Note this means that when you hit the tab key you will get 4 space characters instead of a tab character. To check that this is the case do:-

    View->Show Symbol->Show white space and Tab

Then Notepad++ will give you a faint orange dot for a space character and an arrow for a tab. You are advised to delete any tabs you have in your *.pyml files.

Note that it is still possible to introduce tabs into your text file accidentally using cut and paste.

Python using spaces instead of the more conventional curly brackets is an endearing (but perhaps controversial) language feature. See this blog post, for a fairly balanced discussion of the pros and cons of white spacing:-

https://jayconrod.com/posts/101/how-python-parses-white-space

However PoPy uses Python, so it is white space for us.

### Configure Notepad++ Path

Note that to use Notepad++ with popy_edit you need to make sure your PoPy Config File contains this entry:-

    text_editor_path: "C:/Program Files/Notepad++/notepad++.exe"

Which points to where you have installed Notepad++. Note with the path above set correctly you can now Open a PoPy Command Prompt and do:-

    $ popy_edit my_script.pyml

The file ‘my_script.pyml’ should then open within Notepad++. See popy_edit.

### Configure Notepad++ Colouring

It is highly advisable to load in the PoPy xml colouring file. You do this by opening Notepad++ and doing:-

    Language->Define your language->Import..

Then selecting:-

    c:\PoPy\conf\notepadplusplus_popy.xml

You should then be able to open any *.pyml file and see the variables coloured like this:-

    DERIVATIVES: |
        # s[DEPOT,CENTRAL,PERI] = @dep_two_cmp_cl{dose:@bolus{amt:c[AMT]}}
        d[DEPOT] = @bolus{amt:c[AMT]} - m[KA]*s[DEPOT]
        d[CENTRAL] = (
            m[KA]*s[DEPOT] - s[CENTRAL]*m[CL]/m[V1]
            - s[CENTRAL]*m[Q]/m[V1]  + s[PERI]*m[Q]/m[V2]
        )
        d[PERI] = s[CENTRAL]*m[Q]/m[V1] - s[PERI]*m[Q]/m[V2]
    PREDICTIONS: |
        p[DV_CENTRAL] = s[CENTRAL]/m[V1]
        var = m[ANOISE]**2 + m[PNOISE]**2 * p[DV_CENTRAL]**2
        c[DV_CENTRAL] ~ norm(p[DV_CENTRAL], var)

As opposed to the default (plain) Notepad++ text display, like this:-

    DERIVATIVES: |
        # s[DEPOT,CENTRAL,PERI] = @dep_two_cmp_cl{dose:@bolus{amt:c[AMT]}}
        d[DEPOT] = @bolus{amt:c[AMT]} - m[KA]*s[DEPOT]
        d[CENTRAL] = (
            m[KA]*s[DEPOT] - s[CENTRAL]*m[CL]/m[V1]
            - s[CENTRAL]*m[Q]/m[V1]  + s[PERI]*m[Q]/m[V2]
        )
        d[PERI] = s[CENTRAL]*m[Q]/m[V1] - s[PERI]*m[Q]/m[V2]
    PREDICTIONS: |
        p[DV_CENTRAL] = s[CENTRAL]/m[V1]
        var = m[ANOISE]**2 + m[PNOISE]**2 * p[DV_CENTRAL]**2
        c[DV_CENTRAL] ~ norm(p[DV_CENTRAL], var)

Note that it might be necessary to restart Notepad++ to get the colouring file to work.

We find that the variable colouring, makes model editing easier and less error prone. For example, if you misspell a section header e.g “DERVIATIVES”, then you will notice because the section header will not appear in bold.

The colouring file also just makes PK/PD models look nicer.

## Next Steps

Now you have your editor setup correctly take a look at Fitting a Simple PopPK Model using PoPy.