capaulson / pyKriging

Welcome to the User Friendly Python Kriging Toolbox!
http://www.pykriging.com
MIT License
384 stars 113 forks source link

Python 3 Support #11

Closed mattharrigan closed 7 years ago

mattharrigan commented 8 years ago

Does pykriging support python 3? I'm using 3.4 and get the following when trying to do the demo:

Traceback (most recent call last): File "D:/MRSE/apdl-submodels/krige.py", line 1, in import pyKriging File "C:\Anaconda\envs\full-py3\lib\site-packages\pyKriginginit.py", line 2, in from .krige import * File "C:\Anaconda\envs\full-py3\lib\site-packages\pyKriging\krige.py", line 142 except Exception, err: ^ SyntaxError: invalid syntax

If its not supported, is python 3 support planned?

capaulson commented 8 years ago

It doesn't support Python3 now, but shouldn't be too difficult to port. It's on the todo list, but please feel free to start a Python3 branch!

Jwely commented 7 years ago

+1

Lack of python3 was a total showstopper for me. If a scikit-learn GaussianProcess implementation doesn't seem easier for my use case I may port this myself.

capaulson commented 7 years ago

Hey @Jwely @mattharrigan, I've just started a new branch aimed at moving to Python3. There are likely to be a large number of bugs, but it seems that the basic functionality for at least 2D plotting is there.

See: https://github.com/capaulson/pyKriging/tree/Python3-Support

More coming shortly, I'll leave open until Python3 support is in master.

capaulson commented 7 years ago

To get this to work I needed to run the following in Ubuntu 16.04:

apt-get install python3-pip python3-numpy python3-matplotlib python3-scipy pip3 install inspyred apt-get install python3-cairocffi

I've attached a screen shot of the expected result. first_python3_result

capaulson commented 7 years ago

Also, to install the Python3 version, you would do:

git clone https://github.com/capaulson/pyKriging.git
(or git pull, if you've already cloned it)
git checkout Python3-Support
python3 setup.py install

edit: seems that the plotting library for 3D isocontour on my system isn't running. seems that you need vtk compiled with Python3 support. I'm trying to build vtk following these instructions: http://ghoshbishakh.github.io/blog/blogpost/2016/07/13/building-vtk-with-python3-wrappers.html

takluyver commented 7 years ago

I've done a bit more work on Py3 support in PR #16. Some tests would be good to check that things aren't breaking. ;-) I'm running the examples to check that they don't crash, but I'm not sure how to check if it's doing the right thing.

capaulson commented 7 years ago

@takluyver the quickest way to check is to plot a test function contour lines over the end result (scaled the same). The 2D_simple_train.py example shows how to do this. Simply pass the test function to the main Kriging call: 'testfunction=testfun'. This then plots black contours on the filled color plot that is predicted from PyKriging. That provides a quick visual check to make sure the code is working. I'll take a look at the PR this weekend. Have you tested in in Py2.7?

capaulson commented 7 years ago

Also, @takluyver thanks for the contributions on this code!!

takluyver commented 7 years ago

I've posted on #16 screenshots of running 2D_simple_train on Python 3 and 2; it appears to be working nicely. I assume the choice of sampling points in non-deterministic, so we wouldn't expect those to be the same.

capaulson commented 7 years ago

I've just merged Python3 support into the main branch. Closing this thread now

Daniel-M commented 7 years ago

In Debian Linux 4.13.0-1-amd64 #1 SMP Debian 4.13.4-2 (2017-10-15) x86_64 GNU/Linux, with python 3.5.4, The package pykriging installed from the pip sources (using pip3, pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)) still produces the same issue,

# python3 -c "import pyKriging"
...
except Exception, err:
^
SyntaxError: invalid syntax

Fixed with,

git clone https://github.com/capaulson/pyKriging.git
cd pyKriging
python3 setup.py install # installed as root 

I'm not sure why, if the python3 support was merged months ago, the pip package had the same problems. That's why i'm posting at this issue.

takluyver commented 6 years ago

It will need a new version released on PyPI before you can pip install it with the Python 3 support.

https://pypi.python.org/pypi/pyKriging

Daniel-M commented 6 years ago

I see that the version on PyPI is the 0.1.0, though this repo is 0.2.0. Why the update isn't sent?

takluyver commented 6 years ago

Making a release is a separate thing from updating the repo - it's up to @capaulson when he wants to release.