code: def test_to_dict(self):
      np.random.seed(0)
      random.seed(0)
      corpus = build_hamlet_jz_corpus()
      j = ScatterChartExplorer(
          corpus, minimum_term_frequency=0
      ).to_dict("hamlet")
      self.assertEqual(set(j.keys()), set(["info", "data", "docs"]))
      self.assertEqual(
          set(j["info"].keys()),
          set(
              [
                  "not_category_name",
                  "category_name",
                  "category_terms",
                  "not_category_internal_names",
                  "not_category_terms",
                  "category_internal_name",
                  "categories",
                  "neutral_category_name",
                  "extra_category_name",
                  "neutral_category_internal_names",
                  "extra_category_internal_names",
              ]
          ),
      )
  
      self.assertEqual(
          list(j["docs"]["labels"]), [0, 0, 0, 0, 1, 1, 1, 1]
      )
      self.assertEqual(
          list(j["docs"]["texts"]),
          [
              "what art thou that usurp'st this time of night,",
              "together with that fair and warlike form",
              "in which the majesty of buried denmark",
              "did sometimes march? by heaven i charge thee, speak!",
              "halt! who goes there?",
              "it is i sire tone from brooklyn.",
              "well, speak up man what is it?",
              "news from the east sire! the best of both worlds has returned!",
          ],
      )
      expected = {
          "y": 0.5,
          "ncat": 0,
          "ncat25k": 0,
          "bg": 5,
          "cat": 1,
          "s": 0.5,
          "term": "art",
          "os": 0.5192,
          "extra": 0,
          "extra25k": 0,
          "cat25k": 758,
          "x": 0.06,
          "neut": 0,
          "neut25k": 0,
          "ox": 5,
          "oy": 3,
      }
  
      actual = [t for t in j["data"] if t["term"] == "art"][0]
      """
  		for var in expected.keys():
  			try:
  				#np.testing.assert_almost_equal(actual[var], expected[var],decimal=1)
  			except TypeError:
  				self.assertEqual(actual[var], expected[var])
  		"""
      self.assertEqual(set(expected.keys()), set(actual.keys()))
      self.assertEqual(expected["term"], actual["term"])
      self.assertEqual(
          j["docs"].keys(), {"texts", "labels", "categories"}
      )
  
      j = (
          ScatterChartExplorer(corpus, minimum_term_frequency=0)
          .inject_term_metadata(
              {"art": {"display": "blah blah blah", "color": "red"}}
          )
          .to_dict("hamlet")
      )
  
      actual = [t for t in j["data"] if t["term"] == "art"][0]
      expected = {
          "y": 0.5,
          "ncat": 0,
          "ncat25k": 0,
          "bg": 5,
          "cat": 1,
          "s": 0.5,
          "term": "art",
          "os": 0.5192,
          "extra": 0,
          "extra25k": 0,
          "cat25k": 758,
          "x": 0.06,
          "neut": 0,
          "neut25k": 0,
          "ox": 5,
          "oy": 3,
          "etc": {"display": "blah blah blah", "color": "red"},
      }
      self.assertEqual(set(actual.keys()), set(expected.keys()))
      self.assertEqual(actual["etc"], expected["etc"])
  
      actual = [t for t in j["data"] if t["term"] != "art"][0]
      self.assertEqual(set(actual.keys()), set(expected.keys()))
      self.assertEqual(actual["etc"], {})
  
file_path: scattertext/scattertext/test/test_scatterChartExplorer.py
imports: import random
  from unittest import TestCase
  import numpy
  from scattertext.ScatterChartExplorer import ScatterChartExplorer
  from scattertext.test.test_semioticSquare import get_test_corpus
  from scattertext.test.test_termDocMatrixFactory import build_hamlet_jz_corpus, build_hamlet_jz_corpus_with_meta, build_hamlet_jz_corpus_with_alt_text
label_desc: Use image node_id 1 for calling the TestScatterChartExplorer obj's underlying member method code with example usage: obj.test_to_dict() without return types