Skip to content

Commit f511954

Browse files
authored
Merge pull request #121 from yarikoptic/enh-codespell
codespell: action, config + typos fixed
2 parents dfafba4 + f7641ba commit f511954

File tree

22 files changed

+74
-47
lines changed

22 files changed

+74
-47
lines changed

.codespellrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[codespell]
2+
skip = .git,*.pdf,*.svg,*.ipynb,*.js,*.css,build
3+
# interm,te - quick variables used
4+
# alph - skip as might be not desired change at this stage
5+
ignore-words-list = ges,interm,te,alph

.github/workflows/codespell.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Codespell
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
codespell:
15+
name: Check for spelling errors
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v3
21+
- name: Codespell
22+
uses: codespell-project/actions-codespell@v2

causallearn/search/ConstraintBased/FCI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def doDdpOrientation(node_d: Node, node_a: Node, node_b: Node, node_c: Node, pre
387387
independence_test_method, alpha: float, sep_sets: Dict[Tuple[int, int], Set[int]],
388388
change_flag: bool, bk, verbose: bool = False) -> (bool, bool):
389389
"""
390-
Orients the edges inside the definte discriminating path triangle. Takes
390+
Orients the edges inside the definite discriminating path triangle. Takes
391391
the left endpoint, and a,b,c as arguments.
392392
"""
393393
if graph.is_adjacent_to(node_d, node_c):

causallearn/search/ConstraintBased/PC.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def detect_parent(r: int, data_: ndarray, alpha: float, indep_test, stable: bool
394394
def get_parent(r: int, cg_skel_adj: ndarray) -> ndarray:
395395
"""Get the neighbors of missingness indicators which are the parents
396396
:param r: the missingness indicator index
397-
:param cg_skel_adj: adjacancy matrix of a causal skeleton
397+
:param cg_skel_adj: adjacency matrix of a causal skeleton
398398
:return:
399399
prt: list, parents of the missingness indicator r
400400
"""

causallearn/search/FCMBased/lingam/causal_effect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _get_propagated_effects(self, En, intervention_index, intervention_value):
8080
8181
Parameters
8282
----------
83-
En : array-like, shpae (n_features)
83+
En : array-like, shape (n_features)
8484
Expectations of each noise variable.
8585
intervention_index : int
8686
Index of variable to apply intervention.
@@ -89,7 +89,7 @@ def _get_propagated_effects(self, En, intervention_index, intervention_value):
8989
9090
Returns
9191
-------
92-
propagated_effects : array-like, shpae (n_features)
92+
propagated_effects : array-like, shape (n_features)
9393
Propagated effects, where ``n_features`` is the number of features.
9494
"""
9595
effects = np.zeros(len(self._causal_order))
@@ -106,7 +106,7 @@ def _predict(self, X, pred_model):
106106
107107
Parameters
108108
----------
109-
X : array-like, shpae (n_predictors)
109+
X : array-like, shape (n_predictors)
110110
Predictors, where ``n_predictors`` is the number of variables.
111111
pred_model : model object implementing 'predict' or 'predict_proba'
112112
Model to predict the expectation. For linear regression or non-linear reggression, model object must have ``predict`` method.

causallearn/search/FCMBased/lingam/direct_lingam.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _entropy(self, u):
146146
k2 * (np.mean(u * np.exp((-u ** 2) / 2))) ** 2
147147

148148
def _diff_mutual_info(self, xi_std, xj_std, ri_j, rj_i):
149-
"""Calculate the difference of the mutual informations."""
149+
"""Calculate the difference of the mutual information."""
150150
return (self._entropy(xj_std) + self._entropy(ri_j / np.std(ri_j))) - \
151151
(self._entropy(xi_std) + self._entropy(rj_i / np.std(rj_i)))
152152

@@ -215,7 +215,7 @@ def _search_causal_order(self, X, U):
215215
return Uc[np.argmax(M_list)]
216216

217217
def _mutual_information(self, x1, x2, param):
218-
"""Calculate the mutual informations."""
218+
"""Calculate the mutual information."""
219219
kappa, sigma = param
220220
n = len(x1)
221221
X1 = np.tile(x1, (n, 1))

causallearn/search/FCMBased/lingam/utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def print_causal_directions(cdc, n_sampling, labels=None):
2424
n_sampling : int
2525
Number of bootstrapping samples.
2626
labels : array-like, optional (default=None)
27-
List of feature lables.
27+
List of feature labels.
2828
If set labels, the output feature name will be the specified label.
2929
"""
3030
for i, (fr, to, co) in enumerate(zip(cdc['from'], cdc['to'], cdc['count'])):
@@ -47,7 +47,7 @@ def print_dagc(dagc, n_sampling, labels=None):
4747
n_sampling : int
4848
Number of bootstrapping samples.
4949
labels : array-like, optional (default=None)
50-
List of feature lables.
50+
List of feature labels.
5151
If set labels, the output feature name will be the specified label.
5252
"""
5353
for i, (dag, co) in enumerate(zip(dagc['dag'], dagc['count'])):

causallearn/search/ScoreBased/ExactSearch.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def bic_exact_search(X, super_graph=None, search_method='astar',
6060
dag_est : numpy.ndarray, shape=(d, d)
6161
Estimated DAG.
6262
search_stats : dict
63-
Some statistics related to the seach procedure.
63+
Some statistics related to the search procedure.
6464
"""
6565
n, d = X.shape
6666
if super_graph is None:
@@ -76,7 +76,7 @@ def bic_exact_search(X, super_graph=None, search_method='astar',
7676
if max_parents is None:
7777
max_parents = d
7878

79-
# To store statistics related to the seach procedure
79+
# To store statistics related to the search procedure
8080
search_stats = {}
8181

8282
# Generate parent graphs (without parallel computing)
@@ -102,7 +102,7 @@ def bic_exact_search(X, super_graph=None, search_method='astar',
102102
if verbose:
103103
_logger.info("Finished searching for shortest path.")
104104

105-
# Covnert structures to adjacency matrix
105+
# Convert structures to adjacency matrix
106106
dag_est = np.zeros((d, d))
107107
for i, parents in enumerate(structures):
108108
dag_est[parents, i] = 1
@@ -135,14 +135,14 @@ def astar_shortest_path(parent_graphs, use_path_extension=True,
135135
structures : tuple, shape=(d,)
136136
Optimal parents for each variable.
137137
shortest_path_stats : dict
138-
Some statistics related to the shortest path seach.
138+
Some statistics related to the shortest path search.
139139
"""
140140
d = len(parent_graphs)
141141
opened = PriorityQueue()
142142
closed = set()
143143

144144
if use_k_cycle_heuristic:
145-
# Create pattern databse
145+
# Create pattern database
146146
PD = create_dynamic_pd(parent_graphs, k)
147147
if verbose:
148148
_logger.info('Finished creating pattern database.')
@@ -234,7 +234,7 @@ def dp_shortest_path(parent_graphs, use_path_extension=True, verbose=False):
234234
structures : tuple, shape=(d,)
235235
Optimal parents for each variable.
236236
shortest_path_stats : dict
237-
Some statistics related to the shortest path seach.
237+
Some statistics related to the shortest path search.
238238
"""
239239
d = len(parent_graphs)
240240
order_graph = nx.DiGraph()
@@ -320,7 +320,7 @@ def generate_parent_graph(X, i, max_parents=None, parent_set=None, include_paren
320320
parent_set = tuple(set(parent_set))
321321

322322
if include_parents is None:
323-
include_parents = () # Emptry tuple
323+
include_parents = () # Empty tuple
324324

325325
parent_graph = []
326326
for j in range(len(parent_set) + 1):

causallearn/utils/DAG2CPDAG.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
def dag2cpdag(G: Dag) -> GeneralGraph:
1010
"""
11-
Covert a DAG to its corresponding PDAG
11+
Convert a DAG to its corresponding PDAG
1212
1313
Parameters
1414
----------
@@ -99,7 +99,7 @@ def dag2cpdag(G: Dag) -> GeneralGraph:
9999
id2 = np.intersect1d(np.where(sign_edges == 0)[0], id1)
100100
sign_edges[id2] = -1 # label all "unknown" edges incident into y with "reversible"
101101

102-
# create CPDAG accoring the labelled edge
102+
# create CPDAG according the labelled edge
103103
nodes = G.get_nodes()
104104
CPDAG = GeneralGraph(nodes)
105105
for m in range(M):

causallearn/utils/DAG2PAG.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def dag2pag(dag: Dag, islatent: List[Node]) -> GeneralGraph:
1717
"""
18-
Covert a DAG to its corresponding PAG
18+
Convert a DAG to its corresponding PAG
1919
Parameters
2020
----------
2121
dag : Direct Acyclic Graph

0 commit comments

Comments
 (0)