Skip to content

Commit

Permalink
test for ndjson
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyAJohnston committed May 23, 2024
1 parent 892e3ec commit 788c0ea
Show file tree
Hide file tree
Showing 2 changed files with 214 additions and 0 deletions.
205 changes: 205 additions & 0 deletions tests/__snapshots__/test_star.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# serializer version: 1
# name: test_read_ndjson_oriented
array([[67.89524841, 17.43763161, 22.13544273],
[23.08059692, 61.77287674, 12.38536263],
[64.4564743 , 30.65621567, 18.54438591],
[52.86577606, 55.69303131, 16.25313187],
[ 6.20414495, 36.64030838, 6.37513065],
[54.58604813, 29.43314171, 22.34353828],
[14.06875038, 47.85198975, 21.17700577],
[43.96713638, 65.11677551, 23.58200073],
[44.89732361, 62.41956711, 24.19034004],
[55.74905396, 65.76979065, 11.86001968],
[36.090065 , 52.66305542, 10.34024143],
[31.31638527, 47.66959763, 15.3553524 ],
[11.97279644, 44.25136948, 5.44673634],
[54.46987152, 15.13813591, 15.97834492],
[56.21677399, 25.87101746, 27.18723679],
[ 9.87597847, 49.51506424, 12.3587141 ],
[13.91390419, 29.99807358, 17.72655106],
[51.93511963, 22.36917496, 25.15249634],
[49.47748184, 57.96022797, 21.6821804 ],
[ 4.06388712, 38.19799042, 20.83314323],
[65.57754517, 28.05740929, 14.07811737],
[43.66610718, 64.83459473, 7.38464451],
[26.45141983, 47.54461288, 4.86148834],
[16.60074997, 48.76285934, 10.41742802],
[23.39784622, 49.58771515, 16.01901054],
[27.15598679, 60.88577271, 16.65639687],
[31.21142197, 61.35739136, 7.98280048],
[51.30709839, 70.84198761, 15.93934345],
[43.68464279, 67.27449036, 8.0412693 ],
[31.54167747, 59.21632004, 16.35448837],
[22.91976166, 59.52243805, 16.25029373],
[51.98854446, 24.20150185, 15.58591747],
[54.71170044, 15.0560379 , 17.85561371],
[25.1693058 , 62.42335129, 10.15520573],
[57.03777313, 64.6453476 , 15.02038097],
[13.97542381, 46.53133392, 6.43689632],
[11.97700691, 28.90350914, 17.25115776],
[18.58106995, 52.79833221, 10.71258163],
[11.74255943, 50.15063858, 16.04758453],
[60.33190155, 12.66550255, 20.32970047],
[ 7.96153736, 43.63059616, 22.08521652],
[ 5.49580622, 44.04118729, 6.52855778],
[22.61281013, 58.95380402, 3.78601503],
[66.59542847, 16.63515091, 24.53244209],
[16.94487572, 45.76476669, 21.01480103],
[52.56850433, 16.10758781, 18.12054443],
[47.89723969, 68.80099487, 23.15443802],
[26.38423729, 47.07402039, 16.12504959],
[18.8255558 , 56.94241333, 9.12901497],
[65.56826019, 13.91527367, 22.31264687],
[28.25974083, 62.25115967, 6.38484001],
[22.13425255, 54.66535568, 17.81489944],
[26.53245926, 51.2662735 , 18.65706635],
[51.91865158, 65.96222687, 22.762043 ],
[21.3722744 , 53.96972656, 3.95877957],
[53.4070816 , 70.58049774, 14.29399395],
[ 3.03580284, 42.6346283 , 20.07530975],
[50.95928574, 60.73108673, 8.92034912],
[49.10300446, 71.2615509 , 10.48911572],
[52.7314949 , 64.73478699, 9.15091419],
[59.65195847, 16.06346321, 12.86775494],
[45.29924774, 71.99123383, 18.51223946],
[20.26343155, 53.94652557, 16.16703606],
[30.77408791, 62.75239944, 11.20719719],
[ 3.03875661, 44.45789719, 16.58519936],
[32.51819611, 60.58320999, 6.13994789],
[33.47792053, 47.73781204, 7.47792149],
[34.68603134, 57.75600433, 10.39967346],
[ 7.70740891, 41.5221138 , 5.9620266 ],
[21.57788849, 47.93281555, 13.86778736],
[41.58405685, 70.51507568, 15.03430176],
[21.74500656, 39.35902405, 9.85125637],
[18.2670536 , 46.38023758, 9.74495792],
[29.56215858, 57.72190094, 18.15228462],
[12.9010601 , 35.85571289, 23.22083855],
[55.52906418, 60.04745483, 15.85917091],
[55.91930389, 61.78018951, 18.17969894],
[ 7.917624 , 31.53142929, 10.73446465],
[39.50636292, 67.61630249, 14.806674 ],
[29.11103249, 46.35424042, 6.58320856],
[66.68469238, 17.95492935, 15.60600567],
[19.33745193, 32.94595337, 14.82588196],
[54.20957565, 27.03795815, 14.55182838],
[46.05752182, 60.26448822, 23.45272446],
[53.70537186, 59.13062668, 10.18519878],
[ 9.53022194, 38.52846146, 3.62488604],
[47.12935638, 67.64637756, 8.32175255],
[21.92087173, 42.05246353, 18.90416145],
[44.4587326 , 71.62984467, 13.65610313],
[ 4.66935396, 35.73403931, 9.03784275],
[55.569664 , 68.1591568 , 16.75448799],
[68.70695496, 17.89582253, 18.19699669],
[59.20109177, 25.53931046, 11.85580921],
[60.05117798, 15.56478405, 27.01594162],
[60.28691483, 13.42234039, 23.85629845],
[ 8.50437355, 48.19210052, 8.54011059],
[ 4.83738613, 40.87253571, 20.46499634],
[28.72857285, 45.92423248, 11.60600471],
[14.89724255, 43.91654587, 22.46966362],
[30.94048691, 53.90393066, 17.74952698]])
# ---
# name: test_read_ndjson_oriented.1
array([[ 0.01165986, 0.26973841, -0.05671988, 0.961191 ],
[ 0.20568496, 0.47465736, -0.49774304, -0.6961652 ],
[ 0.65922862, -0.6307537 , -0.02235707, -0.40873903],
[ 0.61917615, 0.68662608, 0.29060724, 0.2464001 ],
[ 0.5028708 , -0.68689299, -0.48177201, -0.20783338],
[ 0.97054797, -0.2270066 , -0.03676705, -0.07178352],
[ 0.64959109, -0.26697949, 0.44688636, 0.55411732],
[ 0.50046355, 0.24306978, -0.22359243, -0.80028731],
[ 0.50269175, 0.34565437, 0.09242386, -0.78694463],
[ 0.24900492, -0.3077893 , 0.91828686, -0.00339005],
[ 0.04729332, 0.56279492, 0.52536601, 0.63640851],
[ 0.00817937, 0.16262607, 0.01075885, -0.98659521],
[ 0.31087241, -0.61101663, -0.54363126, -0.48423356],
[ 0.6187619 , 0.23691496, -0.67747039, 0.31943521],
[ 0.21407017, 0.62656647, -0.42357978, -0.61819786],
[ 0.51207268, 0.12057482, -0.55980891, -0.64020097],
[ 0.55729759, 0.35780478, 0.74763316, -0.04939436],
[ 0.65925491, -0.31891984, -0.12759112, 0.66887486],
[ 0.22392197, -0.20416659, -0.5168516 , 0.8006494 ],
[ 0.29253396, 0.68869442, -0.28154191, -0.60071462],
[ 0.36342955, -0.6651094 , -0.2784259 , -0.58993852],
[ 0.49133933, -0.29379687, -0.80720025, -0.14386387],
[ 0.40611276, 0.36245346, -0.62338287, 0.56133211],
[ 0.27524036, -0.31630579, 0.81295896, 0.404093 ],
[ 0.27923387, -0.51176804, -0.59488028, 0.55338895],
[ 0.50544256, -0.13078219, -0.24339749, -0.8174237 ],
[ 0.49053118, -0.48331833, -0.25138521, -0.68013823],
[ 0.33721629, -0.66322315, 0.66565847, 0.05761116],
[ 0.54318863, -0.50447255, -0.65436196, -0.14921117],
[ 0.54965496, -0.25327405, 0.49039441, 0.62709248],
[ 0.37705773, 0.16249676, -0.23099521, -0.88207906],
[ 0.66107124, -0.56409508, -0.48657024, 0.08961532],
[ 0.07631762, 0.88267839, 0.42946264, -0.17497541],
[ 0.32220572, 0.49269286, -0.62195808, -0.51633847],
[ 0.66604161, 0.02181097, 0.74364197, -0.05393944],
[ 0.38377339, -0.65919769, -0.51948309, -0.38511536],
[ 0.50604278, 0.16893536, -0.3894538 , 0.75080442],
[ 0.67288703, -0.38259628, -0.58422321, 0.24398032],
[ 0.13857608, 0.19388862, -0.66998696, -0.70307988],
[ 0.02878221, 0.42860818, 0.52347046, -0.73582965],
[ 0.27467957, -0.71080571, 0.19578849, 0.6172303 ],
[ 0.41451845, 0.42875811, -0.749412 , 0.28761527],
[ 0.00321258, -0.83674419, 0.54744577, 0.01232888],
[ 0.46513048, 0.14468452, -0.05970852, 0.87129498],
[ 0.03280167, 0.05649693, 0.6983788 , 0.71274066],
[ 0.49252811, -0.23296186, -0.5858537 , 0.59993362],
[ 0.33713034, -0.59418738, 0.23825966, 0.69030201],
[ 0.63572448, 0.70402735, 0.19583964, -0.24868985],
[ 0.29654577, -0.78962505, 0.19650972, 0.49993682],
[ 0.81499642, 0.39857918, 0.40172198, 0.12463921],
[ 0.17653082, -0.24536671, -0.71727026, -0.62781805],
[ 0.98083609, -0.0852363 , -0.00399728, 0.1751551 ],
[ 0.74531239, -0.01691453, 0.14961761, 0.64949054],
[ 0.1716169 , -0.08210115, -0.33125943, -0.92416137],
[ 0.23303799, 0.91210693, -0.33640358, -0.02422602],
[ 0.01521522, -0.30596042, -0.61165524, -0.72940707],
[ 0.38833329, 0.40910742, -0.24513678, -0.78850257],
[ 0.45633873, 0.59147322, -0.1380755 , 0.65026885],
[ 0.23281951, -0.60571468, 0.73714674, 0.18846628],
[ 0.2608555 , 0.3158451 , 0.49160177, 0.76845556],
[ 0.50938028, 0.45303518, -0.51089406, 0.52371573],
[ 0.79478317, -0.29619101, -0.34876254, -0.39869204],
[ 0.92361897, 0.02632416, -0.2961238 , -0.24196233],
[ 0.53817773, -0.343499 , 0.6360839 , 0.43332496],
[ 0.80808812, -0.51701188, -0.18986481, -0.20891055],
[ 0.15368363, 0.03496722, 0.78980905, 0.59275651],
[ 0.42950997, 0.74398404, 0.10350103, 0.50129491],
[ 0.46698269, -0.35147074, 0.087143 , -0.80672276],
[ 0.22523183, 0.49443585, -0.83838147, 0.04382144],
[ 0.87831867, 0.41994146, 0.0324602 , -0.22616765],
[ 0.48158255, -0.75169069, 0.22109202, 0.39262918],
[ 0.18715473, -0.70094311, -0.09221867, -0.68201733],
[ 0.38380659, -0.35910818, -0.39569405, -0.75310028],
[ 0.16785546, -0.05949348, 0.08951101, -0.97993517],
[ 0.49587467, 0.61889935, 0.41556957, -0.44539183],
[ 0.33370054, 0.40408763, 0.54749066, 0.65238881],
[ 0.02596377, 0.24302907, -0.17708994, 0.95336348],
[ 0.26652336, 0.93402851, 0.12205516, -0.20410436],
[ 0.84993595, -0.43094248, -0.29281324, 0.07847214],
[ 0.59610945, 0.43046644, -0.45888138, 0.49877855],
[ 0.0350038 , -0.40455717, 0.09291609, -0.90910661],
[ 0.01702069, -0.20637929, -0.53974718, 0.81596011],
[ 0.04112349, -0.99446005, -0.08324496, -0.0492792 ],
[ 0.0209744 , -0.40991148, -0.44546321, 0.79567277],
[ 0.046996 , 0.63618207, -0.48131526, 0.601165 ],
[ 0.01733323, 0.94805014, -0.18496925, 0.25823799],
[ 0.47238344, -0.37355524, -0.44867331, -0.66030496],
[ 0.28241423, 0.3463482 , 0.46593332, 0.76366961],
[ 0.16079472, -0.82011914, 0.46437907, 0.29309008],
[ 0.83899975, 0.49771485, -0.14417572, -0.16605034],
[ 0.5555445 , -0.59087068, 0.19896477, -0.55014098],
[ 0.29223406, 0.02139156, 0.87528747, -0.38472521],
[ 0.1226824 , 0.97407031, -0.08102459, 0.17196265],
[ 0.00799717, 0.24473511, 0.50840843, -0.82556748],
[ 0.67629206, 0.29045978, -0.00961014, 0.67688245],
[ 0.07493034, -0.78267843, 0.5275259 , 0.32173958],
[ 0.89750737, -0.42547289, 0.0998721 , -0.05898306],
[ 0.10108523, 0.61559635, 0.6792655 , -0.38655055],
[ 0.6405831 , -0.36886588, 0.55069333, -0.38772172],
[ 0.72442305, 0.1615794 , 0.58008015, -0.33557472]])
# ---
9 changes: 9 additions & 0 deletions tests/test_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from scipy.spatial.transform import Rotation as R
import starfile
from .constants import data_dir
from .utils import sample_attribute

mn.unregister()
mn.register()
Expand Down Expand Up @@ -49,6 +50,14 @@ def test_starfile_attributes(type):
assert (rot_from_euler * rot_from_geo_nodes.inv()).magnitude().max() < 1e-5


def test_read_ndjson_oriented(snapshot):
file = data_dir / "cryoet/oriented_point.ndjson"
ensemble = mn.io.star.load(file)
for attr in ['position', 'rotation']:
assert snapshot == sample_attribute(
ensemble.object, attr, evaluate=False)


def test_categorical_attributes():
file = data_dir / "cistem.star"
ensemble = mn.io.star.load(file)
Expand Down

0 comments on commit 788c0ea

Please sign in to comment.