From 08f6bdafbebd6b95bf378e9735b9bcfbc583aef8 Mon Sep 17 00:00:00 2001 From: Zmavli Caimle <87019067+Zmavli@users.noreply.github.com> Date: Sat, 13 Jul 2024 15:34:37 +0800 Subject: [PATCH 1/2] Add typecheck to text_neuron_activations requiring String not Int --- python/circuitsvis/activations.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/circuitsvis/activations.py b/python/circuitsvis/activations.py index 1f634c2..940bca4 100644 --- a/python/circuitsvis/activations.py +++ b/python/circuitsvis/activations.py @@ -46,6 +46,11 @@ def text_neuron_activations( f"activations must be of type np.ndarray, torch.Tensor, or list, not {type(activations)}" ) + if isinstance(tokens, (Int)): + raise TypeError( + f"tokens should be list of tokens as strings" + ) + return render( "TextNeuronActivations", tokens=tokens, From 6eecfa38e1a75ddb387750f01145d57a43ede890 Mon Sep 17 00:00:00 2001 From: Zmavli Caimle <87019067+Zmavli@users.noreply.github.com> Date: Sat, 13 Jul 2024 16:16:09 +0800 Subject: [PATCH 2/2] Correct typo "Int" to "int" --- python/circuitsvis/activations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/circuitsvis/activations.py b/python/circuitsvis/activations.py index 940bca4..321e9ba 100644 --- a/python/circuitsvis/activations.py +++ b/python/circuitsvis/activations.py @@ -46,7 +46,7 @@ def text_neuron_activations( f"activations must be of type np.ndarray, torch.Tensor, or list, not {type(activations)}" ) - if isinstance(tokens, (Int)): + if isinstance(tokens, int): raise TypeError( f"tokens should be list of tokens as strings" )