Skip to content

Commit 3e409f9

Browse files
author
Ralf W. Grosse-Kunstleve
committed
boost/python/slice.hpp: correct long-standing spelling error; affects interface; keeping old interface for backward compatibility
[SVN r72602]
1 parent 1212a14 commit 3e409f9

File tree

4 files changed

+30
-20
lines changed

4 files changed

+30
-20
lines changed

doc/v2/slice.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ <h4><a name="slice-spec-synopsis"></a>Class <code>slice</code> synopsis</h4>
8585
object stop();
8686
object step();
8787

88-
// The return type of slice::get_indicies()
88+
// The return type of slice::get_indices()
8989
template &lt;typename RandomAccessIterator&gt;
9090
struct range
9191
{
@@ -96,7 +96,7 @@ <h4><a name="slice-spec-synopsis"></a>Class <code>slice</code> synopsis</h4>
9696

9797
template &lt;typename RandomAccessIterator&gt;
9898
range&lt;RandomAccessIterator&gt;
99-
get_indicies(
99+
get_indices(
100100
RandomAccessIterator const&amp; begin,
101101
RandomAccessIterator const&amp; end);
102102
};
@@ -164,7 +164,7 @@ <h4><a name="slice-spec-observers"></a>Class <code>slice</code>
164164
<pre>
165165
template &lt;typename RandomAccessIterator&gt;
166166
slice::range&lt;RandomAccessIterator&gt;
167-
slice::get_indicies(
167+
slice::get_indices(
168168
RandomAccessIterator const&amp; begin,
169169
RandomAccessIterator const&amp; end) const;
170170
</pre>
@@ -173,16 +173,16 @@ <h4><a name="slice-spec-observers"></a>Class <code>slice</code>
173173
Iterators that form a half-open range.</dt>
174174
<dt><b>Effects:</b> Create a RandomAccessIterator pair that defines a
175175
fully-closed range within the [begin,end) range of its arguments.&nbsp;
176-
This function translates this slice's indicies while accounting for the
177-
effects of any PyNone or negative indicies, and non-singular step sizes.</dt>
176+
This function translates this slice's indices while accounting for the
177+
effects of any PyNone or negative indices, and non-singular step sizes.</dt>
178178
<dt><b>Returns:</b> a slice::range
179179
that has been initialized with a non-zero value of step and a pair of
180180
RandomAccessIterators that point within the range of this functions
181181
arguments and define a closed interval.</dt>
182182
<dt><b>Throws:</b> <a href="definitions.html#raise">Raises</a> a Python <code>TypeError</code> exception if any of this slice's arguments
183183
are neither references to <code>PyNone</code> nor convertible to <code>int</code>.&nbsp; Throws
184184
<code>std::invalid_argument</code> if the resulting range would be empty.&nbsp; You
185-
should always wrap calls to <code>slice::get_indicies()</code>
185+
should always wrap calls to <code>slice::get_indices()</code>
186186
within <code>try { ...; } catch (std::invalid_argument) {}</code> to
187187
handle this case and take appropriate action.</dt>
188188
<dt><b>Rationale</b>: closed-interval: If
@@ -221,7 +221,7 @@ <h2><a name="examples"></a><b>Examples</b></h2>
221221
{
222222
slice::range&lt;std::vector&lt;double&gt;::const_iterator&gt; bounds;
223223
try {
224-
bounds = index.get_indicies&lt;&gt;(Foo.begin(), Foo.end());
224+
bounds = index.get_indices&lt;&gt;(Foo.begin(), Foo.end());
225225
}
226226
catch (std::invalid_argument) {
227227
return 0.0;

include/boost/python/slice.hpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace detail
3030
// that created this slice, than that parameter is None here, and compares
3131
// equal to a default-constructed boost::python::object.
3232
// If a user-defined type wishes to support slicing, then support for the
33-
// special meaning associated with negative indicies is up to the user.
33+
// special meaning associated with negative indices is up to the user.
3434
object start() const;
3535
object stop() const;
3636
object step() const;
@@ -63,7 +63,7 @@ class slice : public detail::slice_base
6363

6464
// The following algorithm is intended to automate the process of
6565
// determining a slice range when you want to fully support negative
66-
// indicies and non-singular step sizes. Its functionallity is simmilar to
66+
// indices and non-singular step sizes. Its functionallity is simmilar to
6767
// PySlice_GetIndicesEx() in the Python/C API, but tailored for C++ users.
6868
// This template returns a slice::range struct that, when used in the
6969
// following iterative loop, will traverse a slice of the function's
@@ -110,7 +110,7 @@ class slice : public detail::slice_base
110110

111111
template<typename RandomAccessIterator>
112112
slice::range<RandomAccessIterator>
113-
get_indicies( const RandomAccessIterator& begin,
113+
get_indices( const RandomAccessIterator& begin,
114114
const RandomAccessIterator& end) const
115115
{
116116
// This is based loosely on PySlice_GetIndicesEx(), but it has been
@@ -240,6 +240,16 @@ class slice : public detail::slice_base
240240

241241
return ret;
242242
}
243+
244+
// Incorrect spelling. DO NOT USE. Only here for backward compatibility.
245+
// Corrected 2011-06-14.
246+
template<typename RandomAccessIterator>
247+
slice::range<RandomAccessIterator>
248+
get_indicies( const RandomAccessIterator& begin,
249+
const RandomAccessIterator& end) const
250+
{
251+
get_indices(begin, end);
252+
}
243253

244254
public:
245255
// This declaration, in conjunction with the specialization of

test/slice.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ bool accept_slice( slice) { return true; }
9898

9999
#if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1400)) \
100100
|| BOOST_WORKAROUND( BOOST_INTEL_WIN, == 710)
101-
int check_slice_get_indicies(slice index);
101+
int check_slice_get_indices(slice index);
102102
#endif
103-
int check_slice_get_indicies(
103+
int check_slice_get_indices(
104104
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
105105
const
106106
#endif
@@ -116,7 +116,7 @@ int check_slice_get_indicies(
116116

117117
slice::range<std::vector<int>::iterator> bounds;
118118
try {
119-
bounds = index.get_indicies(coll.begin(), coll.end());
119+
bounds = index.get_indices(coll.begin(), coll.end());
120120
}
121121
catch (std::invalid_argument) {
122122
return 0;
@@ -136,5 +136,5 @@ BOOST_PYTHON_MODULE(slice_ext)
136136
def( "accept_slice", accept_slice);
137137
def( "check_numeric_array_rich_slice", check_numeric_array_rich_slice);
138138
def( "check_string_rich_slice", check_string_rich_slice);
139-
def( "check_slice_get_indicies", check_slice_get_indicies);
139+
def( "check_slice_get_indices", check_slice_get_indices);
140140
}

test/slice.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@
3737
... print 1
3838
...
3939
1
40-
>>> check_slice_get_indicies( slice(None))
40+
>>> check_slice_get_indices( slice(None))
4141
0
42-
>>> check_slice_get_indicies( slice(2,-2))
42+
>>> check_slice_get_indices( slice(2,-2))
4343
0
44-
>>> check_slice_get_indicies( slice(2, None, 2))
44+
>>> check_slice_get_indices( slice(2, None, 2))
4545
5
46-
>>> check_slice_get_indicies( slice(2, None, -1))
46+
>>> check_slice_get_indices( slice(2, None, -1))
4747
-12
48-
>>> check_slice_get_indicies( slice( 20, None))
48+
>>> check_slice_get_indices( slice( 20, None))
4949
0
50-
>>> check_slice_get_indicies( slice( -2, -5, -2))
50+
>>> check_slice_get_indices( slice( -2, -5, -2))
5151
6
5252
"""
5353

0 commit comments

Comments
 (0)