risk-network 0.0.7b12__tar.gz → 0.0.8b0__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.
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/PKG-INFO +1 -1
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/__init__.py +1 -1
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/permutation/permutation.py +20 -7
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk_network.egg-info/PKG-INFO +1 -1
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/LICENSE +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/MANIFEST.in +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/README.md +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/pyproject.toml +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/annotations/__init__.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/annotations/annotations.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/annotations/io.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/constants.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/log/__init__.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/log/config.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/log/params.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/neighborhoods/__init__.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/neighborhoods/community.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/neighborhoods/domains.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/neighborhoods/neighborhoods.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/network/__init__.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/network/geometry.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/network/graph.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/network/io.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/network/plot.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/risk.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/__init__.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/hypergeom.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/permutation/__init__.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/permutation/test_functions.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/poisson.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/stats.py +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk_network.egg-info/SOURCES.txt +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk_network.egg-info/dependency_links.txt +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk_network.egg-info/requires.txt +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk_network.egg-info/top_level.txt +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/setup.cfg +0 -0
- {risk_network-0.0.7b12 → risk_network-0.0.8b0}/setup.py +0 -0
@@ -133,6 +133,7 @@ def _run_permutation_test(
|
|
133
133
|
observed_neighborhood_scores,
|
134
134
|
neighborhood_score_func,
|
135
135
|
subset_size + (1 if i < remainder else 0),
|
136
|
+
num_permutations,
|
136
137
|
progress_counter,
|
137
138
|
max_workers,
|
138
139
|
rng, # Pass the random number generator to each worker
|
@@ -144,11 +145,9 @@ def _run_permutation_test(
|
|
144
145
|
results = pool.starmap_async(_permutation_process_subset, params_list, chunksize=1)
|
145
146
|
|
146
147
|
# Update progress bar based on progress_counter
|
147
|
-
# NOTE: Waiting for results to be ready while updating progress bar gives a big improvement
|
148
|
-
# in performance, especially for large number of permutations and workers
|
149
148
|
while not results.ready():
|
150
149
|
progress.update(progress_counter.value - progress.n)
|
151
|
-
results.wait(0.
|
150
|
+
results.wait(0.1) # Wait for 100ms
|
152
151
|
# Ensure progress bar reaches 100%
|
153
152
|
progress.update(total_progress - progress.n)
|
154
153
|
|
@@ -167,6 +166,7 @@ def _permutation_process_subset(
|
|
167
166
|
observed_neighborhood_scores: np.ndarray,
|
168
167
|
neighborhood_score_func: Callable,
|
169
168
|
subset_size: int,
|
169
|
+
num_permutations: int,
|
170
170
|
progress_counter: ValueProxy,
|
171
171
|
max_workers: int,
|
172
172
|
rng: np.random.Generator,
|
@@ -180,6 +180,7 @@ def _permutation_process_subset(
|
|
180
180
|
observed_neighborhood_scores (np.ndarray): Observed neighborhood scores.
|
181
181
|
neighborhood_score_func (Callable): Function to calculate neighborhood scores.
|
182
182
|
subset_size (int): Number of permutations to run in this subset.
|
183
|
+
num_permutations (int): Number of total permutations across all subsets.
|
183
184
|
progress_counter (multiprocessing.managers.ValueProxy): Shared counter for tracking progress.
|
184
185
|
max_workers (int): Number of workers for multiprocessing.
|
185
186
|
rng (np.random.Generator): Random number generator object.
|
@@ -190,11 +191,15 @@ def _permutation_process_subset(
|
|
190
191
|
# Initialize local count matrices for this worker
|
191
192
|
local_counts_depletion = np.zeros(observed_neighborhood_scores.shape)
|
192
193
|
local_counts_enrichment = np.zeros(observed_neighborhood_scores.shape)
|
194
|
+
|
193
195
|
# NOTE: Limit the number of threads used by NumPy's BLAS implementation to 1 when more than one worker is used.
|
194
|
-
# This can help prevent oversubscription of CPU resources during multiprocessing, ensuring that each process
|
195
|
-
# doesn't use more than one CPU core.
|
196
196
|
limits = None if max_workers == 1 else 1
|
197
197
|
with threadpool_limits(limits=limits, user_api="blas"):
|
198
|
+
# Initialize a local counter for batched progress updates
|
199
|
+
local_progress = 0
|
200
|
+
# Calculate the modulo value based on total permutations for 1/100th frequency updates
|
201
|
+
modulo_value = max(1, num_permutations // 100)
|
202
|
+
|
198
203
|
for _ in range(subset_size):
|
199
204
|
# Permute the annotation matrix using the RNG
|
200
205
|
annotation_matrix_permut = annotation_matrix[rng.permutation(idxs)]
|
@@ -212,7 +217,15 @@ def _permutation_process_subset(
|
|
212
217
|
local_counts_enrichment,
|
213
218
|
permuted_neighborhood_scores >= observed_neighborhood_scores,
|
214
219
|
)
|
215
|
-
|
216
|
-
|
220
|
+
|
221
|
+
# Update local progress counter
|
222
|
+
local_progress += 1
|
223
|
+
# Update shared progress counter every 1/100th of total permutations
|
224
|
+
if local_progress % modulo_value == 0:
|
225
|
+
progress_counter.value += modulo_value
|
226
|
+
|
227
|
+
# Final progress update for any remaining iterations
|
228
|
+
if local_progress % modulo_value != 0:
|
229
|
+
progress_counter.value += modulo_value
|
217
230
|
|
218
231
|
return local_counts_depletion, local_counts_enrichment
|
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
|
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
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|