mutwo.abjad_utilities

Object

Documentation

mutwo.abjad_utilities.AbjadTestCase

mutwo.abjad_utilities.run_if_ekmelily_available

Decorator which only runs test if ekmelily is found

mutwo.abjad_utilities.NoTimeSignatureError

mutwo.abjad_utilities.concatenate_adjacent_tuplets

Rewrite tuplets in voice, so that adjacent tuplets are concatenated if possible.

mutwo.abjad_utilities.reduce_multiplier

Reduces multipliers of tuplets in voice.

mutwo.abjad_utilities.group_consecutive_numbers

Group consecutive numbers into the lists

run_if_ekmelily_available(method_to_wrap)[source]

Decorator which only runs test if ekmelily is found

Parameters:

method_to_wrap (Callable) –

concatenate_adjacent_tuplets(voice)[source]

Rewrite tuplets in voice, so that adjacent tuplets are concatenated if possible.

Parameters:

voice (abjad.Voice) – The voice which should be rewritten. This abjad.Voice should contain bars (e.g. abjad.Container) with leaves or tuplets.

reduce_multiplier(voice)[source]

Reduces multipliers of tuplets in voice.

Essentially the same as rmakers.reduce_multiplier(), see:

https://github.com/Abjad/abjad-ext-rmakers/blob/ebb47f6/abjadext/rmakers/functions.py#L3781

Parameters:

voice (Voice) –

group_consecutive_numbers(number_tuple)[source]

Group consecutive numbers into the lists

Example:

>>> from mutwo import abjad_utilities
>>> abjad_utilities.group_consecutive_numbers([1,2,4,5, 10, 15, 16])
[[1, 2], [4, 5], [10], [15, 16]]
Parameters:

number_tuple (tuple[int, ...]) –

Return type:

list[list[int]]

class AbjadTestCase(methodName='runTest')[source]

Bases: TestCase

Public Data Attributes:

base_path

Inherited from TestCase

longMessage

maxDiff

Public Methods:

t([reset_tests, force_png])

setUp()

Hook method for setting up the test fixture before exercising it.

Inherited from TestCase

addTypeEqualityFunc(typeobj, function)

Add a type specific assertEqual style function to compare a type.

addCleanup(function, /, *args, **kwargs)

Add a function, with arguments, to be called when the test is completed.

addClassCleanup(function, /, *args, **kwargs)

Same as addCleanup, except the cleanup items are called even if setUpClass fails (unlike tearDownClass).

setUp()

Hook method for setting up the test fixture before exercising it.

tearDown()

Hook method for deconstructing the test fixture after testing it.

setUpClass()

Hook method for setting up class fixture before running tests in the class.

tearDownClass()

Hook method for deconstructing the class fixture after running all tests in the class.

countTestCases()

defaultTestResult()

shortDescription()

Returns a one-line description of the test, or None if no description has been provided.

id()

subTest([msg])

Return a context manager that will return the enclosed block of code in a subtest identified by the optional message and keyword parameters.

run([result])

doCleanups()

Execute all cleanup functions.

doClassCleanups()

Execute all class cleanup functions.

debug()

Run the test without collecting errors in a TestResult

skipTest(reason)

Skip this test.

fail([msg])

Fail immediately, with the given message.

assertFalse(expr[, msg])

Check that the expression is false.

assertTrue(expr[, msg])

Check that the expression is true.

assertRaises(expected_exception, *args, **kwargs)

Fail unless an exception of class expected_exception is raised by the callable when invoked with specified positional and keyword arguments.

assertWarns(expected_warning, *args, **kwargs)

Fail unless a warning of class warnClass is triggered by the callable when invoked with specified positional and keyword arguments.

assertLogs([logger, level])

Fail unless a log message of level level or higher is emitted on logger_name or its children.

assertNoLogs([logger, level])

Fail unless no log messages of level level or higher are emitted on logger_name or its children.

assertEqual(first, second[, msg])

Fail if the two objects are unequal as determined by the '==' operator.

assertNotEqual(first, second[, msg])

Fail if the two objects are equal as determined by the '!=' operator.

assertAlmostEqual(first, second[, places, ...])

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is more than the given delta.

assertNotAlmostEqual(first, second[, ...])

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is less than the given delta.

assertSequenceEqual(seq1, seq2[, msg, seq_type])

An equality assertion for ordered sequences (like lists and tuples).

assertListEqual(list1, list2[, msg])

A list-specific equality assertion.

assertTupleEqual(tuple1, tuple2[, msg])

A tuple-specific equality assertion.

assertSetEqual(set1, set2[, msg])

A set-specific equality assertion.

assertIn(member, container[, msg])

Just like self.assertTrue(a in b), but with a nicer default message.

assertNotIn(member, container[, msg])

Just like self.assertTrue(a not in b), but with a nicer default message.

assertIs(expr1, expr2[, msg])

Just like self.assertTrue(a is b), but with a nicer default message.

assertIsNot(expr1, expr2[, msg])

Just like self.assertTrue(a is not b), but with a nicer default message.

assertDictEqual(d1, d2[, msg])

assertDictContainsSubset(subset, dictionary)

Checks whether dictionary is a superset of subset.

assertCountEqual(first, second[, msg])

Asserts that two iterables have the same elements, the same number of times, without regard to order.

assertMultiLineEqual(first, second[, msg])

Assert that two multi-line strings are equal.

assertLess(a, b[, msg])

Just like self.assertTrue(a < b), but with a nicer default message.

assertLessEqual(a, b[, msg])

Just like self.assertTrue(a <= b), but with a nicer default message.

assertGreater(a, b[, msg])

Just like self.assertTrue(a > b), but with a nicer default message.

assertGreaterEqual(a, b[, msg])

Just like self.assertTrue(a >= b), but with a nicer default message.

assertIsNone(obj[, msg])

Same as self.assertTrue(obj is None), with a nicer default message.

assertIsNotNone(obj[, msg])

Included for symmetry with assertIsNone.

assertIsInstance(obj, cls[, msg])

Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.

assertNotIsInstance(obj, cls[, msg])

Included for symmetry with assertIsInstance.

assertRaisesRegex(expected_exception, ...)

Asserts that the message in a raised exception matches a regex.

assertWarnsRegex(expected_warning, ...)

Asserts that the message in a triggered warning matches a regexp.

assertRegex(text, expected_regex[, msg])

Fail the test unless the text matches the regular expression.

assertNotRegex(text, unexpected_regex[, msg])

Fail the test if the text matches the regular expression.

failUnlessEqual(**kwargs)

assertEquals(**kwargs)

failIfEqual(**kwargs)

assertNotEquals(**kwargs)

failUnlessAlmostEqual(**kwargs)

assertAlmostEquals(**kwargs)

failIfAlmostEqual(**kwargs)

assertNotAlmostEquals(**kwargs)

failUnless(**kwargs)

assert_(**kwargs)

failUnlessRaises(**kwargs)

failIf(**kwargs)

assertRaisesRegexp(**kwargs)

assertRegexpMatches(**kwargs)

assertNotRegexpMatches(**kwargs)


setUp()[source]

Hook method for setting up the test fixture before exercising it.

static t(reset_tests=False, force_png=False)[source]
Parameters:
  • reset_tests (bool) –

  • force_png (bool) –

base_path = 'tests/testdata'
class NoTimeSignatureError[source]

Bases: Exception

Public Data Attributes:

Inherited from BaseException

args

Public Methods:

Inherited from BaseException

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.