def test_slice_end(self):
        with self.session(use_gpu=False) as sess:

            root = create_expression.create_expression_from_prensor(
                prensor_test_util.create_big_prensor())
            root_2 = slice_expression.slice_expression(root,
                                                       path.Path(["doc"]),
                                                       "new_doc", None, 1)
            result = prensor_value.materialize(
                calculate.calculate_prensors([root_2])[0], sess)

            self.assertAllEqual(
                result.get_descendant_or_error(path.Path(
                    ["new_doc"])).node.parent_index, [0, 1])
            self.assertAllEqual(
                result.get_descendant_or_error(
                    path.Path(["new_doc", "keep_me"])).node.parent_index,
                [0, 1])
            self.assertAllEqual(
                result.get_descendant_or_error(
                    path.Path(["new_doc", "keep_me"])).node.values,
                [False, True])
            self.assertAllEqual(
                result.get_descendant_or_error(path.Path(
                    ["new_doc", "bar"])).node.parent_index, [0, 1, 1])
            self.assertAllEqual(
                result.get_descendant_or_error(path.Path(["new_doc",
                                                          "bar"])).node.values,
                [b"a", b"b", b"c"])
    def test_slice_begin(self):
        """Test slice with only begin specified.

    Starts with:
    {
      foo:9,
      foorepeated:[9],
      doc:[{
         bar:["a"],
         keep_me:False
        }],
      user:[
        {
          friends:["a"]
        }]
    }
    {foo:8,
     foorepeated:[8,7],
     doc:[{
       bar:["b","c"],
       keep_me:True
     },{
       bar:["d"]
     }],
     user:[{
       friends:["b", "c"]
     },{
       friends:["d"]
     }],
     }
     {foo:7,
      foorepeated:[6],
      user:[{friends:["e"]}]}

    Creates new_doc by slicing doc[1:]:
    {foo:9,
     foorepeated:[9],
     doc:[{
       bar:["a"],
       keep_me:False
     }],
     user:[{
       friends:["a"]
     }]}
    {foo:8,
     foorepeated:[8,7],
     doc:[{
       bar:["b","c"],
       keep_me:True
     },{
       bar:["d"]
     }],
     new_doc[{
       bar:["d"]
     }],
     user:[{
       friends:["b", "c"]
     },{
       friends:["d"]}],}
    {foo:7,
     foorepeated:[6],
     user:[{
       friends:["e"]
     }]}
    """
        with self.session(use_gpu=False) as sess:
            root = create_expression.create_expression_from_prensor(
                prensor_test_util.create_big_prensor())
            root_2 = slice_expression.slice_expression(root,
                                                       path.Path(["doc"]),
                                                       "new_doc", 1, None)
            result = prensor_value.materialize(
                calculate.calculate_prensors([root_2])[0], sess)
            self.assertAllEqual(
                result.get_descendant_or_error(path.Path(
                    ["new_doc"])).node.parent_index, [1])
            self.assertAllEqual(
                result.get_descendant_or_error(
                    path.Path(["new_doc", "keep_me"])).node.parent_index, [])
            self.assertAllEqual(
                result.get_descendant_or_error(
                    path.Path(["new_doc", "keep_me"])).node.values, [])
            self.assertAllEqual(
                result.get_descendant_or_error(path.Path(
                    ["new_doc", "bar"])).node.parent_index, [0])
            self.assertAllEqual(
                result.get_descendant_or_error(path.Path(["new_doc",
                                                          "bar"])).node.values,
                [b"d"])