Skip to content

Commit

Permalink
Ready for release that supports Python 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
elainethale committed Apr 19, 2017
1 parent d267824 commit ba898b5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
v0.6.0, 04/19/17 -- now works with Python 2 and Python 3
v0.5.3, 01/17/17 -- fixing bugs related to non-standard indexes and scalars
v0.5.2, 01/12/17 -- fixing bug related to divide by zero error for reading empty symbols
v0.5.1, 01/10/17 -- fixing bug with writing dataframes without 0 in the index
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,23 @@ python C:\your_python_path\Scripts\csv_to_gdx.py --help

### Preliminaries

- Python 2.7
- Python 2.6 or higher 2.X; Python 3.4 or higher 3.X
- pandas (In general you will want the SciPy stack. Anaconda comes with it, or see [my notes for Windows](http://elainethale.wordpress.com/programming-notes/python-environment-set-up/).)
- nose
- psutil (optional--for monitoring memory use)
- nose (optional--for running tests)
- GAMS Python bindings
- See GAMS/win64/XX.X/apifiles/readme.txt
- See GAMS/win64/XX.X/apifiles/Python/api/setup.py, in particular, run
- Run the following for the correct version of the Python bindings

```bash
python setup.py install
```

- GAMS/win64/XX.X/apifiles/Python/api/setup.py works for Python 2.X
- For Python 3.X, use GAMS/win64/XX.X/apifiles/Python/api_3X/setup.py, for
which you will need GAMS version >= 24.5.1 (Python 3.4, Windows and Linux),
24.7.4 (Python 3.4, Mac OS X), or >= 24.8.4 (Python 3.6)

### Get the Latest Package

```bash
Expand All @@ -79,7 +85,7 @@ pip install git+https://github.com/NREL/gdx-pandas.git@master
or

```bash
pip install git+https://github.com/NREL/gdx-pandas.git@v0.5.3
pip install git+https://github.com/NREL/gdx-pandas.git@v0.6.0
```

Versions are listed at https://github.com/NREL/gdx-pandas/releases.
Expand Down
25 changes: 19 additions & 6 deletions gdxpds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,30 @@
'''


__version__ = '0.5.3'
__version__ = '0.6.0'

import logging
import os
import psutil

logger = logging.getLogger(__name__)

HAVE_PSUTIL = False
try:
import psutil
HAVE_PSUTIL = True
except ImportError:
logger.info("Optional package psutil not found. pip install psutil if " + \
"you would like to monitor memory usage.")

from gdxpds.read_gdx import to_dataframes
from gdxpds.read_gdx import list_symbols
from gdxpds.read_gdx import to_dataframe
from gdxpds.write_gdx import to_gdx

def memory_use_str(pid = None):
pid = os.getpid() if pid is None else pid
rss = psutil.Process(pid).memory_info().rss
return 'Process {} using {:.2f} GB of memory.'.format(pid, float(rss) / (1024.0**3))
def memory_use_str(pid=None):
if HAVE_PSUTIL:
pid = os.getpid() if pid is None else pid
rss = psutil.Process(pid).memory_info().rss
return "Process {} using {:.2f} GB of memory.".format(pid, float(rss) / (1024.0**3))
return "Feature unavailable."

1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pandas
gdxcc
psutil
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name = 'gdxpds',
version = "0.5.3",
version = "0.6.0",
author = 'Elaine T. Hale',
author_email = '[email protected]',
packages = ['gdxpds', 'gdxpds.test'],
Expand Down

0 comments on commit ba898b5

Please sign in to comment.