diff --git a/doc/v2/slice.html b/doc/v2/slice.html index 8831d971..fb6b47c7 100644 --- a/doc/v2/slice.html +++ b/doc/v2/slice.html @@ -85,7 +85,7 @@ namespace boost { namespace python object stop(); object step(); - // The return type of slice::get_indicies() + // The return type of slice::get_indices() template <typename RandomAccessIterator> struct range { @@ -96,7 +96,7 @@ namespace boost { namespace python template <typename RandomAccessIterator> range<RandomAccessIterator> - get_indicies( + get_indices( RandomAccessIterator const& begin, RandomAccessIterator const& end); }; @@ -164,7 +164,7 @@ slice object, but in practice they are usually integers.
 template <typename RandomAccessIterator>
 slice::range<RandomAccessIterator>
-slice::get_indicies( 
+slice::get_indices( 
     RandomAccessIterator const& begin, 
     RandomAccessIterator const& end) const;
 
@@ -173,8 +173,8 @@ slice::get_indicies( Iterators that form a half-open range.
Effects: Create a RandomAccessIterator pair that defines a fully-closed range within the [begin,end) range of its arguments.  -This function translates this slice's indicies while accounting for the -effects of any PyNone or negative indicies, and non-singular step sizes.
+This function translates this slice's indices while accounting for the +effects of any PyNone or negative indices, and non-singular step sizes.
Returns: a slice::range that has been initialized with a non-zero value of step and a pair of RandomAccessIterators that point within the range of this functions @@ -182,7 +182,7 @@ arguments and define a closed interval.
Throws: Raises a Python TypeError exception if any of this slice's arguments are neither references to PyNone nor convertible to int.  Throws std::invalid_argument if the resulting range would be empty.  You -should always wrap calls to slice::get_indicies() +should always wrap calls to slice::get_indices() within try { ...; } catch (std::invalid_argument) {} to handle this case and take appropriate action.
Rationale: closed-interval: If @@ -221,7 +221,7 @@ double partial_sum(std::vector<double> const& Foo, const slice index) { slice::range<std::vector<double>::const_iterator> bounds; try { - bounds = index.get_indicies<>(Foo.begin(), Foo.end()); + bounds = index.get_indices<>(Foo.begin(), Foo.end()); } catch (std::invalid_argument) { return 0.0; diff --git a/include/boost/python/slice.hpp b/include/boost/python/slice.hpp index 382ceb81..4fc62418 100644 --- a/include/boost/python/slice.hpp +++ b/include/boost/python/slice.hpp @@ -30,7 +30,7 @@ namespace detail // that created this slice, than that parameter is None here, and compares // equal to a default-constructed boost::python::object. // If a user-defined type wishes to support slicing, then support for the - // special meaning associated with negative indicies is up to the user. + // special meaning associated with negative indices is up to the user. object start() const; object stop() const; object step() const; @@ -63,7 +63,7 @@ class slice : public detail::slice_base // The following algorithm is intended to automate the process of // determining a slice range when you want to fully support negative - // indicies and non-singular step sizes. Its functionallity is simmilar to + // indices and non-singular step sizes. Its functionallity is simmilar to // PySlice_GetIndicesEx() in the Python/C API, but tailored for C++ users. // This template returns a slice::range struct that, when used in the // following iterative loop, will traverse a slice of the function's @@ -110,7 +110,7 @@ class slice : public detail::slice_base template slice::range - get_indicies( const RandomAccessIterator& begin, + get_indices( const RandomAccessIterator& begin, const RandomAccessIterator& end) const { // This is based loosely on PySlice_GetIndicesEx(), but it has been @@ -240,6 +240,16 @@ class slice : public detail::slice_base return ret; } + + // Incorrect spelling. DO NOT USE. Only here for backward compatibility. + // Corrected 2011-06-14. + template + slice::range + get_indicies( const RandomAccessIterator& begin, + const RandomAccessIterator& end) const + { + get_indices(begin, end); + } public: // This declaration, in conjunction with the specialization of diff --git a/test/slice.cpp b/test/slice.cpp index 032bf7cf..5072d7f7 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -98,9 +98,9 @@ bool accept_slice( slice) { return true; } #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1400)) \ || BOOST_WORKAROUND( BOOST_INTEL_WIN, == 710) -int check_slice_get_indicies(slice index); +int check_slice_get_indices(slice index); #endif -int check_slice_get_indicies( +int check_slice_get_indices( #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) const #endif @@ -116,7 +116,7 @@ int check_slice_get_indicies( slice::range::iterator> bounds; try { - bounds = index.get_indicies(coll.begin(), coll.end()); + bounds = index.get_indices(coll.begin(), coll.end()); } catch (std::invalid_argument) { return 0; @@ -136,5 +136,5 @@ BOOST_PYTHON_MODULE(slice_ext) def( "accept_slice", accept_slice); def( "check_numeric_array_rich_slice", check_numeric_array_rich_slice); def( "check_string_rich_slice", check_string_rich_slice); - def( "check_slice_get_indicies", check_slice_get_indicies); + def( "check_slice_get_indices", check_slice_get_indices); } diff --git a/test/slice.py b/test/slice.py index c281845b..95f4883b 100644 --- a/test/slice.py +++ b/test/slice.py @@ -37,17 +37,17 @@ test passed ... print 1 ... 1 ->>> check_slice_get_indicies( slice(None)) +>>> check_slice_get_indices( slice(None)) 0 ->>> check_slice_get_indicies( slice(2,-2)) +>>> check_slice_get_indices( slice(2,-2)) 0 ->>> check_slice_get_indicies( slice(2, None, 2)) +>>> check_slice_get_indices( slice(2, None, 2)) 5 ->>> check_slice_get_indicies( slice(2, None, -1)) +>>> check_slice_get_indices( slice(2, None, -1)) -12 ->>> check_slice_get_indicies( slice( 20, None)) +>>> check_slice_get_indices( slice( 20, None)) 0 ->>> check_slice_get_indicies( slice( -2, -5, -2)) +>>> check_slice_get_indices( slice( -2, -5, -2)) 6 """