Skip to content

Commit d892aea

Browse files
committed
Inline default values into signature
1 parent ffdbddf commit d892aea

File tree

3 files changed

+173
-178
lines changed

3 files changed

+173
-178
lines changed

graphdatascience/procedure_surface/api/similarity/knn_endpoints.py

Lines changed: 63 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ def mutate(
1818
mutate_relationship_type: str,
1919
mutate_property: str,
2020
node_properties: str | list[str] | dict[str, str],
21-
top_k: int | None = None,
22-
similarity_cutoff: float | None = None,
23-
delta_threshold: float | None = None,
24-
max_iterations: int | None = None,
25-
sample_rate: float | None = None,
26-
perturbation_rate: float | None = None,
27-
random_joins: int | None = None,
21+
top_k: int = 10,
22+
similarity_cutoff: float = 0.0,
23+
delta_threshold: float = 0.001,
24+
max_iterations: int = 100,
25+
sample_rate: float = 0.5,
26+
perturbation_rate: float = 0.0,
27+
random_joins: int = 10,
2828
random_seed: int | None = None,
29-
initial_sampler: Any | None = None,
29+
initial_sampler: str = "UNIFORM",
3030
relationship_types: list[str] | None = None,
3131
node_labels: list[str] | None = None,
32-
sudo: bool | None = None,
32+
sudo: bool = False,
3333
log_progress: bool = True,
3434
username: str | None = None,
35-
concurrency: Any | None = None,
36-
job_id: Any | None = None,
35+
concurrency: int | None = None,
36+
job_id: str | None = None,
3737
) -> KnnMutateResult:
3838
"""
3939
Runs the K-Nearest Neighbors algorithm and stores the results as new relationships in the graph catalog.
@@ -92,22 +92,22 @@ def stats(
9292
self,
9393
G: GraphV2,
9494
node_properties: str | list[str] | dict[str, str],
95-
top_k: int | None = None,
96-
similarity_cutoff: float | None = None,
97-
delta_threshold: float | None = None,
98-
max_iterations: int | None = None,
99-
sample_rate: float | None = None,
100-
perturbation_rate: float | None = None,
101-
random_joins: int | None = None,
95+
top_k: int = 10,
96+
similarity_cutoff: float = 0.0,
97+
delta_threshold: float = 0.001,
98+
max_iterations: int = 100,
99+
sample_rate: float = 0.5,
100+
perturbation_rate: float = 0.0,
101+
random_joins: int = 10,
102102
random_seed: int | None = None,
103-
initial_sampler: Any | None = None,
103+
initial_sampler: str = "UNIFORM",
104104
relationship_types: list[str] | None = None,
105105
node_labels: list[str] | None = None,
106-
sudo: bool | None = None,
106+
sudo: bool = False,
107107
log_progress: bool = True,
108108
username: str | None = None,
109-
concurrency: Any | None = None,
110-
job_id: Any | None = None,
109+
concurrency: int | None = None,
110+
job_id: str | None = None,
111111
) -> KnnStatsResult:
112112
"""
113113
Runs the K-Nearest Neighbors algorithm and returns execution statistics.
@@ -162,22 +162,22 @@ def stream(
162162
self,
163163
G: GraphV2,
164164
node_properties: str | list[str] | dict[str, str],
165-
top_k: int | None = None,
166-
similarity_cutoff: float | None = None,
167-
delta_threshold: float | None = None,
168-
max_iterations: int | None = None,
169-
sample_rate: float | None = None,
170-
perturbation_rate: float | None = None,
171-
random_joins: int | None = None,
165+
top_k: int = 10,
166+
similarity_cutoff: float = 0.0,
167+
delta_threshold: float = 0.001,
168+
max_iterations: int = 100,
169+
sample_rate: float = 0.5,
170+
perturbation_rate: float = 0.0,
171+
random_joins: int = 10,
172172
random_seed: int | None = None,
173-
initial_sampler: Any | None = None,
173+
initial_sampler: str = "UNIFORM",
174174
relationship_types: list[str] | None = None,
175175
node_labels: list[str] | None = None,
176-
sudo: bool | None = None,
176+
sudo: bool = False,
177177
log_progress: bool = True,
178178
username: str | None = None,
179-
concurrency: Any | None = None,
180-
job_id: Any | None = None,
179+
concurrency: int | None = None,
180+
job_id: str | None = None,
181181
) -> DataFrame:
182182
"""
183183
Runs the K-Nearest Neighbors algorithm and returns the result as a DataFrame.
@@ -234,22 +234,22 @@ def write(
234234
write_relationship_type: str,
235235
write_property: str,
236236
node_properties: str | list[str] | dict[str, str],
237-
top_k: int | None = None,
238-
similarity_cutoff: float | None = None,
239-
delta_threshold: float | None = None,
240-
max_iterations: int | None = None,
241-
sample_rate: float | None = None,
242-
perturbation_rate: float | None = None,
243-
random_joins: int | None = None,
237+
top_k: int = 10,
238+
similarity_cutoff: float = 0.0,
239+
delta_threshold: float = 0.001,
240+
max_iterations: int = 100,
241+
sample_rate: float = 0.5,
242+
perturbation_rate: float = 0.0,
243+
random_joins: int = 10,
244244
random_seed: int | None = None,
245-
initial_sampler: Any | None = None,
245+
initial_sampler: str = "UNIFORM",
246246
relationship_types: list[str] | None = None,
247247
node_labels: list[str] | None = None,
248-
sudo: bool | None = None,
248+
sudo: bool = False,
249249
log_progress: bool = True,
250250
username: str | None = None,
251-
concurrency: Any | None = None,
252-
job_id: Any | None = None,
251+
concurrency: int | None = None,
252+
job_id: str | None = None,
253253
write_concurrency: int | None = None,
254254
) -> KnnWriteResult:
255255
"""
@@ -311,22 +311,21 @@ def estimate(
311311
self,
312312
G: GraphV2,
313313
node_properties: str | list[str] | dict[str, str],
314-
top_k: int | None = None,
315-
similarity_cutoff: float | None = None,
316-
delta_threshold: float | None = None,
317-
max_iterations: int | None = None,
318-
sample_rate: float | None = None,
319-
perturbation_rate: float | None = None,
320-
random_joins: int | None = None,
314+
top_k: int = 10,
315+
similarity_cutoff: float = 0.0,
316+
delta_threshold: float = 0.001,
317+
max_iterations: int = 100,
318+
sample_rate: float = 0.5,
319+
perturbation_rate: float = 0.0,
320+
random_joins: int = 10,
321321
random_seed: int | None = None,
322-
initial_sampler: Any | None = None,
322+
initial_sampler: str = "UNIFORM",
323323
relationship_types: list[str] | None = None,
324324
node_labels: list[str] | None = None,
325-
sudo: bool | None = None,
325+
sudo: bool = False,
326326
log_progress: bool = True,
327327
username: str | None = None,
328-
concurrency: Any | None = None,
329-
job_id: Any | None = None,
328+
concurrency: int | None = None,
330329
) -> EstimationResult:
331330
"""
332331
Estimates the memory requirements for running the K-Nearest Neighbors algorithm.
@@ -337,29 +336,29 @@ def estimate(
337336
The graph to run the algorithm on
338337
node_properties: str | list[str] | dict[str, str],
339338
The node properties to use for similarity computation.
340-
top_k : int | None, default=None
339+
top_k : int, default=10
341340
The number of nearest neighbors to find for each node.
342-
similarity_cutoff : float | None, default=None
341+
similarity_cutoff : float, default=0.0
343342
The threshold for similarity scores.
344-
delta_threshold : float | None, default=None
343+
delta_threshold : float, default=0.001
345344
The threshold for convergence assessment.
346-
max_iterations : int | None, default=None
345+
max_iterations : int, default=100
347346
The maximum number of iterations to run.
348-
sample_rate : float | None, default=None
347+
sample_rate : float, default=0.5
349348
The sampling rate for the algorithm.
350-
perturbation_rate : float | None, default=None
349+
perturbation_rate : float, default=0.0
351350
The rate at which to perturb the similarity graph.
352-
random_joins : int | None, default=None
351+
random_joins : int, default=10
353352
The number of random joins to perform.
354353
random_seed : int | None, default=None
355354
The seed for the random number generator.
356-
initial_sampler : Any | None, default=None
355+
initial_sampler : str, default="UNIFORM"
357356
The initial sampling strategy.
358357
relationship_types : list[str] | None, default=None
359358
Filter on relationship types.
360359
node_labels : list[str] | None, default=None
361360
Filter on node labels.
362-
sudo : bool | None, default=None
361+
sudo : bool, default=False
363362
Run the algorithm with elevated privileges.
364363
log_progress : bool, default=True
365364
Whether to log progress.

graphdatascience/procedure_surface/arrow/similarity/knn_arrow_endpoints.py

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import annotations
22

3-
from typing import Any
4-
53
from pandas import DataFrame
64

75
from graphdatascience.arrow_client.authenticated_flight_client import AuthenticatedArrowClient
@@ -35,22 +33,22 @@ def mutate(
3533
mutate_relationship_type: str,
3634
mutate_property: str,
3735
node_properties: str | list[str] | dict[str, str],
38-
top_k: int | None = None,
39-
similarity_cutoff: float | None = None,
40-
delta_threshold: float | None = None,
41-
max_iterations: int | None = None,
42-
sample_rate: float | None = None,
43-
perturbation_rate: float | None = None,
44-
random_joins: int | None = None,
36+
top_k: int = 10,
37+
similarity_cutoff: float = 0.0,
38+
delta_threshold: float = 0.001,
39+
max_iterations: int = 100,
40+
sample_rate: float = 0.5,
41+
perturbation_rate: float = 0.0,
42+
random_joins: int = 10,
4543
random_seed: int | None = None,
46-
initial_sampler: Any | None = None,
44+
initial_sampler: str = "UNIFORM",
4745
relationship_types: list[str] | None = None,
4846
node_labels: list[str] | None = None,
49-
sudo: bool | None = None,
47+
sudo: bool = False,
5048
log_progress: bool = True,
5149
username: str | None = None,
52-
concurrency: Any | None = None,
53-
job_id: Any | None = None,
50+
concurrency: int | None = None,
51+
job_id: str | None = None,
5452
) -> KnnMutateResult:
5553
config = self._endpoints_helper.create_base_config(
5654
G,
@@ -83,22 +81,22 @@ def stats(
8381
self,
8482
G: GraphV2,
8583
node_properties: str | list[str] | dict[str, str],
86-
top_k: int | None = None,
87-
similarity_cutoff: float | None = None,
88-
delta_threshold: float | None = None,
89-
max_iterations: int | None = None,
90-
sample_rate: float | None = None,
91-
perturbation_rate: float | None = None,
92-
random_joins: int | None = None,
84+
top_k: int = 10,
85+
similarity_cutoff: float = 0.0,
86+
delta_threshold: float = 0.001,
87+
max_iterations: int = 100,
88+
sample_rate: float = 0.5,
89+
perturbation_rate: float = 0.0,
90+
random_joins: int = 10,
9391
random_seed: int | None = None,
94-
initial_sampler: Any | None = None,
92+
initial_sampler: str = "UNIFORM",
9593
relationship_types: list[str] | None = None,
9694
node_labels: list[str] | None = None,
97-
sudo: bool | None = None,
95+
sudo: bool = False,
9896
log_progress: bool = True,
9997
username: str | None = None,
100-
concurrency: Any | None = None,
101-
job_id: Any | None = None,
98+
concurrency: int | None = None,
99+
job_id: str | None = None,
102100
) -> KnnStatsResult:
103101
config = self._endpoints_helper.create_base_config(
104102
G,
@@ -129,22 +127,22 @@ def stream(
129127
self,
130128
G: GraphV2,
131129
node_properties: str | list[str] | dict[str, str],
132-
top_k: int | None = None,
133-
similarity_cutoff: float | None = None,
134-
delta_threshold: float | None = None,
135-
max_iterations: int | None = None,
136-
sample_rate: float | None = None,
137-
perturbation_rate: float | None = None,
138-
random_joins: int | None = None,
130+
top_k: int = 10,
131+
similarity_cutoff: float = 0.0,
132+
delta_threshold: float = 0.001,
133+
max_iterations: int = 100,
134+
sample_rate: float = 0.5,
135+
perturbation_rate: float = 0.0,
136+
random_joins: int = 10,
139137
random_seed: int | None = None,
140-
initial_sampler: Any | None = None,
138+
initial_sampler: str = "UNIFORM",
141139
relationship_types: list[str] | None = None,
142140
node_labels: list[str] | None = None,
143-
sudo: bool | None = None,
141+
sudo: bool = False,
144142
log_progress: bool = True,
145143
username: str | None = None,
146-
concurrency: Any | None = None,
147-
job_id: Any | None = None,
144+
concurrency: int | None = None,
145+
job_id: str | None = None,
148146
) -> DataFrame:
149147
config = self._endpoints_helper.create_base_config(
150148
G,
@@ -177,22 +175,22 @@ def write(
177175
write_relationship_type: str,
178176
write_property: str,
179177
node_properties: str | list[str] | dict[str, str],
180-
top_k: int | None = None,
181-
similarity_cutoff: float | None = None,
182-
delta_threshold: float | None = None,
183-
max_iterations: int | None = None,
184-
sample_rate: float | None = None,
185-
perturbation_rate: float | None = None,
186-
random_joins: int | None = None,
178+
top_k: int = 10,
179+
similarity_cutoff: float = 0.0,
180+
delta_threshold: float = 0.001,
181+
max_iterations: int = 100,
182+
sample_rate: float = 0.5,
183+
perturbation_rate: float = 0.0,
184+
random_joins: int = 10,
187185
random_seed: int | None = None,
188-
initial_sampler: Any | None = None,
186+
initial_sampler: str = "UNIFORM",
189187
relationship_types: list[str] | None = None,
190188
node_labels: list[str] | None = None,
191-
sudo: bool | None = None,
189+
sudo: bool = False,
192190
log_progress: bool = True,
193191
username: str | None = None,
194-
concurrency: Any | None = None,
195-
job_id: Any | None = None,
192+
concurrency: int | None = None,
193+
job_id: str | None = None,
196194
write_concurrency: int | None = None,
197195
) -> KnnWriteResult:
198196
config = self._endpoints_helper.create_base_config(
@@ -232,22 +230,22 @@ def estimate(
232230
self,
233231
G: GraphV2,
234232
node_properties: str | list[str] | dict[str, str],
235-
top_k: int | None = None,
236-
similarity_cutoff: float | None = None,
237-
delta_threshold: float | None = None,
238-
max_iterations: int | None = None,
239-
sample_rate: float | None = None,
240-
perturbation_rate: float | None = None,
241-
random_joins: int | None = None,
233+
top_k: int = 10,
234+
similarity_cutoff: float = 0.0,
235+
delta_threshold: float = 0.001,
236+
max_iterations: int = 100,
237+
sample_rate: float = 0.5,
238+
perturbation_rate: float = 0.0,
239+
random_joins: int = 10,
242240
random_seed: int | None = None,
243-
initial_sampler: Any | None = None,
241+
initial_sampler: str = "UNIFORM",
244242
relationship_types: list[str] | None = None,
245243
node_labels: list[str] | None = None,
246-
sudo: bool | None = None,
244+
sudo: bool = False,
247245
log_progress: bool = True,
248246
username: str | None = None,
249-
concurrency: Any | None = None,
250-
job_id: Any | None = None,
247+
concurrency: int | None = None,
248+
job_id: str | None = None,
251249
) -> EstimationResult:
252250
config = self._endpoints_helper.create_estimate_config(
253251
nodeProperties=node_properties,

0 commit comments

Comments
 (0)