code: def test_highlight_spaces(
      boston_train, hl_spaces, add_invisible_spaces
  ):
      reg = LinearRegression()
      X, y, feature_names = boston_train
      # last is left unmodified to check that we are doing "any", not "all"
      modified_feature_names = [
          ("{} " if add_invisible_spaces else "A {}").format(name)
          for name in feature_names[:-1]
      ] + [feature_names[-1]]
      reg.fit(X, y)
      res = explain_weights_sklearn(
          reg,
          feature_names=modified_feature_names,
          top=len(feature_names) + 1,
      )
      expls = format_as_all(res, reg, highlight_spaces=hl_spaces)
      for is_html, expl in enumerate(expls):
          print(expl)
          if hl_spaces == False or (
              hl_spaces is None and not add_invisible_spaces
          ):
              for f in modified_feature_names:
                  assert f in expl
          else:
              if not add_invisible_spaces:
                  assert hl_spaces
              for f in modified_feature_names[:-1]:
                  assert f not in expl
              for f in feature_names[:-1]:
                  if is_html:
                      if add_invisible_spaces:
                          assert re.search(
                              f + '<span.*title="A space symbol"', expl
                          )
                      else:
                          assert re.search(
                              'A<span.*title="A space symbol".*>' + f,
                              expl,
                          )
                  else:
                      if add_invisible_spaces:
                          assert (f + _SPACE) in expl
                      else:
                          assert ("A" + _SPACE + f) in expl
  
file_path: eli5/tests/test_formatters.py
imports: from __future__ import absolute_import
  import re
  import pytest
  import numpy
  from sklearn.feature_extraction.text import TfidfVectorizer
  from sklearn.linear_model import LogisticRegression, LinearRegression
  from eli5.sklearn import explain_weights_sklearn, explain_prediction_sklearn
  from eli5.formatters import fields
  from eli5.formatters.text import _SPACE
  from .utils import format_as_all, get_all_features
label_desc: Use image node_id 3 for calling a global function with example usage: test_highlight_spaces(boston_train, hl_spaces, add_invisible_spaces) without return types