Skip to content

nC doc example in sympy live shows TypeError: 'Integer' object is not iterable #52

Closed
@snowch

Description

@snowch

The first code block for nC shows an error:

Python console for SymPy 1.5.1 (Python 2.7.12)

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)

>>> from sympy.functions.combinatorial.numbers import nC
>>> from sympy.utilities.iterables import multiset_combinations
>>> nC(3, 2)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/base/data/home/apps/s~sympy-live-hrd/66.426491309333028408/sympy/sympy/functions/combinatorial/numbers.py", line 1715, in nC
    return nC(_multiset_histogram(n), k, replacement)
  File "/base/data/home/apps/s~sympy-live-hrd/66.426491309333028408/sympy/sympy/functions/combinatorial/numbers.py", line 1435, in _multiset_histogram
    n = list(n)
TypeError: 'Integer' object is not iterable
>>> nC('abc', 2)
3

>>> nC('aab', 2)
2

Also the last code block errors too:

>>> sum(nC(4, i) for i in range(5))
Exception in SymPy Live of type 
<type 'exceptions.TypeError'>
for reference the last 5 stack trace entries are
Traceback (most recent call last):
  File "/base/data/home/apps/s~sympy-live-hrd/66.426491309333028408/app/handlers.py", line 271, in post
    live.evaluate(statement, session, printer, stream)
  File "/base/data/home/apps/s~sympy-live-hrd/66.426491309333028408/app/shell.py", line 280, in evaluate
    exec code in statement_module.__dict__
  File "<string>", line 1, in <module>
TypeError: 'NoneType' object is not iterable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions