From bdb2f93518587e4e2e210415c96220241833e700 Mon Sep 17 00:00:00 2001 From: Seth M Morton Date: Mon, 28 Jul 2014 18:28:56 -0700 Subject: Fixed README typos. --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index ee5fc1f..6ba80c8 100644 --- a/README.rst +++ b/README.rst @@ -37,7 +37,7 @@ Using ``natsorted`` is simple:: ``natsorted`` identifies real numbers anywhere in a string and sorts them naturally. -Sorting version numbers is just as easy:: +Sorting version numbers is just as easy with the ``versorted`` function:: >>> from natsort import versorted >>> a = ['version-1.9', 'version-2.0', 'version-1.11', 'version-1.10'] @@ -60,7 +60,7 @@ The natsort algorithm does other fancy things like - recursively descend into lists of lists - sort file paths correctly - allow custom sorting keys - - allow exposed a natsort_key generator to pass to list.sort + - exposes a natsort_key generator to pass to list.sort Please see the package documentation for more details, including additional examples and recipes. -- cgit v1.2.1 From 6b24585bba2030710c23d0abe2767aa1766dcd4b Mon Sep 17 00:00:00 2001 From: Seth M Morton Date: Mon, 28 Jul 2014 18:29:18 -0700 Subject: Added docs and all tests to MANIFEST.in. --- MANIFEST.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index ef9c943..be74ec3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,8 +5,11 @@ include natsort/_version.py include natsort/__main__.py include natsort/__init__.py include natsort/py23compat.py -include test_natsort/test_natsorted.py +include test_natsort/profile_natsorted.py +include test_natsort/stress_natsort.py +include test_natsort/test_natsort.py include test_natsort/test_main.py include setup.py include setup.cfg prune natsort/__pycache__ +graft docs/source -- cgit v1.2.1 From 824545e08697ac3b6f455a4e85ad813971155282 Mon Sep 17 00:00:00 2001 From: Seth M Morton Date: Mon, 28 Jul 2014 18:29:37 -0700 Subject: Fixed bug in the doc conf.py. --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index ee8ea53..abeb7da 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -145,7 +145,7 @@ html_theme_path = ['.'] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +# html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied -- cgit v1.2.1 From e6619e653aefb19121f9381882ba91c95c3a6aae Mon Sep 17 00:00:00 2001 From: Seth M Morton Date: Thu, 7 Aug 2014 21:28:53 -0700 Subject: Manually install wheels, otherwise bdist_wheel fails. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 72df9c9..015e35b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ install: - pip install pytest-cov pytest-flakes pytest-pep8 - pip install coveralls - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install argparse; fi +- pip install wheel script: - python -m pytest --cov natsort --flakes --pep8 - python -m pytest --doctest-modules natsort -- cgit v1.2.1 From 51f9f04929b125ad9578d7c12bab1d7a6ca8d0be Mon Sep 17 00:00:00 2001 From: Seth M Morton Date: Mon, 11 Aug 2014 21:06:20 -0700 Subject: Deployment now happens on Python 2.7. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 015e35b..7be6466 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,6 @@ deploy: tags: true all_branches: true repo: SethMMorton/natsort - python: 3.3 + python: 2.7 distributions: "sdist bdist_wheel" docs_dir: build/sphinx/html -- cgit v1.2.1 From 5840e801f2175798a91f197c4cfd2c03fa683f8d Mon Sep 17 00:00:00 2001 From: Seth M Morton Date: Sun, 10 Aug 2014 23:11:22 -0700 Subject: Updated the documentation. This includes adding links to useful sites, and updating the examples section. --- README.rst | 11 +++++++---- docs/source/examples.rst | 19 +++++++++++++++++++ docs/source/intro.rst | 9 ++++++--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 6ba80c8..6b664ab 100644 --- a/README.rst +++ b/README.rst @@ -7,8 +7,11 @@ natsort .. image:: https://coveralls.io/repos/SethMMorton/natsort/badge.png?branch=develop :target: https://coveralls.io/r/SethMMorton/natsort?branch=develop -Natural sorting for python. Check out the source code at -https://github.com/SethMMorton/natsort. +Natural sorting for python. + + - Source Code: https://github.com/SethMMorton/natsort + - Downloads: https://pypi.python.org/pypi/natsort + - Documentation: http://pythonhosted.org//natsort/ Quick Description ----------------- @@ -62,8 +65,8 @@ The natsort algorithm does other fancy things like - allow custom sorting keys - exposes a natsort_key generator to pass to list.sort -Please see the package documentation for more details, including additional examples -and recipes. +Please see the package documentation for more details, including +`examples and recipes `_. Shell script ------------ diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 9704495..5176dd1 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -62,6 +62,25 @@ and ``signed=False``, and the :func:`~versorted` is a shortcut for ``natsorted(number_type=None)``. The recommend manner to sort version numbers is to use :func:`~versorted`. +Sorting with Alpha, Beta, and Release Candidates +++++++++++++++++++++++++++++++++++++++++++++++++ + +By default, if you wish to sort versions with a non-strict versioning +scheme, you may not get the results you expect:: + + >>> a = ['1.2', '1.2rc1', '1.2beta2', '1.2beta', '1.2alpha', '1.2.1', '1.1', '1.3'] + >>> versorted(a) + ['1.1', '1.2', '1.2.1', '1.2alpha', '1.2beta', '1.2beta2', '1.2rc1', '1.3'] + +To make the '1.2' pre-releases come before '1.2.1', you need to use the following +recipe:: + + >>> versorted(a, key=lambda x: x.replace('.', '~')) + ['1.1', '1.2', '1.2alpha', '1.2beta', '1.2beta2', '1.2rc1', '1.2.1', '1.3'] + +Please see `this issue `_ to +see why this works. + Sort OS-Generated Paths ----------------------- diff --git a/docs/source/intro.rst b/docs/source/intro.rst index d4977e8..257c49a 100644 --- a/docs/source/intro.rst +++ b/docs/source/intro.rst @@ -4,13 +4,16 @@ The :mod:`natsort` module ========================= -Natural sorting for python. Check out the source code at -https://github.com/SethMMorton/natsort. +Natural sorting for python. + + - Source Code: https://github.com/SethMMorton/natsort + - Downloads: https://pypi.python.org/pypi/natsort + - Documentation: http://pythonhosted.org//natsort/ :mod:`natsort` was initially created for sorting scientific output filenames that contained floating point numbers in the names. There was a serious lack of algorithms out there that could perform a natural sort on `floats` but -plenty for ints; check out +plenty for `ints`; check out `this StackOverflow question `_ and its answers and links therein, `this ActiveState forum `_, -- cgit v1.2.1 From d94de806ce6ee78cd15a78b8a746adb287b06cd9 Mon Sep 17 00:00:00 2001 From: Seth M Morton Date: Tue, 12 Aug 2014 18:18:58 -0700 Subject: Adopted new fastnumbers module. This module quickly confers strings to numbers, and will speed up the natsort algorithm significantly (if it is installed). In case it is not installed, a "fake_fastnumbers" module is added to natsort that simulates the needed functions. It is found that up to 30% gain in efficiency can be had by using the fastnumbers module. --- .coveragerc | 3 ++ natsort/fake_fastnumbers.py | 30 +++++++++++++++ natsort/natsort.py | 71 +++++++++++++++-------------------- test_natsort/test_fake_fastnumbers.py | 26 +++++++++++++ test_natsort/test_natsort.py | 61 ++++++++++++++++-------------- 5 files changed, 123 insertions(+), 68 deletions(-) create mode 100644 natsort/fake_fastnumbers.py create mode 100644 test_natsort/test_fake_fastnumbers.py diff --git a/.coveragerc b/.coveragerc index 1bbfe9d..8622bd1 100644 --- a/.coveragerc +++ b/.coveragerc @@ -9,6 +9,9 @@ exclude_lines = raise NotImplementedError raise$ + # Don't complain about alternate imports + except ImportError + # Don't complain if non-runnable code isn't run: if 0: if __name__ == .__main__.: diff --git a/natsort/fake_fastnumbers.py b/natsort/fake_fastnumbers.py new file mode 100644 index 0000000..15d7e88 --- /dev/null +++ b/natsort/fake_fastnumbers.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +"""\ +This module is intended to replicate some of the functionality +from the fastnumbers module in the event that module is not +installed. +""" +from __future__ import (print_function, division, + unicode_literals, absolute_import) + +import re + +float_re = re.compile(r'[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?$') +int_re = re.compile(r'[-+]?\d+$') + + +def fast_float(x, regex_matcher=float_re.match): + """Convert a string to a float quickly""" + return float(x) if regex_matcher(x) else x + + +def fast_int(x, regex_matcher=int_re.match): + """\ + Convert a string to a int quickly, return input as-is if not possible. + """ + return int(x) if regex_matcher(x) else x + + +def isreal(x, ntypes=set([int, float])): + """Returns true if the input is a real number, false otherwise.""" + return type(x) in ntypes diff --git a/natsort/natsort.py b/natsort/natsort.py index c67ec3f..5974199 100644 --- a/natsort/natsort.py +++ b/natsort/natsort.py @@ -23,6 +23,13 @@ from functools import partial from itertools import islice from warnings import warn +# If the user has fastnumbers installed, they will get great speed +# benefits. If not, we simulate the functions here. +try: + from fastnumbers import fast_float, fast_int, isreal +except ImportError: + from .fake_fastnumbers import fast_float, fast_int, isreal + from .py23compat import u_format, py23_str, py23_zip # Make sure the doctest works for either python2 or python3 @@ -38,54 +45,37 @@ int_nosign_re = re.compile(r'(\d+)') int_sign_re = re.compile(r'([-+]?\d+)') # This dict will help select the correct regex and number conversion function. regex_and_num_function_chooser = { - (float, True, True): (float_sign_exp_re, float), - (float, True, False): (float_sign_noexp_re, float), - (float, False, True): (float_nosign_exp_re, float), - (float, False, False): (float_nosign_noexp_re, float), - (int, True, True): (int_sign_re, int), - (int, True, False): (int_sign_re, int), - (int, False, True): (int_nosign_re, int), - (int, False, False): (int_nosign_re, int), - (None, True, True): (int_nosign_re, int), - (None, True, False): (int_nosign_re, int), - (None, False, True): (int_nosign_re, int), - (None, False, False): (int_nosign_re, int), + (float, True, True): (float_sign_exp_re, fast_float), + (float, True, False): (float_sign_noexp_re, fast_float), + (float, False, True): (float_nosign_exp_re, fast_float), + (float, False, False): (float_nosign_noexp_re, fast_float), + (int, True, True): (int_sign_re, fast_int), + (int, True, False): (int_sign_re, fast_int), + (int, False, True): (int_nosign_re, fast_int), + (int, False, False): (int_nosign_re, fast_int), + (None, True, True): (int_nosign_re, fast_int), + (None, True, False): (int_nosign_re, fast_int), + (None, False, True): (int_nosign_re, fast_int), + (None, False, False): (int_nosign_re, fast_int), } -# Number types. I have to use set([...]) and not {...} -# because I am supporting Python 2.6. -number_types = set([float, int]) - -# This regex is to make sure we don't mistake a number for a file extension -decimal = re.compile(r'\.\d') - def _number_finder(s, regex, numconv, py3_safe): """Helper to split numbers""" - # Split the input string by numbers. - # If there are no splits, return now. - # If the input is not a string, ValueError is raised. + # Split the input string by numbers. If there are no splits, return now. + # If the input is not a string, TypeError is raised. s = regex.split(s) if len(s) == 1: return tuple(s) # Now convert the numbers to numbers, and leave strings as strings. # Remove empty strings from the list. - # Profiling showed that using regex here is much faster than - # try/except with the numconv function. - r = regex.match - s = [numconv(x) if r(x) else x for x in s if x] + s = [numconv(x) for x in s if x] # If the list begins with a number, lead with an empty string. # This is used to get around the "unorderable types" issue. - # The most common case will be a string at the front of the - # list, and in that case the try/except method is faster than - # using isinstance. This was chosen at the expense of the less - # common case of a number being at the front of the list. - try: - s[0][0] # str supports indexing, but not numbers - except TypeError: + if isreal(s[0]): s = [''] + s # The _py3_safe function inserts "" between numbers in the list, @@ -95,11 +85,12 @@ def _number_finder(s, regex, numconv, py3_safe): return _py3_safe(s) if py3_safe else s -def _path_splitter(s): +def _path_splitter(s, _d_match=re.compile(r'\.\d').match): """Split a string into its path components. Assumes a string is a path.""" path_parts = [] p_append = path_parts.append path_location = s + # Continue splitting the path from the back until we have reached # '..' or '.', or until there is nothing left to split. while path_location != curdir and path_location != pardir: @@ -108,29 +99,32 @@ def _path_splitter(s): if path_location == parent_path: break p_append(child_path) + # This last append is the base path. # Only append if the string is non-empty. if path_location: p_append(path_location) + # We created this list in reversed order, so we now correct the order. path_parts.reverse() + # Now, split off the file extensions using a similar method to above. # Continue splitting off file extensions until we reach a decimal number # or there are no more extensions. base = path_parts.pop() base_parts = [] b_append = base_parts.append - d_match = decimal.match while True: front = base base, ext = splitext(front) - if d_match(ext) or not ext: + if _d_match(ext) or not ext: # Reset base to before the split if the split is invalid. base = front break b_append(ext) b_append(base) base_parts.reverse() + # Return the split parent paths and then the split basename. return path_parts + base_parts @@ -143,12 +137,9 @@ def _py3_safe(parsed_list): else: new_list = [parsed_list[0]] nl_append = new_list.append - ntypes = number_types for before, after in py23_zip(islice(parsed_list, 0, length-1), islice(parsed_list, 1, None)): - # I realize that isinstance is favored over type, but - # in this case type is SO MUCH FASTER than isinstance!! - if type(before) in ntypes and type(after) in ntypes: + if isreal(before) and isreal(after): nl_append("") nl_append(after) return new_list diff --git a/test_natsort/test_fake_fastnumbers.py b/test_natsort/test_fake_fastnumbers.py new file mode 100644 index 0000000..29ba9af --- /dev/null +++ b/test_natsort/test_fake_fastnumbers.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +"""\ +Test the fake fastnumbers module. +""" +from natsort.fake_fastnumbers import fast_float, fast_int, isreal + + +def test_fast_float(): + assert fast_float('45.8') == 45.8 + assert fast_float('-45') == -45.0 + assert fast_float('45.8e-2') == 45.8e-2 + assert fast_float('invalid') == 'invalid' + + +def test_fast_int(): + assert fast_int('45.8') == '45.8' + assert fast_int('-45') == -45 + assert fast_int('+45') == 45 + assert fast_int('invalid') == 'invalid' + + +def test_isreal(): + assert not isreal('45.8') + assert isreal(-45) + assert isreal(45.8e-2) + assert not isreal('invalid') diff --git a/test_natsort/test_natsort.py b/test_natsort/test_natsort.py index 0eeed12..264b508 100644 --- a/test_natsort/test_natsort.py +++ b/test_natsort/test_natsort.py @@ -11,25 +11,30 @@ from natsort.natsort import _number_finder, _py3_safe, _natsort_key from natsort.natsort import float_sign_exp_re, float_nosign_exp_re, float_sign_noexp_re from natsort.natsort import float_nosign_noexp_re, int_nosign_re, int_sign_re +try: + from fastnumbers import fast_float, fast_int +except ImportError: + from natsort.fake_fastnumbers import fast_float, fast_int + def test_number_finder(): - assert _number_finder('a5+5.034e-1', float_sign_exp_re, float, False) == ['a', 5.0, 0.5034] - assert _number_finder('a5+5.034e-1', float_nosign_exp_re, float, False) == ['a', 5.0, '+', 0.5034] - assert _number_finder('a5+5.034e-1', float_sign_noexp_re, float, False) == ['a', 5.0, 5.034, 'e', -1.0] - assert _number_finder('a5+5.034e-1', float_nosign_noexp_re, float, False) == ['a', 5.0, '+', 5.034, 'e-', 1.0] - assert _number_finder('a5+5.034e-1', int_nosign_re, int, False) == ['a', 5, '+', 5, '.', 34, 'e-', 1] - assert _number_finder('a5+5.034e-1', int_sign_re, int, False) == ['a', 5, 5, '.', 34, 'e', -1] + assert _number_finder('a5+5.034e-1', float_sign_exp_re, fast_float, False) == ['a', 5.0, 0.5034] + assert _number_finder('a5+5.034e-1', float_nosign_exp_re, fast_float, False) == ['a', 5.0, '+', 0.5034] + assert _number_finder('a5+5.034e-1', float_sign_noexp_re, fast_float, False) == ['a', 5.0, 5.034, 'e', -1.0] + assert _number_finder('a5+5.034e-1', float_nosign_noexp_re, fast_float, False) == ['a', 5.0, '+', 5.034, 'e-', 1.0] + assert _number_finder('a5+5.034e-1', int_nosign_re, fast_int, False) == ['a', 5, '+', 5, '.', 34, 'e-', 1] + assert _number_finder('a5+5.034e-1', int_sign_re, fast_int, False) == ['a', 5, 5, '.', 34, 'e', -1] - assert _number_finder('a5+5.034e-1', float_sign_exp_re, float, True) == ['a', 5.0, '', 0.5034] - assert _number_finder('a5+5.034e-1', float_nosign_exp_re, float, True) == ['a', 5.0, '+', 0.5034] - assert _number_finder('a5+5.034e-1', float_sign_noexp_re, float, True) == ['a', 5.0, '', 5.034, 'e', -1.0] - assert _number_finder('a5+5.034e-1', float_nosign_noexp_re, float, True) == ['a', 5.0, '+', 5.034, 'e-', 1.0] - assert _number_finder('a5+5.034e-1', int_nosign_re, int, True) == ['a', 5, '+', 5, '.', 34, 'e-', 1] - assert _number_finder('a5+5.034e-1', int_sign_re, int, True) == ['a', 5, '', 5, '.', 34, 'e', -1] + assert _number_finder('a5+5.034e-1', float_sign_exp_re, fast_float, True) == ['a', 5.0, '', 0.5034] + assert _number_finder('a5+5.034e-1', float_nosign_exp_re, fast_float, True) == ['a', 5.0, '+', 0.5034] + assert _number_finder('a5+5.034e-1', float_sign_noexp_re, fast_float, True) == ['a', 5.0, '', 5.034, 'e', -1.0] + assert _number_finder('a5+5.034e-1', float_nosign_noexp_re, fast_float, True) == ['a', 5.0, '+', 5.034, 'e-', 1.0] + assert _number_finder('a5+5.034e-1', int_nosign_re, fast_int, True) == ['a', 5, '+', 5, '.', 34, 'e-', 1] + assert _number_finder('a5+5.034e-1', int_sign_re, fast_int, True) == ['a', 5, '', 5, '.', 34, 'e', -1] - assert _number_finder('6a5+5.034e-1', float_sign_exp_re, float, False) == ['', 6.0, 'a', 5.0, 0.5034] - assert _number_finder('6a5+5.034e-1', float_sign_exp_re, float, True) == ['', 6.0, 'a', 5.0, '', 0.5034] + assert _number_finder('6a5+5.034e-1', float_sign_exp_re, fast_float, False) == ['', 6.0, 'a', 5.0, 0.5034] + assert _number_finder('6a5+5.034e-1', float_sign_exp_re, fast_float, True) == ['', 6.0, 'a', 5.0, '', 0.5034] def test_py3_safe(): @@ -47,21 +52,21 @@ def test_natsort_key_private(): assert a == ['num2', 'num3', 'num5'] # The below illustrates how the key works, and how the different options affect sorting. - assert _natsort_key('a-5.034e1') == ('a', -50.34) - assert _natsort_key('a-5.034e1', number_type=float, signed=True, exp=True) == ('a', -50.34) - assert _natsort_key('a-5.034e1', number_type=float, signed=True, exp=False) == ('a', -5.034, 'e', 1.0) - assert _natsort_key('a-5.034e1', number_type=float, signed=False, exp=True) == ('a-', 50.34) - assert _natsort_key('a-5.034e1', number_type=float, signed=False, exp=False) == ('a-', 5.034, 'e', 1.0) - assert _natsort_key('a-5.034e1', number_type=int) == ('a', -5, '.', 34, 'e', 1) - assert _natsort_key('a-5.034e1', number_type=int, signed=False) == ('a-', 5, '.', 34, 'e', 1) - assert _natsort_key('a-5.034e1', number_type=None) == _natsort_key('a-5.034e1', number_type=int, signed=False) - assert _natsort_key('a-5.034e1', key=lambda x: x.upper()) == ('A', -50.34) + assert _natsort_key('a-5.034e2') == ('a', -503.4) + assert _natsort_key('a-5.034e2', number_type=float, signed=True, exp=True) == ('a', -503.4) + assert _natsort_key('a-5.034e2', number_type=float, signed=True, exp=False) == ('a', -5.034, 'e', 2.0) + assert _natsort_key('a-5.034e2', number_type=float, signed=False, exp=True) == ('a-', 503.4) + assert _natsort_key('a-5.034e2', number_type=float, signed=False, exp=False) == ('a-', 5.034, 'e', 2.0) + assert _natsort_key('a-5.034e2', number_type=int) == ('a', -5, '.', 34, 'e', 2) + assert _natsort_key('a-5.034e2', number_type=int, signed=False) == ('a-', 5, '.', 34, 'e', 2) + assert _natsort_key('a-5.034e2', number_type=None) == _natsort_key('a-5.034e2', number_type=int, signed=False) + assert _natsort_key('a-5.034e2', key=lambda x: x.upper()) == ('A', -503.4) # Iterables are parsed recursively so you can sort lists of lists. - assert _natsort_key(('a1', 'a-5.034e1')) == (('a', 1.0), ('a', -50.34)) - assert _natsort_key(('a1', 'a-5.034e1'), number_type=None) == (('a', 1), ('a-', 5, '.', 34, 'e', 1)) + assert _natsort_key(('a1', 'a-5.034e2')) == (('a', 1.0), ('a', -503.4)) + assert _natsort_key(('a1', 'a-5.034e2'), number_type=None) == (('a', 1), ('a-', 5, '.', 34, 'e', 2)) # A key is applied before recursion, but not in the recursive calls. - assert _natsort_key(('a1', 'a-5.034e1'), key=itemgetter(1)) == ('a', -50.34) + assert _natsort_key(('a1', 'a-5.034e2'), key=itemgetter(1)) == ('a', -503.4) # Strings that lead with a number get an empty string at the front of the tuple. # This is designed to get around the "unorderable types" issue. @@ -100,10 +105,10 @@ def test_natsort_key_public(): # But it raises a depreciation warning with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") - assert natsort_key('a-5.034e1') == _natsort_key('a-5.034e1') + assert natsort_key('a-5.034e2') == _natsort_key('a-5.034e2') assert len(w) == 1 assert "natsort_key is depreciated as of 3.4.0, please use natsort_keygen" in str(w[-1].message) - assert natsort_key('a-5.034e1', number_type=float, signed=False, exp=False) == _natsort_key('a-5.034e1', number_type=float, signed=False, exp=False) + assert natsort_key('a-5.034e2', number_type=float, signed=False, exp=False) == _natsort_key('a-5.034e2', number_type=float, signed=False, exp=False) # It is called for each element in a list when sorting with warnings.catch_warnings(record=True) as w: -- cgit v1.2.1 From 13b10e82dc8164c4dbf702c4028d61c2161d6d63 Mon Sep 17 00:00:00 2001 From: Seth M Morton Date: Tue, 12 Aug 2014 23:09:51 -0700 Subject: Updated .travis.yml. Deployment will now be done manually... Travis-CI deployment was found to be buggy. Additionally, testing with and without fastnumbers will be done. --- .travis.yml | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7be6466..797241c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,11 +5,14 @@ python: - 3.2 - 3.3 - 3.4 +env: +- WITH_FASTNUMBERS=true +- WITH_FASTNUMBERS=false install: - pip install pytest-cov pytest-flakes pytest-pep8 - pip install coveralls +- if [[ $WITH_FASTNUMBERS == true ]]; then pip install fastnumbers; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install argparse; fi -- pip install wheel script: - python -m pytest --cov natsort --flakes --pep8 - python -m pytest --doctest-modules natsort @@ -17,18 +20,18 @@ script: - python -m pytest test_natsort/stress_natsort.py after_success: coveralls -before_deploy: -- pip install Sphinx numpydoc -- python setup.py build_sphinx -deploy: - provider: pypi - user: SethMMorton - password: - secure: OaYQtVh4mGT0ozN7Ar2lSm2IEVMKIyvOESGPGLwVyVxPqp6oC101MovJ7041bZdjMzirMs54EJwtEGQpKFmDBGcKgbjPiYId5Nqb/yDhLC/ojgarbLoFJvUKV6dWJePyY7EOycrqcMdiDabdG80Bw4zziQExbmIOdUiscsAVVmA= - on: - tags: true - all_branches: true - repo: SethMMorton/natsort - python: 2.7 - distributions: "sdist bdist_wheel" - docs_dir: build/sphinx/html +# before_deploy: +# - pip install Sphinx numpydoc +# - python setup.py build_sphinx +# deploy: +# provider: pypi +# user: SethMMorton +# password: +# secure: OaYQtVh4mGT0ozN7Ar2lSm2IEVMKIyvOESGPGLwVyVxPqp6oC101MovJ7041bZdjMzirMs54EJwtEGQpKFmDBGcKgbjPiYId5Nqb/yDhLC/ojgarbLoFJvUKV6dWJePyY7EOycrqcMdiDabdG80Bw4zziQExbmIOdUiscsAVVmA= +# on: +# tags: true +# all_branches: true +# repo: SethMMorton/natsort +# python: 2.7 +# distributions: "sdist bdist_wheel" +# docs_dir: build/sphinx/html -- cgit v1.2.1 From 013f9090000714506af105e6b590e759b326a48e Mon Sep 17 00:00:00 2001 From: Seth M Morton Date: Tue, 12 Aug 2014 23:20:24 -0700 Subject: Updated documentation and upped version. --- README.rst | 27 ++++++++++++++++++++------- docs/source/changelog.rst | 9 +++++++++ docs/source/intro.rst | 7 +++++++ natsort/_version.py | 2 +- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 6b664ab..4a9a71c 100644 --- a/README.rst +++ b/README.rst @@ -84,6 +84,16 @@ Requirements (this includes python 3.x). To run version 2.6, 3.0, or 3.1 the `argparse `_ module is required. +Optional Dependency +------------------- + +The most efficient sorting can occur if you install the +`fastnumbers `_ package (it helps +with the string to number conversions.) ``natsort`` will still run (efficiently) +without the package, but if you need to squeeze out that extra juice it is +recommended you include this as a dependency. ``natsort`` will not require (or +check) that `fastnumbers `_ is installed. + Depreciation Notices -------------------- @@ -106,7 +116,16 @@ History ------- These are the last three entries of the changelog. See the package documentation -for the complete changelog. +for the complete `changelog `_. + +08-12-2014 v. 3.4.1 +''''''''''''''''''' + + - 'natsort' will now use the 'fastnumbers' module if it is installed. This + gives up to an extra 30% boost in speed over the previous performance + enhancements. + - Made documentation point to more 'natsort' resources, and also added a + new example in the examples section. 07-19-2014 v. 3.4.0 ''''''''''''''''''' @@ -151,9 +170,3 @@ for the complete changelog. - Made docstrings for public functions mirror the README API. - Connected natsort development to Travis-CI to help ensure quality releases. - -06-20-2014 v. 3.2.1 -''''''''''''''''''' - - - Re-"Fixed" unorderable types issue on Python 3.x - this workaround - is for when the problem occurs in the middle of the string. diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 807bfe5..c4f8c30 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -3,6 +3,15 @@ Changelog --------- +08-12-2014 v. 3.4.1 +''''''''''''''''''' + + - 'natsort' will now use the 'fastnumbers' module if it is installed. This + gives up to an extra 30% boost in speed over the previous performance + enhancements. + - Made documentation point to more 'natsort' resources, and also added a + new example in the examples section. + 07-19-2014 v. 3.4.0 ''''''''''''''''''' diff --git a/docs/source/intro.rst b/docs/source/intro.rst index 257c49a..3348356 100644 --- a/docs/source/intro.rst +++ b/docs/source/intro.rst @@ -112,6 +112,13 @@ If you want to build this documentation, enter:: (this includes python 3.x). To run version 2.6, 3.0, or 3.1 the `argparse `_ module is required. +The most efficient sorting can occur if you install the +`fastnumbers `_ package (it helps +with the string to number conversions.) ``natsort`` will still run (efficiently) +without the package, but if you need to squeeze out that extra juice it is +recommended you include this as a dependency. ``natsort`` will not require (or +check) that `fastnumbers `_ is installed. + :mod:`natsort` comes with a shell script called :mod:`natsort`, or can also be called from the command line with ``python -m natsort``. The command line script is only installed onto your ``PATH`` if you don't install via a wheel. There is diff --git a/natsort/_version.py b/natsort/_version.py index d220a20..d364806 100644 --- a/natsort/_version.py +++ b/natsort/_version.py @@ -2,4 +2,4 @@ from __future__ import (print_function, division, unicode_literals, absolute_import) -__version__ = '3.4.0' +__version__ = '3.4.1' -- cgit v1.2.1