diff --git a/CHANGELOG.md b/CHANGELOG.md index fd1a183..7b8f369 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.1 - 2016-05-11 + +The `math.prime_generator` was not working correctly if the parameter `p_min` was an even integer greater than two. + ## 1.2 - 2016-04-27 New packages `dicts` and `dates`. `dates` provides an easy to use timer class to mesure the execution time diff --git a/README.md b/README.md index 68a5baa..19139d5 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ utools A set of useful functions to use for various purposes in any Python project. * Author: Julien CHAUMONT (https://julienc.io) -* Version: 1.2 -* Date: 2016-04-28 +* Version: 1.2.1 +* Date: 2016-05-11 * Licence: MIT * Url: http://github.com/julienc91/utools diff --git a/docs/conf.py b/docs/conf.py index 6c134db..0a9f196 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -55,9 +55,9 @@ # built documents. # # The short X.Y version. -version = '1.2' +version = '1.2.1' # The full version, including alpha/beta/rc tags. -release = '1.2' +release = '1.2.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index b87e2ff..f0212d5 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name="utools", - version="1.2", + version="1.2.1", author="Julien Chaumont", author_email="utools@julienc.io", description="A set of useful functions to use for various purposes in any Python project", diff --git a/tests/test_math.py b/tests/test_math.py index af5245a..a0834df 100644 --- a/tests/test_math.py +++ b/tests/test_math.py @@ -133,7 +133,7 @@ def test_prime_generator_with_bad_parameters(p_min, p_max, expected_exception): # we want to test that the two prime generators functions return the same primes @pytest.mark.parametrize("p_min, p_max,", [ - (2, 4), (4, 2), (3, None), (2, None), (-1, 21) + (2, 4), (4, 2), (3, None), (2, None), (-1, 21), (20, 101) ]) def test_prime_generator_and_sieve_of_eratosthenes(p_min, p_max): count_max = 1000 diff --git a/utools/__init__.py b/utools/__init__.py index 28a90a2..7a1faa9 100644 --- a/utools/__init__.py +++ b/utools/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -__version__ = "1.2" +__version__ = "1.2.1" diff --git a/utools/math.py b/utools/math.py index 878ead1..43a45f0 100644 --- a/utools/math.py +++ b/utools/math.py @@ -106,6 +106,9 @@ def prime_generator(p_min=2, p_max=None): q = max(p_min, 3) if p_min <= 2 and (p_max is None or p_max >= 2): yield 2 # outside the while block to make the double increment optimization work + if p_min % 2 == 0: + p_min += 1 + while p_max is None or q <= p_max: if is_prime(q): yield q