kinnala / scikit-fem

Simple finite element assemblers
https://scikit-fem.readthedocs.io
BSD 3-Clause "New" or "Revised" License
470 stars 76 forks source link

Docstring incorrect with_subdomains #1134

Closed kinnala closed 1 month ago

kinnala commented 1 month ago

Hi, everyone) I don't want to set up a separate topic, so I'll leave a couple of sentences about Mesh.with_subdomains.

The current signature is:

def with_subdomains(self, subdomains: Dict[str, Callable[[ndarray], ndarray]]):
"""Return a copy of the mesh with named subdomains.

        Parameters
        ----------
        boundaries
            A dictionary of lambda functions with the names of the subdomains
            as keys.  The midpoint of the element should return ``True`` for
            the corresponding lambda function if the element belongs to the
            subdomain.

        """
        return replace(
            self,
            _subdomains={
                **({} if self._subdomains is None else self._subdomains),
                **{name: (self.elements_satisfying(test)
                          if callable(test) else test)
                   for name, test in subdomains.items()},
            },
        )
  1. In the docstring, 'boundaries' should be replaced with 'subdomains'.
  2. This function is similar to with_boundaries, so: 2.1 Perhaps the following signature should be defined:
    def with_subdomains(self, subdomains: Dict[str, Union[Callable[[ndarray], ndarray],  ndarray]]):

    2.2 Make changes to the Parameters description: " Parameters

    subdomains
        A dictionary of index arrays or lambda functions with the names of the subdomains
        as keys.

    "

Originally posted by @valvikby in https://github.com/kinnala/scikit-fem/discussions/1093#discussioncomment-9781255