Skip to content

TypeError on import TypeError: data type "float128" not understood #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
karnn opened this issue May 19, 2020 · 8 comments
Closed

TypeError on import TypeError: data type "float128" not understood #90

karnn opened this issue May 19, 2020 · 8 comments

Comments

@karnn
Copy link

karnn commented May 19, 2020

On Windows, Anaconda 4.8.3. Created conda environment with conda env create -f environment.yml inside Rethinking_2 directory.

Doing import pymc3 gives the following error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-75554ce6e5eb> in <module>
      2 import matplotlib.pyplot as plt
      3 import numpy as np
----> 4 import pymc3 as pm
      5 import scipy.stats as stats

~\Miniconda3\envs\stat-rethink2-pymc3\lib\site-packages\pymc3\__init__.py in <module>
     49 
     50 from .blocking import *
---> 51 from .distributions import *
     52 from .distributions import transforms
     53 from .glm import *

~\Miniconda3\envs\stat-rethink2-pymc3\lib\site-packages\pymc3\distributions\__init__.py in <module>
     13 #   limitations under the License.
     14 
---> 15 from . import timeseries
     16 from . import transforms
     17 from . import shape_utils

~\Miniconda3\envs\stat-rethink2-pymc3\lib\site-packages\pymc3\distributions\timeseries.py in <module>
     20 
     21 from pymc3.util import get_variable_name
---> 22 from .continuous import get_tau_sigma, Normal, Flat
     23 from .shape_utils import to_tuple
     24 from . import multivariate

~\Miniconda3\envs\stat-rethink2-pymc3\lib\site-packages\pymc3\distributions\continuous.py in <module>
     30 from .special import log_i0
     31 from ..math import invlogit, logit, logdiffexp
---> 32 from .dist_math import (
     33     alltrue_elemwise, betaln, bound, gammaln, i0e, incomplete_beta, logpow,
     34     normal_lccdf, normal_lcdf, SplineWrapper, std_cdf, zvalue,

~\Miniconda3\envs\stat-rethink2-pymc3\lib\site-packages\pymc3\distributions\dist_math.py in <module>
     35 f = floatX
     36 c = - .5 * np.log(2. * np.pi)
---> 37 _beta_clip_values = {
     38     dtype: (np.nextafter(0, 1, dtype=dtype), np.nextafter(1, 0, dtype=dtype))
     39     for dtype in ["float16", "float32", "float64", "float128"]

~\Miniconda3\envs\stat-rethink2-pymc3\lib\site-packages\pymc3\distributions\dist_math.py in <dictcomp>(.0)
     36 c = - .5 * np.log(2. * np.pi)
     37 _beta_clip_values = {
---> 38     dtype: (np.nextafter(0, 1, dtype=dtype), np.nextafter(1, 0, dtype=dtype))
     39     for dtype in ["float16", "float32", "float64", "float128"]
     40 }

TypeError: data type "float128" not understood
@AlexAndorra
Copy link
Contributor

Hi,
That's strange -- it works for me 🤔
Do you know which versions of python and numpy are on your env?

@karnn
Copy link
Author

karnn commented May 19, 2020

Hi
Thanks for your reply. I just checked and my Python is at 3.8.2. I suppose it's too recent? I directly installed from the yml file in the repo. It's strange. Numpy is 1.18.4

@lucianopaz
Copy link
Member

Oh damn! It's a windows bug. Numpy under windows doesn't have a float128, we should use the longdouble dtype instead. That will be equal to float128 on Linux but it will equal float64 on windows. It we could even just remove float128. @karnn, could you please open an issue on pymc3? I'll fix it in the next few days.

@AlexAndorra
Copy link
Contributor

These OS bugs keep coming 🤦 It's indeed related to your latest PR @lucianopaz.
Assign me to review the fix when you submit it -- or tell me if you don't have time in the coming days and I can take a stab (looks pretty simple).
Closing this in favor of the issue on PyMC repo.

@fonnesbeck
Copy link
Member

I'm getting this on MacOS (M1 hardware) using miniforge. This is with NumPy 1.21.0.

ImportError while loading conftest '/Users/cfonnesbeck/GitHub/pymc3/pymc3/tests/conftest.py'.
pymc3/__init__.py:82: in <module>
    from pymc3 import gp, ode, sampling
pymc3/gp/__init__.py:16: in <module>
    from pymc3.gp.gp import TP, Latent, LatentKron, Marginal, MarginalKron, MarginalSparse
pymc3/gp/gp.py:25: in <module>
    from pymc3.distributions import draw_values
pymc3/distributions/__init__.py:15: in <module>
    from pymc3.distributions import shape_utils, timeseries, transforms
pymc3/distributions/timeseries.py:21: in <module>
    from pymc3.distributions import distribution, multivariate
pymc3/distributions/multivariate.py:35: in <module>
    from pymc3.distributions.continuous import ChiSquared, Normal
pymc3/distributions/continuous.py:30: in <module>
    from pymc3.distributions.dist_math import (
pymc3/distributions/dist_math.py:49: in <module>
    np.nextafter(0, 1, dtype="float128"),
E   TypeError: data type 'float128' not understood

@ogrisel
Copy link

ogrisel commented Oct 4, 2021

For reference, on macOS ARM64 (Apple Silicon M1), float128 is not supported on numpy (at least when installed from conda-forge):

>>> import numpy as np
>>> np.dtype("float128")
Traceback (most recent call last):
  File "<ipython-input-5-10c53c28af62>", line 1, in <module>
    np.dtype("float128")
TypeError: data type 'float128' not understood

So it would be great to make float128 support an optional requirement for PyMC3 and pymc.

@ricardoV94
Copy link
Member

Which version are you using? If I recall correctly our next release dos not use float128 anywhere, so it should not be a problem.

@elbamos
Copy link

elbamos commented Oct 17, 2021

I'm seeing this also. The most recent release of pymc3 that's available through conda on m1 is 3.9.3, because the versions of theano-pymc required for later versions of pymc3 aren't available for m1. At least that's what conda is telling me.

I was able to workaround this by downgrading pymc3 to 3.8.

Edit: theano-pymc and therefore pymc3 3.11.4 are now available on conda for m1, so I think this issue is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants