def test_last_index(self):
     assert ja.JaggedIntArray([[[1, 3], [4, 5], [7]],
                               [[1, 2, 3], [2, 2], [8, 8, 8]],
                               [[0], [1], [2, 3, 4],
                                [7, 7, 7, 7,
                                 7]]]).last_index(3) == [2, 3, 4]
     assert ja.JaggedIntArray([[[1, 3], [4, 5], [7]],
                               [[1, 2, 3], [2, 2], [8, 8, 8]],
                               [[0], [1], [2, 3, 4], [7, 7, 7, 7, 7], [],
                                []]]).last_index(3) == [2, 3, 4]
Example #2
0
 def test_mask(self):
     assert ja.JaggedTextArray(twoby).mask() == ja.JaggedIntArray(two_by_mask)
     assert ja.JaggedTextArray(
         [
             ["a",[],[],["",""],["b"]],
             ["a",[],["","a"],["",""],["b"]]
         ]
     ).mask() == ja.JaggedIntArray(
         [
             [1,[],[],[0,0],[1]],
             [1,[],[0,1],[0,0],[1]]
         ]
     )
Example #3
0
 def test_depth_0(self):
     j = ja.JaggedTextArray("Fee Fi Fo Fum")
     assert j.store == "Fee Fi Fo Fum"
     assert j.is_full()
     assert not j.is_empty()
     assert j.verse_count() == 1
     assert j.mask() == ja.JaggedIntArray(1)
    def test_mask(self):
        assert ja.JaggedTextArray(twoby).mask() == ja.JaggedIntArray(
            two_by_mask)
        assert ja.JaggedTextArray([["a", [], [], ["", ""], ["b"]],
                                   ["a", [], ["", "a"], ["", ""],
                                    ["b"]]]).mask() == ja.JaggedIntArray(
                                        [[1, [], [], [0, 0], [1]],
                                         [1, [], [0, 1], [0, 0], [1]]])

        assert ja.JaggedTextArray([["a", [], [], ["", ""], ["b"]],
                                   ["a", [], ["", "a"], ["", ""],
                                    ["b"]]]).zero_mask() == ja.JaggedIntArray(
                                        [[0, [], [], [0, 0], [0]],
                                         [0, [], [0, 0], [0, 0], [0]]])

        assert ja.JaggedTextArray(
            [["a", [], [], ["", ""], ["b"]],
             ["a", [], ["", "a"], ["", ""],
              ["b"]]]).constant_mask(None) == ja.JaggedIntArray(
                  [[None, [], [], [None, None], [None]],
                   [None, [], [None, None], [None, None], [None]]])
Example #5
0
    def _set_derived_attributes(self):
        from . import text

        if getattr(self, "title", None):
            try:
                indx = text.library.get_index(self.title)
                attrs = indx.contents()
                #del attrs["_id"]
                self.index_attr_keys = list(attrs.keys())
                self.__dict__.update(attrs)
            except BookNameError as e:
                logger.warning("Count object failed to get Index for {} : {} Normal right after Index name change.".format(self.title, e))

        #todo: this needs to be considered.  What happens when the data is modified? etc.
        if getattr(self, "allVersionCounts", None) is not None:
            self._allVersionCountsJA = ja.JaggedIntArray(self.allVersionCounts)
Example #6
0
 def test_sum(self):
     x = ja.JaggedIntArray([[1, 2], [3, 4]]) + ja.JaggedIntArray([[2, 3], [4]])
     assert x.array() == [[3, 5], [7, 4]]
Example #7
0
 def test_sum(self):
     assert ja.JaggedIntArray([[1, 2], [3, 4]]) + ja.JaggedIntArray(
         [[2, 3], [4]]) == ja.JaggedIntArray([[3, 5], [7, 4]])