code: def test_sense2vec_object():
      s2v = Sense2Vec(shape=(10, 4))
      assert s2v.vectors.shape == (10, 4)
      assert len(s2v) == 10
      test_vector = numpy.asarray([4, 2, 2, 2], dtype=numpy.float32)
      s2v.add("test", test_vector)
      assert "test" in s2v
      assert isinstance(s2v.strings["test"], int)
      assert s2v.strings["test"] in s2v
      assert "foo" not in s2v
      assert numpy.array_equal(s2v["test"], test_vector)
      assert numpy.array_equal(s2v[s2v.strings["test"]], test_vector)
      assert list(s2v.keys()) == ["test"]
      s2v.add("test2", test_vector)
      assert "test2" in s2v
      assert sorted(list(s2v.keys())) == ["test", "test2"]
      with pytest.raises(ValueError):
          s2v["test3"] = test_vector
      s2v["test2"] = test_vector
  
file_path: sense2vec/sense2vec/tests/test_sense2vec.py
imports: import pytest
  import numpy
  from sense2vec import Sense2Vec, registry
label_desc: Use image node_id 1 for calling a global function with example usage: test_sense2vec_object() without return types