From 165cad48a20c8bd41a98bf83033b7e8d9bb8f7fe Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Thu, 5 Sep 2024 18:26:39 +0300 Subject: [PATCH] ci: add typos and fix errors --- .github/workflows/ci.yml | 9 +++++++-- README.rst | 2 +- examples/to_firedrake.py | 4 ++-- meshmode/discretization/connection/chained.py | 6 +++--- .../discretization/connection/opposite_face.py | 14 +++++++------- meshmode/distributed.py | 13 ++++++++++--- pyproject.toml | 12 ++++++++++++ 7 files changed, 42 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b5af8dbb..98a4892b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,13 +8,18 @@ on: - cron: '17 3 * * 0' jobs: + typos: + name: Typos + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@master + ruff: name: Ruff runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: - submodules: true - uses: actions/setup-python@v5 - name: "Main Script" run: | diff --git a/README.rst b/README.rst index 83330b81e..d453bc637 100644 --- a/README.rst +++ b/README.rst @@ -31,7 +31,7 @@ Features: Meshmode emerged as the shared discretization layer for `pytential `__ (layer potentials) and `grudge -`__ (discontinous Galerkin). +`__ (discontinuous Galerkin). Places on the web related to meshmode: diff --git a/examples/to_firedrake.py b/examples/to_firedrake.py index cb15bccbf..8027a8fd7 100644 --- a/examples/to_firedrake.py +++ b/examples/to_firedrake.py @@ -71,8 +71,8 @@ def main(): discr = Discretization(actx, mesh, group_factory) # Get our solution: we will use - # Real(e^z) = Real(e^{x+iy}) - # = e^x Real(e^{iy}) + # Real(e^z) = Real(e^{x+i y}) + # = e^x Real(e^{i y}) # = e^x cos(y) nodes = discr.nodes() for i in range(len(nodes)): diff --git a/meshmode/discretization/connection/chained.py b/meshmode/discretization/connection/chained.py index 51ef4f24c..9bc7e5817 100644 --- a/meshmode/discretization/connection/chained.py +++ b/meshmode/discretization/connection/chained.py @@ -105,13 +105,13 @@ def find_batch(nodes, gtb): return (-1, -1) nfrom_groups = len(from_conn.groups) - nto_groups = len(to_conn.groups) + n_to_groups = len(to_conn.groups) # construct a table from (old groups) -> (new groups) # NOTE: we try to reduce the number of new groups and batches by matching # the `result_unit_nodes` and only adding a new batch if necessary grp_to_grp = {} - batch_info = [[] for i in range(nfrom_groups * nto_groups)] + batch_info = [[] for i in range(nfrom_groups * n_to_groups)] for (igrp, ibatch), (_, fbatch) in _iterbatches(from_conn.groups): for (jgrp, jbatch), (_, tbatch) in _iterbatches(to_conn.groups): # compute result_unit_nodes @@ -132,7 +132,7 @@ def find_batch(nodes, gtb): # find new (group, batch) (igrp_new, ibatch_new) = find_batch(result_unit_nodes, batch_info) if igrp_new < 0: - igrp_new = nto_groups * igrp + jgrp + igrp_new = n_to_groups * igrp + jgrp ibatch_new = len(batch_info[igrp_new]) batch_info[igrp_new].append(_ConnectionBatchData( diff --git a/meshmode/discretization/connection/opposite_face.py b/meshmode/discretization/connection/opposite_face.py index 048397a60..7db8b9e04 100644 --- a/meshmode/discretization/connection/opposite_face.py +++ b/meshmode/discretization/connection/opposite_face.py @@ -251,15 +251,15 @@ def get_map_jacobian(unit_nodes): if dim == 1: # A is df.T - ata = np.einsum("iket,jket->ijet", df, df) - atb = np.einsum("iket,ket->iet", df, resid) + ata = np.einsum("ikes,jkes->ijes", df, df) + atb = np.einsum("ikes,kes->ies", df, resid) df_inv_resid = atb / ata[0, 0] elif dim == 2: # A is df.T - ata = np.einsum("iket,jket->ijet", df, df) - atb = np.einsum("iket,ket->iet", df, resid) + ata = np.einsum("ikes,jkes->ijes", df, df) + atb = np.einsum("ikes,kes->ies", df, resid) det = ata[0, 0]*ata[1, 1] - ata[0, 1]*ata[1, 0] @@ -481,9 +481,9 @@ def make_opposite_face_connection(actx, volume_to_bdry_conn): # {{{ visualization (for debugging) if 0: - print("TVE", adj.elements[adj_tgt_flags]) - print("TBE", tgt_bdry_element_indices) - print("FVE", src_vol_element_indices) + print("target volume elements:", adj.elements[adj_tgt_flags]) + print("target boundary elements:", tgt_bdry_element_indices) + print("neighbor volume elements:", src_vol_element_indices) import matplotlib.pyplot as pt from meshmode.mesh.visualization import draw_2d_mesh diff --git a/meshmode/distributed.py b/meshmode/distributed.py index ad2a0049b..dea865217 100644 --- a/meshmode/distributed.py +++ b/meshmode/distributed.py @@ -68,7 +68,7 @@ class MPIMeshDistributor: """ - .. automethod:: is_mananger_rank + .. automethod:: is_manager_rank .. automethod:: send_mesh_parts .. automethod:: receive_mesh_part """ @@ -84,6 +84,13 @@ def __init__(self, mpi_comm, manager_rank=0): DeprecationWarning, stacklevel=2) def is_mananger_rank(self): + warn(f"'{type(self).__name__}.is_mananger_rank' is deprecated and will " + "be removed in 2025 (obvious typo). Use 'is_manager_rank' instead.", + DeprecationWarning, stacklevel=2) + + return self.is_manager_rank() + + def is_manager_rank(self): return self.mpi_comm.Get_rank() == self.manager_rank def send_mesh_parts(self, mesh, part_per_element, num_parts): @@ -101,7 +108,7 @@ def send_mesh_parts(self, mesh, part_per_element, num_parts): rank = mpi_comm.Get_rank() assert num_parts <= mpi_comm.Get_size() - assert self.is_mananger_rank() + assert self.is_manager_rank() part_num_to_elements = membership_list_to_map(part_per_element) @@ -130,7 +137,7 @@ def receive_mesh_part(self): mpi_comm = self.mpi_comm rank = mpi_comm.Get_rank() - assert not self.is_mananger_rank(), "Manager rank cannot receive mesh" + assert not self.is_manager_rank(), "Manager rank cannot receive mesh" from mpi4py import MPI status = MPI.Status() diff --git a/pyproject.toml b/pyproject.toml index 1dd0c09b3..c84467021 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -181,3 +181,15 @@ module = [ "scipy.*", ] ignore_missing_imports = true + + +[tool.typos.default] +extend-ignore-re = [ + "(?Rm)^.*(#|//)\\s*spellchecker:\\s*disable-line$" +] + +[tool.typos.default.extend-words] +"PN" = "PN" +"nd" = "nd" +# TODO: needed by deprecated MPIMeshDistributor.is_mananger_rank +"mananger" = "mananger"