Skip to content

Commit 3da8fae

Browse files
committed
Added ignore tags to false positives
1 parent 41c6d57 commit 3da8fae

5 files changed

Lines changed: 10 additions & 9 deletions

File tree

polygraph/datasets/lobster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def is_lobster_graph(graph: nx.Graph) -> bool:
2222
leaves = [n for n, d in graph.degree() if d == 1] # pyright: ignore
2323
graph.remove_nodes_from(leaves)
2424

25-
num_nodes = len(graph.nodes())
25+
num_nodes = len(graph.nodes()) # pyright: ignore
2626
num_degree_one = [d for n, d in graph.degree() if d == 1] # pyright: ignore
2727
num_degree_two = [d for n, d in graph.degree() if d == 2] # pyright: ignore
2828

polygraph/datasets/planar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(
3737
memmap: bool = False,
3838
show_generation_progress: bool = False,
3939
):
40-
config_hash: str = joblib.hash(
40+
config_hash: str = joblib.hash( # pyright: ignore
4141
(num_graphs, n_nodes, seed, split), hash_name="md5"
4242
)
4343
self._rng = np.random.default_rng(

polygraph/metrics/base/polygraphscore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,12 @@ def compute(
373373
samples = []
374374
for _ in range(num_samples):
375375
ref_idx = rng.choice(
376-
self._reference_descriptions.shape[0],
376+
self._reference_descriptions.shape[0], # pyright: ignore
377377
size=subsample_size,
378378
replace=False,
379379
)
380380
gen_idx = rng.choice(
381-
descriptions.shape[0], size=subsample_size, replace=False
381+
descriptions.shape[0], size=subsample_size, replace=False # pyright: ignore
382382
)
383383
samples.append(
384384
_descriptions_to_classifier_metric(

polygraph/utils/graph_descriptors.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def __call__(self, graphs: Iterable[nx.Graph]) -> csr_array:
153153
ptr[1:] = np.cumsum([len(idx) for idx in index]).astype(np.int32)
154154
result = csr_array(
155155
(np.concatenate(data), np.concatenate(index), ptr),
156-
(len(graphs), 100_000),
156+
(len(hists), 100_000),
157157
)
158158
return result
159159

@@ -223,6 +223,7 @@ def __init__(
223223

224224
def __call__(self, graphs: Iterable[nx.Graph]):
225225
# Check if any graph has a self-loop
226+
graphs = list(graphs)
226227
self_loops = [list(nx.selfloop_edges(g)) for g in graphs]
227228
if any(len(loops) > 0 for loops in self_loops):
228229
warnings.warn(
@@ -389,7 +390,7 @@ def __call__(self, graphs: Iterable[nx.Graph]) -> np.ndarray:
389390
self._device
390391
)
391392

392-
batch = Batch.from_data_list(pyg_graphs).to(self._device)
393+
batch = Batch.from_data_list(pyg_graphs).to(self._device) # pyright: ignore
393394

394395
graph_embeds = self._feat_fn(
395396
feats, batch.edge_index, batch.batch, edge_attr=edge_attr

polygraph/utils/kernels.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def pre_gram_block(self, x: MatrixLike, y: MatrixLike) -> np.ndarray:
208208
comparison = np.expand_dims(comparison, -1)
209209

210210
comparison = np.exp(-self.lbd * comparison)
211-
assert comparison.shape[:2] == (x.shape[0], y.shape[0])
211+
assert comparison.shape[:2] == (x.shape[0], y.shape[0]) # pyright: ignore
212212
return comparison
213213

214214

@@ -264,7 +264,7 @@ def pre_gram_block(self, x: MatrixLike, y: MatrixLike) -> np.ndarray:
264264
comparison = np.expand_dims(comparison, -1)
265265

266266
comparison = np.exp(-((comparison / 2) ** 2) / (2 * self.bw**2))
267-
assert comparison.shape[:2] == (x.shape[0], y.shape[0])
267+
assert comparison.shape[:2] == (x.shape[0], y.shape[0]) # pyright: ignore
268268
return comparison
269269

270270

@@ -318,7 +318,7 @@ def pre_gram_block(self, x: MatrixLike, y: MatrixLike) -> np.ndarray:
318318
comparison = np.expand_dims(comparison, -1)
319319

320320
comparison = np.exp(-comparison / (2 * self.bw**2))
321-
assert comparison.shape[:2] == (x.shape[0], y.shape[0])
321+
assert comparison.shape[:2] == (x.shape[0], y.shape[0]) # pyright: ignore
322322
return comparison
323323

324324

0 commit comments

Comments
 (0)