diff --git a/GooseBib/journals.py b/GooseBib/journals.py index f04fcad..36cd132 100644 --- a/GooseBib/journals.py +++ b/GooseBib/journals.py @@ -273,7 +273,7 @@ def _renum(self): def _map(self, journals: list[str], case_sensitive: bool, field: ArrayLike) -> list[str]: """ - Map List of names. + Map list of names. :param journals: List to map. :param case_sensitive: Keep case during look-up. @@ -281,14 +281,16 @@ def _map(self, journals: list[str], case_sensitive: bool, field: ArrayLike) -> l :return: Input list with mapped items replaced where a positive match was found. """ - ret = [i for i in journals] + _, iforward, ibackward = np.unique(journals, return_index=True, return_inverse=True) if case_sensitive: variations = self.names - search = journals + search = [journals[i] for i in iforward] + ret = [i for i in journals] else: variations = [str(i).lower() for i in self.names] - search = [i.lower() for i in journals] + search = [journals[i].lower() for i in iforward] + ret = [journals[i] for i in iforward] _, v_index, s_index = np.intersect1d(variations, search, return_indices=True) @@ -299,11 +301,11 @@ def _map(self, journals: list[str], case_sensitive: bool, field: ArrayLike) -> l for i in np.argwhere(np.array(ret) == ret[s]).ravel(): ret[i] = r - return ret + return [ret[i] for i in ibackward] def map2name(self, journals: list[str], case_sensitive: bool = False) -> list[str]: """ - Map List of names. + Map list of names. :param journals: List to map. :param case_sensitive: Keep case during look-up. @@ -313,7 +315,7 @@ def map2name(self, journals: list[str], case_sensitive: bool = False) -> list[st def map2abbreviation(self, journals: list[str], case_sensitive: bool = False) -> list[str]: """ - Map List of names. + Map list of names. :param journals: List to map. :param case_sensitive: Keep case during look-up. @@ -323,7 +325,7 @@ def map2abbreviation(self, journals: list[str], case_sensitive: bool = False) -> def map2acronym(self, journals: list[str], case_sensitive: bool = False) -> list[str]: """ - Map List of names. + Map list of names. :param journals: List to map. :param case_sensitive: Keep case during look-up.