DARTsort 0.5.8__tar.gz → 0.5.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. {dartsort-0.5.8 → dartsort-0.5.9}/PKG-INFO +2 -2
  2. {dartsort-0.5.8 → dartsort-0.5.9}/pyproject.toml +1 -1
  3. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/agglomerate.py +3 -4
  4. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/kmeans.py +13 -6
  5. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/mixture.py +8 -9
  6. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/main.py +3 -2
  7. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/matching_util/drifty.py +3 -3
  8. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/matching_util/matching_base.py +5 -5
  9. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/templates/realignment.py +2 -1
  10. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/mixture_classifier.py +3 -2
  11. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/interpolation_util.py +5 -5
  12. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/main_util.py +5 -3
  13. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/motion.py +6 -4
  14. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/spiketorch.py +46 -15
  15. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/torch_util.py +46 -3
  16. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort.egg-info/PKG-INFO +2 -2
  17. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort.egg-info/requires.txt +1 -1
  18. {dartsort-0.5.8 → dartsort-0.5.9}/.github/workflows/ci.yml +0 -0
  19. {dartsort-0.5.8 → dartsort-0.5.9}/.github/workflows/ci_windows.yml +0 -0
  20. {dartsort-0.5.8 → dartsort-0.5.9}/.github/workflows/deploy.yml +0 -0
  21. {dartsort-0.5.8 → dartsort-0.5.9}/.github/workflows/docs.yml +0 -0
  22. {dartsort-0.5.8 → dartsort-0.5.9}/.gitignore +0 -0
  23. {dartsort-0.5.8 → dartsort-0.5.9}/README.md +0 -0
  24. {dartsort-0.5.8 → dartsort-0.5.9}/docs/index.md +0 -0
  25. {dartsort-0.5.8 → dartsort-0.5.9}/docs/main_api.md +0 -0
  26. {dartsort-0.5.8 → dartsort-0.5.9}/docs/toolkit_api.md +0 -0
  27. {dartsort-0.5.8 → dartsort-0.5.9}/environment.yml +0 -0
  28. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/.keep +0 -0
  29. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/basic_integration_test.py +0 -0
  30. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/ci diag.py +0 -0
  31. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/dartsort_dredge_demo.ipynb +0 -0
  32. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/dartsort_dredge_demo.py +0 -0
  33. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/data test.py +0 -0
  34. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/dead reckoning.py +0 -0
  35. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/denoise np1.py +0 -0
  36. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/denoise np2.py +0 -0
  37. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/exploratory.py +0 -0
  38. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/geom debug.py +0 -0
  39. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/hdbscan_clustering_5min.py +0 -0
  40. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/hybrid 10.py +0 -0
  41. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/hybrid cluster.py +0 -0
  42. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/hybrid_11.py +0 -0
  43. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/initial training.py +0 -0
  44. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/make hybrid.py +0 -0
  45. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/mgh.py +0 -0
  46. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/np1 feats.py +0 -0
  47. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/np2 processing version c.py +0 -0
  48. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/paperfigs.py +0 -0
  49. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/pdists.py +0 -0
  50. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/postcheck.py +0 -0
  51. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/ptp vae.py +0 -0
  52. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/re clust.py +0 -0
  53. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/reg fig loop.py +0 -0
  54. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/reg_sim_exp.py +0 -0
  55. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/relocating.py +0 -0
  56. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/relocating_all.py +0 -0
  57. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/restats +0 -0
  58. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/sortStinger1.py +0 -0
  59. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/sortStinger3.py +0 -0
  60. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/sortStinger4.py +0 -0
  61. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/sortStinger5.py +0 -0
  62. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/sortStinger6.py +0 -0
  63. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/spike farm.py +0 -0
  64. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/ss_ensemble_sim.py +0 -0
  65. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/ss_ensemble_sim_drift.py +0 -0
  66. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/ss_sim.py +0 -0
  67. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/stan diagnostics.py +0 -0
  68. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/storytelling c.py +0 -0
  69. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/storytelling.py +0 -0
  70. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/subtract_with_phaseshift_denoiser.py +0 -0
  71. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/tests/debug_matching.py +0 -0
  72. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/tests/test_agreement.py +0 -0
  73. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/tests/test_amplitude_scaling.py +0 -0
  74. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/tests/test_batch_optim.py +0 -0
  75. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/tests/test_ibme.py +0 -0
  76. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/tests/test_mm_initialization.py +0 -0
  77. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/tests/test_normxcorr1d.py +0 -0
  78. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/tests/test_reassignment.py +0 -0
  79. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/tests/test_relocation.py +0 -0
  80. {dartsort-0.5.8 → dartsort-0.5.9}/notebook/thomas.py +0 -0
  81. {dartsort-0.5.8 → dartsort-0.5.9}/setup.cfg +0 -0
  82. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/__init__.py +0 -0
  83. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/cli.py +0 -0
  84. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/__init__.py +0 -0
  85. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/cluster_util.py +0 -0
  86. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/clustering.py +0 -0
  87. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/clustering_features.py +0 -0
  88. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/density.py +0 -0
  89. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/forward_backward.py +0 -0
  90. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/merge.py +0 -0
  91. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/modes.py +0 -0
  92. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/clustering/refine_util.py +0 -0
  93. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/config.py +0 -0
  94. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/detect/__init__.py +0 -0
  95. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/detect/detect.py +0 -0
  96. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/detect/detect_filters.py +0 -0
  97. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/evaluate/__init__.py +0 -0
  98. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/evaluate/analysis.py +0 -0
  99. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/evaluate/comparison.py +0 -0
  100. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/evaluate/hybrid_util.py +0 -0
  101. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/evaluate/noise_recording_tools.py +0 -0
  102. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/evaluate/sim_template_tools.py +0 -0
  103. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/evaluate/simkit.py +0 -0
  104. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/evaluate/simlib.py +0 -0
  105. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/localize/__init__.py +0 -0
  106. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/localize/localize_torch.py +0 -0
  107. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/localize/localize_util.py +0 -0
  108. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/__init__.py +0 -0
  109. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/grab.py +0 -0
  110. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/matching.py +0 -0
  111. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/matching_util/__init__.py +0 -0
  112. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/matching_util/compressed_upsampled.py +0 -0
  113. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/matching_util/pairwise.py +0 -0
  114. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/matching_util/pairwise_util.py +0 -0
  115. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/peel_base.py +0 -0
  116. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/peel_lib.py +0 -0
  117. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/reduction_template.py +0 -0
  118. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/shaver.py +0 -0
  119. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/subtract.py +0 -0
  120. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/peel/threshold.py +0 -0
  121. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/pretrained/default_temporal_kernel.npy +0 -0
  122. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/pretrained/detect_np1.pt +0 -0
  123. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/pretrained/detect_np2.pt +0 -0
  124. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/pretrained/glasbey1024.npz +0 -0
  125. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/pretrained/offset_trained_denoiser.pt +0 -0
  126. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/pretrained/offset_trained_denoiser_added_temp.pt +0 -0
  127. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/pretrained/offset_trained_denoiser_added_temp_boost.pt +0 -0
  128. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/pretrained/original_single_chan_denoiser.pt +0 -0
  129. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/pretrained/single_chan_denoiser.pt +0 -0
  130. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/templates/__init__.py +0 -0
  131. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/templates/get_templates.py +0 -0
  132. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/templates/postprocess_util.py +0 -0
  133. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/templates/template_util.py +0 -0
  134. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/templates/templates.py +0 -0
  135. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/templates/templib.py +0 -0
  136. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/__init__.py +0 -0
  137. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/_multichan_denoiser_kit.py +0 -0
  138. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/all_transformers.py +0 -0
  139. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/amortized_localization.py +0 -0
  140. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/amplitudes.py +0 -0
  141. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/decollider.py +0 -0
  142. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/denoising_scorer.py +0 -0
  143. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/enforce_decrease.py +0 -0
  144. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/fixed_prop.py +0 -0
  145. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/interp.py +0 -0
  146. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/localize.py +0 -0
  147. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/matching_denoiser.py +0 -0
  148. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/pipeline.py +0 -0
  149. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/reduction.py +0 -0
  150. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/single_channel_denoiser.py +0 -0
  151. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/supervised_denoiser.py +0 -0
  152. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/temporal_pca.py +0 -0
  153. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/transform_base.py +0 -0
  154. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/transform/whiten.py +0 -0
  155. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/__init__.py +0 -0
  156. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/cli_util.py +0 -0
  157. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/data_util.py +0 -0
  158. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/drift_util.py +0 -0
  159. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/internal_config.py +0 -0
  160. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/job_util.py +0 -0
  161. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/logging_util.py +0 -0
  162. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/more_operators.py +0 -0
  163. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/multiprocessing_util.py +0 -0
  164. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/nn_util.py +0 -0
  165. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/noise_util.py +0 -0
  166. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/peel_util.py +0 -0
  167. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/preprocess_util.py +0 -0
  168. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/py_util.py +0 -0
  169. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/registration_util.py +0 -0
  170. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/residual_util.py +0 -0
  171. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/sparse_util.py +0 -0
  172. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/spikeio.py +0 -0
  173. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/testing_util/__init__.py +0 -0
  174. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/testing_util/matching_debug_util.py +0 -0
  175. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/testing_util/mixture_testing_util.py +0 -0
  176. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/torch_optimization_util.py +0 -0
  177. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/util/waveform_util.py +0 -0
  178. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/__init__.py +0 -0
  179. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/analysis_plots.py +0 -0
  180. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/colors.py +0 -0
  181. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/gt.py +0 -0
  182. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/layout.py +0 -0
  183. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/metrics_util.py +0 -0
  184. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/mixture.py +0 -0
  185. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/recanim.py +0 -0
  186. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/scatterplots.py +0 -0
  187. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/sorting.py +0 -0
  188. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/unit.py +0 -0
  189. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/unit_comparison.py +0 -0
  190. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/versus.py +0 -0
  191. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/vismain.py +0 -0
  192. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort/vis/waveforms.py +0 -0
  193. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort.egg-info/SOURCES.txt +0 -0
  194. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort.egg-info/dependency_links.txt +0 -0
  195. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort.egg-info/entry_points.txt +0 -0
  196. {dartsort-0.5.8 → dartsort-0.5.9}/src/dartsort.egg-info/top_level.txt +0 -0
  197. {dartsort-0.5.8 → dartsort-0.5.9}/tests/conftest.py +0 -0
  198. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_alignment.py +0 -0
  199. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_cluster_util.py +0 -0
  200. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_clustering.py +0 -0
  201. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_config.py +0 -0
  202. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_dartsort.py +0 -0
  203. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_data_util.py +0 -0
  204. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_density.py +0 -0
  205. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_detect.py +0 -0
  206. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_drift_util.py +0 -0
  207. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_drifty_matching.py +0 -0
  208. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_enforce_decrease.py +0 -0
  209. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_grab_and_featurize.py +0 -0
  210. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_kmeans.py +0 -0
  211. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_linalg.py +0 -0
  212. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_localize_torch.py +0 -0
  213. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_matching.py +0 -0
  214. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_mixture_classifier.py +0 -0
  215. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_modeling.py +0 -0
  216. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_simkit.py +0 -0
  217. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_spiketorch.py +0 -0
  218. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_subtract.py +0 -0
  219. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_templates.py +0 -0
  220. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_threshold.py +0 -0
  221. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_torch_optimization_util.py +0 -0
  222. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_transform.py +0 -0
  223. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_util.py +0 -0
  224. {dartsort-0.5.8 → dartsort-0.5.9}/tests/test_waveform_util.py +0 -0
  225. {dartsort-0.5.8 → dartsort-0.5.9}/zensical.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dartsort
3
- Version: 0.5.8
3
+ Version: 0.5.9
4
4
  Summary: DARTsort
5
5
  Author-email: Charlie Windolf <ciw2048@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/cwindolf/dartsort
@@ -27,7 +27,7 @@ Requires-Dist: scipy>=1.13
27
27
  Requires-Dist: scikit-learn
28
28
  Requires-Dist: spikeinterface>=0.104.0
29
29
  Requires-Dist: sympy
30
- Requires-Dist: torch>=2.0
30
+ Requires-Dist: torch>=2.2
31
31
  Requires-Dist: tqdm
32
32
  Requires-Dist: typing-extensions
33
33
  Provides-Extra: doc
@@ -32,7 +32,7 @@ dependencies = [
32
32
  "scikit-learn",
33
33
  "spikeinterface>=0.104.0",
34
34
  "sympy",
35
- "torch>=2.0",
35
+ "torch>=2.2",
36
36
  "tqdm",
37
37
  "typing-extensions",
38
38
  ]
@@ -155,6 +155,9 @@ def agglomerate(
155
155
  axis=0,
156
156
  )
157
157
  qda_mask = np.logical_or(qda_mask_uni, qda_mask_bi)
158
+ assert np.all(qda_mask <= mask)
159
+ if fcorr_mask is not None:
160
+ assert np.all(np.logical_and(qda_mask, fcorr_mask) <= mask)
158
161
  force_mask = linkage_mask(
159
162
  tdist.distances,
160
163
  linkage_method=template_merge_cfg.linkage,
@@ -162,10 +165,6 @@ def agglomerate(
162
165
  )
163
166
  qda_mask = np.logical_or(qda_mask, force_mask)
164
167
  np.fill_diagonal(qda_mask, True)
165
- if fcorr_mask is None:
166
- assert np.all(qda_mask <= mask)
167
- else:
168
- assert np.all((qda_mask & fcorr_mask) <= mask)
169
168
  qda_as_dist = np.logical_not(qda_mask).astype(np.float32)
170
169
 
171
170
  agg_sorting, new_ids = recluster(
@@ -22,6 +22,7 @@ from ..util.sparse_util import (
22
22
  sparse_centroid_distsq,
23
23
  )
24
24
  from ..util.spiketorch import spawn_torch_rg, sqeuc_cdist_known_norm
25
+ from ..util.torch_util import torch_compile, torch_compiler
25
26
 
26
27
  logger = get_logger(__name__)
27
28
 
@@ -465,13 +466,19 @@ def kmeans(
465
466
  )
466
467
 
467
468
 
468
- @torch.jit.script
469
+ @torch.compiler.disable
470
+ def _uniform(gen: torch.Generator, buf: Tensor):
471
+ return buf.uniform_(generator=gen)
472
+
473
+
474
+ @torch_compiler(fullgraph=False)
469
475
  def _one_gumbel_nolog(p: Tensor, gen: torch.Generator, buf: Tensor):
470
- z = buf.uniform_(generator=gen).log_()
476
+ z = _uniform(gen, buf)
477
+ z = z.log_()
471
478
  return torch.divide(p, z, out=z).argmin(dim=0)
472
479
 
473
480
 
474
- @torch.jit.script
481
+ @torch_compile
475
482
  def _sqeuc(X: Tensor, Xnormsq: Tensor, Y: Tensor, out: Tensor):
476
483
  torch.addmm(Xnormsq, X, Y.transpose(0, 1), alpha=-2.0, out=out)
477
484
  Ynormsq = (Y**2).sum(dim=1)
@@ -479,7 +486,7 @@ def _sqeuc(X: Tensor, Xnormsq: Tensor, Y: Tensor, out: Tensor):
479
486
  return out
480
487
 
481
488
 
482
- @torch.jit.script
489
+ @torch_compiler(fullgraph=False)
483
490
  def _kmeanspp_simple_loop(
484
491
  *,
485
492
  X: Tensor,
@@ -515,7 +522,7 @@ def _kmeanspp_simple_loop(
515
522
  torch.minimum(dists, newdists, out=dists)
516
523
 
517
524
 
518
- @torch.jit.script
525
+ @torch_compiler(fullgraph=False)
519
526
  def _kmeanspp_noassign_loop(
520
527
  *,
521
528
  X: Tensor,
@@ -547,7 +554,7 @@ def _kmeanspp_noassign_loop(
547
554
  torch.minimum(dists, newdists, out=dists)
548
555
 
549
556
 
550
- @torch.jit.script
557
+ @torch_compiler(fullgraph=False)
551
558
  def _kmeans_main_loop(
552
559
  n_iter: int,
553
560
  e: Tensor,
@@ -97,7 +97,7 @@ from ..util.spiketorch import (
97
97
  sign,
98
98
  spawn_torch_rg,
99
99
  )
100
- from ..util.torch_util import BModule
100
+ from ..util.torch_util import BModule, torch_compiler
101
101
  from .cluster_util import linkage, maximal_leaf_groups
102
102
  from .clustering_features import StableWaveformFeatures
103
103
  from .kmeans import kmeans
@@ -5220,7 +5220,6 @@ def _select_partition(
5220
5220
  return best_part, best_imp
5221
5221
 
5222
5222
 
5223
- # @torch.jit.script
5224
5223
  def _determine_part_score(
5225
5224
  rest_logliks: Tensor,
5226
5225
  crit_full_log_liks: Tensor,
@@ -5708,7 +5707,7 @@ def _whiten_and_noise_score_batch(
5708
5707
  )
5709
5708
 
5710
5709
 
5711
- @torch.jit.script
5710
+ @torch_compiler(fullgraph=False)
5712
5711
  def _whiten_and_noise_score_batch_k(
5713
5712
  x: Tensor, neighb_ids: Tensor, Linv: Tensor, lik_const: Tensor
5714
5713
  ):
@@ -6207,7 +6206,7 @@ else:
6207
6206
  return x.nonzero_static(size=size)
6208
6207
 
6209
6208
 
6210
- @torch.jit.script
6209
+ @torch_compiler(fullgraph=False)
6211
6210
  def _combine_similar_resps(resps: Tensor, keep_mask: Tensor, n_keep: int) -> Tensor:
6212
6211
  n_discard = resps.shape[1] - n_keep
6213
6212
  assert n_discard + n_keep == resps.shape[1]
@@ -6649,7 +6648,7 @@ def _sparsify_candidates(
6649
6648
  # = | A (x'-z') |^2.
6650
6649
 
6651
6650
 
6652
- @torch.jit.script
6651
+ @torch_compiler(fullgraph=False)
6653
6652
  def _calc_loglik_rank0(
6654
6653
  *,
6655
6654
  whitenedx: Tensor,
@@ -6669,7 +6668,7 @@ def _calc_loglik_rank0(
6669
6668
  return ll
6670
6669
 
6671
6670
 
6672
- @torch.jit.script
6671
+ @torch_compiler(fullgraph=False)
6673
6672
  def _calc_loglik_ppca(
6674
6673
  *,
6675
6674
  whitenedx: Tensor,
@@ -6777,7 +6776,7 @@ def _stat_pass_batch(
6777
6776
  return stats
6778
6777
 
6779
6778
 
6780
- @torch.jit.script
6779
+ @torch_compiler(fullgraph=False)
6781
6780
  def _count_batch(
6782
6781
  *,
6783
6782
  responsibilities: Tensor,
@@ -6812,7 +6811,7 @@ def _count_batch(
6812
6811
  return noise_N, N, Nlut, Qnflat, Qnflatlut
6813
6812
 
6814
6813
 
6815
- @torch.jit.script
6814
+ @torch_compiler(fullgraph=False)
6816
6815
  def _stat_pass_batch_ppca(
6817
6816
  *,
6818
6817
  xt: Tensor,
@@ -6931,7 +6930,7 @@ def _stat_pass_batch_ppca(
6931
6930
  return noise_N, N, Nlut, Ulut, R, elb
6932
6931
 
6933
6932
 
6934
- @torch.jit.script
6933
+ @torch_compiler(fullgraph=False)
6935
6934
  def _stat_pass_batch_rank0(
6936
6935
  *,
6937
6936
  xt: Tensor,
@@ -247,7 +247,7 @@ def _dartsort_impl(
247
247
  sampling_cfg=cfg.peeler_sampling_cfg,
248
248
  waveform_cfg=cfg.waveform_cfg,
249
249
  overwrite=overwrite,
250
- _saving_intermediates=cfg.save_intermediate_features,
250
+ _save_cfg=cfg,
251
251
  _save_dir=output_dir,
252
252
  )
253
253
  ret["motion"] = motion
@@ -287,7 +287,8 @@ def _dartsort_impl(
287
287
  sampling_cfg=cfg.peeler_sampling_cfg,
288
288
  waveform_cfg=cfg.waveform_cfg,
289
289
  overwrite=overwrite,
290
- _saving_intermediates=cfg.save_intermediate_features,
290
+ _save_cfg=cfg,
291
+ _save_dir=output_dir,
291
292
  )
292
293
  ret["motion"] = motion
293
294
  ds_save_motion(motion, output_dir, work_dir, overwrite)
@@ -58,6 +58,7 @@ from ...util.motion import MotionInfo
58
58
  from ...util.noise_util import SpatialWhitener
59
59
  from ...util.py_util import databag
60
60
  from ...util.spiketorch import full_shared_pconv, shared_temporal_pconv
61
+ from ...util.torch_util import torch_compiler
61
62
  from ...util.waveform_util import upsample_singlechan_torch
62
63
  from .matching_base import (
63
64
  ChunkTemplateData,
@@ -647,7 +648,7 @@ def get_interp_upsampling_data(
647
648
  # -- convolution
648
649
 
649
650
 
650
- @torch.jit.script
651
+ @torch_compiler()
651
652
  def convolve_lowrank_shared(
652
653
  traces: Tensor,
653
654
  spatial_singular: Tensor,
@@ -677,7 +678,7 @@ def convolve_lowrank_shared(
677
678
  # -- fine matching
678
679
 
679
680
 
680
- @torch.jit.script
681
+ @torch_compiler(fullgraph=False)
681
682
  def _upsampling_fine_match(
682
683
  *,
683
684
  conv: Tensor,
@@ -730,7 +731,6 @@ def _upsampling_fine_match(
730
731
  # --
731
732
 
732
733
 
733
- @torch.jit.script
734
734
  def _subtract_templates_loop(
735
735
  traces: Tensor,
736
736
  up_inds: Tensor | None,
@@ -12,7 +12,7 @@ from ...util.logging_util import DARTSORTVERBOSE, get_logger
12
12
  from ...util.motion import MotionInfo
13
13
  from ...util.py_util import databag
14
14
  from ...util.spiketorch import argrelmax_dedup, grab_spikes, ptp
15
- from ...util.torch_util import BModule
15
+ from ...util.torch_util import BModule, torch_compiler
16
16
 
17
17
  logger = get_logger(__name__)
18
18
  _extra_checks = logger.isEnabledFor(DARTSORTVERBOSE)
@@ -534,7 +534,7 @@ def subtract_precomputed_pconv(
534
534
  )
535
535
 
536
536
 
537
- @torch.jit.script
537
+ @torch_compiler(fullgraph=False)
538
538
  def _subtract_precomputed_pconv_unscaled(
539
539
  conv: Tensor,
540
540
  pconv: Tensor,
@@ -557,7 +557,7 @@ def _subtract_precomputed_pconv_unscaled(
557
557
  conv[i0:i1].scatter_add_(dim=1, src=batch, index=ix)
558
558
 
559
559
 
560
- @torch.jit.script
560
+ @torch_compiler(fullgraph=False)
561
561
  def _subtract_precomputed_pconv_scaled(
562
562
  conv: Tensor,
563
563
  pconv: Tensor,
@@ -583,7 +583,7 @@ def _subtract_precomputed_pconv_scaled(
583
583
  conv[i0:i1].scatter_add_(dim=1, src=batch, index=ix)
584
584
 
585
585
 
586
- @torch.jit.script
586
+ @torch_compiler()
587
587
  def _free_coarse_objective(
588
588
  conv: Tensor,
589
589
  normsq: Tensor,
@@ -597,7 +597,7 @@ def _free_coarse_objective(
597
597
  return obj
598
598
 
599
599
 
600
- @torch.jit.script
600
+ @torch_compiler()
601
601
  def _scaled_coarse_objective(
602
602
  conv: Tensor,
603
603
  normsq: Tensor,
@@ -19,6 +19,7 @@ from ..util.job_util import ensure_computation_config
19
19
  from ..util.logging_util import get_logger, progrange
20
20
  from ..util.motion import MotionInfo
21
21
  from ..util.spiketorch import ptp
22
+ from ..util.torch_util import torch_compile
22
23
  from .templates import TemplateData
23
24
 
24
25
  logger = get_logger(__name__)
@@ -96,7 +97,7 @@ def realign(
96
97
  return aligned_sorting, templates
97
98
 
98
99
 
99
- @torch.jit.script
100
+ @torch_compile
100
101
  def singlechan_alignments(
101
102
  traces: torch.Tensor, trough_factor: float = 3.0, dim: int = 1
102
103
  ) -> torch.Tensor:
@@ -29,7 +29,7 @@ from ..util.internal_config import (
29
29
  from ..util.interpolation_util import StableFeaturesInterpolator, pad_geom
30
30
  from ..util.motion import MotionInfo
31
31
  from ..util.multiprocessing_util import handle_negative_jobs
32
- from ..util.torch_util import cleanup_and_log_gpu_usage
32
+ from ..util.torch_util import cleanup_and_log_gpu_usage, torch_compile
33
33
  from .transform_base import BaseWaveformFeaturizer
34
34
 
35
35
  if TYPE_CHECKING:
@@ -38,6 +38,7 @@ if TYPE_CHECKING:
38
38
 
39
39
  class TruncatedMixtureModelTransformer(BaseWaveformFeaturizer):
40
40
  """Gaussian mixture clustering and classification as a featurization node."""
41
+
41
42
  is_multi = True
42
43
  needs_residual = True
43
44
  fits_from_disk = True
@@ -430,7 +431,7 @@ def neighborhood_mapping_at_time(
430
431
  return index, nid_map
431
432
 
432
433
 
433
- @torch.jit.script
434
+ @torch_compile
434
435
  def _outer_all_equal(x: torch.Tensor, y: torch.Tensor):
435
436
  dim = x.shape[1]
436
437
  x = x[:, None, :]
@@ -9,7 +9,7 @@ import torch.nn.functional as F
9
9
  from .data_util import yield_masked_chunks
10
10
  from .internal_config import InterpolationParams, tps_interp_params
11
11
  from .motion import MotionInfo
12
- from .torch_util import BModule
12
+ from .torch_util import BModule, torch_compile
13
13
  from .waveform_util import make_channel_index
14
14
 
15
15
  if TYPE_CHECKING:
@@ -579,20 +579,20 @@ def kriging_neighborhood_solve(
579
579
  return out
580
580
 
581
581
 
582
- @torch.jit.script
582
+ @torch_compile
583
583
  def _kneighb_loop(
584
584
  features_padded_flat: torch.Tensor,
585
585
  neighborhoods_padded: torch.Tensor,
586
586
  neighb_solved: torch.Tensor,
587
587
  ):
588
588
  out = features_padded_flat.new_empty(
589
- (features_padded_flat.shape[0], neighborhoods_padded.shape[0])
589
+ (neighborhoods_padded.shape[0], features_padded_flat.shape[0])
590
590
  )
591
591
  for j in range(neighborhoods_padded.shape[0]):
592
592
  neighb = neighborhoods_padded[j]
593
593
  fj = features_padded_flat[:, neighb]
594
- torch.mv(fj, neighb_solved[j], out=out[:, j])
595
- return out
594
+ torch.mv(fj, neighb_solved[j], out=out[j])
595
+ return out.t().contiguous()
596
596
 
597
597
 
598
598
  def kriging_poly_expand(
@@ -128,7 +128,7 @@ def ds_all_to_workdir(
128
128
 
129
129
 
130
130
  def ds_save_motion(
131
- motion: MotionInfo,
131
+ motion: "MotionInfo",
132
132
  output_dir: Path,
133
133
  work_dir: Path | None = None,
134
134
  overwrite: bool = False,
@@ -209,7 +209,7 @@ def ds_handle_link_from(cfg: DARTsortInternalConfig, output_dir: Path):
209
209
  def ds_save_features(
210
210
  cfg: DARTsortInternalConfig | None,
211
211
  sorting: DARTsortSorting,
212
- output_dir: Path,
212
+ output_dir: Path | None,
213
213
  work_dir: Path | None = None,
214
214
  is_final=False,
215
215
  ensure_saving: bool | None = None,
@@ -225,6 +225,8 @@ def ds_save_features(
225
225
  elif not ensure_saving:
226
226
  return
227
227
 
228
+ assert output_dir is not None
229
+
228
230
  # find h5 and models and copy
229
231
  assert sorting.parent_h5_path is not None
230
232
  h5_path = ensure_path(sorting.parent_h5_path)
@@ -281,7 +283,7 @@ def ds_handle_delete_intermediate_features(
281
283
 
282
284
  def ds_fast_forward(
283
285
  store_dir: Path, cfg: DARTsortInternalConfig
284
- ) -> tuple[int, DARTsortSorting | None, MotionInfo | None]:
286
+ ) -> "tuple[int, DARTsortSorting | None, MotionInfo | None]":
285
287
  """Fast-forward to the where sorting left off
286
288
 
287
289
  # TODO: error if there is a saved cfg which differs? Maybe just optionally?
@@ -15,6 +15,7 @@ if TYPE_CHECKING:
15
15
  from .drift_util import get_pitch, registered_geometry
16
16
  from .internal_config import (
17
17
  ComputationConfig,
18
+ DARTsortInternalConfig,
18
19
  FeaturizationConfig,
19
20
  FitSamplingConfig,
20
21
  MotionEstimationConfig,
@@ -57,7 +58,7 @@ def get_motion_info(
57
58
  amplitudes_dataset_name="denoised_ptp_amplitudes",
58
59
  overwrite: bool = False,
59
60
  show_progress: bool = True,
60
- _saving_intermediates: bool = False,
61
+ _save_cfg: DARTsortInternalConfig | None = None,
61
62
  _save_dir: Path | None = None,
62
63
  ) -> "MotionInfo":
63
64
  """Get a MotionInfo object by loading from disk, from SI/dredge, or by computing it
@@ -79,6 +80,9 @@ def get_motion_info(
79
80
  need_motion_estimate = motion_cfg.do_motion_estimation and not have_motion
80
81
 
81
82
  # skip peak detection if possible
83
+ _saving_intermediates = (
84
+ _save_cfg is not None and _save_cfg.save_intermediate_features
85
+ )
82
86
  need_new_peaks = detect_new_peaks and (
83
87
  need_motion_estimate or _saving_intermediates
84
88
  )
@@ -99,13 +103,11 @@ def get_motion_info(
99
103
  overwrite=overwrite,
100
104
  show_progress=show_progress,
101
105
  )
102
- assert _save_dir is not None
103
106
  ds_save_features(
104
- cfg=None,
107
+ cfg=_save_cfg,
105
108
  sorting=motion_sorting,
106
109
  work_dir=output_directory,
107
110
  output_dir=_save_dir,
108
- ensure_saving=_saving_intermediates,
109
111
  )
110
112
  else:
111
113
  motion_sorting = sorting
@@ -15,6 +15,7 @@ from torch import Tensor
15
15
  from torch.fft import irfft, rfft
16
16
 
17
17
  from .logging_util import progrange
18
+ from .torch_util import torch_compile, torch_compiler
18
19
 
19
20
  logger = getLogger(__name__)
20
21
  log2pi = torch.log(torch.tensor(2 * np.pi))
@@ -103,7 +104,7 @@ def ptp(waveforms, dim=1, keepdims=False):
103
104
  return v.numpy()
104
105
 
105
106
 
106
- @torch.jit.script
107
+ @torch_compile
107
108
  def mean_elbo_dim1(Q: Tensor, log_liks: Tensor) -> Tensor:
108
109
  logQ = Q.log().nan_to_num_(nan=None, neginf=0.0)
109
110
  logP = log_liks.nan_to_num(nan=None, neginf=0.0)
@@ -112,7 +113,7 @@ def mean_elbo_dim1(Q: Tensor, log_liks: Tensor) -> Tensor:
112
113
  return oelbo
113
114
 
114
115
 
115
- @torch.jit.script
116
+ @torch_compile
116
117
  def elbo(Q: Tensor, log_liks: Tensor, reduce_mean: bool = True, dim: int = 1) -> Tensor:
117
118
  logQ = Q.log().nan_to_num_(neginf=0.0)
118
119
  logP = log_liks.nan_to_num(neginf=0.0)
@@ -122,7 +123,7 @@ def elbo(Q: Tensor, log_liks: Tensor, reduce_mean: bool = True, dim: int = 1) ->
122
123
  return oelbo
123
124
 
124
125
 
125
- @torch.jit.script
126
+ @torch_compile
126
127
  def entropy(Q: Tensor, reduce_mean: bool = True, dim: int = 1) -> Tensor:
127
128
  logQ = Q.log().nan_to_num_(neginf=0.0)
128
129
  H = logQ.mul_(Q).sum(dim=dim)
@@ -131,7 +132,7 @@ def entropy(Q: Tensor, reduce_mean: bool = True, dim: int = 1) -> Tensor:
131
132
  return H.neg_()
132
133
 
133
134
 
134
- @torch.jit.script
135
+ @torch_compile
135
136
  def ecl(
136
137
  resps: Tensor, log_liks: Tensor, cl_alpha: float = 1.0, reduce_mean: bool = True
137
138
  ) -> Tensor:
@@ -162,7 +163,7 @@ def minmax(x: np.ndarray) -> np.ndarray:
162
163
  return x / np.max(x)
163
164
 
164
165
 
165
- @torch.jit.script
166
+ @torch_compile
166
167
  def sqeuc_cdist_known_norm(
167
168
  X: Tensor,
168
169
  Xnormsq: Tensor,
@@ -233,7 +234,7 @@ def shared_temporal_pconv(temporal_comps: Tensor, up_temporal_comps: Tensor) ->
233
234
  return pconv
234
235
 
235
236
 
236
- @torch.jit.script
237
+ @torch_compile
237
238
  def full_shared_pconv(
238
239
  tconv: Tensor, spatial_sing: Tensor, batch_size: int = 64
239
240
  ) -> Tensor:
@@ -256,7 +257,7 @@ def full_shared_pconv(
256
257
  return out
257
258
 
258
259
 
259
- @torch.jit.script
260
+ @torch_compile
260
261
  def best_shared_pconv(
261
262
  tconv: Tensor, spatial_sing: Tensor, batch_size: int = 1024
262
263
  ) -> tuple[Tensor, Tensor]:
@@ -310,7 +311,7 @@ def best_shared_pconv(
310
311
  return conv_out, lag_out
311
312
 
312
313
 
313
- @torch.jit.script
314
+ @torch_compiler(fullgraph=False)
314
315
  def weighted_best_lagged_scaled_normeuc_dist(
315
316
  tconv: Tensor,
316
317
  spatial_sing: Tensor,
@@ -509,7 +510,7 @@ def scaled_normeuc_from_dots(
509
510
  return dist
510
511
 
511
512
 
512
- @torch.jit.script
513
+ @torch_compile
513
514
  def scaled_normeuc_distance(
514
515
  means: Tensor,
515
516
  scale_std: float = 0.01,
@@ -742,13 +743,24 @@ def reduce_at_(dest, ix, src, reduce, include_self=True):
742
743
  )
743
744
 
744
745
 
745
- @torch.jit.script
746
746
  def argrelmax(
747
747
  *,
748
748
  x: Tensor,
749
749
  radius: int,
750
750
  threshold: float,
751
751
  arange: Tensor,
752
+ ):
753
+ msk = _argrelmax_mask(x=x, radius=radius, threshold=threshold, arange=arange)
754
+ return msk.nonzero()[:, 0]
755
+
756
+
757
+ @torch_compile
758
+ def _argrelmax_mask(
759
+ *,
760
+ x: Tensor,
761
+ radius: int,
762
+ threshold: float,
763
+ arange: Tensor,
752
764
  ):
753
765
  x1, inds = F.max_pool1d_with_indices(
754
766
  x[None, None], kernel_size=(2 * radius + 1,), padding=(radius,), stride=(1,)
@@ -763,11 +775,9 @@ def argrelmax(
763
775
  # exclude edge
764
776
  x1[0].zero_()
765
777
  x1[-1].zero_()
766
- ix = torch.nonzero(x1)[:, 0]
767
- return ix
778
+ return x1
768
779
 
769
780
 
770
- @torch.jit.script
771
781
  def argrelmax_dedup(
772
782
  peak_radius: int = 1,
773
783
  *,
@@ -800,6 +810,27 @@ def argrelmax_dedup(
800
810
  peak time by +/- 1 (temporal upsampling stuff). Make your chunk margin 1 sample
801
811
  bigger if you care about that.
802
812
  """
813
+ msk = _argrelmax_dedup_mask(
814
+ peak_radius,
815
+ x=x,
816
+ dedup_radius=dedup_radius,
817
+ threshold=threshold,
818
+ arange=arange,
819
+ padding=padding,
820
+ )
821
+ return msk.nonzero()[:, 0]
822
+
823
+
824
+ @torch_compile
825
+ def _argrelmax_dedup_mask(
826
+ peak_radius: int = 1,
827
+ *,
828
+ x: Tensor,
829
+ dedup_radius: int,
830
+ threshold: float,
831
+ arange: Tensor,
832
+ padding: int,
833
+ ):
803
834
  nt = x.shape[0]
804
835
  xv = x.clone()
805
836
  x = x[None, None]
@@ -818,7 +849,7 @@ def argrelmax_dedup(
818
849
  remove2 = torch.logical_or(x1 < x2, inds2 != arange)
819
850
  x2.masked_fill_(remove2, 0.0)
820
851
  x2 = x2[0, 0]
821
- return x2.nonzero()[:, 0]
852
+ return x2
822
853
 
823
854
 
824
855
  _cdtypes = {torch.float32: torch.complex64, torch.float64: torch.complex128}
@@ -1046,7 +1077,7 @@ def maxz_distance(means, stderrs, weights, batch_size=512, min_iou=0.75):
1046
1077
  return squareform(pdist)
1047
1078
 
1048
1079
 
1049
- @torch.jit.script
1080
+ @torch_compile
1050
1081
  def normeuc_distance(means: Tensor):
1051
1082
  """|a-b|/sqrt(|a||b|)"""
1052
1083
  means = means.reshape(means.shape[0], -1)
@@ -5,7 +5,7 @@ import torch
5
5
  from torch import Tensor
6
6
  from torch.nn import Module
7
7
 
8
- from .logging_util import get_logger
8
+ from .logging_util import DARTSORTVERBOSE, get_logger
9
9
 
10
10
  if TYPE_CHECKING:
11
11
  from .internal_config import ComputationConfig
@@ -112,5 +112,48 @@ def cleanup_and_log_gpu_usage(computation_cfg: "ComputationConfig", message=""):
112
112
 
113
113
  torch.cuda.empty_cache()
114
114
 
115
- message = f"{message}\n{torch.cuda.memory_summary(device=dev, abbreviated=True)}"
116
- logger.dartsortdebug(message)
115
+ if logger.isEnabledFor(DARTSORTVERBOSE):
116
+ message = (
117
+ f"{message}\n{torch.cuda.memory_summary(device=dev, abbreviated=True)}"
118
+ )
119
+ logger.dartsortverbose(message)
120
+
121
+
122
+ _logged_compile_thing = False
123
+
124
+
125
+ def torch_compile(fn, dynamic=True, fullgraph=True):
126
+ """Try to use torch.compile if GPU is supported, else fall back on jit.script.
127
+
128
+ But they don't like us to use script anymore and say it's not supported on
129
+ Python 3.14 and later. Still, I have an old GPU personally so it helps me to
130
+ do this.
131
+
132
+ Here I'm using dynamic=True and fullgraph=True to try to be similar to how
133
+ script works, because I like the strictness but also this is used for little
134
+ utility functions where the input shapes change all the time.
135
+ """
136
+ # clearly I don't understand what compile does.
137
+ return torch.jit.script(fn)
138
+
139
+ # global _logged_compile_thing
140
+ # if not torch.cuda.is_available():
141
+ # return torch.compile(fn, dynamic=dynamic, fullgraph=fullgraph)
142
+ # major, _ = torch.cuda.get_device_capability()
143
+ # if major >= 7:
144
+ # return torch.compile(fn, dynamic=dynamic, fullgraph=fullgraph)
145
+ # else:
146
+ # if not _logged_compile_thing:
147
+ # logger.dartsortdebug(
148
+ # "Falling back on torch.jit.script since GPU's capability version "
149
+ # f"is {major}. You might see a deprecation warning from torch "
150
+ # "depending on your Python version."
151
+ # )
152
+ # _logged_compile_thing = True
153
+ # return torch.jit.script(fn)
154
+
155
+
156
+ def torch_compiler(dynamic=True, fullgraph=True):
157
+ def dec(fn):
158
+ return torch_compile(fn, dynamic=dynamic, fullgraph=fullgraph)
159
+ return dec
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dartsort
3
- Version: 0.5.8
3
+ Version: 0.5.9
4
4
  Summary: DARTsort
5
5
  Author-email: Charlie Windolf <ciw2048@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/cwindolf/dartsort
@@ -27,7 +27,7 @@ Requires-Dist: scipy>=1.13
27
27
  Requires-Dist: scikit-learn
28
28
  Requires-Dist: spikeinterface>=0.104.0
29
29
  Requires-Dist: sympy
30
- Requires-Dist: torch>=2.0
30
+ Requires-Dist: torch>=2.2
31
31
  Requires-Dist: tqdm
32
32
  Requires-Dist: typing-extensions
33
33
  Provides-Extra: doc