DARTsort 0.5.26__tar.gz → 0.5.27__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 (181) hide show
  1. {dartsort-0.5.26 → dartsort-0.5.27}/PKG-INFO +1 -1
  2. {dartsort-0.5.26 → dartsort-0.5.27}/pyproject.toml +1 -0
  3. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/clustering/density.py +9 -5
  4. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/clustering/mixture.py +2 -2
  5. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/evaluate/hybrid_util.py +1 -1
  6. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/evaluate/hybridkit.py +2 -1
  7. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/evaluate/noise_recording_tools.py +1 -1
  8. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/evaluate/simkit.py +1 -1
  9. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/evaluate/simlib.py +5 -5
  10. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/main.py +11 -2
  11. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/templates/realignment.py +4 -3
  12. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/templates/templib.py +2 -1
  13. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/transform_base.py +1 -1
  14. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/data_util.py +3 -3
  15. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/internal_config.py +5 -5
  16. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/noise_util.py +5 -5
  17. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/preprocess_util.py +27 -3
  18. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/registration_util.py +1 -1
  19. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/__init__.py +2 -2
  20. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/analysis_plots.py +1 -1
  21. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/gt.py +1 -1
  22. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/vismain.py +2 -0
  23. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort.egg-info/PKG-INFO +1 -1
  24. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_config.py +1 -1
  25. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_hybridkit.py +1 -1
  26. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_matching.py +4 -3
  27. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_modeling.py +7 -0
  28. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_templates.py +2 -2
  29. {dartsort-0.5.26 → dartsort-0.5.27}/.github/workflows/ci.yml +0 -0
  30. {dartsort-0.5.26 → dartsort-0.5.27}/.github/workflows/ci_windows.yml +0 -0
  31. {dartsort-0.5.26 → dartsort-0.5.27}/.github/workflows/deploy.yml +0 -0
  32. {dartsort-0.5.26 → dartsort-0.5.27}/.github/workflows/docs.yml +0 -0
  33. {dartsort-0.5.26 → dartsort-0.5.27}/.gitignore +0 -0
  34. {dartsort-0.5.26 → dartsort-0.5.27}/README.md +0 -0
  35. {dartsort-0.5.26 → dartsort-0.5.27}/docs/index.md +0 -0
  36. {dartsort-0.5.26 → dartsort-0.5.27}/docs/main_api.md +0 -0
  37. {dartsort-0.5.26 → dartsort-0.5.27}/docs/toolkit_api.md +0 -0
  38. {dartsort-0.5.26 → dartsort-0.5.27}/environment.yml +0 -0
  39. {dartsort-0.5.26 → dartsort-0.5.27}/notebook/.keep +0 -0
  40. {dartsort-0.5.26 → dartsort-0.5.27}/notebook/fit_and_batch_matching.py +0 -0
  41. {dartsort-0.5.26 → dartsort-0.5.27}/notebook/ibl_dandi_example.py +0 -0
  42. {dartsort-0.5.26 → dartsort-0.5.27}/setup.cfg +0 -0
  43. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/__init__.py +0 -0
  44. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/__main__.py +0 -0
  45. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/cli.py +0 -0
  46. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/clustering/__init__.py +0 -0
  47. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/clustering/agglomerate.py +0 -0
  48. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/clustering/cluster_util.py +0 -0
  49. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/clustering/clustering.py +0 -0
  50. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/clustering/clustering_features.py +0 -0
  51. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/clustering/forward_backward.py +0 -0
  52. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/clustering/kmeans.py +0 -0
  53. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/clustering/merge.py +0 -0
  54. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/clustering/refine_util.py +0 -0
  55. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/config.py +0 -0
  56. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/detect/__init__.py +0 -0
  57. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/detect/detect.py +0 -0
  58. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/evaluate/__init__.py +0 -0
  59. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/evaluate/analysis.py +0 -0
  60. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/evaluate/comparison.py +0 -0
  61. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/evaluate/sim_template_tools.py +0 -0
  62. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/localize/__init__.py +0 -0
  63. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/localize/localize_torch.py +0 -0
  64. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/localize/localize_util.py +0 -0
  65. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/__init__.py +0 -0
  66. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/grab.py +0 -0
  67. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/matching.py +0 -0
  68. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/matching_util/__init__.py +0 -0
  69. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/matching_util/compressed_upsampled.py +0 -0
  70. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/matching_util/drifty.py +0 -0
  71. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/matching_util/matching_base.py +0 -0
  72. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/matching_util/pairwise.py +0 -0
  73. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/matching_util/pairwise_util.py +0 -0
  74. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/peel_base.py +0 -0
  75. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/peel_lib.py +0 -0
  76. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/reduction_template.py +0 -0
  77. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/shaver.py +0 -0
  78. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/subtract.py +0 -0
  79. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/subtract_util.py +0 -0
  80. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/peel/threshold.py +0 -0
  81. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/pretrained/default_temporal_kernel.npy +0 -0
  82. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/pretrained/detect_np1.pt +0 -0
  83. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/pretrained/detect_np2.pt +0 -0
  84. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/pretrained/glasbey1024.npz +0 -0
  85. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/pretrained/offset_trained_denoiser.pt +0 -0
  86. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/pretrained/offset_trained_denoiser_added_temp.pt +0 -0
  87. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/pretrained/offset_trained_denoiser_added_temp_boost.pt +0 -0
  88. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/pretrained/original_single_chan_denoiser.pt +0 -0
  89. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/pretrained/single_chan_denoiser.pt +0 -0
  90. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/templates/__init__.py +0 -0
  91. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/templates/get_templates.py +0 -0
  92. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/templates/postprocess_util.py +0 -0
  93. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/templates/template_util.py +0 -0
  94. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/templates/templates.py +0 -0
  95. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/__init__.py +0 -0
  96. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/_multichan_denoiser_kit.py +0 -0
  97. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/all_transformers.py +0 -0
  98. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/amortized_localization.py +0 -0
  99. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/amplitudes.py +0 -0
  100. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/decollider.py +0 -0
  101. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/denoising_scorer.py +0 -0
  102. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/enforce_decrease.py +0 -0
  103. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/fixed_prop.py +0 -0
  104. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/interp.py +0 -0
  105. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/localize.py +0 -0
  106. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/matched_filter_net.py +0 -0
  107. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/matching_denoiser.py +0 -0
  108. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/mixture_classifier.py +0 -0
  109. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/pipeline.py +0 -0
  110. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/reduction.py +0 -0
  111. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/single_channel_denoiser.py +0 -0
  112. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/supervised_denoiser.py +0 -0
  113. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/temporal_pca.py +0 -0
  114. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/vq_matched_filter.py +0 -0
  115. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/transform/whiten.py +0 -0
  116. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/__init__.py +0 -0
  117. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/cli_util.py +0 -0
  118. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/drift_util.py +0 -0
  119. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/interpolation_util.py +0 -0
  120. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/job_util.py +0 -0
  121. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/logging_util.py +0 -0
  122. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/main_util.py +0 -0
  123. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/more_operators.py +0 -0
  124. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/motion.py +0 -0
  125. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/multiprocessing_util.py +0 -0
  126. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/nn_util.py +0 -0
  127. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/peel_util.py +0 -0
  128. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/py_util.py +0 -0
  129. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/residual_util.py +0 -0
  130. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/sparse_util.py +0 -0
  131. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/spikeio.py +0 -0
  132. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/spiketorch.py +0 -0
  133. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/testing_util/__init__.py +0 -0
  134. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/testing_util/matching_debug_util.py +0 -0
  135. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/testing_util/mixture_testing_util.py +0 -0
  136. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/torch_optimization_util.py +0 -0
  137. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/torch_util.py +0 -0
  138. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/util/waveform_util.py +0 -0
  139. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/colors.py +0 -0
  140. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/layout.py +0 -0
  141. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/metrics_util.py +0 -0
  142. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/mixture.py +0 -0
  143. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/recanim.py +0 -0
  144. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/scatterplots.py +0 -0
  145. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/sorting.py +0 -0
  146. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/unit.py +0 -0
  147. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/unit_comparison.py +0 -0
  148. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/versus.py +0 -0
  149. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort/vis/waveforms.py +0 -0
  150. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort.egg-info/SOURCES.txt +0 -0
  151. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort.egg-info/dependency_links.txt +0 -0
  152. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort.egg-info/entry_points.txt +0 -0
  153. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort.egg-info/requires.txt +0 -0
  154. {dartsort-0.5.26 → dartsort-0.5.27}/src/dartsort.egg-info/top_level.txt +0 -0
  155. {dartsort-0.5.26 → dartsort-0.5.27}/tests/conftest.py +0 -0
  156. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_agglomerate.py +0 -0
  157. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_alignment.py +0 -0
  158. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_cluster_util.py +0 -0
  159. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_clustering.py +0 -0
  160. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_clustering_features.py +0 -0
  161. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_dartsort.py +0 -0
  162. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_data_util.py +0 -0
  163. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_density.py +0 -0
  164. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_detect.py +0 -0
  165. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_drift_util.py +0 -0
  166. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_drifty_matching.py +0 -0
  167. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_enforce_decrease.py +0 -0
  168. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_grab_and_featurize.py +0 -0
  169. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_kmeans.py +0 -0
  170. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_linalg.py +0 -0
  171. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_localize_torch.py +0 -0
  172. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_mixture_classifier.py +0 -0
  173. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_simkit.py +0 -0
  174. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_spiketorch.py +0 -0
  175. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_subtract.py +0 -0
  176. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_threshold.py +0 -0
  177. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_torch_optimization_util.py +0 -0
  178. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_transform.py +0 -0
  179. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_util.py +0 -0
  180. {dartsort-0.5.26 → dartsort-0.5.27}/tests/test_waveform_util.py +0 -0
  181. {dartsort-0.5.26 → dartsort-0.5.27}/zensical.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dartsort
3
- Version: 0.5.26
3
+ Version: 0.5.27
4
4
  Summary: DARTsort
5
5
  Author-email: Charlie Windolf <ciw2048@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/cwindolf/dartsort
@@ -97,3 +97,4 @@ replace-imports-with-any = ["hdbscan"]
97
97
  [tool.ty.rules]
98
98
  "unsupported-base" = "ignore"
99
99
  "possibly-unresolved-reference" = "error"
100
+ "invalid-key" = "ignore"
@@ -64,7 +64,7 @@ def kdtree_inliers(
64
64
 
65
65
  def get_smoothed_density(
66
66
  X,
67
- inliers: np.ndarray | slice = slice(None),
67
+ inliers: np.ndarray | slice = slice(None), # noqa: B008
68
68
  sigma: float = 1.0,
69
69
  sigma_low: float | None = None,
70
70
  sigma_ramp_ax=-1,
@@ -154,7 +154,7 @@ def get_smoothed_density(
154
154
  def get_smoothed_density_ratio(
155
155
  X,
156
156
  *,
157
- inliers: np.ndarray | slice = slice(None),
157
+ inliers: np.ndarray | slice = slice(None), # noqa: B008
158
158
  sigmas: list[float],
159
159
  sigma_lows: list[float] | list[None] | None = None,
160
160
  sigma_ramp_ax=-1,
@@ -504,7 +504,7 @@ def density_peaks(
504
504
  remove_borders=False,
505
505
  border_search_radius=10.0,
506
506
  border_search_neighbors=3,
507
- inlier_dims=slice(0, 2),
507
+ inlier_dims=slice(0, 2), # noqa: B008
508
508
  leafsize=24,
509
509
  density_strategy="sort",
510
510
  workers=-1,
@@ -599,7 +599,9 @@ def density_peaks(
599
599
  )
600
600
 
601
601
  if remove_clusters_smaller_than:
602
- labels = decrumb_labels(labels, min_size=remove_clusters_smaller_than, in_place=True)
602
+ labels = decrumb_labels(
603
+ labels, min_size=remove_clusters_smaller_than, in_place=True
604
+ )
603
605
 
604
606
  return dict(density=density, nhdn=nhdn, labels=labels, kdtree=kdtree)
605
607
 
@@ -796,7 +798,9 @@ def gmm_density_peaks(
796
798
  if remove_clusters_smaller_than:
797
799
  if show_progress:
798
800
  logger.info("Clean...")
799
- labels = decrumb_labels(labels, min_size=remove_clusters_smaller_than, in_place=True)
801
+ labels = decrumb_labels(
802
+ labels, min_size=remove_clusters_smaller_than, in_place=True
803
+ )
800
804
  res["labels"] = labels
801
805
 
802
806
  if mop:
@@ -7598,7 +7598,7 @@ def _update_lut_mean_batch(
7598
7598
 
7599
7599
  # constplogdet. add in the signal-rank-0-only terms.
7600
7600
  lut_params.constplogdet[i0:i1] = neighb_cov.nobs[nn].mul_(LOG_2PI) # type: ignore # ty: ignore[x]
7601
- lut_params.constplogdet[i0:i1] += neighb_cov.b.logdet[nn] # ty: ignore[not-subscriptable]
7601
+ lut_params.constplogdet[i0:i1] += neighb_cov.b.logdet[nn]
7602
7602
  if pnoid:
7603
7603
  assert lut_params.constplogdet[i0:i1].isfinite().all() # type: ignore # ty: ignore[x]
7604
7604
 
@@ -7658,7 +7658,7 @@ def _update_lut_ppca_batch(
7658
7658
  assert lut_params.Tpad is not None
7659
7659
  lut_params.Tpad[i0:i1, :, :-1] = T # type: ignore # ty: ignore[x]
7660
7660
  cap_logdet = L.diagonal(dim1=-2, dim2=-1).log().sum(dim=1).mul_(2.0)
7661
- lut_params.constplogdet[i0:i1] += cap_logdet # ty: ignore[not-subscriptable]
7661
+ lut_params.constplogdet[i0:i1] += cap_logdet
7662
7662
  if pnoid:
7663
7663
  assert lut_params.b.constplogdet[i0:i1].isfinite().all()
7664
7664
 
@@ -118,7 +118,7 @@ def precompute_displaced_registered_templates(
118
118
  geometry: np.ndarray,
119
119
  displacements: np.ndarray,
120
120
  sampling_frequency: float = 30000,
121
- template_subset=slice(None),
121
+ template_subset=slice(None), # noqa: B008
122
122
  ) -> DriftingTemplates:
123
123
  """Use spikeinterface tools to turn templates on registered geom into
124
124
  precomputed drifting templates on the regular geom.
@@ -134,7 +134,8 @@ def make_hybrid_recording(
134
134
  assert injected_sorting._recording is None
135
135
  assert target_recording.get_num_segments() == 1
136
136
  assert injected_sorting.get_num_segments() == 1
137
- assert injected_sorting.get_last_spike_frame() < target_recording.get_num_frames()
137
+ if hasattr(injected_sorting, "get_last_spike_frame"):
138
+ assert injected_sorting.get_last_spike_frame() < target_recording.get_num_frames() # ty:ignore[call-non-callable]
138
139
  assert abs(templates.sampling_frequency - target_sampling_frequency) < 10
139
140
 
140
141
  if folder is not None and not overwrite:
@@ -71,7 +71,7 @@ def get_background_recording(
71
71
  spatial_std, spatial_vt = rbf_kernel_sqrt(
72
72
  geom, bandwidth=noise_spatial_kernel_bandwidth
73
73
  )
74
- noise_temporal_kernel = noise_temporal_kernel.astype(spatial_vt.dtype) + 0j
74
+ noise_temporal_kernel = noise_temporal_kernel.astype(spatial_vt.dtype) + 0j # ty:ignore[no-matching-overload]
75
75
  noise = StationaryFactorizedNoise(
76
76
  spatial_std=spatial_std,
77
77
  vt_spatial=spatial_vt,
@@ -90,7 +90,7 @@ def generate_simulation(
90
90
  if folder is not None and not (overwrite or just_noise or no_save):
91
91
  try:
92
92
  return load_simulation(folder)
93
- except Exception: # noqa: BLE001, S110
93
+ except Exception:
94
94
  pass
95
95
 
96
96
  if noise_recording_folder is not None:
@@ -3,7 +3,7 @@ import sys
3
3
  import warnings
4
4
  from dataclasses import replace
5
5
  from pathlib import Path
6
- from typing import TYPE_CHECKING, Literal, cast
6
+ from typing import TYPE_CHECKING, Any, Literal, cast
7
7
 
8
8
  import h5py
9
9
  import numpy as np
@@ -343,7 +343,7 @@ def add_features(h5_path, recording, featurization_cfg, computation_cfg):
343
343
  _, feats = gt_pipeline(
344
344
  chunk, channels=cast(h5py.Dataset, h5["channels"])[sli]
345
345
  )
346
- for k in f_dsets: # noqa: PLC0206
346
+ for k in f_dsets:
347
347
  f_dsets[k][sli] = feats[k].numpy(force=True)
348
348
 
349
349
 
@@ -834,11 +834,11 @@ class InjectSpikesPreprocessor(BasePreprocessor):
834
834
 
835
835
  # arrays discovered in batches below
836
836
  f_dt = self.features_dtype
837
- inj_wf_shape = (
837
+ inj_wf_shape: tuple[int, int] = (
838
838
  self.spike_length_samples,
839
839
  self.extract_channel_index.shape[1],
840
840
  )
841
- dataset_shapes = {
841
+ dataset_shapes: dict[str, tuple[tuple[int, ...], Any]] = {
842
842
  "localizations": ((3,), f_dt),
843
843
  "displacements": ((), f_dt),
844
844
  "ptp_amplitudes": ((), f_dt),
@@ -1004,7 +1004,7 @@ class InjectSpikesPreprocessor(BasePreprocessor):
1004
1004
  try:
1005
1005
  recording = read_binary_folder(recording_dir)
1006
1006
  logger.info("Loaded %s", recording_dir)
1007
- except Exception: # noqa: BLE001
1007
+ except Exception:
1008
1008
  recording = None
1009
1009
  else:
1010
1010
  recording = None
@@ -140,10 +140,19 @@ def dartsort(
140
140
  ds_handle_link_from(cfg, output_dir)
141
141
 
142
142
  # preprocess
143
- copy_rec_flag = ds_will_copy_recording(cfg, recording)
143
+ # saves provenance info (lightweight) about the preprocessing, including
144
+ # noise levels in standardization etc to a json file
144
145
  recording = preprocess(
145
- recording, cfg.preprocessing, cfg.already_preprocessed, cfg.preprocessing_dtype
146
+ recording,
147
+ output_dir=output_dir,
148
+ strategy=cfg.preprocessing,
149
+ already_preprocessed=cfg.already_preprocessed,
150
+ dtype=cfg.preprocessing_dtype,
146
151
  )
152
+
153
+ # determine if recording will be saved to a tmpdir and warn the user
154
+ # if they're going to hit a slow case
155
+ copy_rec_flag = ds_will_copy_recording(cfg, recording)
147
156
  check_recording(recording, copy_flag=copy_rec_flag)
148
157
 
149
158
  needs_dir = copy_rec_flag or cfg.work_in_tmpdir
@@ -18,6 +18,7 @@ from ..util.internal_config import (
18
18
  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
+ from ..util.py_util import panic
21
22
  from ..util.spiketorch import ptp
22
23
  from ..util.torch_util import torch_compile
23
24
  from .templates import TemplateData
@@ -205,7 +206,7 @@ def estimate_offset(
205
206
  offsets = torch.round(offsets).long()
206
207
  return offsets - padded_trough_offset_samples
207
208
 
208
- assert False
209
+ panic(strategy)
209
210
 
210
211
 
211
212
  def realign_templates(
@@ -236,7 +237,7 @@ def realign_templates(
236
237
  elif realign_strategy.startswith("ampsq_weighted"):
237
238
  main_channels = np.ptp(templates).max(1).argmax(1)
238
239
  else:
239
- assert False
240
+ panic(realign_strategy)
240
241
  assert main_channels is not None
241
242
 
242
243
  # find template peak time
@@ -368,7 +369,7 @@ def dredge_realign(
368
369
  main_channels = snrs_by_channel.argmax(1)
369
370
 
370
371
  # start with trough alignment
371
- main_channels, main_channel_traces, offsets = get_main_channels_and_alignments(
372
+ main_channels, _main_channel_traces, offsets = get_main_channels_and_alignments(
372
373
  None,
373
374
  trough_factor=trough_factor,
374
375
  templates=templates.numpy(force=True),
@@ -14,6 +14,7 @@ from ..util.internal_config import (
14
14
  )
15
15
  from ..util.logging_util import get_logger
16
16
  from ..util.motion import MotionInfo
17
+ from ..util.py_util import panic
17
18
  from ..util.spikeio import read_waveforms_channel_index
18
19
  from ..util.waveform_util import make_channel_index
19
20
 
@@ -183,7 +184,7 @@ def denoising_weights(
183
184
  elif edge_behavior == "raw":
184
185
  snc = snrs
185
186
  else:
186
- assert False
187
+ panic(edge_behavior)
187
188
 
188
189
  # pass it through a hand picked squashing function
189
190
  wntc = 1.0 / (1.0 + np.exp(d + a * vt[None, :, None] - b * snc[:, None, :]))
@@ -164,7 +164,7 @@ class BaseWaveformModule(BModule):
164
164
  self.initialize_spike_length_dependent_params()
165
165
 
166
166
  if self.submodule_names:
167
- for sn, smk in zip(self.submodule_names, all_submodule_keys):
167
+ for sn, smk in zip(self.submodule_names, all_submodule_keys, strict=True):
168
168
  sn_dict = {smk: state_dict[smk]}
169
169
  getattr(self, sn)._pre_load_state(sn_dict, prefix, *args, **kwargs)
170
170
 
@@ -153,7 +153,7 @@ class DARTsortSorting:
153
153
  ) -> NumpySorting:
154
154
  """Clean up and produce a spikeinterface NumpySorting object."""
155
155
  if drop_doubles:
156
- self = self.drop_doubles() # noqa: PLW0642
156
+ self = self.drop_doubles()
157
157
  assert self.labels is not None
158
158
  st = self.drop_missing()
159
159
  assert st.labels is not None
@@ -1096,7 +1096,7 @@ class DARTsortSorting:
1096
1096
  yield chunk
1097
1097
 
1098
1098
  def slice_feature_by_name(
1099
- self, dataset_name: str, mask: np.ndarray | slice = slice(None)
1099
+ self, dataset_name: str, mask: np.ndarray | slice = slice(None) # noqa: B008
1100
1100
  ) -> np.ndarray:
1101
1101
  if hasattr(self, dataset_name):
1102
1102
  return getattr(self, dataset_name)[mask]
@@ -2279,7 +2279,7 @@ def fit_reweighting(
2279
2279
  if h5 is not None:
2280
2280
  voltages: np.ndarray = h5[voltages_dataset_name][:]
2281
2281
  elif hdf5_path is not None:
2282
- with h5py.File(hdf5_path) as h5: # noqa: PLR1704
2282
+ with h5py.File(hdf5_path) as h5:
2283
2283
  voltages: np.ndarray = h5[voltages_dataset_name][:]
2284
2284
  else:
2285
2285
  panic()
@@ -1544,6 +1544,8 @@ def _post_refinement_cfgs(
1544
1544
  collision_cleaning_error_threshold=cfg.collision_cleaning_error_threshold,
1545
1545
  )
1546
1546
  if cc_flag_active:
1547
+ assert isinstance(initial_detection_cfg, SubtractionConfig)
1548
+ temporal_dedup_radius = initial_detection_cfg.temporal_dedup_radius_samples
1547
1549
  filter_cfg = replace(
1548
1550
  filter_cfg,
1549
1551
  max_cc_flag_rate=cfg.max_cc_flag_rate,
@@ -1551,11 +1553,9 @@ def _post_refinement_cfgs(
1551
1553
  cc_flag_excess_rate=cfg.cc_flag_excess_rate,
1552
1554
  cc_flag_chance_jitter_samples=cfg.cc_flag_chance_jitter_samples,
1553
1555
  cc_flag_chance_draws=cfg.cc_flag_chance_draws,
1554
- cc_flag_temporal_radius_samples=(
1555
- cfg.cc_flag_temporal_radius_samples
1556
- or initial_detection_cfg.temporal_dedup_radius_samples
1557
- ),
1558
- cc_flag_dedup_temporal_radius_samples=initial_detection_cfg.temporal_dedup_radius_samples,
1556
+ cc_flag_temporal_radius_samples=cfg.cc_flag_temporal_radius_samples
1557
+ or temporal_dedup_radius,
1558
+ cc_flag_dedup_temporal_radius_samples=temporal_dedup_radius,
1559
1559
  cc_flag_spatial_dedup_radius_um=initial_detection_cfg.spatial_dedup_radius_um,
1560
1560
  cc_flag_radius_um=initial_detection_cfg.subtract_radius_um,
1561
1561
  )
@@ -525,14 +525,14 @@ class EmbeddedNoise(BModule):
525
525
  return self.mean
526
526
  panic(self.mean_kind)
527
527
 
528
- def whitener(self, channels=slice(None)):
528
+ def whitener(self, channels=slice(None)): # noqa: B008
529
529
  cov = self.marginal_covariance(channels=channels)
530
530
  chol = cov.cholesky().to_dense()
531
531
  eye = torch.eye(cov.shape[0], dtype=cov.dtype, device=cov.device)
532
532
  whitener = torch.linalg.solve_triangular(chol, eye, upper=False)
533
533
  return whitener.reshape(cov.shape)
534
534
 
535
- def whiten(self, data, channels=slice(None)):
535
+ def whiten(self, data, channels=slice(None)): # noqa: B008
536
536
  assert self.mean_kind == "zero"
537
537
  cov = self.marginal_covariance(channels=channels)
538
538
  assert data.ndim == 3
@@ -677,7 +677,7 @@ class EmbeddedNoise(BModule):
677
677
 
678
678
  def marginal_covariance(
679
679
  self,
680
- channels: Tensor | slice = slice(None),
680
+ channels: Tensor | slice = slice(None), # noqa: B008
681
681
  cache_prefix=None,
682
682
  cache_key=None,
683
683
  device=None,
@@ -717,7 +717,7 @@ class EmbeddedNoise(BModule):
717
717
  return cov
718
718
 
719
719
  def offdiag_covariance(
720
- self, channels_left=slice(None), channels_right=slice(None), device=None
720
+ self, channels_left=slice(None), channels_right=slice(None), device=None # noqa: B008
721
721
  ):
722
722
  odc = self._marginal_covariance(
723
723
  channels=channels_right, channels_left=channels_left
@@ -727,7 +727,7 @@ class EmbeddedNoise(BModule):
727
727
  return odc
728
728
 
729
729
  def _marginal_covariance(
730
- self, channels: Tensor | slice = slice(None), channels_left=None
730
+ self, channels: Tensor | slice = slice(None), channels_left=None # noqa: B008
731
731
  ):
732
732
  channels = self.b.chans_arange[channels]
733
733
  have_left = channels_left is not None
@@ -1,13 +1,14 @@
1
1
  import warnings
2
+ from pathlib import Path
2
3
  from typing import Literal
3
4
 
4
5
  import numpy as np
5
6
  import spikeinterface.full as si
6
- from spikeinterface.core import BaseRecording
7
+ from spikeinterface.core import BaseRecording, load
7
8
 
8
9
  from .internal_config import PreprocessingStrategy
9
10
  from .logging_util import get_logger
10
- from .py_util import panic
11
+ from .py_util import ensure_path, panic
11
12
 
12
13
  logger = get_logger(__name__)
13
14
 
@@ -134,10 +135,13 @@ def warn_about_preprocessing(rec: BaseRecording, will_preprocess: bool):
134
135
 
135
136
  def preprocess(
136
137
  rec: BaseRecording,
138
+ *,
139
+ output_dir: str | Path | None = None,
137
140
  strategy: PreprocessingStrategy = "none",
138
141
  already_preprocessed: Literal[
139
142
  "yes", "no", "assume_yes_if_float"
140
143
  ] = "assume_yes_if_float",
144
+ json_filename: str = "dartsort_preprocessed_recording.json",
141
145
  dtype: str = "float32",
142
146
  ) -> BaseRecording:
143
147
  if already_preprocessed == "yes":
@@ -157,6 +161,26 @@ def preprocess(
157
161
  else:
158
162
  panic(already_preprocessed)
159
163
 
164
+ if output_dir is not None:
165
+ json_path = ensure_path(output_dir) / json_filename
166
+ if json_path.exists():
167
+ extractor = load(json_path)
168
+ assert isinstance(extractor, BaseRecording)
169
+ return extractor
170
+ else:
171
+ json_path = None
172
+
160
173
  logger.info("applying preprocessing: %s", strategy)
161
174
  warn_about_preprocessing(rec=rec, will_preprocess=strategy != "none")
162
- return preprocessing_strategies[strategy](rec, dtype)
175
+ rec = preprocessing_strategies[strategy](rec, dtype)
176
+
177
+ # save provenance
178
+ if json_path is not None:
179
+ rec.dump_to_json(
180
+ file_path=json_path,
181
+ include_extra_metadata=True,
182
+ include_properties=True,
183
+ include_annotations=True,
184
+ )
185
+
186
+ return rec
@@ -35,7 +35,7 @@ def dredge_estimate_motion(
35
35
 
36
36
  # features for registration
37
37
  z = z[valid]
38
- t_s = getattr(sorting, "times_seconds")
38
+ t_s = sorting.times_seconds
39
39
  t_s = t_s[valid]
40
40
  a = a[valid]
41
41
 
@@ -1,11 +1,11 @@
1
1
  "Vis helpers. Install with [vis]."
2
2
  try:
3
3
  import seaborn
4
- except ImportError:
4
+ except ImportError as e:
5
5
  raise ImportError(
6
6
  'seaborn isn\'t installed; pip install "dartsort[vis]" or "dartsort[full]" to '
7
7
  "get the dartsort.vis dependencies."
8
- )
8
+ ) from e
9
9
 
10
10
  from .analysis_plots import *
11
11
  from .colors import *
@@ -204,7 +204,7 @@ def distance_matrix_dendro(
204
204
  ax_dendro = panel.add_subplot(gs[:, 2], sharey=ax_im)
205
205
  ax_dendro.axis("off")
206
206
 
207
- Z, labels = get_linkage(
207
+ Z, _labels = get_linkage(
208
208
  distances, method=dendrogram_linkage, threshold=dendrogram_threshold
209
209
  )
210
210
  dendro = dendrogram(
@@ -83,7 +83,7 @@ class TrimmedAgreementMatrix(ComparisonPlot):
83
83
  width = 3
84
84
  height = 2
85
85
 
86
- def __init__(self, trim_kind="auto", ordered=True, cmap=table_cmap):
86
+ def __init__(self, trim_kind="auto", ordered=True, cmap=table_cmap): # ty:ignore[possibly-unresolved-reference]
87
87
  self.trim_kind = trim_kind
88
88
  self.ordered = ordered
89
89
  self.cmap = cmap
@@ -22,6 +22,7 @@ from ..util.internal_config import (
22
22
  )
23
23
  from ..util.job_util import ensure_computation_config
24
24
  from ..util.motion import try_load_motion_info
25
+ from ..util.py_util import ensure_path
25
26
  from . import gt, mixture, scatterplots, unit, unit_comparison, versus
26
27
  from .sorting import make_sorting_summary
27
28
 
@@ -63,6 +64,7 @@ def visualize_sorting(
63
64
  computation_cfg: ComputationConfig | None = None,
64
65
  errors_to_warnings=True,
65
66
  ):
67
+ output_directory = ensure_path(output_directory)
66
68
  output_directory.mkdir(exist_ok=True, parents=True)
67
69
  computation_cfg = ensure_computation_config(computation_cfg)
68
70
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dartsort
3
- Version: 0.5.26
3
+ Version: 0.5.27
4
4
  Summary: DARTsort
5
5
  Author-email: Charlie Windolf <ciw2048@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/cwindolf/dartsort
@@ -80,7 +80,7 @@ def test_shared_flags_agree(detection_type):
80
80
  "agglomerate template": agg_cfg.template_merge_cfg.template_cfg.whitening, # ty: ignore[unresolved-attribute]
81
81
  }
82
82
  if detection_type == "subtract":
83
- whitening_cfgs["subtraction"] = detection_cfg.whiten_cfg # ty: ignore[unresolved-attribute]
83
+ whitening_cfgs["subtraction"] = detection_cfg.whiten_cfg # ty: ignore[unresolved-attribute, invalid-assignment]
84
84
  for name, whitening_cfg in whitening_cfgs.items():
85
85
  assert whitening_cfg is not None
86
86
  assert whitening_cfg.estimator == "sparsechol", name
@@ -422,7 +422,7 @@ def test_grid_sample_average(target_geom, simulator):
422
422
  avg_ptps = np.ptp(avg_temps, axis=1).max(1)
423
423
  plain_temps = plain.templates()[1]
424
424
  plain_ptps = np.ptp(plain_temps, axis=1).max(1)
425
- assert not np.allclose(avg_temps, plain_temps, atol=1e-5 * scale)
425
+ assert not np.allclose(avg_temps, plain_temps, atol=1e-5 * scale) # ty:ignore[possibly-unresolved-reference]
426
426
  assert (avg_ptps < plain_ptps).all()
427
427
  assert (avg_ptps > 0.9 * plain_ptps).all()
428
428
 
@@ -634,7 +634,7 @@ def test_static(tmp_path, up_factor, cd_iter):
634
634
  )
635
635
 
636
636
  matcher = dartsort.ObjectiveUpdateTemplateMatchingPeeler.from_config(
637
- rec,
637
+ rec, # ty:ignore[invalid-argument-type]
638
638
  waveform_cfg=dartsort.default_waveform_cfg,
639
639
  matching_cfg=matching_cfg,
640
640
  featurization_cfg=nofeatcfg,
@@ -702,7 +702,8 @@ def test_static(tmp_path, up_factor, cd_iter):
702
702
 
703
703
  res = matcher.peel_chunk(
704
704
  torch.asarray(
705
- rec.get_traces().copy(), device=matcher.b.channel_index.device
705
+ rec.get_traces().copy(), # ty:ignore[unresolved-attribute]
706
+ device=matcher.b.channel_index.device,
706
707
  ),
707
708
  return_residual=True,
708
709
  return_conv=True,
@@ -811,7 +812,7 @@ def test_fakedata_nonn(tmp_path, threshold=7.0):
811
812
  for rec in [rec1, rec0]:
812
813
  (tmp_path / "match").mkdir()
813
814
  st = dartsort.match(
814
- recording=rec,
815
+ recording=rec, # ty:ignore[invalid-argument-type]
815
816
  sorting=gts,
816
817
  output_dir=tmp_path / "match",
817
818
  motion=no_motion,
@@ -458,12 +458,19 @@ def test_truncated_mixture_low_k(low_k_simulations, K):
458
458
  eval_scores = tmm.soft_assign(
459
459
  data=val_data, full_proposal_view=True, needs_bootstrap=False
460
460
  )
461
+ else:
462
+ train_scores = eval_scores = None
463
+
461
464
  if step == "split":
465
+ assert train_scores is not None
466
+ assert eval_scores is not None
462
467
  split_res = tmm.split(
463
468
  train_data, val_data, train_scores=train_scores, eval_scores=eval_scores
464
469
  )
465
470
  assert split_res.n_new_units == 0
466
471
  if step == "merge":
472
+ assert train_scores is not None
473
+ assert eval_scores is not None
467
474
  pair_mask = mixture.violation_pair_mask(
468
475
  tmm=tmm,
469
476
  full_data=full_data,
@@ -305,7 +305,7 @@ def test_static_templates(tmp_path):
305
305
  rec1 = rec0.save(format="binary", folder=Path(tdir) / "rec")
306
306
  for rec in [rec0, rec1]:
307
307
  res = get_templates(
308
- recording=rec,
308
+ recording=rec, # ty:ignore[invalid-argument-type]
309
309
  sorting=sorting,
310
310
  waveform_cfg=waveform_cfg,
311
311
  template_cfg=raw_template_cfg,
@@ -357,7 +357,7 @@ def test_drifting_templates(tmp_path):
357
357
  )
358
358
 
359
359
  res = get_templates(
360
- recording=rec,
360
+ recording=rec, # ty:ignore[invalid-argument-type]
361
361
  sorting=sorting,
362
362
  motion=motion,
363
363
  waveform_cfg=waveform_cfg,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes