class_docstr: Tests for basics.py
class_docstr_tok: ["Tests","for","basics.py"]
code: def test_set_and_load_topology(self):
      _, size = mpi_env_rank_and_size()
      if size == 4:
          expected_topology = nx.DiGraph(
              np.array(
                  [
                      [1 / 3.0, 1 / 3.0, 1 / 3.0, 0.0],
                      [0.0, 1 / 3.0, 1 / 3.0, 1 / 3.0],
                      [1 / 3.0, 0.0, 1 / 3.0, 1 / 3.0],
                      [1 / 3.0, 1 / 3.0, 0.0, 1 / 3.0],
                  ]
              )
          )
      elif size == 1:
          expected_topology = nx.DiGraph(np.array([[1.0]]))
      else:
          expected_topology = ExponentialGraph(size)
      bf.init()
      topology = bf.load_topology()
      assert isinstance(topology, nx.DiGraph)
      np.testing.assert_array_equal(
          nx.to_numpy_array(expected_topology),
          nx.to_numpy_array(topology),
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import unittest
  import warnings
  import numpy
  import networkx
  import pytest
  import tensorflow
  from common import mpi_env_rank_and_size
  import bluefog.tensorflow
  from bluefog.common.topology_util import ExponentialGraph, RingGraph
label_desc: Use image node_id 4 for calling the BasicsTests obj's underlying member method code with example usage: obj.test_set_and_load_topology() without return types