scott-maddox / fdint

Precise and fast Fermi-Dirac integrals of integer and half integer order.
BSD 3-Clause "New" or "Revised" License
17 stars 7 forks source link

Windows 10 install? #17

Open CoryWeber opened 7 years ago

CoryWeber commented 7 years ago

I love this package and use it on Linux workstations at work, but would really like to get it working on my Windows laptop. Has anyone successfully installed this on Windows 10? If so, what Python, Numpy, and Scipy did you use?

I've tried it on Anaconda and with just Python 2.7.x with Numpy and Scipy packages from http://www.lfd.uci.edu/~gohlke/pythonlibs/, and both times it fails when calling Microsoft compilers. I have the Microsoft compiler for pythong installed.

cgohlke commented 7 years ago

Just uploaded wheels at http://www.lfd.uci.edu/~gohlke/pythonlibs/#fdint

scott-maddox commented 7 years ago

Trying to compile right now on Windows 10. It looks like it might be a Windows vs. Unix path (i.e. '\' vs '/') issue.

@cgohlke Did you have to make any changes to the setup.py or source code to get it to compile?

cgohlke commented 7 years ago

Did you have to make any changes to the setup.py

Yes, the names of the extensions should use . instead of /, e.g. "fdint._fdint" instead of "fdint/_fdint".

scott-maddox commented 7 years ago

@cgohlke Did you run into the following error when trying to test the package, and if so how did you fix it? Clearly my packaging experience on Windows is limited (i.e. nonexistent)...

ImportError: DLL load failed: %1 is not a valid Win32 application.

Edit: Nevermind, it seems to work fine through powershell. Should have a new version out with the appropriate fixes soon.

scott-maddox commented 7 years ago

Fixed in v2.0.2

cgohlke commented 7 years ago

Too late for 2.0.2, but may I also suggest two other changes:

1) use ssize_t type for indices and lengths. This fixes many compiler warnings of type conversion from 'npy_intp' to 'int', possible loss of data on 64-bit.:

diff --git a/scripts/gen__vdfd_pyx.py b/scripts/gen__vdfd_pyx.py
index 0851608..bf45cf2 100644
--- a/scripts/gen__vdfd_pyx.py
+++ b/scripts/gen__vdfd_pyx.py
@@ -16,9 +16,9 @@ cpdef void vdfd{a}h(np.ndarray[double] phi, np.ndarray[double] out):
     \'\'\'
     Vectorized form of dfd{a}h.
     \'\'\'
-    cdef int imax = phi.shape[0]
+    cdef ssize_t imax = phi.shape[0]
     assert imax == out.shape[0]
-    cdef int i
+    cdef ssize_t i
     for i in range(imax):
         out[i] = dfd{a}h(phi[i])
 '''.format(a=a))
diff --git a/scripts/gen__vdgfd_pyx.py b/scripts/gen__vdgfd_pyx.py
index 10913ce..ea3160e 100644
--- a/scripts/gen__vdgfd_pyx.py
+++ b/scripts/gen__vdgfd_pyx.py
@@ -17,10 +17,10 @@ cpdef void vdgfd{a}h(np.ndarray[double] phi, np.ndarray[double] beta,
     \'\'\'
     Vectorized form of dgfd{a}h.
     \'\'\'
-    cdef int imax = phi.shape[0]
+    cdef ssize_t imax = phi.shape[0]
     assert imax == beta.shape[0]
     assert imax == out.shape[0]
-    cdef int i
+    cdef ssize_t i
     for i in range(imax):
         out[i] = dgfd{a}h(phi[i], beta[i])
 '''.format(a=a))
diff --git a/scripts/gen__vdnonparabolic_pyx.py b/scripts/gen__vdnonparabolic_pyx.py
index 4c06283..9f35273 100644
--- a/scripts/gen__vdnonparabolic_pyx.py
+++ b/scripts/gen__vdnonparabolic_pyx.py
@@ -15,10 +15,10 @@ cpdef void vdnonparabolic(np.ndarray[double] phi, np.ndarray[double] alpha,
     \'\'\'
     Vectorized form of dnonparabolic.
     \'\'\'
-    cdef int imax = phi.shape[0]
+    cdef ssize_t imax = phi.shape[0]
     assert imax == alpha.shape[0]
     assert imax == out.shape[0]
-    cdef int i
+    cdef ssize_t i
     for i in range(imax):
         out[i] = dnonparabolic(phi[i], alpha[i])
 ''')
\ No newline at end of file
diff --git a/scripts/gen__vfd_pyx.py b/scripts/gen__vfd_pyx.py
index a355bac..679404e 100644
--- a/scripts/gen__vfd_pyx.py
+++ b/scripts/gen__vfd_pyx.py
@@ -16,9 +16,9 @@ cpdef void vfd{a}h(np.ndarray[double] phi, np.ndarray[double] out):
     \'\'\'
     Vectorized form of fd{a}h.
     \'\'\'
-    cdef int imax = phi.shape[0]
+    cdef ssize_t imax = phi.shape[0]
     assert imax == out.shape[0]
-    cdef int i
+    cdef ssize_t i
     for i in range(imax):
         out[i] = fd{a}h(phi[i])
 '''.format(a=a))
diff --git a/scripts/gen__vgfd_pyx.py b/scripts/gen__vgfd_pyx.py
index 6455a96..194a395 100644
--- a/scripts/gen__vgfd_pyx.py
+++ b/scripts/gen__vgfd_pyx.py
@@ -17,10 +17,10 @@ cpdef void vgfd{a}h(np.ndarray[double] phi, np.ndarray[double] beta,
     \'\'\'
     Vectorized form of gfd{a}h.
     \'\'\'
-    cdef int imax = phi.shape[0]
+    cdef ssize_t imax = phi.shape[0]
     assert imax == beta.shape[0]
     assert imax == out.shape[0]
-    cdef int i
+    cdef ssize_t i
     for i in range(imax):
         out[i] = gfd{a}h(phi[i], beta[i])
 '''.format(a=a))
diff --git a/scripts/gen__vifd_pyx.py b/scripts/gen__vifd_pyx.py
index 802984c..9200056 100644
--- a/scripts/gen__vifd_pyx.py
+++ b/scripts/gen__vifd_pyx.py
@@ -15,9 +15,9 @@ cpdef void vifd{a}h(np.ndarray[double] phi, np.ndarray[double] out):
     \'\'\'
     Vectorized form of ifd{a}h.
     \'\'\'
-    cdef int imax = phi.shape[0]
+    cdef ssize_t imax = phi.shape[0]
     assert imax == out.shape[0]
-    cdef int i
+    cdef ssize_t i
     for i in range(imax):
         out[i] = ifd{a}h(phi[i])
 '''.format(a=a))
diff --git a/scripts/gen__vnonparabolic_pyx.py b/scripts/gen__vnonparabolic_pyx.py
index aa0e0ab..09d603d 100644
--- a/scripts/gen__vnonparabolic_pyx.py
+++ b/scripts/gen__vnonparabolic_pyx.py
@@ -15,10 +15,10 @@ cpdef void vnonparabolic(np.ndarray[double] phi, np.ndarray[double] alpha,
     \'\'\'
     Vectorized form of nonparabolic.
     \'\'\'
-    cdef int imax = phi.shape[0]
+    cdef ssize_t imax = phi.shape[0]
     assert imax == alpha.shape[0]
     assert imax == out.shape[0]
-    cdef int i
+    cdef ssize_t i
     for i in range(imax):
         out[i] = nonparabolic(phi[i], alpha[i])
 ''')
\ No newline at end of file

2) Python 3 fix for the example:

diff --git a/fdint/examples/plot.py b/fdint/examples/plot.py
index 639f54b..5d1c0d6 100644
--- a/fdint/examples/plot.py
+++ b/fdint/examples/plot.py
@@ -49,7 +49,7 @@ def plot_fd_and_dfd():
     fig, ax1 = plt.subplots()
     prefix='fd'
     ax1.set_title(prefix)
-    for k2 in xrange(-9,22,2):
+    for k2 in range(-9,22,2):
         k = k2/2.
         k2s = str(k2).replace('-','m')

@@ -71,7 +71,7 @@ def plot_gfd_and_dgfd(beta):
     fig, ax1 = plt.subplots()
     prefix='gfd'
     ax1.set_title(prefix+' beta='+str(beta))
-    for k2 in xrange(-1,6,2):
+    for k2 in range(-1,6,2):
         k = k2/2.
         k2s = str(k2).replace('-','m')
CoryWeber commented 7 years ago

Thanks. I'll try it out tomorrow.

CoryWeber commented 7 years ago

Thanks Scott, I got it to work.   When I installed fdint through pip, it upgrade me to numpy 1.12, but without MKL, so it initially didn't run.     I manually downloaded  numpy‑1.12.0+mkl‑cp27‑cp27m‑win_amd64.whl  from Christoph's webpage, installed it through pip, then everything worked.   Let me know if you want some simulations or a beverage.   I owe you one. -Cory

  From: Christoph Gohlke <notifications@github.com>

To: scott-maddox/fdint fdint@noreply.github.com Cc: CoryWeber mclovin524-freeservices@yahoo.com; Author author@noreply.github.com Sent: Sunday, February 26, 2017 3:40 PM Subject: Re: [scott-maddox/fdint] Windows 10 install? (#17)

Too late for 2.0.2, but may I also suggest two other changes:

@@ -71,7 +71,7 @@ def plot_gfd_and_dgfd(beta): fig, ax1 = plt.subplots() prefix='gfd' ax1.set_title(prefix+' beta='+str(beta))

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

scott-maddox commented 7 years ago

I need to investigate the numpy+MKL issue. It worked for me on a fresh install, so it's not clear why MKL was required. Is it reasonable to require MKL?

I'll open a separate issue for the issues brought up by cgohlke.

cgohlke commented 7 years ago

Is it reasonable to require MKL?

No, I don't see why fdint would require numpy+MKL. Official numpy should work.