Skip to content

Commit a48ec3e

Browse files
authored
Words matter updates (#4155)
* Remove sanity check from code base. * Use main over master. * Better alternative that doesn't collide with language keywords/frequent usage words.
1 parent 68e6fda commit a48ec3e

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

include/pybind11/numpy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ PYBIND11_NOINLINE void register_structured_dtype(any_container<field_descriptor>
14011401
oss << '}';
14021402
auto format_str = oss.str();
14031403

1404-
// Sanity check: verify that NumPy properly parses our buffer format string
1404+
// Smoke test: verify that NumPy properly parses our buffer format string
14051405
auto &api = npy_api::get();
14061406
auto arr = array(buffer_info(nullptr, itemsize, format_str, 1));
14071407
if (!api.PyArray_EquivTypes_(dtype_ptr, arr.dtype().ptr())) {

tests/test_eigen.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ def array_copy_but_one(a, r, c, v):
251251
def test_eigen_return_references():
252252
"""Tests various ways of returning references and non-referencing copies"""
253253

254-
master = np.ones((10, 10))
254+
primary = np.ones((10, 10))
255255
a = m.ReturnTester()
256256
a_get1 = a.get()
257257
assert not a_get1.flags.owndata and a_get1.flags.writeable
258-
assign_both(a_get1, master, 3, 3, 5)
258+
assign_both(a_get1, primary, 3, 3, 5)
259259
a_get2 = a.get_ptr()
260260
assert not a_get2.flags.owndata and a_get2.flags.writeable
261-
assign_both(a_get1, master, 2, 3, 6)
261+
assign_both(a_get1, primary, 2, 3, 6)
262262

263263
a_view1 = a.view()
264264
assert not a_view1.flags.owndata and not a_view1.flags.writeable
@@ -271,91 +271,91 @@ def test_eigen_return_references():
271271

272272
a_copy1 = a.copy_get()
273273
assert a_copy1.flags.owndata and a_copy1.flags.writeable
274-
np.testing.assert_array_equal(a_copy1, master)
274+
np.testing.assert_array_equal(a_copy1, primary)
275275
a_copy1[7, 7] = -44 # Shouldn't affect anything else
276-
c1want = array_copy_but_one(master, 7, 7, -44)
276+
c1want = array_copy_but_one(primary, 7, 7, -44)
277277
a_copy2 = a.copy_view()
278278
assert a_copy2.flags.owndata and a_copy2.flags.writeable
279-
np.testing.assert_array_equal(a_copy2, master)
279+
np.testing.assert_array_equal(a_copy2, primary)
280280
a_copy2[4, 4] = -22 # Shouldn't affect anything else
281-
c2want = array_copy_but_one(master, 4, 4, -22)
281+
c2want = array_copy_but_one(primary, 4, 4, -22)
282282

283283
a_ref1 = a.ref()
284284
assert not a_ref1.flags.owndata and a_ref1.flags.writeable
285-
assign_both(a_ref1, master, 1, 1, 15)
285+
assign_both(a_ref1, primary, 1, 1, 15)
286286
a_ref2 = a.ref_const()
287287
assert not a_ref2.flags.owndata and not a_ref2.flags.writeable
288288
with pytest.raises(ValueError):
289289
a_ref2[5, 5] = 33
290290
a_ref3 = a.ref_safe()
291291
assert not a_ref3.flags.owndata and a_ref3.flags.writeable
292-
assign_both(a_ref3, master, 0, 7, 99)
292+
assign_both(a_ref3, primary, 0, 7, 99)
293293
a_ref4 = a.ref_const_safe()
294294
assert not a_ref4.flags.owndata and not a_ref4.flags.writeable
295295
with pytest.raises(ValueError):
296296
a_ref4[7, 0] = 987654321
297297

298298
a_copy3 = a.copy_ref()
299299
assert a_copy3.flags.owndata and a_copy3.flags.writeable
300-
np.testing.assert_array_equal(a_copy3, master)
300+
np.testing.assert_array_equal(a_copy3, primary)
301301
a_copy3[8, 1] = 11
302-
c3want = array_copy_but_one(master, 8, 1, 11)
302+
c3want = array_copy_but_one(primary, 8, 1, 11)
303303
a_copy4 = a.copy_ref_const()
304304
assert a_copy4.flags.owndata and a_copy4.flags.writeable
305-
np.testing.assert_array_equal(a_copy4, master)
305+
np.testing.assert_array_equal(a_copy4, primary)
306306
a_copy4[8, 4] = 88
307-
c4want = array_copy_but_one(master, 8, 4, 88)
307+
c4want = array_copy_but_one(primary, 8, 4, 88)
308308

309309
a_block1 = a.block(3, 3, 2, 2)
310310
assert not a_block1.flags.owndata and a_block1.flags.writeable
311311
a_block1[0, 0] = 55
312-
master[3, 3] = 55
312+
primary[3, 3] = 55
313313
a_block2 = a.block_safe(2, 2, 3, 2)
314314
assert not a_block2.flags.owndata and a_block2.flags.writeable
315315
a_block2[2, 1] = -123
316-
master[4, 3] = -123
316+
primary[4, 3] = -123
317317
a_block3 = a.block_const(6, 7, 4, 3)
318318
assert not a_block3.flags.owndata and not a_block3.flags.writeable
319319
with pytest.raises(ValueError):
320320
a_block3[2, 2] = -44444
321321

322322
a_copy5 = a.copy_block(2, 2, 2, 3)
323323
assert a_copy5.flags.owndata and a_copy5.flags.writeable
324-
np.testing.assert_array_equal(a_copy5, master[2:4, 2:5])
324+
np.testing.assert_array_equal(a_copy5, primary[2:4, 2:5])
325325
a_copy5[1, 1] = 777
326-
c5want = array_copy_but_one(master[2:4, 2:5], 1, 1, 777)
326+
c5want = array_copy_but_one(primary[2:4, 2:5], 1, 1, 777)
327327

328328
a_corn1 = a.corners()
329329
assert not a_corn1.flags.owndata and a_corn1.flags.writeable
330330
a_corn1 *= 50
331331
a_corn1[1, 1] = 999
332-
master[0, 0] = 50
333-
master[0, 9] = 50
334-
master[9, 0] = 50
335-
master[9, 9] = 999
332+
primary[0, 0] = 50
333+
primary[0, 9] = 50
334+
primary[9, 0] = 50
335+
primary[9, 9] = 999
336336
a_corn2 = a.corners_const()
337337
assert not a_corn2.flags.owndata and not a_corn2.flags.writeable
338338
with pytest.raises(ValueError):
339339
a_corn2[1, 0] = 51
340340

341341
# All of the changes made all the way along should be visible everywhere
342342
# now (except for the copies, of course)
343-
np.testing.assert_array_equal(a_get1, master)
344-
np.testing.assert_array_equal(a_get2, master)
345-
np.testing.assert_array_equal(a_view1, master)
346-
np.testing.assert_array_equal(a_view2, master)
347-
np.testing.assert_array_equal(a_ref1, master)
348-
np.testing.assert_array_equal(a_ref2, master)
349-
np.testing.assert_array_equal(a_ref3, master)
350-
np.testing.assert_array_equal(a_ref4, master)
351-
np.testing.assert_array_equal(a_block1, master[3:5, 3:5])
352-
np.testing.assert_array_equal(a_block2, master[2:5, 2:4])
353-
np.testing.assert_array_equal(a_block3, master[6:10, 7:10])
343+
np.testing.assert_array_equal(a_get1, primary)
344+
np.testing.assert_array_equal(a_get2, primary)
345+
np.testing.assert_array_equal(a_view1, primary)
346+
np.testing.assert_array_equal(a_view2, primary)
347+
np.testing.assert_array_equal(a_ref1, primary)
348+
np.testing.assert_array_equal(a_ref2, primary)
349+
np.testing.assert_array_equal(a_ref3, primary)
350+
np.testing.assert_array_equal(a_ref4, primary)
351+
np.testing.assert_array_equal(a_block1, primary[3:5, 3:5])
352+
np.testing.assert_array_equal(a_block2, primary[2:5, 2:4])
353+
np.testing.assert_array_equal(a_block3, primary[6:10, 7:10])
354354
np.testing.assert_array_equal(
355-
a_corn1, master[0 :: master.shape[0] - 1, 0 :: master.shape[1] - 1]
355+
a_corn1, primary[0 :: primary.shape[0] - 1, 0 :: primary.shape[1] - 1]
356356
)
357357
np.testing.assert_array_equal(
358-
a_corn2, master[0 :: master.shape[0] - 1, 0 :: master.shape[1] - 1]
358+
a_corn2, primary[0 :: primary.shape[0] - 1, 0 :: primary.shape[1] - 1]
359359
)
360360

361361
np.testing.assert_array_equal(a_copy1, c1want)

0 commit comments

Comments
 (0)