Skip to content

Commit

Permalink
Fix dtype type in helper method for AnchorText samplers (#980)
Browse files Browse the repository at this point in the history
* Fix dtype type in helper method for AnchorText samplers

* Lint
  • Loading branch information
jklaise authored Oct 25, 2023
1 parent 71cc77a commit 66e0ed2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions alibi/explainers/anchors/language_model_text_sampler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import string
from functools import partial

from typing import (Dict, List, Optional, Tuple, Type)
from typing import (Dict, List, Optional, Tuple)

import numpy as np
import tensorflow as tf
Expand Down Expand Up @@ -332,7 +332,7 @@ def _append_tail(self, raw: np.ndarray) -> np.ndarray:
# convert to array and return
return np.array(full_raw, dtype=self.dtype_sent)

def _joiner(self, arr: np.ndarray, dtype: Optional[Type[np.generic]] = None) -> np.ndarray:
def _joiner(self, arr: np.ndarray, dtype: Optional[str] = None) -> np.ndarray:
"""
Function to concatenate an `numpy` array of strings along a specified axis.
Expand Down
4 changes: 2 additions & 2 deletions alibi/explainers/anchors/text_samplers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from abc import abstractmethod

from typing import (TYPE_CHECKING, Dict, List, Optional, Tuple, Type, Union)
from typing import (TYPE_CHECKING, Dict, List, Optional, Tuple, Union)

import numpy as np
import spacy
Expand Down Expand Up @@ -127,7 +127,7 @@ def set_text(self, text: str) -> None:
def __call__(self, anchor: tuple, num_samples: int) -> Tuple[np.ndarray, np.ndarray]:
pass

def _joiner(self, arr: np.ndarray, dtype: Optional[Type[np.generic]] = None) -> np.ndarray:
def _joiner(self, arr: np.ndarray, dtype: Optional[str] = None) -> np.ndarray:
"""
Function to concatenate a `numpy` array of strings along a specified axis.
Expand Down

0 comments on commit 66e0ed2

Please sign in to comment.