mathtools.fragment — Abjad v1.1.1 documentation

### Navigation

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

# mathtools.fragment

`abjad.tools.mathtools.` `fragment`(n, cell)

  Fragment scalar n into cell fragments such that `sum(cell) <= n`.

      abjad> mathtools.fragment(1, [Rational(1, 2), Rational(1, 4)])
      [Rational(1, 2), Rational(1, 4), Rational(1, 4)]

      abjad> mathtools.fragment(Rational(1,2), [Rational(1, 6), Rational(1, 10)])
      [Rational(1, 6), Rational(1, 10), Rational(7, 30)]

  Raise `TypeError` on nonnumeric n:

      abjad> mathtools.fragment('foo', [Rational(1, 2), Rational(1, 4)])
      TypeError

  Raise `ValueError` when `sum(cell)` is not less than or equal to n:

      abjad> mathtools.fragment(1, [Rational(3, 4), Rational(3, 4)])
      ValueError

  Todo

  Generalize and rename this function.

### Navigation

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