0todd0000 / rft1d

One-Dimensional Random Field Theory in Python
https://spm1d.org/rft1d/
GNU General Public License v3.0
3 stars 3 forks source link

Update to python3/2 #2

Closed melund closed 1 year ago

melund commented 8 years ago

Hi Todd

I have upgraded the libraries to python3. All future code can be written in python3, and it will remain compatible with legacy python (2.7) using the python-future package. This does add an extra dependency, but the package is easily installed through 'pip'.

I needed a way to ensure that the code worked on both platforms. So I also added a test script that runs all your examples. It collects your and runs your examples with a monkeypatched matplotlib to save all the figures to a pdf file. Then it is easy to compare the output of running all examples in both Python 2 and 3. Simply run py.test execute all examples:

[py2] C:\Users\mel\Documents\GitHub\rft1d\tests>py.test
============================= test session starts =============================
platform win32 -- Python 2.7.10, pytest-2.8.1, py-1.4.30, pluggy-0.3.1
rootdir: C:\Users\mel\Documents\GitHub\rft1d, inifile:
collected 68 items

test_examples.py ....................................................................

========================= 68 passed in 186.60 seconds =========================```
[py3] C:\Users\mel\Documents\GitHub\rft1d\tests>py.test
============================= test session starts =============================
platform win32 -- Python 3.5.0, pytest-2.8.1, py-1.4.30, pluggy-0.3.1
rootdir: C:\Users\mel\Documents\GitHub\rft1d, inifile:
collected 68 items

test_examples.py ....................................................................

========================= 68 passed in 159.80 seconds =========================```

You can see two pdf files here: rft1d_examples_py2.7.pdf rft1d_examples_py3.5.pdf