Git Product home page Git Product logo

Comments (6)

casevh avatar casevh commented on September 27, 2024 1

I've just committed a fix. I will release 2.1.1 soon.

from gmpy.

oscarbenjamin avatar oscarbenjamin commented on September 27, 2024

I guess it comes from here:

gmpy/src/gmpy2_pow.c

Lines 515 to 535 in 1928e1b

static PyObject *
GMPy_Number_Pow_Slot(PyObject *base, PyObject *exp, PyObject *mod)
{
int btype = GMPy_ObjectType(base);
int etype = GMPy_ObjectType(exp);
if (IS_TYPE_INTEGER(btype) && IS_TYPE_INTEGER(etype))
return GMPy_Integer_PowWithType(base, btype, exp, etype, mod, NULL);
if (IS_TYPE_RATIONAL(btype) && IS_TYPE_RATIONAL(etype))
return GMPy_Rational_PowWithType(base, btype, exp, etype, mod, NULL);
if (IS_TYPE_REAL(btype) && IS_TYPE_REAL(etype))
return GMPy_Real_PowWithType(base, btype, exp, etype, mod, NULL);
if (IS_TYPE_COMPLEX(btype) && IS_TYPE_COMPLEX(etype))
return GMPy_Complex_PowWithType(base, btype, exp, etype, mod, NULL);
TYPE_ERROR("unsupported operand type(s) for ** or pow()");
return NULL;
}

from gmpy.

oscarbenjamin avatar oscarbenjamin commented on September 27, 2024

Also the standard error message is better as it includes the types:

In [6]: class A: pass

In [7]: A() ** 2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-9845e827204c> in <module>
----> 1 A() ** 2

TypeError: unsupported operand type(s) for ** or pow(): 'A' and 'int'

from gmpy.

oscarbenjamin avatar oscarbenjamin commented on September 27, 2024

I suppose SymPy CI should probably track prereleases of gmpy2 because we would have picked this up with gmpy2 2.1.0rc2. In fact with rc1 if you try this then it shows a really nasty bug that consumes all the memory in the computer and hardly even responds to Ctrl-C:

from sympy import Rational
from gmpy2 import mpq
mpq(8, 1) ** Rational(1, 3)

from gmpy.

casevh avatar casevh commented on September 27, 2024

I have pushed 2.1.1 to PyPi.

from gmpy.

oscarbenjamin avatar oscarbenjamin commented on September 27, 2024

Thanks!

from gmpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.