Commit a051ea1d authored by Martin Larralde's avatar Martin Larralde
Browse files

Fix tests failing from the latest change in `repr` implementations

parent bf0494eb
......@@ -1088,36 +1088,36 @@ cdef class VectorF(Vector):
3.0
>>> v[0] = v[-1] = 4.0
>>> v
VectorF([4.0, 2.0, 4.0])
pyhmmer.easel.VectorF([4.0, 2.0, 4.0])
Slices are also supported, and they do not copy data (use the
`~pyhmmer.easel.VectorF.copy` method to allocate a new vector)::
>>> v = VectorF(range(10))
>>> v = VectorF(range(6))
>>> v[2:5]
VectorF([2.0, 3.0, 4.0])
>>> v[5:-1] = 10.0
pyhmmer.easel.VectorF([2.0, 3.0, 4.0])
>>> v[2:-1] = 10.0
>>> v
VectorF([0.0, 1.0, 2.0, 3.0, 4.0, 10.0, 10.0, 10.0, 10.0, 9.0])
pyhmmer.easel.VectorF([0.0, 1.0, 10.0, 10.0, 10.0, 5.0])
Addition and multiplication is supported for scalars, in place or not::
>>> v = VectorF([1.0, 2.0, 3.0])
>>> v += 1
>>> v
VectorF([2.0, 3.0, 4.0])
pyhmmer.easel.VectorF([2.0, 3.0, 4.0])
>>> v * 3
VectorF([6.0, 9.0, 12.0])
pyhmmer.easel.VectorF([6.0, 9.0, 12.0])
Pairwise operations can also be performed, but only on vectors of
the same dimension and precision::
>>> v = VectorF([1.0, 2.0, 3.0])
>>> v * v
VectorF([1.0, 4.0, 9.0])
pyhmmer.easel.VectorF([1.0, 4.0, 9.0])
>>> v += VectorF([3.0, 4.0, 5.0])
>>> v
VectorF([4.0, 6.0, 8.0])
pyhmmer.easel.VectorF([4.0, 6.0, 8.0])
>>> v *= VectorF([1.0])
Traceback (most recent call last):
...
......@@ -2221,14 +2221,14 @@ cdef class MatrixF(Matrix):
>>> m = MatrixF.zeros(2, 2)
>>> m[0, 0] = 3.0
>>> m
MatrixF([[3.0, 0.0], [0.0, 0.0]])
pyhmmer.easel.MatrixF([[3.0, 0.0], [0.0, 0.0]])
Indexing can also be performed at the row-level to get a `VectorF`
without copying the underlying data::
>>> m = MatrixF([ [1.0, 2.0], [3.0, 4.0] ])
>>> m[0]
VectorF([1.0, 2.0])
pyhmmer.easel.VectorF([1.0, 2.0])
Objects of this type support the buffer protocol, and can be viewed
as a `numpy.ndarray` with two dimensions using the `numpy.asarray`
......
......@@ -2312,7 +2312,7 @@ cdef class HMM:
>>> hmm = HMM(100, alphabet=easel.Alphabet.dna())
>>> hmm.match_emissions[0]
VectorF([1.0, 0.0, 0.0, 0.0])
pyhmmer.easel.VectorF([1.0, 0.0, 0.0, 0.0])
Caution:
If editing this matrix manually, note that rows must contain
......
......@@ -40,9 +40,9 @@ class TestAlphabet(unittest.TestCase):
self.assertNotEqual(easel.Alphabet.amino(), object())
def test_repr(self):
self.assertEqual(repr(easel.Alphabet.amino()), "Alphabet.amino()")
self.assertEqual(repr(easel.Alphabet.rna()), "Alphabet.rna()")
self.assertEqual(repr(easel.Alphabet.dna()), "Alphabet.dna()")
self.assertEqual(repr(easel.Alphabet.amino()), "pyhmmer.easel.Alphabet.amino()")
self.assertEqual(repr(easel.Alphabet.rna()), "pyhmmer.easel.Alphabet.rna()")
self.assertEqual(repr(easel.Alphabet.dna()), "pyhmmer.easel.Alphabet.dna()")
def test_K(self):
self.assertEqual(easel.Alphabet.dna().K, 4)
......
......@@ -88,7 +88,7 @@ class TestSequenceFile(unittest.TestCase):
with easel.SequenceFile(luxc, "fasta") as seq_file:
self.assertRaises(ValueError, seq_file.read)
# succeeds if ignoring gaps
with easel.SequenceFile(luxc, "fasta", ignore_gaps=True) as seq_file:
with easel.SequenceFile(luxc, "afa") as seq_file:
sequences = list(seq_file)
self.assertEqual(len(sequences), 13)
......
......@@ -27,8 +27,8 @@ class TestErrors(unittest.TestCase):
def test_alphabet_mismatch(self):
err = AlphabetMismatch(Alphabet.dna(), Alphabet.rna())
self.assertEqual(repr(err), "AlphabetMismatch(Alphabet.dna(), Alphabet.rna())")
self.assertEqual(str(err), "Expected Alphabet.dna(), found Alphabet.rna()")
self.assertEqual(repr(err), "AlphabetMismatch(pyhmmer.easel.Alphabet.dna(), pyhmmer.easel.Alphabet.rna())")
self.assertEqual(str(err), "Expected pyhmmer.easel.Alphabet.dna(), found pyhmmer.easel.Alphabet.rna()")
self.assertNotEqual(err, 1)
err2 = AlphabetMismatch(Alphabet.dna(), Alphabet.rna())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment