test_hyp2f1.py 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566
  1. """Tests for hyp2f1 for complex values.
  2. Author: Albert Steppi, with credit to Adam Kullberg (FormerPhycisist) for
  3. the implementation of mp_hyp2f1 below, which modifies mpmath's hyp2f1 to
  4. return the same branch as scipy's on the standard branch cut.
  5. """
  6. import sys
  7. import pytest
  8. import numpy as np
  9. from typing import NamedTuple
  10. from numpy.testing import assert_allclose
  11. from scipy.special import hyp2f1
  12. from scipy.special._testutils import check_version, MissingModule
  13. try:
  14. import mpmath
  15. except ImportError:
  16. mpmath = MissingModule("mpmath")
  17. def mp_hyp2f1(a, b, c, z):
  18. """Return mpmath hyp2f1 calculated on same branch as scipy hyp2f1.
  19. For most values of a,b,c mpmath returns the x - 0j branch of hyp2f1 on the
  20. branch cut x=(1,inf) whereas scipy's hyp2f1 calculates the x + 0j branch.
  21. Thus, to generate the right comparison values on the branch cut, we
  22. evaluate mpmath.hyp2f1 at x + 1e-15*j.
  23. The exception to this occurs when c-a=-m in which case both mpmath and
  24. scipy calculate the x + 0j branch on the branch cut. When this happens
  25. mpmath.hyp2f1 will be evaluated at the original z point.
  26. """
  27. on_branch_cut = z.real > 1.0 and abs(z.imag) < 1.0e-15
  28. cond1 = abs(c - a - round(c - a)) < 1.0e-15 and round(c - a) <= 0
  29. cond2 = abs(c - b - round(c - b)) < 1.0e-15 and round(c - b) <= 0
  30. # Make sure imaginary part is *exactly* zero
  31. if on_branch_cut:
  32. z = z.real + 0.0j
  33. if on_branch_cut and not (cond1 or cond2):
  34. z_mpmath = z.real + 1.0e-15j
  35. else:
  36. z_mpmath = z
  37. return complex(mpmath.hyp2f1(a, b, c, z_mpmath))
  38. class Hyp2f1TestCase(NamedTuple):
  39. a: float
  40. b: float
  41. c: float
  42. z: complex
  43. expected: complex
  44. rtol: float
  45. class TestHyp2f1:
  46. """Tests for hyp2f1 for complex values.
  47. Expected values for test cases were computed using mpmath. See
  48. `scipy.special._precompute.hyp2f1_data`. The verbose style of specifying
  49. test cases is used for readability and to make it easier to mark individual
  50. cases as expected to fail. Expected failures are used to highlight cases
  51. where improvements are needed. See
  52. `scipy.special._precompute.hyp2f1_data.make_hyp2f1_test_cases` for a
  53. function to generate the boilerplate for the test cases.
  54. Assertions have been added to each test to ensure that the test cases match
  55. the situations that are intended. A final test `test_test_hyp2f1` checks
  56. that the expected values in the test cases actually match what is computed
  57. by mpmath. This test is marked slow even though it isn't particularly slow
  58. so that it won't run by default on continuous integration builds.
  59. """
  60. @pytest.mark.parametrize(
  61. "hyp2f1_test_case",
  62. [
  63. pytest.param(
  64. Hyp2f1TestCase(
  65. a=0.5,
  66. b=0.2,
  67. c=-10,
  68. z=0.2 + 0.2j,
  69. expected=np.inf + 0j,
  70. rtol=0
  71. )
  72. ),
  73. pytest.param(
  74. Hyp2f1TestCase(
  75. a=0.5,
  76. b=0.2,
  77. c=-10,
  78. z=0 + 0j,
  79. expected=1 + 0j,
  80. rtol=0
  81. ),
  82. ),
  83. pytest.param(
  84. Hyp2f1TestCase(
  85. a=0.5,
  86. b=0,
  87. c=-10,
  88. z=0.2 + 0.2j,
  89. expected=1 + 0j,
  90. rtol=0
  91. ),
  92. ),
  93. pytest.param(
  94. Hyp2f1TestCase(
  95. a=0.5,
  96. b=0,
  97. c=0,
  98. z=0.2 + 0.2j,
  99. expected=1 + 0j,
  100. rtol=0,
  101. ),
  102. ),
  103. pytest.param(
  104. Hyp2f1TestCase(
  105. a=0.5,
  106. b=0.2,
  107. c=0,
  108. z=0.2 + 0.2j,
  109. expected=np.inf + 0j,
  110. rtol=0,
  111. ),
  112. ),
  113. pytest.param(
  114. Hyp2f1TestCase(
  115. a=0.5,
  116. b=0.2,
  117. c=0,
  118. z=0 + 0j,
  119. expected=np.nan + 0j,
  120. rtol=0,
  121. ),
  122. ),
  123. pytest.param(
  124. Hyp2f1TestCase(
  125. a=0.5,
  126. b=-5,
  127. c=-10,
  128. z=0.2 + 0.2j,
  129. expected=(1.0495404166666666+0.05708208333333334j),
  130. rtol=1e-15,
  131. ),
  132. ),
  133. pytest.param(
  134. Hyp2f1TestCase(
  135. a=0.5,
  136. b=-10,
  137. c=-10,
  138. z=0.2 + 0.2j,
  139. expected=(1.092966013125+0.13455014673750001j),
  140. rtol=1e-15,
  141. ),
  142. ),
  143. pytest.param(
  144. Hyp2f1TestCase(
  145. a=-10,
  146. b=-20,
  147. c=-10,
  148. z=0.2 + 0.2j,
  149. expected=(-0.07712512000000005+0.12752814080000005j),
  150. rtol=1e-13,
  151. ),
  152. ),
  153. pytest.param(
  154. Hyp2f1TestCase(
  155. a=-1,
  156. b=3.2,
  157. c=-1,
  158. z=0.2 + 0.2j,
  159. expected=(1.6400000000000001+0.6400000000000001j),
  160. rtol=1e-13,
  161. ),
  162. ),
  163. pytest.param(
  164. Hyp2f1TestCase(
  165. a=-2,
  166. b=1.2,
  167. c=-4,
  168. z=1 + 0j,
  169. expected=1.8200000000000001 + 0j,
  170. rtol=1e-15,
  171. ),
  172. ),
  173. ]
  174. )
  175. def test_c_non_positive_int(self, hyp2f1_test_case):
  176. a, b, c, z, expected, rtol = hyp2f1_test_case
  177. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  178. @pytest.mark.parametrize(
  179. "hyp2f1_test_case",
  180. [
  181. pytest.param(
  182. Hyp2f1TestCase(
  183. a=0.5,
  184. b=0.2,
  185. c=1.5,
  186. z=1 + 0j,
  187. expected=1.1496439092239847 + 0j,
  188. rtol=1e-15
  189. ),
  190. ),
  191. pytest.param(
  192. Hyp2f1TestCase(
  193. a=12.3,
  194. b=8.0,
  195. c=20.31,
  196. z=1 + 0j,
  197. expected=69280986.75273195 + 0j,
  198. rtol=1e-15
  199. ),
  200. ),
  201. pytest.param(
  202. Hyp2f1TestCase(
  203. a=290.2,
  204. b=321.5,
  205. c=700.1,
  206. z=1 + 0j,
  207. expected=1.3396562400934e117 + 0j,
  208. rtol=1e-12,
  209. ),
  210. ),
  211. # Note that here even mpmath produces different results for
  212. # results that should be equivalent.
  213. pytest.param(
  214. Hyp2f1TestCase(
  215. a=9.2,
  216. b=621.5,
  217. c=700.1,
  218. z=(1+0j),
  219. expected=(952726652.4158565+0j),
  220. rtol=5e-13,
  221. ),
  222. ),
  223. pytest.param(
  224. Hyp2f1TestCase(
  225. a=621.5,
  226. b=9.2,
  227. c=700.1,
  228. z=(1+0j),
  229. expected=(952726652.4160284+0j),
  230. rtol=5e-12,
  231. ),
  232. ),
  233. pytest.param(
  234. Hyp2f1TestCase(
  235. a=-101.2,
  236. b=-400.4,
  237. c=-172.1,
  238. z=(1+0j),
  239. expected=(2.2253618341394838e+37+0j),
  240. rtol=1e-13,
  241. ),
  242. ),
  243. pytest.param(
  244. Hyp2f1TestCase(
  245. a=-400.4,
  246. b=-101.2,
  247. c=-172.1,
  248. z=(1+0j),
  249. expected=(2.2253618341394838e+37+0j),
  250. rtol=5e-13,
  251. ),
  252. ),
  253. pytest.param(
  254. Hyp2f1TestCase(
  255. a=172.5,
  256. b=-201.3,
  257. c=151.2,
  258. z=(1+0j),
  259. expected=(7.072266653650905e-135+0j),
  260. rtol=5e-13,
  261. ),
  262. ),
  263. pytest.param(
  264. Hyp2f1TestCase(
  265. a=-201.3,
  266. b=172.5,
  267. c=151.2,
  268. z=(1+0j),
  269. expected=(7.072266653650905e-135+0j),
  270. rtol=5e-13,
  271. ),
  272. ),
  273. pytest.param(
  274. Hyp2f1TestCase(
  275. a=-102.1,
  276. b=-20.3,
  277. c=1.3,
  278. z=1 + 0j,
  279. expected=2.7899070752746906e22 + 0j,
  280. rtol=3e-14,
  281. ),
  282. ),
  283. pytest.param(
  284. Hyp2f1TestCase(
  285. a=-202.6,
  286. b=60.3,
  287. c=1.5,
  288. z=1 + 0j,
  289. expected=-1.3113641413099326e-56 + 0j,
  290. rtol=1e-12,
  291. ),
  292. ),
  293. ],
  294. )
  295. def test_unital_argument(self, hyp2f1_test_case):
  296. """Tests for case z = 1, c - a - b > 0.
  297. Expected answers computed using mpmath.
  298. """
  299. a, b, c, z, expected, rtol = hyp2f1_test_case
  300. assert z == 1 and c - a - b > 0 # Tests the test
  301. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  302. @pytest.mark.parametrize(
  303. "hyp2f1_test_case",
  304. [
  305. pytest.param(
  306. Hyp2f1TestCase(
  307. a=0.5,
  308. b=0.2,
  309. c=1.3,
  310. z=-1 + 0j,
  311. expected=0.9428846409614143 + 0j,
  312. rtol=1e-15),
  313. ),
  314. pytest.param(
  315. Hyp2f1TestCase(
  316. a=12.3,
  317. b=8.0,
  318. c=5.300000000000001,
  319. z=-1 + 0j,
  320. expected=-4.845809986595704e-06 + 0j,
  321. rtol=1e-15
  322. ),
  323. ),
  324. pytest.param(
  325. Hyp2f1TestCase(
  326. a=221.5,
  327. b=90.2,
  328. c=132.3,
  329. z=-1 + 0j,
  330. expected=2.0490488728377282e-42 + 0j,
  331. rtol=1e-7,
  332. ),
  333. ),
  334. pytest.param(
  335. Hyp2f1TestCase(
  336. a=-102.1,
  337. b=-20.3,
  338. c=-80.8,
  339. z=-1 + 0j,
  340. expected=45143784.46783885 + 0j,
  341. rtol=1e-7,
  342. ),
  343. marks=pytest.mark.xfail(
  344. condition=sys.maxsize < 2**32,
  345. reason="Fails on 32 bit.",
  346. )
  347. ),
  348. ],
  349. )
  350. def test_special_case_z_near_minus_1(self, hyp2f1_test_case):
  351. """Tests for case z ~ -1, c ~ 1 + a - b
  352. Expected answers computed using mpmath.
  353. """
  354. a, b, c, z, expected, rtol = hyp2f1_test_case
  355. assert abs(1 + a - b - c) < 1e-15 and abs(z + 1) < 1e-15
  356. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  357. @pytest.mark.parametrize(
  358. "hyp2f1_test_case",
  359. [
  360. pytest.param(
  361. Hyp2f1TestCase(
  362. a=-4,
  363. b=2.02764642551431,
  364. c=1.0561196186065624,
  365. z=(0.9473684210526314-0.10526315789473695j),
  366. expected=(0.0031961077109535375-0.0011313924606557173j),
  367. rtol=1e-12,
  368. ),
  369. ),
  370. pytest.param(
  371. Hyp2f1TestCase(
  372. a=-8,
  373. b=-7.937789122896016,
  374. c=-15.964218273004214,
  375. z=(2-0.10526315789473695j),
  376. expected=(0.005543763196412503-0.0025948879065698306j),
  377. rtol=5e-13,
  378. ),
  379. ),
  380. pytest.param(
  381. Hyp2f1TestCase(
  382. a=-8,
  383. b=8.095813935368371,
  384. c=4.0013768449590685,
  385. z=(0.9473684210526314-0.10526315789473695j),
  386. expected=(-0.0003054674127221263-9.261359291755414e-05j),
  387. rtol=1e-10,
  388. ),
  389. ),
  390. pytest.param(
  391. Hyp2f1TestCase(
  392. a=-4,
  393. b=-3.956227226099288,
  394. c=-3.9316537064827854,
  395. z=(1.1578947368421053-0.3157894736842106j),
  396. expected=(-0.0020809502580892937-0.0041877333232365095j),
  397. rtol=5e-12,
  398. ),
  399. ),
  400. pytest.param(
  401. Hyp2f1TestCase(
  402. a=2.02764642551431,
  403. b=-4,
  404. c=2.050308316530781,
  405. z=(0.9473684210526314-0.10526315789473695j),
  406. expected=(0.0011282435590058734+0.0002027062303465851j),
  407. rtol=5e-13,
  408. ),
  409. ),
  410. pytest.param(
  411. Hyp2f1TestCase(
  412. a=-7.937789122896016,
  413. b=-8,
  414. c=-15.964218273004214,
  415. z=(1.3684210526315788+0.10526315789473673j),
  416. expected=(-9.134907719238265e-05-0.00040219233987390723j),
  417. rtol=5e-12,
  418. ),
  419. ),
  420. pytest.param(
  421. Hyp2f1TestCase(
  422. a=4.080187217753502,
  423. b=-4,
  424. c=4.0013768449590685,
  425. z=(0.9473684210526314-0.10526315789473695j),
  426. expected=(-0.000519013062087489-0.0005855883076830948j),
  427. rtol=5e-12,
  428. ),
  429. ),
  430. pytest.param(
  431. Hyp2f1TestCase(
  432. a=-10000,
  433. b=2.2,
  434. c=93459345.3,
  435. z=(2+2j),
  436. expected=(0.9995292071559088-0.00047047067522659253j),
  437. rtol=1e-12,
  438. ),
  439. ),
  440. ]
  441. )
  442. def test_a_b_negative_int(self, hyp2f1_test_case):
  443. a, b, c, z, expected, rtol = hyp2f1_test_case
  444. assert a == int(a) and a < 0 or b == int(b) and b < 0 # Tests the test
  445. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  446. @pytest.mark.parametrize(
  447. "hyp2f1_test_case",
  448. [
  449. pytest.param(
  450. Hyp2f1TestCase(
  451. a=-0.5,
  452. b=-0.9629749245209605,
  453. c=-15.5,
  454. z=(1.1578947368421053-1.1578947368421053j),
  455. expected=(0.9778506962676361+0.044083801141231616j),
  456. rtol=3e-12,
  457. ),
  458. ),
  459. pytest.param(
  460. Hyp2f1TestCase(
  461. a=8.5,
  462. b=-3.9316537064827854,
  463. c=1.5,
  464. z=(0.9473684210526314-0.10526315789473695j),
  465. expected=(4.0793167523167675-10.11694246310966j),
  466. rtol=6e-12,
  467. ),
  468. ),
  469. pytest.param(
  470. Hyp2f1TestCase(
  471. a=8.5,
  472. b=-0.9629749245209605,
  473. c=2.5,
  474. z=(1.1578947368421053-0.10526315789473695j),
  475. expected=(-2.9692999501916915+0.6394599899845594j),
  476. rtol=1e-11,
  477. ),
  478. ),
  479. pytest.param(
  480. Hyp2f1TestCase(
  481. a=-0.5,
  482. b=-0.9629749245209605,
  483. c=-15.5,
  484. z=(1.5789473684210522-1.1578947368421053j),
  485. expected=(0.9493076367106102-0.04316852977183447j),
  486. rtol=1e-11,
  487. ),
  488. ),
  489. pytest.param(
  490. Hyp2f1TestCase(
  491. a=-0.9220024191881196,
  492. b=-0.5,
  493. c=-15.5,
  494. z=(0.5263157894736841+0.10526315789473673j),
  495. expected=(0.9844377175631795-0.003120587561483841j),
  496. rtol=1e-10,
  497. ),
  498. ),
  499. ],
  500. )
  501. def test_a_b_neg_int_after_euler_hypergeometric_transformation(
  502. self, hyp2f1_test_case
  503. ):
  504. a, b, c, z, expected, rtol = hyp2f1_test_case
  505. assert ( # Tests the test
  506. (abs(c - a - int(c - a)) < 1e-15 and c - a < 0) or
  507. (abs(c - b - int(c - b)) < 1e-15 and c - b < 0)
  508. )
  509. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  510. @pytest.mark.parametrize(
  511. "hyp2f1_test_case",
  512. [
  513. pytest.param(
  514. Hyp2f1TestCase(
  515. a=-0.9220024191881196,
  516. b=-0.9629749245209605,
  517. c=-15.963511401609862,
  518. z=(0.10526315789473673-0.3157894736842106j),
  519. expected=(0.9941449585778349+0.01756335047931358j),
  520. rtol=1e-14,
  521. ),
  522. ),
  523. pytest.param(
  524. Hyp2f1TestCase(
  525. a=1.0272592605282642,
  526. b=-0.9629749245209605,
  527. c=-15.963511401609862,
  528. z=(0.5263157894736841+0.5263157894736841j),
  529. expected=(1.0388722293372104-0.09549450380041416j),
  530. rtol=5e-11,
  531. ),
  532. ),
  533. pytest.param(
  534. Hyp2f1TestCase(
  535. a=2.02764642551431,
  536. b=1.0561196186065624,
  537. c=-7.93846038215665,
  538. z=(0.10526315789473673+0.7368421052631575j),
  539. expected=(2.1948378809826434+24.934157235172222j),
  540. rtol=5e-15,
  541. ),
  542. ),
  543. pytest.param(
  544. Hyp2f1TestCase(
  545. a=2.02764642551431,
  546. b=16.088264119063613,
  547. c=8.031683612216888,
  548. z=(0.3157894736842106-0.736842105263158j),
  549. expected=(-0.4075277891264672-0.06819344579666956j),
  550. rtol=2e-12,
  551. ),
  552. ),
  553. pytest.param(
  554. Hyp2f1TestCase(
  555. a=4.080187217753502,
  556. b=2.050308316530781,
  557. c=8.031683612216888,
  558. z=(0.7368421052631575-0.10526315789473695j),
  559. expected=(2.833535530740603-0.6925373701408158j),
  560. rtol=5e-15,
  561. ),
  562. ),
  563. pytest.param(
  564. Hyp2f1TestCase(
  565. a=2.02764642551431,
  566. b=2.050308316530781,
  567. c=4.078873014294075,
  568. z=(0.10526315789473673-0.3157894736842106j),
  569. expected=(1.005347176329683-0.3580736009337313j),
  570. rtol=5e-16,
  571. ),
  572. ),
  573. pytest.param(
  574. Hyp2f1TestCase(
  575. a=-0.9220024191881196,
  576. b=-0.9629749245209605,
  577. c=-15.963511401609862,
  578. z=(0.3157894736842106-0.5263157894736843j),
  579. expected=(0.9824353641135369+0.029271018868990268j),
  580. rtol=5e-13,
  581. ),
  582. ),
  583. pytest.param(
  584. Hyp2f1TestCase(
  585. a=-0.9220024191881196,
  586. b=-0.9629749245209605,
  587. c=-159.63511401609862,
  588. z=(0.3157894736842106-0.5263157894736843j),
  589. expected=(0.9982436200365834+0.002927268199671111j),
  590. rtol=1e-7,
  591. ),
  592. marks=pytest.mark.xfail(reason="Poor convergence.")
  593. ),
  594. pytest.param(
  595. Hyp2f1TestCase(
  596. a=2.02764642551431,
  597. b=16.088264119063613,
  598. c=8.031683612216888,
  599. z=(0.5263157894736841-0.5263157894736843j),
  600. expected=(-0.6906825165778091+0.8176575137504892j),
  601. rtol=5e-13,
  602. ),
  603. ),
  604. ]
  605. )
  606. def test_region1(self, hyp2f1_test_case):
  607. """|z| < 0.9 and real(z) >= 0."""
  608. a, b, c, z, expected, rtol = hyp2f1_test_case
  609. assert abs(z) < 0.9 and z.real >= 0 # Tests the test
  610. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  611. @pytest.mark.parametrize(
  612. "hyp2f1_test_case",
  613. [
  614. pytest.param(
  615. Hyp2f1TestCase(
  616. a=2.02764642551431,
  617. b=1.0561196186065624,
  618. c=4.078873014294075,
  619. z=(-0.3157894736842106+0.7368421052631575j),
  620. expected=(0.7751915029081136+0.24068493258607315j),
  621. rtol=5e-15,
  622. ),
  623. ),
  624. pytest.param(
  625. Hyp2f1TestCase(
  626. a=16.087593263474208,
  627. b=16.088264119063613,
  628. c=2.0397202577726152,
  629. z=(-0.9473684210526316-0.3157894736842106j),
  630. expected=(6.564549348474962e-07+1.6761570598334562e-06j),
  631. rtol=5e-09,
  632. ),
  633. ),
  634. pytest.param(
  635. Hyp2f1TestCase(
  636. a=1.0272592605282642,
  637. b=2.050308316530781,
  638. c=16.056809865262608,
  639. z=(-0.10526315789473695-0.10526315789473695j),
  640. expected=(0.9862043298997204-0.013293151372712681j),
  641. rtol=5e-15,
  642. ),
  643. ),
  644. pytest.param(
  645. Hyp2f1TestCase(
  646. a=4.080187217753502,
  647. b=8.077282662161238,
  648. c=16.056809865262608,
  649. z=(-0.3157894736842106-0.736842105263158j),
  650. expected=(0.16163826638754716-0.41378530376373734j),
  651. rtol=5e-15,
  652. ),
  653. ),
  654. pytest.param(
  655. Hyp2f1TestCase(
  656. a=2.02764642551431,
  657. b=2.050308316530781,
  658. c=-0.906685989801748,
  659. z=(-0.5263157894736843+0.3157894736842106j),
  660. expected=(-6.256871535165936+0.13824973858225484j),
  661. rtol=1e-15,
  662. ),
  663. ),
  664. pytest.param(
  665. Hyp2f1TestCase(
  666. a=2.02764642551431,
  667. b=8.077282662161238,
  668. c=-3.9924618758357022,
  669. z=(-0.9473684210526316-0.3157894736842106j),
  670. expected=(75.54672526086316+50.56157041797548j),
  671. rtol=5e-12,
  672. ),
  673. ),
  674. pytest.param(
  675. Hyp2f1TestCase(
  676. a=16.087593263474208,
  677. b=8.077282662161238,
  678. c=-1.9631175993998025,
  679. z=(-0.5263157894736843+0.5263157894736841j),
  680. expected=(282.0602536306534-82.31597306936214j),
  681. rtol=5e-13,
  682. ),
  683. ),
  684. pytest.param(
  685. Hyp2f1TestCase(
  686. a=8.095813935368371,
  687. b=-3.9316537064827854,
  688. c=8.031683612216888,
  689. z=(-0.5263157894736843-0.10526315789473695j),
  690. expected=(5.179603735575851+1.4445374002099813j),
  691. rtol=5e-14,
  692. ),
  693. ),
  694. pytest.param(
  695. Hyp2f1TestCase(
  696. a=4.080187217753502,
  697. b=-7.949900487447654,
  698. c=1.0651378143226575,
  699. z=(-0.3157894736842106-0.9473684210526316j),
  700. expected=(2317.623517606141-269.51476321010324j),
  701. rtol=5e-13,
  702. ),
  703. ),
  704. pytest.param(
  705. Hyp2f1TestCase(
  706. a=16.087593263474208,
  707. b=-1.92872979730171,
  708. c=2.0397202577726152,
  709. z=(-0.736842105263158-0.3157894736842106j),
  710. expected=(29.179154096175836+22.126690357535043j),
  711. rtol=5e-15,
  712. ),
  713. ),
  714. pytest.param(
  715. Hyp2f1TestCase(
  716. a=8.095813935368371,
  717. b=-3.9316537064827854,
  718. c=-15.963511401609862,
  719. z=(-0.736842105263158-0.10526315789473695j),
  720. expected=(0.20820247892032057-0.04763956711248794j),
  721. rtol=5e-14,
  722. ),
  723. ),
  724. pytest.param(
  725. Hyp2f1TestCase(
  726. a=1.0272592605282642,
  727. b=-15.964218273004214,
  728. c=-1.9631175993998025,
  729. z=(-0.3157894736842106-0.5263157894736843j),
  730. expected=(-157471.63920142158+991294.0587828817j),
  731. rtol=5e-14,
  732. ),
  733. ),
  734. pytest.param(
  735. Hyp2f1TestCase(
  736. a=8.095813935368371,
  737. b=-7.949900487447654,
  738. c=-7.93846038215665,
  739. z=(-0.10526315789473695-0.10526315789473695j),
  740. expected=(0.30765349653210194-0.2979706363594157j),
  741. rtol=1e-15,
  742. ),
  743. ),
  744. pytest.param(
  745. Hyp2f1TestCase(
  746. a=-3.956227226099288,
  747. b=1.0561196186065624,
  748. c=8.031683612216888,
  749. z=(-0.9473684210526316-0.10526315789473695j),
  750. expected=(1.6787607400597109+0.10056620134616838j),
  751. rtol=5e-14,
  752. ),
  753. ),
  754. pytest.param(
  755. Hyp2f1TestCase(
  756. a=-7.937789122896016,
  757. b=16.088264119063613,
  758. c=4.078873014294075,
  759. z=(-0.5263157894736843-0.736842105263158j),
  760. expected=(7062.07842506049-12768.77955655703j),
  761. rtol=5e-15,
  762. ),
  763. ),
  764. pytest.param(
  765. Hyp2f1TestCase(
  766. a=-7.937789122896016,
  767. b=16.088264119063613,
  768. c=2.0397202577726152,
  769. z=(-0.3157894736842106+0.7368421052631575j),
  770. expected=(54749.216391029935-23078.144720887536j),
  771. rtol=2e-15,
  772. ),
  773. ),
  774. pytest.param(
  775. Hyp2f1TestCase(
  776. a=-3.956227226099288,
  777. b=1.0561196186065624,
  778. c=-0.906685989801748,
  779. z=(-0.10526315789473695-0.10526315789473695j),
  780. expected=(1.21521766411428-4.449385173946672j),
  781. rtol=5e-15,
  782. ),
  783. ),
  784. pytest.param(
  785. Hyp2f1TestCase(
  786. a=-15.980848054962111,
  787. b=4.0013768449590685,
  788. c=-1.9631175993998025,
  789. z=(-0.736842105263158+0.5263157894736841j),
  790. expected=(19234693144.196907+1617913967.7294445j),
  791. rtol=5e-14,
  792. ),
  793. ),
  794. pytest.param(
  795. Hyp2f1TestCase(
  796. a=-1.9214641416286231,
  797. b=1.0561196186065624,
  798. c=-15.963511401609862,
  799. z=(-0.5263157894736843+0.3157894736842106j),
  800. expected=(0.9345201094534371+0.03745712558992195j),
  801. rtol=5e-15,
  802. ),
  803. ),
  804. pytest.param(
  805. Hyp2f1TestCase(
  806. a=-7.937789122896016,
  807. b=-0.9629749245209605,
  808. c=2.0397202577726152,
  809. z=(-0.10526315789473695+0.10526315789473673j),
  810. expected=(0.605732446296829+0.398171533680972j),
  811. rtol=5e-15,
  812. ),
  813. ),
  814. pytest.param(
  815. Hyp2f1TestCase(
  816. a=-1.9214641416286231,
  817. b=-15.964218273004214,
  818. c=2.0397202577726152,
  819. z=(-0.10526315789473695-0.5263157894736843j),
  820. expected=(-9.753761888305416-4.590126012666959j),
  821. rtol=5e-15,
  822. ),
  823. ),
  824. pytest.param(
  825. Hyp2f1TestCase(
  826. a=-3.956227226099288,
  827. b=-1.92872979730171,
  828. c=2.0397202577726152,
  829. z=(-0.10526315789473695+0.3157894736842106j),
  830. expected=(0.45587226291120714+1.0694545265819797j),
  831. rtol=5e-15,
  832. ),
  833. ),
  834. pytest.param(
  835. Hyp2f1TestCase(
  836. a=-0.9220024191881196,
  837. b=-7.949900487447654,
  838. c=-0.906685989801748,
  839. z=(-0.736842105263158+0.3157894736842106j),
  840. expected=(12.334808243233418-76.26089051819054j),
  841. rtol=5e-14,
  842. ),
  843. ),
  844. pytest.param(
  845. Hyp2f1TestCase(
  846. a=-0.9220024191881196,
  847. b=-7.949900487447654,
  848. c=-15.963511401609862,
  849. z=(-0.5263157894736843+0.10526315789473673j),
  850. expected=(1.2396019687632678-0.047507973161146286j),
  851. rtol=1e-14,
  852. ),
  853. ),
  854. pytest.param(
  855. Hyp2f1TestCase(
  856. a=-15.980848054962111,
  857. b=-0.9629749245209605,
  858. c=-0.906685989801748,
  859. z=(-0.3157894736842106-0.5263157894736843j),
  860. expected=(97.7889554372208-18.999754543400016j),
  861. rtol=5e-13,
  862. ),
  863. ),
  864. ]
  865. )
  866. def test_region2(self, hyp2f1_test_case):
  867. """|z| < 1 and real(z) < 0."""
  868. a, b, c, z, expected, rtol = hyp2f1_test_case
  869. assert abs(z) < 1 and z.real < 0 # Tests the test
  870. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  871. @pytest.mark.parametrize(
  872. "hyp2f1_test_case",
  873. [
  874. pytest.param(
  875. Hyp2f1TestCase(
  876. a=16.25,
  877. b=-3.75,
  878. c=-3.5,
  879. z=(0.5263157894736841+0.7368421052631575j),
  880. expected=(-1279.4894322256655-2302.914821389276j),
  881. rtol=5e-14,
  882. ),
  883. ),
  884. pytest.param(
  885. Hyp2f1TestCase(
  886. a=-15.75,
  887. b=8.25,
  888. c=-1.5,
  889. z=(0.9473684210526314+0.3157894736842106j),
  890. expected=(-8889.452798586273-11961.162305065242j),
  891. rtol=5e-14,
  892. ),
  893. ),
  894. pytest.param(
  895. Hyp2f1TestCase(
  896. a=2.25,
  897. b=2.25,
  898. c=-1.5,
  899. z=(0.5263157894736841-0.736842105263158j),
  900. expected=(-236.58971357952055-238.5228224781136j),
  901. rtol=5e-15,
  902. ),
  903. ),
  904. pytest.param(
  905. Hyp2f1TestCase(
  906. a=-0.75,
  907. b=-7.75,
  908. c=-15.5,
  909. z=(0.5263157894736841+0.7368421052631575j),
  910. expected=(0.8116076584352279-0.29360565398246036j),
  911. rtol=5e-16,
  912. ),
  913. ),
  914. pytest.param(
  915. Hyp2f1TestCase(
  916. a=1.25,
  917. b=4.25,
  918. c=-0.5,
  919. z=(0.5263157894736841-0.736842105263158j),
  920. expected=(-28.119407485189985+98.89858821348005j),
  921. rtol=5e-15,
  922. ),
  923. ),
  924. pytest.param(
  925. Hyp2f1TestCase(
  926. a=-0.75,
  927. b=2.25,
  928. c=1.5,
  929. z=(0.5263157894736841+0.7368421052631575j),
  930. expected=(0.5311049067450484-0.9434347326448517j),
  931. rtol=5e-14,
  932. ),
  933. ),
  934. pytest.param(
  935. Hyp2f1TestCase(
  936. a=8.25,
  937. b=-15.75,
  938. c=-7.5,
  939. z=(0.9473684210526314+0.10526315789473673j),
  940. expected=(1262084.378141873+1775569.6338380123j),
  941. rtol=5e-14,
  942. ),
  943. ),
  944. pytest.param(
  945. Hyp2f1TestCase(
  946. a=-15.75,
  947. b=-7.75,
  948. c=-15.5,
  949. z=(0.5263157894736841-0.736842105263158j),
  950. expected=(-0.009810480794804165+0.3648997569257999j),
  951. rtol=1e-15,
  952. ),
  953. ),
  954. pytest.param(
  955. Hyp2f1TestCase(
  956. a=8.25,
  957. b=2.25,
  958. c=-3.5,
  959. z=(0.5263157894736841-0.736842105263158j),
  960. expected=(585660.8815535795-33646.68398590896j),
  961. rtol=5e-14,
  962. ),
  963. ),
  964. pytest.param(
  965. Hyp2f1TestCase(
  966. a=4.080187217753502,
  967. b=-3.9316537064827854,
  968. c=-15.963511401609862,
  969. z=(0.9473684210526314-0.10526315789473695j),
  970. expected=(181899621848365.2-173207123998705.7j),
  971. rtol=5e-14,
  972. ),
  973. ),
  974. pytest.param(
  975. Hyp2f1TestCase(
  976. a=-15.75,
  977. b=8.25,
  978. c=-0.5,
  979. z=(0.9473684210526314-0.10526315789473695j),
  980. expected=(0.04271686244952705-0.14087902824639406j),
  981. rtol=5e-14,
  982. ),
  983. ),
  984. pytest.param(
  985. Hyp2f1TestCase(
  986. a=-7.937789122896016,
  987. b=-1.92872979730171,
  988. c=-0.906685989801748,
  989. z=(0.9473684210526314-0.3157894736842106j),
  990. expected=(-449.5119088817207+320.1423128036188j),
  991. rtol=5e-14,
  992. ),
  993. ),
  994. pytest.param(
  995. Hyp2f1TestCase(
  996. a=-3.956227226099288,
  997. b=1.0561196186065624,
  998. c=8.031683612216888,
  999. z=(0.9473684210526314-0.10526315789473695j),
  1000. expected=(0.6361479738012501+0.028575620091205088j),
  1001. rtol=5e-15,
  1002. ),
  1003. ),
  1004. pytest.param(
  1005. Hyp2f1TestCase(
  1006. a=4.25,
  1007. b=16.25,
  1008. c=16.5,
  1009. z=(0.5263157894736841+0.7368421052631575j),
  1010. expected=(-0.9038811840552261-1.5356250756164884j),
  1011. rtol=1e-8,
  1012. ),
  1013. marks=pytest.mark.xfail(
  1014. reason="Unhandled parameters."
  1015. )
  1016. ),
  1017. pytest.param(
  1018. Hyp2f1TestCase(
  1019. a=8.25,
  1020. b=-1.75,
  1021. c=-1.5,
  1022. z=(0.9473684210526314+0.3157894736842106j),
  1023. expected=(653.0109150415394-4554.162605155542j),
  1024. rtol=1e-15,
  1025. ),
  1026. ),
  1027. pytest.param(
  1028. Hyp2f1TestCase(
  1029. a=-15.75,
  1030. b=-3.75,
  1031. c=4.5,
  1032. z=(0.9473684210526314-0.10526315789473695j),
  1033. expected=(118.7009859241035-34.18713648654642j),
  1034. rtol=1e-15,
  1035. ),
  1036. ),
  1037. pytest.param(
  1038. Hyp2f1TestCase(
  1039. a=4.25,
  1040. b=-15.75,
  1041. c=-3.5,
  1042. z=(0.5263157894736841+0.7368421052631575j),
  1043. expected=(-540204.4774526551+4970059.109251281j),
  1044. rtol=1e-14,
  1045. ),
  1046. ),
  1047. pytest.param(
  1048. Hyp2f1TestCase(
  1049. a=8.25,
  1050. b=-15.75,
  1051. c=-0.5,
  1052. z=(0.5263157894736841-0.736842105263158j),
  1053. expected=(2253490.972258385+3318620.683390017j),
  1054. rtol=5e-13,
  1055. ),
  1056. ),
  1057. pytest.param(
  1058. Hyp2f1TestCase(
  1059. a=16.25,
  1060. b=-7.75,
  1061. c=-7.5,
  1062. z=(0.9473684210526314+0.3157894736842106j),
  1063. expected=(-46159826.46716958-17880663.82218242j),
  1064. rtol=5e-14,
  1065. ),
  1066. ),
  1067. pytest.param(
  1068. Hyp2f1TestCase(
  1069. a=-0.9220024191881196,
  1070. b=-7.949900487447654,
  1071. c=-7.93846038215665,
  1072. z=(0.9473684210526314-0.10526315789473695j),
  1073. expected=(0.07116833581404514+0.11823358038036977j),
  1074. rtol=5e-13,
  1075. ),
  1076. ),
  1077. pytest.param(
  1078. Hyp2f1TestCase(
  1079. a=16.087593263474208,
  1080. b=4.0013768449590685,
  1081. c=-7.93846038215665,
  1082. z=(0.7368421052631575+0.5263157894736841j),
  1083. expected=(4.7724909620664006e+17-6.039064078946702e+16j),
  1084. rtol=5e-13,
  1085. ),
  1086. ),
  1087. pytest.param(
  1088. Hyp2f1TestCase(
  1089. a=1.25,
  1090. b=-7.75,
  1091. c=1.5,
  1092. z=(0.9473684210526314-0.10526315789473695j),
  1093. expected=(0.0188022179759303+0.002921737281641378j),
  1094. rtol=5e-15,
  1095. ),
  1096. ),
  1097. pytest.param(
  1098. Hyp2f1TestCase(
  1099. a=1.0272592605282642,
  1100. b=1.0561196186065624,
  1101. c=-7.93846038215665,
  1102. z=(0.7368421052631575-0.5263157894736843j),
  1103. expected=(-9203.462928334846+12390.110518017136j),
  1104. rtol=5e-13,
  1105. ),
  1106. ),
  1107. pytest.param(
  1108. Hyp2f1TestCase(
  1109. a=-3.75,
  1110. b=-15.75,
  1111. c=8.5,
  1112. z=(0.7368421052631575+0.5263157894736841j),
  1113. expected=(6.468457061368628+24.190040684917374j),
  1114. rtol=6e-16,
  1115. ),
  1116. ),
  1117. pytest.param(
  1118. Hyp2f1TestCase(
  1119. a=2.02764642551431,
  1120. b=16.088264119063613,
  1121. c=2.0397202577726152,
  1122. z=(0.7368421052631575+0.5263157894736841j),
  1123. expected=(2408.3451340186543-4275.257316636014j),
  1124. rtol=5e-14,
  1125. ),
  1126. ),
  1127. pytest.param(
  1128. Hyp2f1TestCase(
  1129. a=-3.75,
  1130. b=-7.75,
  1131. c=8.5,
  1132. z=(0.7368421052631575-0.5263157894736843j),
  1133. expected=(4.1379984626381345-5.183654781039423j),
  1134. rtol=5e-15,
  1135. ),
  1136. ),
  1137. pytest.param(
  1138. Hyp2f1TestCase(
  1139. a=8.25,
  1140. b=-7.75,
  1141. c=-0.5,
  1142. z=(0.5263157894736841+0.7368421052631575j),
  1143. expected=(-81177.775295738+56079.73286548954j),
  1144. rtol=5e-14,
  1145. ),
  1146. ),
  1147. pytest.param(
  1148. Hyp2f1TestCase(
  1149. a=4.080187217753502,
  1150. b=2.050308316530781,
  1151. c=-0.906685989801748,
  1152. z=(0.9473684210526314+0.3157894736842106j),
  1153. expected=(1192868.5068926765+3624210.8182139914j),
  1154. rtol=5e-14,
  1155. ),
  1156. ),
  1157. pytest.param(
  1158. Hyp2f1TestCase(
  1159. a=-7.937789122896016,
  1160. b=-1.92872979730171,
  1161. c=8.031683612216888,
  1162. z=(0.5263157894736841+0.7368421052631575j),
  1163. expected=(1.8286341846195202+1.9295255682312178j),
  1164. rtol=5e-14,
  1165. ),
  1166. ),
  1167. pytest.param(
  1168. Hyp2f1TestCase(
  1169. a=1.0272592605282642,
  1170. b=1.0561196186065624,
  1171. c=16.056809865262608,
  1172. z=(0.7368421052631575-0.5263157894736843j),
  1173. expected=(1.0514645669696452-0.0430834059440128j),
  1174. rtol=5e-10,
  1175. ),
  1176. ),
  1177. pytest.param(
  1178. Hyp2f1TestCase(
  1179. a=16.087593263474208,
  1180. b=-15.964218273004214,
  1181. c=2.0397202577726152,
  1182. z=(0.5263157894736841+0.7368421052631575j),
  1183. expected=(541983.236432269+288200.2043029435j),
  1184. rtol=5e-13,
  1185. ),
  1186. ),
  1187. pytest.param(
  1188. Hyp2f1TestCase(
  1189. a=2.25,
  1190. b=8.25,
  1191. c=1.5,
  1192. z=(0.5263157894736841-0.736842105263158j),
  1193. expected=(-10.931988086039945+1.9136272843579096j),
  1194. rtol=1e-15,
  1195. ),
  1196. ),
  1197. ]
  1198. )
  1199. def test_region3(self, hyp2f1_test_case):
  1200. """0.9 <= |z| <= 1 and |1 - z| < 0.9."""
  1201. a, b, c, z, expected, rtol = hyp2f1_test_case
  1202. assert 0.9 <= abs(z) <= 1 and abs(1 - z) < 0.9 # Tests the test
  1203. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  1204. @pytest.mark.parametrize(
  1205. "hyp2f1_test_case",
  1206. [
  1207. pytest.param(
  1208. Hyp2f1TestCase(
  1209. a=16.25,
  1210. b=4.25,
  1211. c=2.5,
  1212. z=(0.4931034482758623-0.7965517241379311j),
  1213. expected=(38.41207903409937-30.510151276075792j),
  1214. rtol=5e-14,
  1215. ),
  1216. ),
  1217. pytest.param(
  1218. Hyp2f1TestCase(
  1219. a=2.0,
  1220. b=16.087593263474208,
  1221. c=16.088264119063613,
  1222. z=(0.5689655172413794-0.7965517241379311j),
  1223. expected=(-0.6667857912761286-1.0206224321443573j),
  1224. rtol=1e-15,
  1225. ),
  1226. ),
  1227. pytest.param(
  1228. Hyp2f1TestCase(
  1229. a=8.0,
  1230. b=1.0272592605282642,
  1231. c=-7.949900487447654,
  1232. z=(0.4931034482758623-0.7965517241379311j),
  1233. expected=(1679024.1647997478-2748129.775857212j),
  1234. rtol=5e-14,
  1235. ),
  1236. ),
  1237. pytest.param(
  1238. Hyp2f1TestCase(
  1239. a=4.080187217753502,
  1240. b=16.0,
  1241. c=-7.949900487447654,
  1242. z=(0.4931034482758623-0.7965517241379311j),
  1243. expected=(424747226301.16986-1245539049327.2856j),
  1244. rtol=1e-14,
  1245. ),
  1246. ),
  1247. pytest.param(
  1248. Hyp2f1TestCase(
  1249. a=2.02764642551431,
  1250. b=-15.964218273004214,
  1251. c=4.0,
  1252. z=(0.4931034482758623-0.7965517241379311j),
  1253. expected=(-0.0057826199201757595+0.026359861999025885j),
  1254. rtol=5e-06,
  1255. ),
  1256. ),
  1257. pytest.param(
  1258. Hyp2f1TestCase(
  1259. a=2.02764642551431,
  1260. b=-0.9629749245209605,
  1261. c=2.0397202577726152,
  1262. z=(0.5689655172413794-0.7965517241379311j),
  1263. expected=(0.4671901063492606+0.7769632229834897j),
  1264. rtol=5e-14,
  1265. ),
  1266. ),
  1267. pytest.param(
  1268. Hyp2f1TestCase(
  1269. a=2.0,
  1270. b=-3.956227226099288,
  1271. c=-7.949900487447654,
  1272. z=(0.4931034482758623+0.7965517241379312j),
  1273. expected=(0.9422283708145973+1.3476905754773343j),
  1274. rtol=5e-15,
  1275. ),
  1276. ),
  1277. pytest.param(
  1278. Hyp2f1TestCase(
  1279. a=1.0,
  1280. b=-15.980848054962111,
  1281. c=-15.964218273004214,
  1282. z=(0.4931034482758623-0.7965517241379311j),
  1283. expected=(0.4168719497319604-0.9770953555235625j),
  1284. rtol=5e-10,
  1285. ),
  1286. ),
  1287. pytest.param(
  1288. Hyp2f1TestCase(
  1289. a=-0.5,
  1290. b=16.088264119063613,
  1291. c=2.5,
  1292. z=(0.5689655172413794+0.7965517241379312j),
  1293. expected=(1.279096377550619-2.173827694297929j),
  1294. rtol=5e-12,
  1295. ),
  1296. ),
  1297. pytest.param(
  1298. Hyp2f1TestCase(
  1299. a=-1.9214641416286231,
  1300. b=4.0013768449590685,
  1301. c=2.0397202577726152,
  1302. z=(0.4931034482758623+0.7965517241379312j),
  1303. expected=(-2.071520656161738-0.7846098268395909j),
  1304. rtol=5e-14,
  1305. ),
  1306. ),
  1307. pytest.param(
  1308. Hyp2f1TestCase(
  1309. a=-0.9220024191881196,
  1310. b=8.0,
  1311. c=-0.9629749245209605,
  1312. z=(0.5689655172413794-0.7965517241379311j),
  1313. expected=(-7.740015495862889+3.386766435696699j),
  1314. rtol=5e-12,
  1315. ),
  1316. ),
  1317. pytest.param(
  1318. Hyp2f1TestCase(
  1319. a=-1.9214641416286231,
  1320. b=16.088264119063613,
  1321. c=-7.93846038215665,
  1322. z=(0.4931034482758623+0.7965517241379312j),
  1323. expected=(-6318.553685853241-7133.416085202879j),
  1324. rtol=5e-9,
  1325. ),
  1326. ),
  1327. pytest.param(
  1328. Hyp2f1TestCase(
  1329. a=-15.980848054962111,
  1330. b=-3.9316537064827854,
  1331. c=16.056809865262608,
  1332. z=(0.5689655172413794+0.7965517241379312j),
  1333. expected=(-0.8854577905547399+8.135089099967278j),
  1334. rtol=5e-14,
  1335. ),
  1336. ),
  1337. pytest.param(
  1338. Hyp2f1TestCase(
  1339. a=-1.9214641416286231,
  1340. b=-0.9629749245209605,
  1341. c=4.078873014294075,
  1342. z=(0.4931034482758623+0.7965517241379312j),
  1343. expected=(1.224291301521487+0.36014711766402485j),
  1344. rtol=1e-15,
  1345. ),
  1346. ),
  1347. pytest.param(
  1348. Hyp2f1TestCase(
  1349. a=-15.75,
  1350. b=-0.75,
  1351. c=-1.5,
  1352. z=(0.4931034482758623+0.7965517241379312j),
  1353. expected=(-1.5765685855028473-3.9399766961046323j),
  1354. rtol=1e-3,
  1355. ),
  1356. marks=pytest.mark.xfail(
  1357. reason="Unhandled parameters."
  1358. )
  1359. ),
  1360. pytest.param(
  1361. Hyp2f1TestCase(
  1362. a=-15.980848054962111,
  1363. b=-1.92872979730171,
  1364. c=-7.93846038215665,
  1365. z=(0.5689655172413794-0.7965517241379311j),
  1366. expected=(56.794588688231194+4.556286783533971j),
  1367. rtol=5e-14,
  1368. ),
  1369. ),
  1370. pytest.param(
  1371. Hyp2f1TestCase(
  1372. a=4.5,
  1373. b=4.5,
  1374. c=2.050308316530781,
  1375. z=(0.5689655172413794+0.7965517241379312j),
  1376. expected=(-4.251456563455306+6.737837111569671j),
  1377. rtol=5e-14,
  1378. ),
  1379. ),
  1380. pytest.param(
  1381. Hyp2f1TestCase(
  1382. a=4.5,
  1383. b=8.5,
  1384. c=-1.92872979730171,
  1385. z=(0.4931034482758623-0.7965517241379311j),
  1386. expected=(2177143.9156599627-3313617.2748088865j),
  1387. rtol=5e-14,
  1388. ),
  1389. ),
  1390. pytest.param(
  1391. Hyp2f1TestCase(
  1392. a=2.5,
  1393. b=-1.5,
  1394. c=4.0013768449590685,
  1395. z=(0.4931034482758623-0.7965517241379311j),
  1396. expected=(0.45563554481603946+0.6212000158060831j),
  1397. rtol=5e-14,
  1398. ),
  1399. ),
  1400. pytest.param(
  1401. Hyp2f1TestCase(
  1402. a=8.5,
  1403. b=-7.5,
  1404. c=-15.964218273004214,
  1405. z=(0.4931034482758623+0.7965517241379312j),
  1406. expected=(61.03201617828073-37.185626416756214j),
  1407. rtol=5e-14,
  1408. ),
  1409. ),
  1410. pytest.param(
  1411. Hyp2f1TestCase(
  1412. a=-15.5,
  1413. b=16.5,
  1414. c=4.0013768449590685,
  1415. z=(0.4931034482758623+0.7965517241379312j),
  1416. expected=(-33143.425963520735+20790.608514722644j),
  1417. rtol=1e-14,
  1418. ),
  1419. ),
  1420. pytest.param(
  1421. Hyp2f1TestCase(
  1422. a=-0.5,
  1423. b=4.5,
  1424. c=-0.9629749245209605,
  1425. z=(0.5689655172413794+0.7965517241379312j),
  1426. expected=(30.778600270824423-26.65160354466787j),
  1427. rtol=5e-13,
  1428. ),
  1429. ),
  1430. pytest.param(
  1431. Hyp2f1TestCase(
  1432. a=-0.5,
  1433. b=-3.5,
  1434. c=16.088264119063613,
  1435. z=(0.5689655172413794-0.7965517241379311j),
  1436. expected=(1.0629792615560487-0.08308454486044772j),
  1437. rtol=1e-15,
  1438. ),
  1439. ),
  1440. pytest.param(
  1441. Hyp2f1TestCase(
  1442. a=-3.5,
  1443. b=-7.5,
  1444. c=-0.9629749245209605,
  1445. z=(0.4931034482758623-0.7965517241379311j),
  1446. expected=(17431.571802591767+3553.7129767034507j),
  1447. rtol=5e-14,
  1448. ),
  1449. ),
  1450. pytest.param(
  1451. Hyp2f1TestCase(
  1452. a=2.25,
  1453. b=8.25,
  1454. c=16.5,
  1455. z=(0.11379310344827598+0.9482758620689657j),
  1456. expected=(0.4468600750211926+0.7313214934036885j),
  1457. rtol=1e-3,
  1458. ),
  1459. marks=pytest.mark.xfail(
  1460. reason="Unhandled parameters."
  1461. )
  1462. ),
  1463. pytest.param(
  1464. Hyp2f1TestCase(
  1465. a=8.25,
  1466. b=16.25,
  1467. c=4.5,
  1468. z=(0.3413793103448277+0.8724137931034486j),
  1469. expected=(-3.905704438293991+3.693347860329299j),
  1470. rtol=5e-14,
  1471. ),
  1472. ),
  1473. pytest.param(
  1474. Hyp2f1TestCase(
  1475. a=4.25,
  1476. b=4.25,
  1477. c=-0.5,
  1478. z=(0.11379310344827598-0.9482758620689655j),
  1479. expected=(-40.31777941834244-89.89852492432011j),
  1480. rtol=5e-15,
  1481. ),
  1482. ),
  1483. pytest.param(
  1484. Hyp2f1TestCase(
  1485. a=1.0272592605282642,
  1486. b=8.0,
  1487. c=-15.964218273004214,
  1488. z=(0.11379310344827598-0.9482758620689655j),
  1489. expected=(52584.347773055284-109197.86244309516j),
  1490. rtol=5e-14,
  1491. ),
  1492. ),
  1493. pytest.param(
  1494. Hyp2f1TestCase(
  1495. a=8.095813935368371,
  1496. b=-15.964218273004214,
  1497. c=16.056809865262608,
  1498. z=(0.03793103448275881+0.9482758620689657j),
  1499. expected=(-1.187733570412592-1.5147865053584582j),
  1500. rtol=5e-10,
  1501. ),
  1502. ),
  1503. pytest.param(
  1504. Hyp2f1TestCase(
  1505. a=4.080187217753502,
  1506. b=-3.9316537064827854,
  1507. c=1.0651378143226575,
  1508. z=(0.26551724137931054+0.9482758620689657j),
  1509. expected=(13.077494677898947+35.071599628224966j),
  1510. rtol=5e-13,
  1511. ),
  1512. ),
  1513. pytest.param(
  1514. Hyp2f1TestCase(
  1515. a=4.080187217753502,
  1516. b=-3.5,
  1517. c=-3.5,
  1518. z=(0.26551724137931054+0.8724137931034486j),
  1519. expected=(-0.5359656237994614-0.2344483936591811j),
  1520. rtol=5e-15,
  1521. ),
  1522. ),
  1523. pytest.param(
  1524. Hyp2f1TestCase(
  1525. a=4.25,
  1526. b=-3.75,
  1527. c=-1.5,
  1528. z=(0.26551724137931054+0.9482758620689657j),
  1529. expected=(1204.8114871663133+64.41022826840198j),
  1530. rtol=5e-13,
  1531. ),
  1532. ),
  1533. pytest.param(
  1534. Hyp2f1TestCase(
  1535. a=-1.9214641416286231,
  1536. b=16.0,
  1537. c=4.0013768449590685,
  1538. z=(0.03793103448275881-0.9482758620689655j),
  1539. expected=(-9.85268872413994+7.011107558429154j),
  1540. rtol=5e-15,
  1541. ),
  1542. ),
  1543. pytest.param(
  1544. Hyp2f1TestCase(
  1545. a=-7.937789122896016,
  1546. b=16.0,
  1547. c=4.0013768449590685,
  1548. z=(0.3413793103448277-0.8724137931034484j),
  1549. expected=(528.5522951158454-1412.21630264791j),
  1550. rtol=5e-14,
  1551. ),
  1552. ),
  1553. pytest.param(
  1554. Hyp2f1TestCase(
  1555. a=-15.5,
  1556. b=1.0561196186065624,
  1557. c=-7.5,
  1558. z=(0.4172413793103451+0.8724137931034486j),
  1559. expected=(133306.45260685298+256510.7045225382j),
  1560. rtol=5e-15,
  1561. ),
  1562. ),
  1563. pytest.param(
  1564. Hyp2f1TestCase(
  1565. a=-7.937789122896016,
  1566. b=8.077282662161238,
  1567. c=-15.963511401609862,
  1568. z=(0.3413793103448277-0.8724137931034484j),
  1569. expected=(-0.998555715276967+2.774198742229889j),
  1570. rtol=5e-11,
  1571. ),
  1572. ),
  1573. pytest.param(
  1574. Hyp2f1TestCase(
  1575. a=-7.75,
  1576. b=-0.75,
  1577. c=1.5,
  1578. z=(0.11379310344827598-0.9482758620689655j),
  1579. expected=(2.072445019723025-2.9793504811373515j),
  1580. rtol=5e-14,
  1581. ),
  1582. ),
  1583. pytest.param(
  1584. Hyp2f1TestCase(
  1585. a=-15.5,
  1586. b=-1.92872979730171,
  1587. c=1.5,
  1588. z=(0.11379310344827598-0.9482758620689655j),
  1589. expected=(-41.87581944176649-32.52980303527139j),
  1590. rtol=5e-13,
  1591. ),
  1592. ),
  1593. pytest.param(
  1594. Hyp2f1TestCase(
  1595. a=-3.75,
  1596. b=-15.75,
  1597. c=-0.5,
  1598. z=(0.11379310344827598-0.9482758620689655j),
  1599. expected=(-3729.6214864209774-30627.510509112635j),
  1600. rtol=5e-15,
  1601. ),
  1602. ),
  1603. pytest.param(
  1604. Hyp2f1TestCase(
  1605. a=-3.956227226099288,
  1606. b=-15.964218273004214,
  1607. c=-0.906685989801748,
  1608. z=(0.03793103448275881+0.9482758620689657j),
  1609. expected=(-131615.07820609974+145596.13384245415j),
  1610. rtol=5e-15,
  1611. ),
  1612. ),
  1613. pytest.param(
  1614. Hyp2f1TestCase(
  1615. a=1.5,
  1616. b=16.5,
  1617. c=16.088264119063613,
  1618. z=(0.26551724137931054+0.8724137931034486j),
  1619. expected=(0.18981844071070744+0.7855036242583742j),
  1620. rtol=1e-15,
  1621. ),
  1622. ),
  1623. pytest.param(
  1624. Hyp2f1TestCase(
  1625. a=16.5,
  1626. b=8.5,
  1627. c=-3.9316537064827854,
  1628. z=(0.11379310344827598-0.9482758620689655j),
  1629. expected=(110224529.2376068+128287212.04290268j),
  1630. rtol=5e-13,
  1631. ),
  1632. ),
  1633. pytest.param(
  1634. Hyp2f1TestCase(
  1635. a=2.5,
  1636. b=-7.5,
  1637. c=4.0013768449590685,
  1638. z=(0.3413793103448277-0.8724137931034484j),
  1639. expected=(0.2722302180888523-0.21790187837266162j),
  1640. rtol=1.2e-12,
  1641. ),
  1642. ),
  1643. pytest.param(
  1644. Hyp2f1TestCase(
  1645. a=8.5,
  1646. b=-7.5,
  1647. c=-15.964218273004214,
  1648. z=(0.11379310344827598-0.9482758620689655j),
  1649. expected=(-2.8252338010989035+2.430661949756161j),
  1650. rtol=5e-14,
  1651. ),
  1652. ),
  1653. pytest.param(
  1654. Hyp2f1TestCase(
  1655. a=-3.5,
  1656. b=16.5,
  1657. c=4.0013768449590685,
  1658. z=(0.03793103448275881+0.9482758620689657j),
  1659. expected=(-20.604894257647945+74.5109432558078j),
  1660. rtol=5e-15,
  1661. ),
  1662. ),
  1663. pytest.param(
  1664. Hyp2f1TestCase(
  1665. a=-7.5,
  1666. b=8.5,
  1667. c=-0.9629749245209605,
  1668. z=(0.3413793103448277+0.8724137931034486j),
  1669. expected=(-2764422.521269463-3965966.9965808876j),
  1670. rtol=5e-14,
  1671. ),
  1672. ),
  1673. pytest.param(
  1674. Hyp2f1TestCase(
  1675. a=-1.5,
  1676. b=-0.5,
  1677. c=1.0561196186065624,
  1678. z=(0.26551724137931054+0.9482758620689657j),
  1679. expected=(1.2262338560994905+0.6545051266925549j),
  1680. rtol=1e-15,
  1681. ),
  1682. ),
  1683. pytest.param(
  1684. Hyp2f1TestCase(
  1685. a=-0.5,
  1686. b=-15.5,
  1687. c=-7.949900487447654,
  1688. z=(0.4172413793103451-0.8724137931034484j),
  1689. expected=(-2258.1590330318213+8860.193389158803j),
  1690. rtol=1.4e-10,
  1691. ),
  1692. ),
  1693. ]
  1694. )
  1695. def test_region4(self, hyp2f1_test_case):
  1696. """0.9 <= |z| <= 1 and |1 - z| >= 1.
  1697. This region is unhandled by of the standard transformations and
  1698. needs special care.
  1699. """
  1700. a, b, c, z, expected, rtol = hyp2f1_test_case
  1701. assert 0.9 <= abs(z) <= 1 and abs(1 - z) >= 0.9 # Tests the test
  1702. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  1703. @pytest.mark.parametrize(
  1704. "hyp2f1_test_case",
  1705. [
  1706. pytest.param(
  1707. Hyp2f1TestCase(
  1708. a=4.5,
  1709. b=16.088264119063613,
  1710. c=8.5,
  1711. z=(0.6448275862068968+0.8724137931034486j),
  1712. expected=(0.018601324701770394-0.07618420586062377j),
  1713. rtol=5e-08,
  1714. ),
  1715. ),
  1716. pytest.param(
  1717. Hyp2f1TestCase(
  1718. a=8.25,
  1719. b=4.25,
  1720. c=4.5,
  1721. z=(0.6448275862068968-0.8724137931034484j),
  1722. expected=(-1.391549471425551-0.118036604903893j),
  1723. rtol=5e-15,
  1724. ),
  1725. ),
  1726. pytest.param(
  1727. Hyp2f1TestCase(
  1728. a=2.02764642551431,
  1729. b=2.050308316530781,
  1730. c=-1.9631175993998025,
  1731. z=(0.6448275862068968+0.8724137931034486j),
  1732. expected=(-2309.178768155151-1932.7247727595172j),
  1733. rtol=5e-15,
  1734. ),
  1735. ),
  1736. pytest.param(
  1737. Hyp2f1TestCase(
  1738. a=16.087593263474208,
  1739. b=1.0,
  1740. c=-15.964218273004214,
  1741. z=(0.6448275862068968+0.8724137931034486j),
  1742. expected=(85592537010.05054-8061416766688.324j),
  1743. rtol=2e-14,
  1744. ),
  1745. ),
  1746. pytest.param(
  1747. Hyp2f1TestCase(
  1748. a=8.095813935368371,
  1749. b=-0.5,
  1750. c=1.5,
  1751. z=(0.6448275862068968+0.8724137931034486j),
  1752. expected=(1.2334498208515172-2.1639498536219732j),
  1753. rtol=5e-11,
  1754. ),
  1755. ),
  1756. pytest.param(
  1757. Hyp2f1TestCase(
  1758. a=16.087593263474208,
  1759. b=-15.964218273004214,
  1760. c=4.0,
  1761. z=(0.6448275862068968+0.8724137931034486j),
  1762. expected=(102266.35398605966-44976.97828737755j),
  1763. rtol=1e-3,
  1764. ),
  1765. marks=pytest.mark.xfail(
  1766. reason="Unhandled parameters."
  1767. )
  1768. ),
  1769. pytest.param(
  1770. Hyp2f1TestCase(
  1771. a=4.0,
  1772. b=-3.956227226099288,
  1773. c=-15.964218273004214,
  1774. z=(0.6448275862068968-0.8724137931034484j),
  1775. expected=(-2.9590030930007236-4.190770764773225j),
  1776. rtol=5e-13,
  1777. ),
  1778. ),
  1779. pytest.param(
  1780. Hyp2f1TestCase(
  1781. a=4.080187217753502,
  1782. b=-15.5,
  1783. c=-7.5,
  1784. z=(0.5689655172413794-0.8724137931034484j),
  1785. expected=(-112554838.92074208+174941462.9202412j),
  1786. rtol=5e-05,
  1787. ),
  1788. ),
  1789. pytest.param(
  1790. Hyp2f1TestCase(
  1791. a=-15.980848054962111,
  1792. b=2.050308316530781,
  1793. c=1.0,
  1794. z=(0.6448275862068968-0.8724137931034484j),
  1795. expected=(3.7519882374080145+7.360753798667486j),
  1796. rtol=5e-13,
  1797. ),
  1798. ),
  1799. pytest.param(
  1800. Hyp2f1TestCase(
  1801. a=-7.937789122896016,
  1802. b=2.050308316530781,
  1803. c=4.0,
  1804. z=(0.6448275862068968-0.8724137931034484j),
  1805. expected=(0.000181132943964693+0.07742903103815582j),
  1806. rtol=5e-14,
  1807. ),
  1808. ),
  1809. pytest.param(
  1810. Hyp2f1TestCase(
  1811. a=-7.937789122896016,
  1812. b=4.0013768449590685,
  1813. c=-1.9631175993998025,
  1814. z=(0.5689655172413794+0.8724137931034486j),
  1815. expected=(386338.760913596-386166.51762171905j),
  1816. rtol=5e-15,
  1817. ),
  1818. ),
  1819. pytest.param(
  1820. Hyp2f1TestCase(
  1821. a=-15.980848054962111,
  1822. b=8.0,
  1823. c=-1.92872979730171,
  1824. z=(0.6448275862068968+0.8724137931034486j),
  1825. expected=(1348667126.3444858-2375132427.158893j),
  1826. rtol=5e-14,
  1827. ),
  1828. ),
  1829. pytest.param(
  1830. Hyp2f1TestCase(
  1831. a=-3.5,
  1832. b=-0.9629749245209605,
  1833. c=4.5,
  1834. z=(0.5689655172413794+0.8724137931034486j),
  1835. expected=(1.428353429538678+0.6472718120804372j),
  1836. rtol=5e-15,
  1837. ),
  1838. ),
  1839. pytest.param(
  1840. Hyp2f1TestCase(
  1841. a=-7.937789122896016,
  1842. b=-0.9629749245209605,
  1843. c=2.0397202577726152,
  1844. z=(0.5689655172413794-0.8724137931034484j),
  1845. expected=(3.1439267526119643-3.145305240375117j),
  1846. rtol=5e-14,
  1847. ),
  1848. ),
  1849. pytest.param(
  1850. Hyp2f1TestCase(
  1851. a=-1.9214641416286231,
  1852. b=-15.964218273004214,
  1853. c=-7.93846038215665,
  1854. z=(0.6448275862068968-0.8724137931034484j),
  1855. expected=(75.27467675681773+144.0946946292215j),
  1856. rtol=1e-07,
  1857. ),
  1858. ),
  1859. pytest.param(
  1860. Hyp2f1TestCase(
  1861. a=-3.75,
  1862. b=-7.75,
  1863. c=-7.5,
  1864. z=(0.5689655172413794+0.8724137931034486j),
  1865. expected=(-0.3699450626264222+0.8732812475910993j),
  1866. rtol=5e-15,
  1867. ),
  1868. ),
  1869. pytest.param(
  1870. Hyp2f1TestCase(
  1871. a=1.5,
  1872. b=16.5,
  1873. c=1.0561196186065624,
  1874. z=(0.5689655172413794-0.8724137931034484j),
  1875. expected=(5.5361025821300665-2.4709693474656285j),
  1876. rtol=5e-09,
  1877. ),
  1878. ),
  1879. pytest.param(
  1880. Hyp2f1TestCase(
  1881. a=1.5,
  1882. b=8.5,
  1883. c=-3.9316537064827854,
  1884. z=(0.6448275862068968-0.8724137931034484j),
  1885. expected=(-782805.6699207705-537192.581278909j),
  1886. rtol=5e-14,
  1887. ),
  1888. ),
  1889. pytest.param(
  1890. Hyp2f1TestCase(
  1891. a=2.5,
  1892. b=-15.5,
  1893. c=1.0561196186065624,
  1894. z=(0.6448275862068968+0.8724137931034486j),
  1895. expected=(12.345113400639693-14.993248992902007j),
  1896. rtol=0.0005,
  1897. ),
  1898. ),
  1899. pytest.param(
  1900. Hyp2f1TestCase(
  1901. a=1.5,
  1902. b=-0.5,
  1903. c=-15.964218273004214,
  1904. z=(0.6448275862068968+0.8724137931034486j),
  1905. expected=(23.698109392667842+97.15002033534108j),
  1906. rtol=5e-14,
  1907. ),
  1908. ),
  1909. pytest.param(
  1910. Hyp2f1TestCase(
  1911. a=-7.5,
  1912. b=16.5,
  1913. c=4.0013768449590685,
  1914. z=(0.6448275862068968-0.8724137931034484j),
  1915. expected=(1115.2978631811834+915.9212658718577j),
  1916. rtol=5e-15,
  1917. ),
  1918. ),
  1919. pytest.param(
  1920. Hyp2f1TestCase(
  1921. a=-15.5,
  1922. b=16.5,
  1923. c=-0.9629749245209605,
  1924. z=(0.6448275862068968+0.8724137931034486j),
  1925. expected=(642077722221.6489+535274495398.21027j),
  1926. rtol=5e-15,
  1927. ),
  1928. ),
  1929. pytest.param(
  1930. Hyp2f1TestCase(
  1931. a=-7.5,
  1932. b=-3.5,
  1933. c=4.0013768449590685,
  1934. z=(0.5689655172413794+0.8724137931034486j),
  1935. expected=(-5.689219222945697+16.877463062787143j),
  1936. rtol=5e-15,
  1937. ),
  1938. ),
  1939. pytest.param(
  1940. Hyp2f1TestCase(
  1941. a=-15.5,
  1942. b=-1.5,
  1943. c=-0.9629749245209605,
  1944. z=(0.5689655172413794-0.8724137931034484j),
  1945. expected=(-44.32070290703576+1026.9127058617403j),
  1946. rtol=5e-14,
  1947. ),
  1948. ),
  1949. pytest.param(
  1950. Hyp2f1TestCase(
  1951. a=16.25,
  1952. b=2.25,
  1953. c=4.5,
  1954. z=(0.11379310344827598-1.024137931034483j),
  1955. expected=(-0.021965227124574663+0.009908300237809064j),
  1956. rtol=1e-3,
  1957. ),
  1958. marks=pytest.mark.xfail(
  1959. reason="Unhandled parameters."
  1960. )
  1961. ),
  1962. pytest.param(
  1963. Hyp2f1TestCase(
  1964. a=2.02764642551431,
  1965. b=1.5,
  1966. c=16.5,
  1967. z=(0.26551724137931054+1.024137931034483j),
  1968. expected=(1.0046072901244183+0.19945500134119992j),
  1969. rtol=5e-14,
  1970. ),
  1971. ),
  1972. pytest.param(
  1973. Hyp2f1TestCase(
  1974. a=16.087593263474208,
  1975. b=1.0,
  1976. c=-3.9316537064827854,
  1977. z=(0.3413793103448277+0.9482758620689657j),
  1978. expected=(21022.30133421465+49175.98317370489j),
  1979. rtol=5e-13,
  1980. ),
  1981. ),
  1982. pytest.param(
  1983. Hyp2f1TestCase(
  1984. a=4.080187217753502,
  1985. b=16.088264119063613,
  1986. c=-1.9631175993998025,
  1987. z=(0.4172413793103451-0.9482758620689655j),
  1988. expected=(-7024239.358547302+2481375.02681063j),
  1989. rtol=5e-14,
  1990. ),
  1991. ),
  1992. pytest.param(
  1993. Hyp2f1TestCase(
  1994. a=16.25,
  1995. b=-15.75,
  1996. c=1.5,
  1997. z=(0.18965517241379315+1.024137931034483j),
  1998. expected=(92371704.94848-403546832.548352j),
  1999. rtol=5e-06,
  2000. ),
  2001. ),
  2002. pytest.param(
  2003. Hyp2f1TestCase(
  2004. a=8.5,
  2005. b=-7.949900487447654,
  2006. c=8.5,
  2007. z=(0.26551724137931054-1.024137931034483j),
  2008. expected=(1.9335109845308265+5.986542524829654j),
  2009. rtol=5e-10,
  2010. ),
  2011. ),
  2012. pytest.param(
  2013. Hyp2f1TestCase(
  2014. a=8.095813935368371,
  2015. b=-1.92872979730171,
  2016. c=-7.93846038215665,
  2017. z=(0.4931034482758623+0.8724137931034486j),
  2018. expected=(-122.52639696039328-59.72428067512221j),
  2019. rtol=5e-14,
  2020. ),
  2021. ),
  2022. pytest.param(
  2023. Hyp2f1TestCase(
  2024. a=16.25,
  2025. b=-1.75,
  2026. c=-1.5,
  2027. z=(0.4931034482758623+0.9482758620689657j),
  2028. expected=(-90.40642053579428+50.50649180047921j),
  2029. rtol=5e-08,
  2030. ),
  2031. ),
  2032. pytest.param(
  2033. Hyp2f1TestCase(
  2034. a=-3.5,
  2035. b=8.077282662161238,
  2036. c=16.5,
  2037. z=(0.4931034482758623+0.9482758620689657j),
  2038. expected=(-0.2155745818150323-0.564628986876639j),
  2039. rtol=5e-15,
  2040. ),
  2041. ),
  2042. pytest.param(
  2043. Hyp2f1TestCase(
  2044. a=-0.9220024191881196,
  2045. b=1.0561196186065624,
  2046. c=8.031683612216888,
  2047. z=(0.4172413793103451-0.9482758620689655j),
  2048. expected=(0.9503140488280465+0.11574960074292677j),
  2049. rtol=5e-15,
  2050. ),
  2051. ),
  2052. pytest.param(
  2053. Hyp2f1TestCase(
  2054. a=-0.75,
  2055. b=2.25,
  2056. c=-15.5,
  2057. z=(0.4172413793103451+0.9482758620689657j),
  2058. expected=(0.9285862488442175+0.8203699266719692j),
  2059. rtol=5e-13,
  2060. ),
  2061. ),
  2062. pytest.param(
  2063. Hyp2f1TestCase(
  2064. a=-7.75,
  2065. b=4.25,
  2066. c=-15.5,
  2067. z=(0.3413793103448277-0.9482758620689655j),
  2068. expected=(-1.0509834850116921-1.1145522325486075j),
  2069. rtol=1.1e-14,
  2070. ),
  2071. ),
  2072. pytest.param(
  2073. Hyp2f1TestCase(
  2074. a=-7.937789122896016,
  2075. b=-0.9629749245209605,
  2076. c=2.0397202577726152,
  2077. z=(0.4931034482758623-0.9482758620689655j),
  2078. expected=(2.88119116536769-3.4249933450696806j),
  2079. rtol=5e-15,
  2080. ),
  2081. ),
  2082. pytest.param(
  2083. Hyp2f1TestCase(
  2084. a=-15.5,
  2085. b=-15.964218273004214,
  2086. c=16.5,
  2087. z=(0.18965517241379315+1.024137931034483j),
  2088. expected=(199.65868451496038+347.79384207302877j),
  2089. rtol=5e-12,
  2090. ),
  2091. ),
  2092. pytest.param(
  2093. Hyp2f1TestCase(
  2094. a=-15.75,
  2095. b=-15.75,
  2096. c=-3.5,
  2097. z=(0.4931034482758623-0.8724137931034484j),
  2098. expected=(-208138312553.07013+58631611809.026955j),
  2099. rtol=5e-14,
  2100. ),
  2101. ),
  2102. pytest.param(
  2103. Hyp2f1TestCase(
  2104. a=-7.937789122896016,
  2105. b=-15.5,
  2106. c=-7.5,
  2107. z=(0.3413793103448277+0.9482758620689657j),
  2108. expected=(-23032.90519856288-18256.94050457296j),
  2109. rtol=5e-15,
  2110. ),
  2111. ),
  2112. pytest.param(
  2113. Hyp2f1TestCase(
  2114. a=4.5,
  2115. b=1.5,
  2116. c=1.0561196186065624,
  2117. z=(0.4931034482758623-0.8724137931034484j),
  2118. expected=(1.507342459587056+1.2332023580148403j),
  2119. rtol=1e-15,
  2120. ),
  2121. ),
  2122. pytest.param(
  2123. Hyp2f1TestCase(
  2124. a=2.5,
  2125. b=4.5,
  2126. c=-3.9316537064827854,
  2127. z=(0.4172413793103451+0.9482758620689657j),
  2128. expected=(7044.766127108853-40210.365567285575j),
  2129. rtol=5e-14,
  2130. ),
  2131. ),
  2132. pytest.param(
  2133. Hyp2f1TestCase(
  2134. a=1.5,
  2135. b=-1.5,
  2136. c=1.0561196186065624,
  2137. z=(0.03793103448275881+1.024137931034483j),
  2138. expected=(0.2725347741628333-2.247314875514784j),
  2139. rtol=1e-15,
  2140. ),
  2141. ),
  2142. pytest.param(
  2143. Hyp2f1TestCase(
  2144. a=4.5,
  2145. b=-1.5,
  2146. c=-7.949900487447654,
  2147. z=(0.26551724137931054+1.024137931034483j),
  2148. expected=(-11.250200011017546+12.597393659160472j),
  2149. rtol=5e-14,
  2150. ),
  2151. ),
  2152. pytest.param(
  2153. Hyp2f1TestCase(
  2154. a=-7.5,
  2155. b=8.5,
  2156. c=16.088264119063613,
  2157. z=(0.26551724137931054+1.024137931034483j),
  2158. expected=(-0.18515160890991517+0.7959014164484782j),
  2159. rtol=2e-15,
  2160. ),
  2161. ),
  2162. pytest.param(
  2163. Hyp2f1TestCase(
  2164. a=-7.5,
  2165. b=16.5,
  2166. c=-3.9316537064827854,
  2167. z=(0.3413793103448277-1.024137931034483j),
  2168. expected=(998246378.8556538+1112032928.103645j),
  2169. rtol=5e-14,
  2170. ),
  2171. ),
  2172. pytest.param(
  2173. Hyp2f1TestCase(
  2174. a=-1.5,
  2175. b=-3.5,
  2176. c=2.050308316530781,
  2177. z=(0.03793103448275881+1.024137931034483j),
  2178. expected=(0.5527670397711952+2.697662715303637j),
  2179. rtol=1.2e-15, # rtol bumped from 1e-15 in gh18414
  2180. ),
  2181. ),
  2182. pytest.param(
  2183. Hyp2f1TestCase(
  2184. a=-15.5,
  2185. b=-1.5,
  2186. c=-0.9629749245209605,
  2187. z=(0.4931034482758623-0.8724137931034484j),
  2188. expected=(55.396931662136886+968.467463806326j),
  2189. rtol=5e-14,
  2190. ),
  2191. ),
  2192. ]
  2193. )
  2194. def test_region5(self, hyp2f1_test_case):
  2195. """1 < |z| < 1.1 and |1 - z| >= 0.9 and real(z) >= 0"""
  2196. a, b, c, z, expected, rtol = hyp2f1_test_case
  2197. assert 1 < abs(z) < 1.1 and abs(1 - z) >= 0.9 and z.real >= 0
  2198. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  2199. @pytest.mark.parametrize(
  2200. "hyp2f1_test_case",
  2201. [
  2202. pytest.param(
  2203. Hyp2f1TestCase(
  2204. a=8.095813935368371,
  2205. b=4.0013768449590685,
  2206. c=4.078873014294075,
  2207. z=(-0.9473684210526316+0.5263157894736841j),
  2208. expected=(-0.0018093573941378783+0.003481887377423739j),
  2209. rtol=5e-15,
  2210. ),
  2211. ),
  2212. pytest.param(
  2213. Hyp2f1TestCase(
  2214. a=16.087593263474208,
  2215. b=2.050308316530781,
  2216. c=1.0651378143226575,
  2217. z=(-0.736842105263158-0.736842105263158j),
  2218. expected=(-0.00023401243818780545-1.7983496305603562e-05j),
  2219. rtol=1e-15,
  2220. ),
  2221. ),
  2222. pytest.param(
  2223. Hyp2f1TestCase(
  2224. a=1.0272592605282642,
  2225. b=8.077282662161238,
  2226. c=4.078873014294075,
  2227. z=(-0.5263157894736843-0.9473684210526316j),
  2228. expected=(0.22359773002226846-0.24092487123993353j),
  2229. rtol=1e-15,
  2230. ),
  2231. ),
  2232. pytest.param(
  2233. Hyp2f1TestCase(
  2234. a=1.0272592605282642,
  2235. b=2.050308316530781,
  2236. c=-15.963511401609862,
  2237. z=(-0.9473684210526316-0.5263157894736843j),
  2238. expected=(1.191573745740011+0.14347394589721466j),
  2239. rtol=5e-14,
  2240. ),
  2241. ),
  2242. pytest.param(
  2243. Hyp2f1TestCase(
  2244. a=4.080187217753502,
  2245. b=4.0013768449590685,
  2246. c=-15.963511401609862,
  2247. z=(-0.9473684210526316-0.5263157894736843j),
  2248. expected=(31.822620756901784-66.09094396747611j),
  2249. rtol=5e-14,
  2250. ),
  2251. ),
  2252. pytest.param(
  2253. Hyp2f1TestCase(
  2254. a=4.080187217753502,
  2255. b=8.077282662161238,
  2256. c=-7.93846038215665,
  2257. z=(-0.9473684210526316+0.5263157894736841j),
  2258. expected=(207.16750179245952+34.80478274924269j),
  2259. rtol=5e-12,
  2260. ),
  2261. ),
  2262. pytest.param(
  2263. Hyp2f1TestCase(
  2264. a=8.095813935368371,
  2265. b=-7.949900487447654,
  2266. c=8.031683612216888,
  2267. z=(-0.736842105263158+0.7368421052631575j),
  2268. expected=(-159.62429364277145+9.154224290644898j),
  2269. rtol=5e-14,
  2270. ),
  2271. ),
  2272. pytest.param(
  2273. Hyp2f1TestCase(
  2274. a=1.0272592605282642,
  2275. b=-1.92872979730171,
  2276. c=16.056809865262608,
  2277. z=(-0.9473684210526316+0.5263157894736841j),
  2278. expected=(1.121122351247184-0.07170260470126685j),
  2279. rtol=5e-15,
  2280. ),
  2281. ),
  2282. pytest.param(
  2283. Hyp2f1TestCase(
  2284. a=16.087593263474208,
  2285. b=-0.9629749245209605,
  2286. c=16.056809865262608,
  2287. z=(-0.9473684210526316+0.5263157894736841j),
  2288. expected=(1.9040596681316053-0.4951799449960107j),
  2289. rtol=5e-14,
  2290. ),
  2291. ),
  2292. pytest.param(
  2293. Hyp2f1TestCase(
  2294. a=1.0272592605282642,
  2295. b=-1.92872979730171,
  2296. c=-0.906685989801748,
  2297. z=(-0.9473684210526316-0.5263157894736843j),
  2298. expected=(-14.496623497780739-21.897524523299875j),
  2299. rtol=5e-14,
  2300. ),
  2301. ),
  2302. pytest.param(
  2303. Hyp2f1TestCase(
  2304. a=4.080187217753502,
  2305. b=-3.9316537064827854,
  2306. c=-3.9924618758357022,
  2307. z=(-0.5263157894736843-0.9473684210526316j),
  2308. expected=(36.33473466026878+253.88728442029577j),
  2309. rtol=5e-14,
  2310. ),
  2311. ),
  2312. pytest.param(
  2313. Hyp2f1TestCase(
  2314. a=1.0272592605282642,
  2315. b=-15.964218273004214,
  2316. c=-0.906685989801748,
  2317. z=(-0.9473684210526316+0.5263157894736841j),
  2318. expected=(1505052.5653144997-50820766.81043443j),
  2319. rtol=1e-14,
  2320. ),
  2321. ),
  2322. pytest.param(
  2323. Hyp2f1TestCase(
  2324. a=-3.956227226099288,
  2325. b=4.0013768449590685,
  2326. c=1.0651378143226575,
  2327. z=(-0.5263157894736843+0.9473684210526314j),
  2328. expected=(-127.79407519260877-28.69899444941112j),
  2329. rtol=5e-15,
  2330. ),
  2331. ),
  2332. pytest.param(
  2333. Hyp2f1TestCase(
  2334. a=-1.9214641416286231,
  2335. b=8.077282662161238,
  2336. c=16.056809865262608,
  2337. z=(-0.9473684210526316-0.5263157894736843j),
  2338. expected=(2.0623331933754976+0.741234463565458j),
  2339. rtol=5e-15,
  2340. ),
  2341. ),
  2342. pytest.param(
  2343. Hyp2f1TestCase(
  2344. a=-3.956227226099288,
  2345. b=8.077282662161238,
  2346. c=2.0397202577726152,
  2347. z=(-0.9473684210526316+0.5263157894736841j),
  2348. expected=(30.729193458862525-292.5700835046965j),
  2349. rtol=1e-15,
  2350. ),
  2351. ),
  2352. pytest.param(
  2353. Hyp2f1TestCase(
  2354. a=-1.9214641416286231,
  2355. b=1.0561196186065624,
  2356. c=-1.9631175993998025,
  2357. z=(-0.5263157894736843-0.9473684210526316j),
  2358. expected=(1.1285917906203495-0.735264575450189j),
  2359. rtol=5e-15,
  2360. ),
  2361. ),
  2362. pytest.param(
  2363. Hyp2f1TestCase(
  2364. a=-0.9220024191881196,
  2365. b=1.0561196186065624,
  2366. c=-3.9924618758357022,
  2367. z=(-0.736842105263158+0.7368421052631575j),
  2368. expected=(0.6356474446678052-0.02429663008952248j),
  2369. rtol=5e-14,
  2370. ),
  2371. ),
  2372. pytest.param(
  2373. Hyp2f1TestCase(
  2374. a=-1.9214641416286231,
  2375. b=16.088264119063613,
  2376. c=-7.93846038215665,
  2377. z=(-0.736842105263158+0.7368421052631575j),
  2378. expected=(0.4718880510273174+0.655083067736377j),
  2379. rtol=1e-11,
  2380. ),
  2381. ),
  2382. pytest.param(
  2383. Hyp2f1TestCase(
  2384. a=-7.937789122896016,
  2385. b=-3.9316537064827854,
  2386. c=16.056809865262608,
  2387. z=(-0.9473684210526316+0.5263157894736841j),
  2388. expected=(-0.14681550942352714+0.16092206364265146j),
  2389. rtol=5e-11,
  2390. ),
  2391. ),
  2392. pytest.param(
  2393. Hyp2f1TestCase(
  2394. a=-0.9220024191881196,
  2395. b=-15.964218273004214,
  2396. c=1.0651378143226575,
  2397. z=(-0.5263157894736843+0.9473684210526314j),
  2398. expected=(-6.436835190526225+22.883156700606182j),
  2399. rtol=5e-14,
  2400. ),
  2401. ),
  2402. pytest.param(
  2403. Hyp2f1TestCase(
  2404. a=-0.9220024191881196,
  2405. b=-7.949900487447654,
  2406. c=4.078873014294075,
  2407. z=(-0.9473684210526316-0.5263157894736843j),
  2408. expected=(-0.7505682955068583-1.1026583264249945j),
  2409. rtol=5e-14,
  2410. ),
  2411. ),
  2412. pytest.param(
  2413. Hyp2f1TestCase(
  2414. a=-3.956227226099288,
  2415. b=-3.9316537064827854,
  2416. c=-7.93846038215665,
  2417. z=(-0.9473684210526316-0.5263157894736843j),
  2418. expected=(3.6247814989198166+2.596041360148318j),
  2419. rtol=5e-15,
  2420. ),
  2421. ),
  2422. pytest.param(
  2423. Hyp2f1TestCase(
  2424. a=-3.956227226099288,
  2425. b=-15.964218273004214,
  2426. c=-1.9631175993998025,
  2427. z=(-0.5263157894736843-0.9473684210526316j),
  2428. expected=(-59537.65287927933-669074.4342539902j),
  2429. rtol=5e-15,
  2430. ),
  2431. ),
  2432. pytest.param(
  2433. Hyp2f1TestCase(
  2434. a=-3.956227226099288,
  2435. b=-15.964218273004214,
  2436. c=-1.9631175993998025,
  2437. z=(-0.9473684210526316-0.5263157894736843j),
  2438. expected=(-433084.9970266166+431088.393918521j),
  2439. rtol=5e-14,
  2440. ),
  2441. ),
  2442. pytest.param(
  2443. Hyp2f1TestCase(
  2444. a=1,
  2445. b=1,
  2446. c=4,
  2447. z=(3 + 4j),
  2448. expected=(0.49234384000963544+0.6051340616612397j),
  2449. rtol=5e-14,
  2450. ),
  2451. ),
  2452. ]
  2453. )
  2454. def test_region6(self, hyp2f1_test_case):
  2455. """|z| > 1 but not in region 5."""
  2456. a, b, c, z, expected, rtol = hyp2f1_test_case
  2457. assert (
  2458. abs(z) > 1 and
  2459. not (1 < abs(z) < 1.1 and abs(1 - z) >= 0.9 and z.real >= 0)
  2460. )
  2461. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  2462. @pytest.mark.parametrize(
  2463. "hyp2f1_test_case",
  2464. [
  2465. # Broke when fixing gamma pole behavior in gh-21827
  2466. pytest.param(
  2467. Hyp2f1TestCase(
  2468. a=1.3,
  2469. b=-0.2,
  2470. c=0.3,
  2471. z=-2.1,
  2472. expected=1.8202169687521206,
  2473. rtol=5e-15,
  2474. ),
  2475. ),
  2476. ]
  2477. )
  2478. def test_miscellaneous(self, hyp2f1_test_case ):
  2479. a, b, c, z, expected, rtol = hyp2f1_test_case
  2480. assert_allclose(hyp2f1(a, b, c, z), expected, rtol=rtol)
  2481. @pytest.mark.slow
  2482. @check_version(mpmath, "1.0.0")
  2483. def test_test_hyp2f1(self):
  2484. """Test that expected values match what is computed by mpmath.
  2485. This gathers the parameters for the test cases out of the pytest marks.
  2486. The parameters are a, b, c, z, expected, rtol, where expected should
  2487. be the value of hyp2f1(a, b, c, z) computed with mpmath. The test
  2488. recomputes hyp2f1(a, b, c, z) using mpmath and verifies that expected
  2489. actually is the correct value. This allows the data for the tests to
  2490. live within the test code instead of an external datafile, while
  2491. avoiding having to compute the results with mpmath during the test,
  2492. except for when slow tests are being run.
  2493. """
  2494. test_methods = [
  2495. test_method for test_method in dir(self)
  2496. if test_method.startswith('test') and
  2497. # Filter properties and attributes (futureproofing).
  2498. callable(getattr(self, test_method)) and
  2499. # Filter out this test
  2500. test_method != 'test_test_hyp2f1'
  2501. ]
  2502. for test_method in test_methods:
  2503. params = self._get_test_parameters(getattr(self, test_method))
  2504. for a, b, c, z, expected, _ in params:
  2505. assert_allclose(mp_hyp2f1(a, b, c, z), expected, rtol=2.25e-16)
  2506. def _get_test_parameters(self, test_method):
  2507. """Get pytest.mark parameters for a test in this class."""
  2508. return [
  2509. case.values[0] for mark in test_method.pytestmark
  2510. if mark.name == 'parametrize'
  2511. for case in mark.args[1]
  2512. ]
  2513. class TestHyp2f1ExtremeInputs:
  2514. @pytest.mark.parametrize("a", [1.0, 2.0, 3.0, -np.inf, np.inf])
  2515. @pytest.mark.parametrize("b", [3.0, 4.0, 5.0, -np.inf, np.inf])
  2516. @pytest.mark.parametrize("c", [3.0, 5.0, 6.0, 7.0])
  2517. @pytest.mark.parametrize("z", [4.0 + 1.0j])
  2518. def test_inf_a_b(self, a, b, c, z):
  2519. if np.any(np.isinf(np.asarray([a, b]))):
  2520. assert(np.isnan(hyp2f1(a, b, c, z)))
  2521. def test_large_a_b(self):
  2522. assert(np.isnan(hyp2f1(10**7, 1.0, 3.0, 4.0 + 1.0j)))
  2523. assert(np.isnan(hyp2f1(-10**7, 1.0, 3.0, 4.0 + 1.0j)))
  2524. assert(np.isnan(hyp2f1(1.0, 10**7, 3.0, 4.0 + 1.0j)))
  2525. assert(np.isnan(hyp2f1(1.0, -10**7, 3.0, 4.0 + 1.0j)))
  2526. # Already correct in main but testing for surety
  2527. assert(np.isnan(hyp2f1(np.inf, 1.0, 3.0, 4.0)))
  2528. assert(np.isnan(hyp2f1(1.0, np.inf, 3.0, 4.0)))