Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
00414597
Unverified
Kaydet (Commit)
00414597
authored
Agu 12, 2018
tarafından
Raymond Hettinger
Kaydeden (comit)
GitHub
Agu 12, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add more tests and assertions for math.hypot() and math.dist() (GH-8747)
üst
4d12e4dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
test_math.py
Lib/test/test_math.py
+12
-5
mathmodule.c
Modules/mathmodule.c
+1
-0
No files found.
Lib/test/test_math.py
Dosyayı görüntüle @
00414597
...
...
@@ -751,6 +751,10 @@ class MathTests(unittest.TestCase):
self
.
assertEqual
(
1.0
,
math
.
copysign
(
1.0
,
hypot
(
-
0.0
))
# Convert negative zero to positive zero
)
self
.
assertEqual
(
# Handling of moving max to the end
hypot
(
1.5
,
1.5
,
0.5
),
hypot
(
1.5
,
0.5
,
1.5
),
)
# Test handling of bad arguments
with
self
.
assertRaises
(
TypeError
):
# Reject keyword args
...
...
@@ -771,7 +775,7 @@ class MathTests(unittest.TestCase):
self
.
assertEqual
(
hypot
(
-
INF
,
-
INF
),
INF
)
self
.
assertEqual
(
hypot
(
10
,
-
INF
),
INF
)
# If no infinity, any NaN gives a Na
n
.
# If no infinity, any NaN gives a Na
N
.
self
.
assertTrue
(
math
.
isnan
(
hypot
(
NAN
)))
self
.
assertTrue
(
math
.
isnan
(
hypot
(
0
,
NAN
)))
self
.
assertTrue
(
math
.
isnan
(
hypot
(
NAN
,
10
)))
...
...
@@ -831,9 +835,13 @@ class MathTests(unittest.TestCase):
self
.
assertEqual
(
1.0
,
# Convert negative zero to positive zero
math
.
copysign
(
1.0
,
dist
((
0.0
,),
(
-
0.0
,)))
)
self
.
assertEqual
(
# Handling of moving max to the end
dist
((
1.5
,
1.5
,
0.5
),
(
0
,
0
,
0
)),
dist
((
1.5
,
0.5
,
1.5
),
(
0
,
0
,
0
))
)
# Verify tuple subclasses are allowed
class
T
(
tuple
):
# tuple subclas
class
T
(
tuple
):
pass
self
.
assertEqual
(
dist
(
T
((
1
,
2
,
3
)),
((
4
,
2
,
-
1
))),
5.0
)
...
...
@@ -855,8 +863,7 @@ class MathTests(unittest.TestCase):
with
self
.
assertRaises
(
ValueError
):
# Check dimension agree
dist
((
1
,
2
,
3
),
(
4
,
5
,
6
,
7
))
# Verify that the one dimensional case equivalent to abs()
# Verify that the one dimensional case is equivalent to abs()
for
i
in
range
(
20
):
p
,
q
=
random
.
random
(),
random
.
random
()
self
.
assertEqual
(
dist
((
p
,),
(
q
,)),
abs
(
p
-
q
))
...
...
@@ -870,7 +877,7 @@ class MathTests(unittest.TestCase):
# Any infinite difference gives positive infinity.
self
.
assertEqual
(
dist
(
p
,
q
),
INF
)
elif
any
(
map
(
math
.
isnan
,
diffs
)):
# If no infinity, any NaN gives a Na
n
.
# If no infinity, any NaN gives a Na
N
.
self
.
assertTrue
(
math
.
isnan
(
dist
(
p
,
q
)))
# Verify scaling for extremely large values
...
...
Modules/mathmodule.c
Dosyayı görüntüle @
00414597
...
...
@@ -2071,6 +2071,7 @@ vector_norm(Py_ssize_t n, double *vec, double max, int found_nan)
assert
(
n
>
0
);
for
(
i
=
0
;
i
<
n
-
1
;
i
++
)
{
x
=
vec
[
i
];
assert
(
Py_IS_FINITE
(
x
)
&&
x
>=
0
.
0
&&
x
<=
max
);
if
(
x
==
max
)
{
x
=
vec
[
n
-
1
];
vec
[
n
-
1
]
=
max
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment