class_docstr: A base class for tests that operate on GraphsNP or GraphsTF.
class_docstr_tok: ["A","base","class","for","tests","that","operate","on","GraphsNP","or","GraphsTF","."]
docstr: Asserts that all the graph fields of graph0 and graph match.
docstr_tok: ["Asserts","that","all","the","graph","fields","of","graph0","and","graph","match","."]
code: def _assert_graph_equals_np(
      self, graph0, graph, force_edges_ordering=False
  ):
      """Asserts that all the graph fields of graph0 and graph match."""
      if graph0.nodes is None:
          self.assertEqual(None, graph.nodes)
      else:
          self.assertAllClose(graph0.nodes, graph.nodes)
      if graph0.globals is None:
          self.assertEqual(None, graph.globals)
      else:
          self.assertAllClose(graph0.globals, graph.globals)
      self.assertAllClose(graph0.n_node, graph.n_node.tolist())
      if graph0.receivers is None:
          self.assertEqual(None, graph.receivers)
          self.assertEqual(None, graph.senders)
          self.assertEqual(None, graph.edges)
          self.assertAllEqual(graph0.n_edge, graph.n_edge)
          return
      self.assertAllClose(graph0.n_edge, graph.n_edge.tolist())
  
      if not force_edges_ordering:
          self.assertAllClose(graph0.receivers, graph.receivers)
          self.assertAllClose(graph0.senders, graph.senders)
          if graph0.edges is not None:
              self.assertAllClose(graph0.edges, graph.edges)
          else:
              self.assertEqual(None, graph.edges)
          return
      # To compare edges content, we need to make sure they appear in the same
      # order
      if graph0.edges is not None:
          sorted_receivers0, sorted_senders0, sorted_content0 = zip(
              *sorted(
                  zip(
                      graph0.receivers,
                      graph0.senders,
                      graph0.edges.tolist(),
                  )
              )
          )
          sorted_receivers, sorted_senders, sorted_content = zip(
              *sorted(
                  zip(
                      graph.receivers,
                      graph.senders,
                      graph.edges.tolist(),
                  )
              )
          )
          self.assertAllClose(sorted_content0, sorted_content)
      elif graph.receivers is not None:
          sorted_receivers0, sorted_senders0 = zip(
              *sorted(zip(graph0.receivers, graph0.senders))
          )
          sorted_receivers, sorted_senders = zip(
              *sorted(zip(graph.receivers, graph.senders))
          )
      else:
          return
      self.assertAllClose(sorted_receivers0, sorted_receivers)
      self.assertAllClose(sorted_senders0, sorted_senders)
  
file_path: graph_nets/graph_nets/tests/test_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import contextlib
  import itertools
  from graph_nets import graphs
  from graph_nets import utils_np
  import numpy
  import tensorflow
label_desc: Use image node_id 2 for calling the GraphsTest obj's underlying member method code with example usage: obj._assert_graph_equals_np(graph0, graph, force_edges_ordering) without return types