@@ -265,4 +265,95 @@ def assertAllNotClose(examples, *args, **kwargs):
265
265
assert math .fmod (3.0 , NINF ) == 3.0
266
266
assert math .fmod (- 3.0 , NINF ) == - 3.0
267
267
assert math .fmod (0.0 , 3.0 ) == 0.0
268
- assert math .fmod (0.0 , NINF ) == 0.0
268
+ assert math .fmod (0.0 , NINF ) == 0.0
269
+
270
+ """
271
+ TODO: math.remainder was added to CPython in 3.7 and RustPython CI runs on 3.6.
272
+ So put the tests of math.remainder in a comment for now.
273
+ https://github.com/RustPython/RustPython/pull/1589#issuecomment-551424940
274
+ """
275
+
276
+ # testcases = [
277
+ # # Remainders modulo 1, showing the ties-to-even behaviour.
278
+ # '-4.0 1 -0.0',
279
+ # '-3.8 1 0.8',
280
+ # '-3.0 1 -0.0',
281
+ # '-2.8 1 -0.8',
282
+ # '-2.0 1 -0.0',
283
+ # '-1.8 1 0.8',
284
+ # '-1.0 1 -0.0',
285
+ # '-0.8 1 -0.8',
286
+ # '-0.0 1 -0.0',
287
+ # ' 0.0 1 0.0',
288
+ # ' 0.8 1 0.8',
289
+ # ' 1.0 1 0.0',
290
+ # ' 1.8 1 -0.8',
291
+ # ' 2.0 1 0.0',
292
+ # ' 2.8 1 0.8',
293
+ # ' 3.0 1 0.0',
294
+ # ' 3.8 1 -0.8',
295
+ # ' 4.0 1 0.0',
296
+
297
+ # # Reductions modulo 2*pi
298
+ # '0x0.0p+0 0x1.921fb54442d18p+2 0x0.0p+0',
299
+ # '0x1.921fb54442d18p+0 0x1.921fb54442d18p+2 0x1.921fb54442d18p+0',
300
+ # '0x1.921fb54442d17p+1 0x1.921fb54442d18p+2 0x1.921fb54442d17p+1',
301
+ # '0x1.921fb54442d18p+1 0x1.921fb54442d18p+2 0x1.921fb54442d18p+1',
302
+ # '0x1.921fb54442d19p+1 0x1.921fb54442d18p+2 -0x1.921fb54442d17p+1',
303
+ # '0x1.921fb54442d17p+2 0x1.921fb54442d18p+2 -0x0.0000000000001p+2',
304
+ # '0x1.921fb54442d18p+2 0x1.921fb54442d18p+2 0x0p0',
305
+ # '0x1.921fb54442d19p+2 0x1.921fb54442d18p+2 0x0.0000000000001p+2',
306
+ # '0x1.2d97c7f3321d1p+3 0x1.921fb54442d18p+2 0x1.921fb54442d14p+1',
307
+ # '0x1.2d97c7f3321d2p+3 0x1.921fb54442d18p+2 -0x1.921fb54442d18p+1',
308
+ # '0x1.2d97c7f3321d3p+3 0x1.921fb54442d18p+2 -0x1.921fb54442d14p+1',
309
+ # '0x1.921fb54442d17p+3 0x1.921fb54442d18p+2 -0x0.0000000000001p+3',
310
+ # '0x1.921fb54442d18p+3 0x1.921fb54442d18p+2 0x0p0',
311
+ # '0x1.921fb54442d19p+3 0x1.921fb54442d18p+2 0x0.0000000000001p+3',
312
+ # '0x1.f6a7a2955385dp+3 0x1.921fb54442d18p+2 0x1.921fb54442d14p+1',
313
+ # '0x1.f6a7a2955385ep+3 0x1.921fb54442d18p+2 0x1.921fb54442d18p+1',
314
+ # '0x1.f6a7a2955385fp+3 0x1.921fb54442d18p+2 -0x1.921fb54442d14p+1',
315
+ # '0x1.1475cc9eedf00p+5 0x1.921fb54442d18p+2 0x1.921fb54442d10p+1',
316
+ # '0x1.1475cc9eedf01p+5 0x1.921fb54442d18p+2 -0x1.921fb54442d10p+1',
317
+
318
+ # # Symmetry with respect to signs.
319
+ # ' 1 0.c 0.4',
320
+ # '-1 0.c -0.4',
321
+ # ' 1 -0.c 0.4',
322
+ # '-1 -0.c -0.4',
323
+ # ' 1.4 0.c -0.4',
324
+ # '-1.4 0.c 0.4',
325
+ # ' 1.4 -0.c -0.4',
326
+ # '-1.4 -0.c 0.4',
327
+
328
+ # # Huge modulus, to check that the underlying algorithm doesn't
329
+ # # rely on 2.0 * modulus being representable.
330
+ # '0x1.dp+1023 0x1.4p+1023 0x0.9p+1023',
331
+ # '0x1.ep+1023 0x1.4p+1023 -0x0.ap+1023',
332
+ # '0x1.fp+1023 0x1.4p+1023 -0x0.9p+1023',
333
+ # ]
334
+
335
+ # for case in testcases:
336
+ # x_hex, y_hex, expected_hex = case.split()
337
+ # # print(x_hex, y_hex, expected_hex)
338
+ # x = float.fromhex(x_hex)
339
+ # y = float.fromhex(y_hex)
340
+ # expected = float.fromhex(expected_hex)
341
+ # actual = math.remainder(x, y)
342
+ # # Cheap way of checking that the floats are
343
+ # # as identical as we need them to be.
344
+ # assert actual.hex() == expected.hex()
345
+ # # self.assertEqual(actual.hex(), expected.hex())
346
+
347
+
348
+ # # Test tiny subnormal modulus: there's potential for
349
+ # # getting the implementation wrong here (for example,
350
+ # # by assuming that modulus/2 is exactly representable).
351
+ # tiny = float.fromhex('1p-1074') # min +ve subnormal
352
+ # for n in range(-25, 25):
353
+ # if n == 0:
354
+ # continue
355
+ # y = n * tiny
356
+ # for m in range(100):
357
+ # x = m * tiny
358
+ # actual = math.remainder(x, y)
359
+ # actual = math.remainder(-x, y)
0 commit comments