SpatioTemporal / pystare

The Python interface for the SpatioTemporal Adaptive Resolution Encoding (STARE), a unified indexing for geolocated data.
https://pystare.readthedocs.io/en/latest/
12 stars 2 forks source link

pystare.intersect() breaks for specific cases #36

Open NiklasPhabian opened 3 years ago

NiklasPhabian commented 3 years ago

example


import pystare
sids = array([4257027547771961349, 4255901647865118726, 4256183122841829382,
       4257731235213737990, 4258012710190448646, 4280671445815656454,
       4280812183304011782, 4281093658280722438, 4281234395769077766,
       4281515870745788422, 4281656608234143750, 4282641770652631046,
       4256359044702273543, 4257625682097471495, 4257907157074182151,
       4280988105164455943, 4281410317629521927, 4281445502001610759,
       4281480686373699591, 4282430664420098055, 4282782508140986375,
       4282817692513075207, 4282888061257252871, 4285245414187204615,
       4541880224203145223, 4254212798004854792, 4254221594097877000,
       4254230390190899208, 4254239186283921416, 4254291962842054664,
       4254327147214143496, 4254335943307165704, 4254344739400187912,
       4256077569725562888, 4256086365818585096, 4256095161911607304,
       4256103958004629512, 4256112754097651720, 4256323860330184712,
       4256332656423206920, 4256341452516229128, 4256350248609251336,
       4256394229074362376, 4256403025167384584, 4256411821260406792,
       4256420617353429000, 4256429413446451208, 4256438209539473416,
       4256447005632495624, 4256455801725517832, 4256605335306895368,
       4256614131399917576, 4256631723585961992, 4256640519678984200,
       4256658111865028616, 4256666907958050824, 4256746072795250696,
       4256763664981295112, 4256772461074317320, 4256816441539428360,
       4256825237632450568, 4256842829818494984, 4256860422004539400,
       4256886810283606024, 4257590497725382664, 4257599293818404872,
       4257608089911427080, 4257616886004449288, 4257660866469560328,
       4257669662562582536, 4257678458655604744, 4257687254748626952,
       4257696050841649160, 4257704846934671368, 4257713643027693576,
       4257722439120715784, 4257871972702093320, 4257880768795115528,
       4257889564888137736, 4257898360981159944, 4257942341446270984,
       4257951137539293192, 4257959933632315400, 4257968729725337608,
       4257977525818359816, 4257986321911382024, 4257995118004404232,
       4258003914097426440, 4258153447678803976, 4258162243771826184,
       4258171039864848392, 4258179835957870600, 4258188632050892808,
       4258197428143915016, 4258206224236937224, 4258215020329959432,
       4258259000795070472, 4258267796888092680, 4258276592981114888,
       4258285389074137096, 4258294185167159304, 4258311777353203720,
       4258320573446225928, 4258364553911336968, 4258373350004359176,
       4258382146097381384, 4258390942190403592, 4258399738283425800,
       4258408534376448008, 4258426126562492424, 4258646028888047624,
       4258654824981069832, 4258672417167114248, 4258997872608935944,
       4260123772515778568, 4271664246560915464, 4271673042653937672,
       4271681838746959880, 4271690634839982088, 4271699430933004296,
       4271717023119048712, 4271725819212070920, 4271787391863226376,
       4271822576235315208, 4271875352793448456, 4271884148886470664,
       4271901741072515080, 4271919333258559496, 4272156827770159112,
       4280961716885389320, 4280970512978411528, 4280979309071433736,
       4281023289536544776, 4281032085629566984, 4281040881722589192,
       4281049677815611400, 4281058473908633608, 4281067270001655816,
       4281076066094678024, 4281084862187700232, 4281375133257433096,
       4281383929350455304, 4281392725443477512, 4281401521536499720,
       4282149189443387400, 4282360295675920392, 4282369091768942600,
       4282377887861964808, 4282386683954987016, 4282395480048009224,
       4282404276141031432, 4282413072234053640, 4282421868327075848,
       4282465848792186888, 4282474644885209096, 4282483440978231304,
       4282492237071253512, 4282536217536364552, 4282545013629386760,
       4282553809722408968, 4282562605815431176, 4282571401908453384,
       4282588994094497800, 4282597790187520008, 4282606586280542216,
       4282852876885164040, 4282861672978186248, 4282870469071208456,
       4282879265164230664, 4284049145536184328, 4284057941629206536,
       4284075533815250952, 4284101922094317576, 4284110718187339784,
       4284172290838495240, 4285175045443026952, 4285183841536049160,
       4285192637629071368, 4285201433722093576, 4285210229815115784,
       4285219025908137992, 4285227822001160200, 4285236618094182408,
       4285280598559293448, 4285289394652315656, 4285298190745337864,
       4285306986838360072, 4285465316512759816, 4285491704791826440,
       4285509296977870856, 4285518093070893064, 4285579665722048520,
       4285588461815070728, 4285632442280181768, 4285641238373203976,
       4285658830559248392, 4285667626652270600, 4285685218838315016,
       4285694014931337224, 4285702811024359432, 4541933000761278472,
       4541950592947322888, 4541959389040345096, 4541968185133367304,
       4541976981226389512, 4541985777319411720, 4541994573412433928,
       4542003369505456136, 4542012165598478344, 4542196883551944712,
       4542337621040300040, 4542346417133322248, 4542364009319366664,
       4553139223271571464, 4571153621781053448, 4571171213967097864,
       4571180010060120072, 4571232786618253320, 4571267970990342152])
pystare.intersect(sids, sids, False)
michaelleerilee commented 3 years ago

This looks like a SWIG interface issue. The calls in _intersect in PySTARE.cpp are doing the right thing, but the results are not being returned to the python side.

NiklasPhabian commented 3 years ago

This is somewhat curious. Depending on the subset of the sids in sid that we use in intersection(), we get a varying case of segfaults:

pystare.intersection(sids, sids, False)

corrupted size vs. prev_size while consolidating
Aborted (core dumped)
corrupted size vs. prev_size
Aborted (core dumped)
double free or corruption (!prev)
Aborted (core dumped)
free(): invalid size
Aborted (core dumped)
NiklasPhabian commented 3 years ago

Also, would we expect the intersection with itself to always be itself?

sids = numpy.array([4541880224203145223, 4254221594097877000])
res = pystare.intersection(sids, sids, False)
numpy.testing.assert_array_equal(sids, res)
NiklasPhabian commented 3 years ago

we have the according tests in https://github.com/SpatioTemporal/pystare/tree/issue_36

NiklasPhabian commented 3 years ago

https://github.com/SpatioTemporal/pystare/pull/83