diff --git a/setup.py b/setup.py index 05e8ca67e1..ba0922b273 100644 --- a/setup.py +++ b/setup.py @@ -500,7 +500,7 @@ def setup_package(): name=package_name, package_dir={"": NRN_PY_ROOT}, packages=py_packages, - package_data={"neuron": ["*.dat", "tests/*.json"]}, + package_data={"neuron": ["*.dat"]}, ext_modules=extensions, scripts=[ os.path.join(NRN_PY_SCRIPTS, f) diff --git a/share/lib/python/neuron/tests/test_rxd.json b/share/lib/python/neuron/tests/test_rxd.json deleted file mode 100644 index 10c681c18f..0000000000 --- a/share/lib/python/neuron/tests/test_rxd.json +++ /dev/null @@ -1,666 +0,0 @@ -{ - "trivial_ecs_data": { - "False": [ - 1.0, - 0.9999975013886804, - 0.9999774378669442, - 0.9998977298459816, - 0.999683249239208, - 0.999233095122319, - 0.9984342775161097, - 0.9971750000657644, - 0.9953548976762606, - 0.9928916564339986, - 0.9897243754423741, - 0.985814368310196, - 0.9811441475925942, - 0.9757152507508027, - 0.9695454356132381, - 0.9626656387440524, - 0.9551169704970437, - 0.9469479227048566, - 0.9382118896237476, - 0.928965047713157, - 0.9192646017261445, - 0.9091673798703476, - 0.8987287461912615, - 0.8880017910312052, - 0.8770367581645542, - 0.8658806682496021, - 0.8545771012638642, - 0.8431661046665001, - 0.8316841985149556, - 0.8201644532317675, - 0.8086366199145236, - 0.7971272968665187, - 0.7856601193366658, - 0.7742559622858297, - 0.7629331483660402, - 0.7517076552500634, - 0.7405933180308322, - 0.729602023674572, - 0.7187438955075627, - 0.7080274664897305, - 0.6974598406190147, - 0.6870468422535746, - 0.6767931534640339, - 0.666702439759881, - 0.6567774646932262, - 0.6470201939460375, - 0.6374318895671022, - 0.6280131950530249, - 0.618764211972033, - 0.6096845688168512, - 0.6007734827485834, - 0.592029814861357, - 0.5834521195604474, - 0.5750386886069674, - 0.566787590341624, - 0.5586967045597302, - 0.5507637534704564, - 0.542986329135765, - 0.5353619177489981, - 0.5278879210798492, - 0.520561675381579, - 0.5133804680278274, - 0.5063415521201762, - 0.4994421592836728, - 0.4926795108456907, - 0.4860508275736653, - 0.47955333812926787, - 0.47318428638032217, - 0.4669409376970896, - 0.46082058434632084, - 0.4548205500845658, - 0.44893819404152296, - 0.4431709139745962, - 0.437516148967192, - 0.4319713816355469, - 0.4265341399019367, - 0.42120199838589845, - 0.4159725794595267, - 0.41084355400792044, - 0.40581264193139277, - 0.40087761242206477, - 0.3960362840438892, - 0.3912865246419576, - 0.38662625110408755, - 0.3820534289951289, - 0.3775660720821487, - 0.37316224176661034, - 0.3688400464378394, - 0.3645976407604392, - 0.3604332249068622, - 0.356345043745043, - 0.3523313859898391, - 0.34839058332598377, - 0.3445210095093366, - 0.3407210794523858, - 0.33698924829922156, - 0.33332401049454546, - 0.3297238988506902, - 0.32618748361610794, - 0.3227133715483166, - 0.319300204993885 - ], - "0.01": [ - 1.0, - 1.0, - 1.0, - 0.9999999999993757, - 0.999999999994894, - 0.9999999999684935, - 0.9999999997476527, - 0.9999999928933891, - 0.9999999611564773, - 0.9999998797767268, - 0.9999996998881439, - 0.9999993374567407, - 0.9999984853833065, - 0.9999969740580187, - 0.9999944882384337, - 0.999990631594901, - 0.9999849509581288, - 0.9999769206381163, - 0.9999582122018839, - 0.99992971528816, - 0.9998885520830331, - 0.9998315279906315, - 0.9996818635176349, - 0.9994522087548297, - 0.9991215537513378, - 0.9986688188931263, - 0.9980737640971887, - 0.9973169807956457, - 0.9963810719470815, - 0.9952501731851596, - 0.9939108695612834, - 0.9923517494757513, - 0.990563762843154, - 0.9885402079277492, - 0.9862765182500737, - 0.9837701825347182, - 0.9810207339245086, - 0.9780291325294735, - 0.9747989764631944, - 0.9713343413786614, - 0.9676399370120405, - 0.961066451151739, - 0.9539287981955907, - 0.9462557577841545, - 0.9380908351574285, - 0.9295048630248105, - 0.9272938750656939, - 0.9250579717836777, - 0.9227970935562565, - 0.916466538640017, - 0.9099911643714976, - 0.903362145740033, - 0.896607665570261, - 0.8897506341029571, - 0.882783639668767, - 0.875743025331908, - 0.8686235564310014, - 0.8614266253277882, - 0.8541863694353786, - 0.8468993821613305, - 0.8395705411269264, - 0.8322240727536439, - 0.8248512178576504, - 0.8174717412783322, - 0.8101012803420092, - 0.8027295128162794, - 0.795382570912665, - 0.7880520562862553, - 0.7807347758418224, - 0.7734449586662135, - 0.7661975818043348, - 0.7589799271016704, - 0.7518171027828684, - 0.7446977692713531, - 0.7376160661849058, - 0.7305954685552188, - 0.7236266087584206, - 0.7167068363521265, - 0.7140993659873981, - 0.7115003569088247, - 0.7053989759513706, - 0.6937157033260776, - 0.6892286429757224, - 0.6847738597616794, - 0.680346043973446, - 0.6736943892225341, - 0.6671180984407125, - 0.662236424428377, - 0.6573969190546712, - 0.6525933206930011, - 0.6478347503609198, - 0.6431166994074956, - 0.6384369406609263, - 0.629051615757503, - 0.6198222188768284, - 0.6175428046075583, - 0.6152735586037428, - 0.6111170811525735, - 0.6031212235932468, - 0.5952593537962105, - 0.5921305073271925, - 0.589021543706074, - 0.5843049292559478, - 0.5796335964525046, - 0.57501603797955, - 0.5704420014938749, - 0.5659178448897603, - 0.5614455517225058, - 0.5591788147005415, - 0.5569248277948933, - 0.5506074431348664, - 0.5478382336692825, - 0.5450878675432425, - 0.5387888979259772, - 0.5362404522913171, - 0.5337094641249713, - 0.5282374991063938, - 0.5259248453123049, - 0.5236262813729924, - 0.5182614252948405, - 0.5158555311460749, - 0.5134660721175922, - 0.5077709278071862, - 0.5053179819941784, - 0.5028817741460606, - 0.49744076421889366, - 0.49520127183112733, - 0.4929770110029178, - 0.4880637158772831, - 0.4859684631915766, - 0.4838861487508862, - 0.4790294757925702, - 0.47687065162757547, - 0.47472669028331466, - 0.4696849124713687, - 0.4675266379954105, - 0.4653827515472591, - 0.46059622403775785, - 0.45860850681188087, - 0.4566341643290534, - 0.45222826180913167, - 0.4503369914749967, - 0.4484573582920104, - 0.4440766399353272, - 0.44214365209440704, - 0.4402239033393764, - 0.4357529446107943, - 0.4338466468246234, - 0.4319526748954548, - 0.42771940093115685, - 0.4259480291636831, - 0.42418839478752657, - 0.4202300998323772, - 0.4185239107729718, - 0.4168280791675472, - 0.4128821813954716, - 0.411151841187283, - 0.40943320175716824, - 0.4054591322631254, - 0.4037685048216922, - 0.40208843869666, - 0.39832558823662206, - 0.39674079574945603, - 0.3951663234845347, - 0.3916025661247801, - 0.3900627879465062, - 0.38853217065630374, - 0.3849784483231059, - 0.38342810283841006, - 0.38188806435279576, - 0.3783453864065237, - 0.37683971858666915, - 0.3753431215943966, - 0.37198272430919915, - 0.3705596473205069, - 0.369145673011817, - 0.36593017118156906, - 0.36453932880580625, - 0.363156559348617, - 0.35995389116692217, - 0.358562523467025, - 0.3571802314864285, - 0.35401195406372227, - 0.3526654576925955, - 0.35132677928092004, - 0.34831289231094187, - 0.34703074630323383, - 0.3457566587383628, - 0.3428492728160761, - 0.34159142512656304, - 0.34034067750180974, - 0.3374508889913977, - 0.33619956600663337, - 0.3349562466940476, - 0.33211336362253635, - 0.3309044582410871, - 0.3297023177069934, - 0.32698870975793815, - 0.32583004833643353, - 0.3246785486149972, - 0.322044467574018, - 0.3209052709390766, - 0.31977231337146067 - ], - "1e-05": [ - 1.0, - 1.0, - 1.0, - 1.0, - 1.0, - 1.0, - 1.0, - 1.0, - 0.9999999999999994, - 0.999999999999973, - 0.9999999999998286, - 0.9999999999994353, - 0.9999999999985202, - 0.9999999999965848, - 0.999999999991421, - 0.9999999999815654, - 0.999999999964278, - 0.999999999935795, - 0.9999999998244792, - 0.9999999995977931, - 0.9999999987558622, - 0.9999999969054565, - 0.9999999933717028, - 0.9999999871894636, - 0.9999999770945371, - 0.9999999615055236, - 0.9999999384936957, - 0.9999999057511308, - 0.9999998222204166, - 0.9999996889877318, - 0.9999994874837334, - 0.999999195494715, - 0.9999987869759616, - 0.9999978778927708, - 0.9999965094234947, - 0.9999945377974364, - 0.9999917976154723, - 0.9999881018395208, - 0.9999832421044165, - 0.99997698930736, - 0.9999690944252602, - 0.9999592894154012, - 0.9999401848217758, - 0.9999149868024333, - 0.9998825523031787, - 0.9998416677700266, - 0.999791059592578, - 0.9997294043566004, - 0.9996553389790277, - 0.9995674703998882, - 0.9994643850266823, - 0.9993446578768971, - 0.9992068613209312, - 0.9990495732666511, - 0.9988713847468418, - 0.9986709069017091, - 0.9984467774205655, - 0.9981976664057219, - 0.9979222816860815, - 0.9976193735297934, - 0.9972877388223238, - 0.9969262246908328, - 0.996533731653732, - 0.9961092162614316, - 0.9956516933112639, - 0.995160237588464, - 0.9946339852522628, - 0.9940721347820276, - 0.9934739476576494, - 0.9928387486094244, - 0.9921659257088754, - 0.9914549300102379, - 0.9907052751690002, - 0.9899165365563947, - 0.9890883505202034, - 0.9882204130405648, - 0.9873124787416938, - 0.9863643591450846, - 0.9853759215363472, - 0.9843470868598637, - 0.9832778285393545, - 0.9821681700454686, - 0.9810181837632249, - 0.9798279882523508, - 0.9785977472498147, - 0.9773276666315711, - 0.9760179936337368, - 0.9746690135138534, - 0.973281049070232, - 0.9718544574226932, - 0.970389628347756, - 0.9688869823638351, - 0.9662560899384262, - 0.9635203094788997, - 0.9606821993780256, - 0.9577444920812167, - 0.9547100690683178, - 0.9515819411366752, - 0.9483632227757351, - 0.9450571205495613, - 0.9416669020994433, - 0.9381959000999215, - 0.9346474739514014, - 0.9310250019996876, - 0.9273318651890746, - 0.9235714575523157, - 0.9197471440736972, - 0.9158622774695346, - 0.9119201741117782, - 0.9079241163948638, - 0.9038773101093882, - 0.8997829152661703, - 0.8956440506833048, - 0.8914637634703556, - 0.8872450198182428, - 0.8829907105064231, - 0.8787036576202755, - 0.8707492329414495, - 0.8687467372991504, - 0.8667391782827082, - 0.8647268018964069, - 0.862709850134354, - 0.8585978518713738, - 0.8544698540373321, - 0.8503277143424198, - 0.8461732532162092, - 0.8420082064910313, - 0.8378342644221053, - 0.8336530592192254, - 0.8294661713938566, - 0.8252750957253966, - 0.8210812732955917, - 0.8168861005800381, - 0.8126909232910099, - 0.808497028390498, - 0.801870527941527, - 0.7952548736200997, - 0.7886543612287468, - 0.7820730076362225, - 0.775514525626251, - 0.7689823476263041, - 0.76247965836786, - 0.756009378236416, - 0.749574210390875, - 0.743176642418555, - 0.7368189633320615, - 0.7305032399754438, - 0.724231346521673, - 0.7180049651772312, - 0.7118256478753264, - 0.7056948259233441, - 0.7032583360819944, - 0.700829860418756, - 0.6984094703765288, - 0.6959972339923495, - 0.6935932151265922, - 0.6889317429731345, - 0.6817668349582598, - 0.6746798126979188, - 0.6676718056770632, - 0.6607437321602112, - 0.6538963342916061, - 0.6471301405555971, - 0.6404455882961573, - 0.638787241606903, - 0.6371340113764097, - 0.6354859019485614, - 0.632317967018681, - 0.6291691359121044, - 0.624349241554268, - 0.619574789517913, - 0.614845708115443, - 0.6101619207501211, - 0.6055232995513015, - 0.6009296921089062, - 0.5963809255909179, - 0.5884265027887375, - 0.5806112287452613, - 0.5729337321697969, - 0.5653924576034643, - 0.5579857024960585, - 0.5561548262393686, - 0.5543322220611878, - 0.5525178614766851, - 0.5497619522652349, - 0.5470251014903538, - 0.5421958421956508, - 0.5374261214848611, - 0.5327153071436265, - 0.5280627574430141, - 0.5234678232476324, - 0.518929844460602, - 0.5144481596200524, - 0.5100220936639072, - 0.5056509822652775, - 0.501334134582734, - 0.497070898714232, - 0.492860583575257, - 0.488702496136303, - 0.4845959780644786, - 0.4805403496661883, - 0.4765349345681554, - 0.47257907275051975, - 0.46867209134329857, - 0.46481334795798307, - 0.4610021777856322, - 0.45723791746718145, - 0.4535199242983486, - 0.44984757092630373, - 0.4462202100082472, - 0.44263723745342903, - 0.4390980178177817, - 0.4356019204361891, - 0.43214835473501945, - 0.4287367135374875, - 0.4253663990336738, - 0.4220368326096732, - 0.41874742793163006, - 0.4154976298562691, - 0.41228686587129565, - 0.4091145679414439, - 0.40436315170089987, - 0.3996975358470319, - 0.3951158478239174, - 0.39061627014508404, - 0.3861970390853348, - 0.3841086119821148, - 0.3820380229802458, - 0.37998508572555983, - 0.3779496187417315, - 0.3745426919167079, - 0.3711844376968717, - 0.3678740151003091, - 0.3646106064268745, - 0.36139339169632445, - 0.3582215708412834, - 0.35509431859041374, - 0.35201085923465375, - 0.34897048346845855, - 0.345972428841367, - 0.3430159436132327, - 0.3401003270324417, - 0.3372248854371575, - 0.33438895086942516, - 0.33159183891956634, - 0.32883286088925856, - 0.32611135696096716, - 0.32342673756054513, - 0.320778362376132 - ] - }, - "scalar_bistable_data": [ - 4.666144368739565e-24, - 2.888704007378301e-23, - 1.9865049531958455e-22, - 1.3417088797559409e-21, - 8.872570814175612e-21, - 5.740880124662936e-20, - 3.632196361482048e-19, - 2.2456041210043948e-18, - 1.3557115052023306e-17, - 7.986451339137776e-17, - 4.587323676899687e-16, - 2.567045965818934e-15, - 1.398326895049454e-14, - 7.407949505967694e-14, - 3.8132509319176133e-13, - 1.905347304599464e-12, - 9.231798364410495e-12, - 4.33273265966826e-11, - 1.9674719569026998e-10, - 8.63399030466642e-10, - 3.657079221471436e-09, - 1.4932070567139546e-08, - 5.869401066025267e-08, - 2.218029569259483e-07, - 8.04721279962928e-07, - 2.79921382956858e-06, - 9.323183477925758e-06, - 2.969562407156746e-05, - 9.035408030381584e-05, - 0.0002623954841897342, - 0.0007269141545185264, - 0.0019207269099111785, - 0.004841879243431059, - 0.01164965343224167, - 0.02674863273052536, - 0.05846777500048251, - 0.12067994530088386, - 0.23084596756508963, - 0.3962758789592411, - 0.5900229199038892, - 0.7586218889021915, - 0.8722981880509894, - 0.9370823930113995, - 0.9705058492437157, - 0.9867204567968437, - 0.9942426940783657, - 0.9975977799681778, - 0.9990359504416326, - 0.9996249801006252, - 0.9998477834074035, - 0.9999041758657206, - 0.9998477834074035, - 0.9996249801006252, - 0.9990359504416326, - 0.9975977799681778, - 0.9942426940783657, - 0.9867204567968437, - 0.9705058492437147, - 0.9370823930113918, - 0.8722981880509718, - 0.75862188890219, - 0.5900229199038813, - 0.39627587895923605, - 0.2308459675650862, - 0.12067994530088234, - 0.058467775000481934, - 0.026748632730525093, - 0.011649653432241593, - 0.0048418792434310265, - 0.0019207269099111698, - 0.0007269141545185239, - 0.00026239548418973194, - 9.035408030381517e-05, - 2.9695624071567297e-05, - 9.323183477925707e-06, - 2.799213829568571e-06, - 8.04721279962927e-07, - 2.2180295692594684e-07, - 5.869401066025244e-08, - 1.4932070567139493e-08, - 3.6570792214714333e-09, - 8.633990304666437e-10, - 1.967471956902688e-10, - 4.332732659668245e-11, - 9.231798364410489e-12, - 1.9053473045994673e-12, - 3.813250931917625e-13, - 7.407949505967726e-14, - 1.3983268950494506e-14, - 2.5670459658189344e-15, - 4.587323676899693e-16, - 7.986451339137798e-17, - 1.3557115052023379e-17, - 2.2456041210043886e-18, - 3.632196361482047e-19, - 5.740880124662945e-20, - 8.872570814175644e-21, - 1.341708879755948e-21, - 1.9865049531958394e-22, - 2.8887040073782976e-23, - 4.66614436873957e-24 - ] -} \ No newline at end of file diff --git a/share/lib/python/neuron/tests/test_rxd.py b/share/lib/python/neuron/tests/test_rxd.py index dc6cd2aef8..db85696c90 100644 --- a/share/lib/python/neuron/tests/test_rxd.py +++ b/share/lib/python/neuron/tests/test_rxd.py @@ -2,9 +2,7 @@ import neuron import unittest import sys -import os -import json -from multiprocessing import Process, Lock +from multiprocessing import Process try: import multiprocessing as mp @@ -13,12 +11,674 @@ except: pass -# load the reference data from rxd_data.json -fdir = os.path.dirname(os.path.abspath(__file__)) -test_data = json.load(open(os.path.join(fdir, "test_rxd.json"), "r")) +scalar_bistable_data = [ + 4.666144368739553e-24, + 2.888704007378294e-23, + 1.986504953195841e-22, + 1.341708879755938e-21, + 8.872570814175589e-21, + 5.740880124662921e-20, + 3.632196361482038e-19, + 2.245604121004388e-18, + 1.355711505202327e-17, + 7.986451339137754e-17, + 4.587323676899676e-16, + 2.567045965818926e-15, + 1.398326895049450e-14, + 7.407949505967670e-14, + 3.813250931917600e-13, + 1.905347304599457e-12, + 9.231798364410461e-12, + 4.332732659668245e-11, + 1.967471956902693e-10, + 8.633990304666386e-10, + 3.657079221471421e-09, + 1.493207056713948e-08, + 5.869401066025243e-08, + 2.218029569259474e-07, + 8.047212799629250e-07, + 2.799213829568570e-06, + 9.323183477925731e-06, + 2.969562407156739e-05, + 9.035408030381566e-05, + 2.623954841897339e-04, + 7.269141545185255e-04, + 1.920726909911178e-03, + 4.841879243431064e-03, + 1.164965343224173e-02, + 2.674863273052559e-02, + 5.846777500048252e-02, + 1.206799453008834e-01, + 2.308459675650935e-01, + 3.962758789592548e-01, + 5.900229199039158e-01, + 7.586218889022415e-01, + 8.722981880510015e-01, + 9.370823930114011e-01, + 9.705058492437171e-01, + 9.867204567968444e-01, + 9.942426940783661e-01, + 9.975977799681778e-01, + 9.990359504416327e-01, + 9.996249801006252e-01, + 9.998477834074035e-01, + 9.999041758657206e-01, + 9.998477834074035e-01, + 9.996249801006252e-01, + 9.990359504416326e-01, + 9.975977799681777e-01, + 9.942426940783655e-01, + 9.867204567968437e-01, + 9.705058492437160e-01, + 9.370823930113995e-01, + 8.722981880509845e-01, + 7.586218889021992e-01, + 5.900229199038706e-01, + 3.962758789592359e-01, + 2.308459675650852e-01, + 1.206799453008814e-01, + 5.846777500048142e-02, + 2.674863273052497e-02, + 1.164965343224158e-02, + 4.841879243431020e-03, + 1.920726909911166e-03, + 7.269141545185224e-04, + 2.623954841897313e-04, + 9.035408030381501e-05, + 2.969562407156726e-05, + 9.323183477925702e-06, + 2.799213829568569e-06, + 8.047212799629269e-07, + 2.218029569259469e-07, + 5.869401066025247e-08, + 1.493207056713951e-08, + 3.657079221471437e-09, + 8.633990304666446e-10, + 1.967471956902691e-10, + 4.332732659668252e-11, + 9.231798364410503e-12, + 1.905347304599471e-12, + 3.813250931917631e-13, + 7.407949505967741e-14, + 1.398326895049453e-14, + 2.567045965818940e-15, + 4.587323676899705e-16, + 7.986451339137816e-17, + 1.355711505202341e-17, + 2.245604121004394e-18, + 3.632196361482056e-19, + 5.740880124662959e-20, + 8.872570814175665e-21, + 1.341708879755951e-21, + 1.986504953195844e-22, + 2.888704007378305e-23, + 4.666144368739581e-24, +] +trivial_ecs_data = { + False: [ + 1.000000000000000e00, + 9.999975013886804e-01, + 9.999774378669442e-01, + 9.998977298459814e-01, + 9.996832492392076e-01, + 9.992330951223182e-01, + 9.984342775161091e-01, + 9.971750000657639e-01, + 9.953548976762590e-01, + 9.928916564339932e-01, + 9.897243754423555e-01, + 9.858143683101370e-01, + 9.811441475924241e-01, + 9.757152507503439e-01, + 9.695454356120868e-01, + 9.626656387413414e-01, + 9.551169704910168e-01, + 9.469479226921377e-01, + 9.382118895981384e-01, + 9.289650476637475e-01, + 9.192646016344460e-01, + 9.091673797060952e-01, + 8.987287459064514e-01, + 8.880017905518656e-01, + 8.770367573796769e-01, + 8.658806669966089e-01, + 8.545770993099358e-01, + 8.431661016850746e-01, + 8.316841940567001e-01, + 8.201644466893430e-01, + 8.086366104805101e-01, + 7.971272834839320e-01, + 7.856601006415908e-01, + 7.742559365417961e-01, + 7.629331133899011e-01, + 7.517076083292696e-01, + 7.405932558321451e-01, + 7.296019421444131e-01, + 7.187437897643434e-01, + 7.080273307086645e-01, + 6.974596679100502e-01, + 6.870466245332152e-01, + 6.767928813219394e-01, + 6.667021023212317e-01, + 6.567770494779278e-01, + 6.470196867258985e-01, + 6.374312742221647e-01, + 6.280124534282580e-01, + 6.187633237355973e-01, + 6.096835113211366e-01, + 6.007722308951912e-01, + 5.920283409711493e-01, + 5.834503932497362e-01, + 5.750366766708355e-01, + 5.667852566452943e-01, + 5.586940099388136e-01, + 5.507606556408047e-01, + 5.429827826135633e-01, + 5.353578737816238e-01, + 5.278833275879240e-01, + 5.205564769125375e-01, + 5.133746057212193e-01, + 5.063349636848303e-01, + 4.994347789867492e-01, + 4.926712695135610e-01, + 4.860416526044784e-01, + 4.795431535169798e-01, + 4.731730127498988e-01, + 4.669284923505265e-01, + 4.608068813190689e-01, + 4.548055002118984e-01, + 4.489217050343421e-01, + 4.431528905041363e-01, + 4.374964927580476e-01, + 4.319499915664357e-01, + 4.265109121135835e-01, + 4.211768263954196e-01, + 4.159453542806875e-01, + 4.108141642766345e-01, + 4.057809740358395e-01, + 4.008435506368045e-01, + 3.959997106673694e-01, + 3.912473201368166e-01, + 3.865842942396779e-01, + 3.820085969917059e-01, + 3.775182407561858e-01, + 3.731112856767305e-01, + 3.687858390308746e-01, + 3.645400545171554e-01, + 3.603721314869148e-01, + 3.562803141307546e-01, + 3.522628906284160e-01, + 3.483181922698216e-01, + 3.444445925540838e-01, + 3.406405062724689e-01, + 3.369043885805584e-01, + 3.332347340641985e-01, + 3.296300758032397e-01, + 3.260889844365475e-01, + 3.226100672312980e-01, + 3.191919671591613e-01, + ], + 1e-2: [ + 1.000000000000000e00, + 1.000000000000000e00, + 1.000000000000000e00, + 9.999999999993757e-01, + 9.999999999948940e-01, + 9.999999999684935e-01, + 9.999999997476527e-01, + 9.999999928933891e-01, + 9.999999611564773e-01, + 9.999998797767268e-01, + 9.999996998881439e-01, + 9.999993374567406e-01, + 9.999984853833063e-01, + 9.999969740580184e-01, + 9.999944882384333e-01, + 9.999906315949002e-01, + 9.999849509581277e-01, + 9.999769206381147e-01, + 9.999582122018814e-01, + 9.999297152881566e-01, + 9.998885520830283e-01, + 9.998315279906250e-01, + 9.996818635176246e-01, + 9.994522087548142e-01, + 9.991215537513162e-01, + 9.986688188930973e-01, + 9.980737640971513e-01, + 9.973169807955987e-01, + 9.963810719470240e-01, + 9.952501731850908e-01, + 9.939108695612021e-01, + 9.923517494756579e-01, + 9.905637628430480e-01, + 9.885402079276301e-01, + 9.862765182499404e-01, + 9.837701825345700e-01, + 9.810207339243457e-01, + 9.780291325292961e-01, + 9.747989764630028e-01, + 9.713343413784561e-01, + 9.676399370118218e-01, + 9.610664511514549e-01, + 9.539287981952346e-01, + 9.462557577837218e-01, + 9.380908351569157e-01, + 9.295048630242134e-01, + 9.272938750650753e-01, + 9.250579717830375e-01, + 9.227970935555948e-01, + 9.164665386395120e-01, + 9.099911643711576e-01, + 9.033621457398684e-01, + 8.966076655702790e-01, + 8.897506341031615e-01, + 8.827836396691656e-01, + 8.757430253325005e-01, + 8.686235564317917e-01, + 8.614266253287830e-01, + 8.541863694365750e-01, + 8.468993821627302e-01, + 8.395705411285332e-01, + 8.322240727554534e-01, + 8.248512178596673e-01, + 8.174717412805539e-01, + 8.101012803444277e-01, + 8.027295128188973e-01, + 7.953825709154709e-01, + 7.880520562892473e-01, + 7.807347758450052e-01, + 7.734449586695845e-01, + 7.661975818078829e-01, + 7.589799271053987e-01, + 7.518171027867613e-01, + 7.446977692754075e-01, + 7.376160661891280e-01, + 7.305954685595947e-01, + 7.236266087629475e-01, + 7.167068363568081e-01, + 7.140993659912696e-01, + 7.115003569118910e-01, + 7.053989759515575e-01, + 6.937157033233743e-01, + 6.892286429728892e-01, + 6.847738597587193e-01, + 6.803460439703601e-01, + 6.736943892201644e-01, + 6.671180984390447e-01, + 6.622364244386257e-01, + 6.573969190766189e-01, + 6.525933207264888e-01, + 6.478347504056896e-01, + 6.431166994633450e-01, + 6.384369407276960e-01, + 6.290516157893640e-01, + 6.198222188748919e-01, + 6.175428045973979e-01, + 6.152735585854211e-01, + 6.111170811451881e-01, + 6.031212236479893e-01, + 5.952593539110380e-01, + 5.921305074751056e-01, + 5.890215438866859e-01, + 5.843049294344698e-01, + 5.796335966290896e-01, + 5.750160381540556e-01, + 5.704420016665088e-01, + 5.659178450605010e-01, + 5.614455518912613e-01, + 5.591788148460601e-01, + 5.569248279174298e-01, + 5.506074431743505e-01, + 5.478382336868175e-01, + 5.450878675391179e-01, + 5.387888979310328e-01, + 5.362404523147913e-01, + 5.337094641666161e-01, + 5.282374991972423e-01, + 5.259248454152894e-01, + 5.236262814879684e-01, + 5.182614254027890e-01, + 5.158555312376837e-01, + 5.134660721930772e-01, + 5.077709278344216e-01, + 5.053179820104490e-01, + 5.028817741515068e-01, + 4.974407642335685e-01, + 4.952012718592664e-01, + 4.929770110443390e-01, + 4.880637159524582e-01, + 4.859684632733423e-01, + 4.838861488391641e-01, + 4.790294758699501e-01, + 4.768706516921771e-01, + 4.747266903353097e-01, + 4.696849124915995e-01, + 4.675266380099869e-01, + 4.653827515562493e-01, + 4.605962240576634e-01, + 4.586085068420688e-01, + 4.566341643693850e-01, + 4.522282618718538e-01, + 4.503369915407668e-01, + 4.484573583607938e-01, + 4.440766399922996e-01, + 4.421436521416536e-01, + 4.402239033770282e-01, + 4.357529446279363e-01, + 4.338466468392896e-01, + 4.319526749076715e-01, + 4.277194009540304e-01, + 4.259480291942094e-01, + 4.241883948256027e-01, + 4.202300998848154e-01, + 4.185239108263153e-01, + 4.168280792217872e-01, + 4.128821814385824e-01, + 4.111518412231812e-01, + 4.094332017859506e-01, + 4.054591322790473e-01, + 4.037685048369686e-01, + 4.020884387112946e-01, + 3.983255882607288e-01, + 3.967407957791139e-01, + 3.951663235196693e-01, + 3.916025661686941e-01, + 3.900627879901100e-01, + 3.885321706996029e-01, + 3.849784483567140e-01, + 3.834281028668022e-01, + 3.818880643760414e-01, + 3.783453864220350e-01, + 3.768397186025170e-01, + 3.753431216105738e-01, + 3.719827243333056e-01, + 3.705596473485314e-01, + 3.691456730437073e-01, + 3.659301712184497e-01, + 3.645393288417587e-01, + 3.631565593836533e-01, + 3.599538911939479e-01, + 3.585625234903733e-01, + 3.571802315061479e-01, + 3.540119540790766e-01, + 3.526654577087503e-01, + 3.513267792978637e-01, + 3.483128923342382e-01, + 3.470307463292109e-01, + 3.457566587669847e-01, + 3.428492728471916e-01, + 3.415914251565042e-01, + 3.403406775305906e-01, + 3.374508890138111e-01, + 3.361995660265230e-01, + 3.349562467114465e-01, + 3.321133636377239e-01, + 3.309044582572311e-01, + 3.297023177240813e-01, + 3.269887097799309e-01, + 3.258300483601927e-01, + 3.246785486404988e-01, + 3.220444676004350e-01, + 3.209052709642934e-01, + 3.197723133954909e-01, + ], + 1e-5: [ + 1.000000000000000e00, + 1.000000000000000e00, + 1.000000000000000e00, + 1.000000000000000e00, + 1.000000000000000e00, + 1.000000000000000e00, + 1.000000000000000e00, + 1.000000000000000e00, + 9.999999999999994e-01, + 9.999999999999730e-01, + 9.999999999998286e-01, + 9.999999999994353e-01, + 9.999999999985202e-01, + 9.999999999965848e-01, + 9.999999999914210e-01, + 9.999999999815654e-01, + 9.999999999642780e-01, + 9.999999999357950e-01, + 9.999999998244792e-01, + 9.999999995977931e-01, + 9.999999987558622e-01, + 9.999999969054565e-01, + 9.999999933717028e-01, + 9.999999871894636e-01, + 9.999999770945371e-01, + 9.999999615055236e-01, + 9.999999384936957e-01, + 9.999999057511308e-01, + 9.999998222204165e-01, + 9.999996889877317e-01, + 9.999994874837332e-01, + 9.999991954947148e-01, + 9.999987869759613e-01, + 9.999978778927705e-01, + 9.999965094234943e-01, + 9.999945377974357e-01, + 9.999917976154713e-01, + 9.999881018395195e-01, + 9.999832421044147e-01, + 9.999769893073577e-01, + 9.999690944252573e-01, + 9.999592894153977e-01, + 9.999401848217710e-01, + 9.999149868024271e-01, + 9.998825523031706e-01, + 9.998416677700163e-01, + 9.997910595925650e-01, + 9.997294043565842e-01, + 9.996553389790078e-01, + 9.995674703998642e-01, + 9.994643850266534e-01, + 9.993446578768627e-01, + 9.992068613208905e-01, + 9.990495732666037e-01, + 9.988713847467867e-01, + 9.986709069016458e-01, + 9.984467774204933e-01, + 9.981976664056399e-01, + 9.979222816859891e-01, + 9.976193735296895e-01, + 9.972877388222079e-01, + 9.969262246907040e-01, + 9.965337316535895e-01, + 9.961092162612745e-01, + 9.956516933110915e-01, + 9.951602375882754e-01, + 9.946339852520572e-01, + 9.940721347818040e-01, + 9.934739476574072e-01, + 9.928387486091628e-01, + 9.921659257085935e-01, + 9.914549300099351e-01, + 9.907052751686757e-01, + 9.899165365560477e-01, + 9.890883505198331e-01, + 9.882204130401707e-01, + 9.873124787412751e-01, + 9.863643591446407e-01, + 9.853759215358775e-01, + 9.843470868593674e-01, + 9.832778285388312e-01, + 9.821681700449177e-01, + 9.810181837626457e-01, + 9.798279882517430e-01, + 9.785977472491776e-01, + 9.773276666309043e-01, + 9.760179936330398e-01, + 9.746690135131258e-01, + 9.732810490694735e-01, + 9.718544574219034e-01, + 9.703896283469345e-01, + 9.688869823629818e-01, + 9.662560899379753e-01, + 9.635203094788860e-01, + 9.606821993784824e-01, + 9.577444920821762e-01, + 9.547100690698106e-01, + 9.515819411387303e-01, + 9.483632227783803e-01, + 9.450571205528219e-01, + 9.416669021033438e-01, + 9.381959001044843e-01, + 9.346474739566473e-01, + 9.310250020056358e-01, + 9.273318651957428e-01, + 9.235714575597201e-01, + 9.197471440818522e-01, + 9.158622774784529e-01, + 9.119201741214706e-01, + 9.079241164053400e-01, + 9.038773101206564e-01, + 8.997829152782374e-01, + 8.956440506961761e-01, + 8.914637634840353e-01, + 8.872450198327338e-01, + 8.829907105217275e-01, + 8.787036576363941e-01, + 8.707492329602121e-01, + 8.687467373185769e-01, + 8.667391783027991e-01, + 8.647268019171629e-01, + 8.627098501557753e-01, + 8.585978518951599e-01, + 8.544698540634895e-01, + 8.503277143709528e-01, + 8.461732532471191e-01, + 8.420082065243172e-01, + 8.378342644577640e-01, + 8.336530592572513e-01, + 8.294661714342418e-01, + 8.252750957681314e-01, + 8.210812733406646e-01, + 8.168861006274361e-01, + 8.126909233407180e-01, + 8.084970284424999e-01, + 8.018705279973948e-01, + 7.952548736797830e-01, + 7.886543612921902e-01, + 7.820730077033664e-01, + 7.755145256970315e-01, + 7.689823477006539e-01, + 7.624796584457091e-01, + 7.560093783176929e-01, + 7.495742104755058e-01, + 7.431766425064636e-01, + 7.368189634231701e-01, + 7.305032400696735e-01, + 7.242313466189446e-01, + 7.180049652774664e-01, + 7.118256479784464e-01, + 7.056948260292686e-01, + 7.032583361895295e-01, + 7.008298605278855e-01, + 6.984094704872370e-01, + 6.959972341046202e-01, + 6.935932152404094e-01, + 6.889317430774708e-01, + 6.817668350489530e-01, + 6.746798127752269e-01, + 6.676718057412527e-01, + 6.607437322115557e-01, + 6.538963343303841e-01, + 6.471301405820917e-01, + 6.404455883106537e-01, + 6.387872416184449e-01, + 6.371340113850150e-01, + 6.354859019542481e-01, + 6.323179670207283e-01, + 6.291691359105558e-01, + 6.243492415503886e-01, + 6.195747895117473e-01, + 6.148457081070352e-01, + 6.101619207395151e-01, + 6.055232995385412e-01, + 6.009296920940354e-01, + 5.963809255739797e-01, + 5.884265027623434e-01, + 5.806112287097513e-01, + 5.729337321255051e-01, + 5.653924575507177e-01, + 5.579857024351769e-01, + 5.561548261765027e-01, + 5.543322219963571e-01, + 5.525178614099090e-01, + 5.497619521958399e-01, + 5.470251014183799e-01, + 5.421958421339816e-01, + 5.374261214332550e-01, + 5.327153071018452e-01, + 5.280627574108234e-01, + 5.234678232248013e-01, + 5.189298444469039e-01, + 5.144481596152644e-01, + 5.100220936678099e-01, + 5.056509822776560e-01, + 5.013341346033774e-01, + 4.970708987429328e-01, + 4.928605836118120e-01, + 4.887024961805134e-01, + 4.845959781161491e-01, + 4.805403497251276e-01, + 4.765349346341766e-01, + 4.725790728234394e-01, + 4.686720914229373e-01, + 4.648133480441644e-01, + 4.610021778781840e-01, + 4.572379175659361e-01, + 4.535199244031417e-01, + 4.498475710369739e-01, + 4.462202101246375e-01, + 4.426372375753840e-01, + 4.390980179451507e-01, + 4.356019205688260e-01, + 4.321483548727800e-01, + 4.287367136802313e-01, + 4.253663991812640e-01, + 4.220368327619753e-01, + 4.187474280885136e-01, + 4.154976300176047e-01, + 4.122868660369579e-01, + 4.091145681113114e-01, + 4.043631518312791e-01, + 3.996975359393022e-01, + 3.951158478794149e-01, + 3.906162701651016e-01, + 3.861970390711226e-01, + 3.841086119708872e-01, + 3.820380229719526e-01, + 3.799850857201517e-01, + 3.779496187391600e-01, + 3.745426919402392e-01, + 3.711844377457629e-01, + 3.678740151738357e-01, + 3.646106065243293e-01, + 3.613933918170190e-01, + 3.582215709845467e-01, + 3.550943187555968e-01, + 3.520108594211252e-01, + 3.489704836755959e-01, + 3.459724290685680e-01, + 3.430159438599149e-01, + 3.401003272980346e-01, + 3.372248857211048e-01, + 3.343889511711801e-01, + 3.315918392385992e-01, + 3.288328612250609e-01, + 3.261113573130471e-01, + 3.234267379284118e-01, + 3.207783627593125e-01, + ], +} -def scalar_bistable(lock, path=None): + +def scalar_bistable(): from neuron import rxd h.load_file("stdrun.hoc") @@ -34,25 +694,15 @@ def scalar_bistable(lock, path=None): # check the results result = h.Vector(c.nodes.concentration) - if path is not None: - lock.acquire() - if os.path.exists(path): - data = json.load(open(path, "r")) - else: - data = {} - data["scalar_bistable_data"] = list(result) - json.dump(data, open(path, "w"), indent=4) - lock.release() - else: - cmpV = h.Vector(test_data["scalar_bistable_data"]) - cmpV.sub(result) - cmpV.abs() - if cmpV.sum() >= 1e-6: - sys.exit(-1) - sys.exit(0) - - -def trivial_ecs(scale, lock, path=None): + cmpV = h.Vector(scalar_bistable_data) + cmpV.sub(result) + cmpV.abs() + if cmpV.sum() < 1e-6: + sys.exit(0) + sys.exit(-1) + + +def trivial_ecs(scale): from neuron import h, crxd as rxd import numpy import warnings @@ -64,7 +714,6 @@ def trivial_ecs(scale, lock, path=None): h.CVode().active(True) h.CVode().event(tstop) else: # fixed step case - h.CVode().active(False) h.dt = 0.1 sec = h.Section() # NEURON requires at least 1 section @@ -108,63 +757,40 @@ def trivial_ecs(scale, lock, path=None): h.finitialize() h.continuerun(tstop) # run the simulation - if path is not None: - lock.acquire() - if os.path.exists(path): - data = json.load(open(path, "r")) - else: - data = {} - if "trivial_ecs_data" not in data: - data["trivial_ecs_data"] = {} - data["trivial_ecs_data"][str(scale)] = list(ecs_vec) - json.dump(data, open(path, "w"), indent=4) - lock.release() - else: - # compare with previous solution - ecs_vec.sub(h.Vector(test_data["trivial_ecs_data"][str(scale)])) - ecs_vec.abs() - if ecs_vec.sum() > 1e-9: - sys.exit(-1) - sys.exit(0) + # compare with previous solution + ecs_vec.sub(h.Vector(trivial_ecs_data[scale])) + ecs_vec.abs() + if ecs_vec.sum() > 1e-9: + return -1 + return 0 class RxDTestCase(unittest.TestCase): """Tests of rxd""" - @classmethod - def setUpClass(cls): - # Check for --save in command-line arguments - cls.path = None - cls.lock = Lock() - if len(sys.argv) > 1: - for arg1, arg2 in zip(sys.argv, sys.argv[1:]): - if arg1 == "--save": - cls.path = arg2 - break - def test_rxd(self): - p = Process(target=scalar_bistable, args=(self.lock, self.path)) + p = Process(target=scalar_bistable) p.start() p.join() assert p.exitcode == 0 return 0 def test_ecs_diffusion_fixed_step(self): - p = Process(target=trivial_ecs, args=(False, self.lock, self.path)) + p = Process(target=trivial_ecs, args=(False,)) p.start() p.join() assert p.exitcode == 0 return 0 def test_ecs_diffusion_variable_step_coarse(self): - p = Process(target=trivial_ecs, args=(1e-2, self.lock, self.path)) + p = Process(target=trivial_ecs, args=(1e-2,)) p.start() p.join() assert p.exitcode == 0 return 0 def test_ecs_diffusion_variable_step_fine(self): - p = Process(target=trivial_ecs, args=(1e-5, self.lock, self.path)) + p = Process(target=trivial_ecs, args=(1e-5,)) p.start() p.join() assert p.exitcode == 0 @@ -181,7 +807,5 @@ def test(): if __name__ == "__main__": - """Run the rxd tests unless --save is given, in which case save the - test data to that path without comparing the results to the reference data. - """ + # unittest.main() test()