Skip to content

Conversation

maximlt
Copy link
Member

@maximlt maximlt commented Nov 6, 2022

This PR adds Python 3.11 in the test matrix. To get the test to pass on Python 3.11 I had to replace usages of asyncio.coroutine (deprecated since Python 3.8) by using async/await keywords. Since they're not supported in Python 2 I had to move some of the tests to their own module to avoid them being collected when the test suite runs with Python 2.

The last issue is related to gmpy that cannot get installed on Python 3.11 at the moment. Shouldn't Param instead use gmpy2?

@jbednar
Copy link
Member

jbednar commented Nov 15, 2022

I don't think Param relies on anything introduced in gmpy2, but if both work, feel free to switch it!

@maximlt
Copy link
Member Author

maximlt commented Nov 18, 2022

In c08ea26 I tried to use gmpy2 but on Linux there was a failing test and some warnings:

   __________ TestTimeDependentDynamic.test_time_hashing_rationals_gmpy2 __________
  
  self = <tests.API1.testtimedependent.TestTimeDependentDynamic testMethod=test_time_hashing_rationals_gmpy2>
  
      @pytest.mark.skipif(gmpy2 is None, reason="gmpy2 is not installed")
      def test_time_hashing_rationals_gmpy2(self):
          """
          Check that hashes of fractions and gmpy2 mpqs match for some
          reasonable rational numbers.
          """
          pi = "3.141592"
          hashfn = numbergen.Hash("test", input_count=1)
          self.assertEqual(hashfn(0.5), hashfn(gmpy2.mpq(0.5)))
  >       self.assertEqual(hashfn(pi), hashfn(gmpy2.mpq(3.141592)))
  E       AssertionError: 238769760 != 243050811
  
  tests/API1/testtimedependent.py:317: AssertionError
  ----------------------------- Captured stderr call -----------------------------
  WARNING:param.main: Casting type 'float' to Fraction.fraction
  WARNING:param.main: Casting type 'mpq' to Fraction.fraction
  WARNING:param.main: Casting type 'str' to Fraction.fraction
  WARNING:param.main: Casting type 'mpq' to Fraction.fraction
  ------------------------------ Captured log call -------------------------------
  WARNING  param.main:parameterized.py:2529 Casting type 'float' to Fraction.fraction
  WARNING  param.main:parameterized.py:2529 Casting type 'mpq' to Fraction.fraction
  WARNING  param.main:parameterized.py:2529 Casting type 'str' to Fraction.fraction
  WARNING  param.main:parameterized.py:2529 Casting type 'mpq' to Fraction.fraction

Also similarly to gmpy, it wouldn't install on Linux and fail with:

        In file included from src/gmpy2.c:500:
        src/gmpy2.h:82:10: fatal error: mpfr.h: No such file or directory
           82 | #include <mpfr.h>
              |          ^~~~~~~~
        compilation terminated.
        error: command '/usr/bin/gcc' failed with exit code 1
        [end of output]

Last update of gmpy on PyPI was in July 2013, it was in January 2022 for gmpy2. I'll open an issue to suggest supporting gmpy2 instead of gmpy.

@maximlt maximlt merged commit 2ae76d1 into master Nov 18, 2022
@maximlt maximlt deleted the add_3.11 branch November 18, 2022 11:40
@maximlt maximlt changed the title Add Python 3.11 in the test matrix Add suuport for Python 3.11 Nov 18, 2022
@maximlt maximlt changed the title Add suuport for Python 3.11 Add support for Python 3.11 Nov 18, 2022
assert inst.single_count == 1
finally:
param.parameterized.async_executor = None
# @pytest.mark.skipif(sys.version_info.major == 2, reason='asyncio only on Python 3')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maximlt I think it might just be worth adding a comment to say this test can uncommented when python 2 is dropped.

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

Successfully merging this pull request may close these issues.

3 participants