mathtools.partition_integer_into_halves — Abjad v1.1.1 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Project Abjad »
- Abjad v1.1.1 documentation »
- Abjad API »

# mathtools.partition_integer_into_halves

`abjad.tools.mathtools.` `partition_integer_into_halves`(n, bigger='left', even='allowed')

  Write positive integer n as the pair `t = (left, right)` such that `n == left + right`.

  When n is odd the greater part of `t` corresponds to the value of bigger:

      abjad> mathtools.partition_integer_into_halves(7, bigger = 'left')
      (4, 3)
      abjad> mathtools.partition_integer_into_halves(7, bigger = 'right')
      (3, 4)

  Likewise when n is even and `even = 'disallowed'`:

      abjad> mathtools.partition_integer_into_halves(8, bigger = 'left', even = 'disallowed')
      (5, 3)
      abjad> mathtools.partition_integer_into_halves(8, bigger = 'right', even = 'disallowed')
      (3, 5)

  But when n is even and `even = 'allowed'` then `left == right` and bigger is ignored:

      abjad> mathtools.partition_integer_into_halves(8)
      (4, 4)
      abjad> mathtools.partition_integer_into_halves(8, bigger = 'left')
      (4, 4)
      abjad> mathtools.partition_integer_into_halves(8, bigger = 'right')
      (4, 4)

  When n is `0` return `(0, 0)`:

      abjad> mathtools.partition_integer_into_halves(0)
      (0, 0)

  When n is `0` and `even = 'disallowed'` raise `PartitionError`:

      abjad> mathtools.partition_integer_into_halves(0, even = 'disallowed')
      PartitionError

  Raise `TypeError` on noninteger n:

      abjad> mathtools.partition_integer_into_halves('foo')
      TypeError

  Raise `ValueError` on negative n:

      abjad> mathtools.partition_integer_into_halves(-1)
      ValueError

### Navigation

- index
- modules |
- next |
- previous |
- Project Abjad »
- Abjad v1.1.1 documentation »
- Abjad API »