Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __len__ and cardinality to cartesian_product_iterator and CartesianProduct #14285

Closed
roed314 opened this issue Mar 16, 2013 · 12 comments
Closed

Comments

@roed314
Copy link
Contributor

roed314 commented Mar 16, 2013

If cartesian_product_iterator has a __len__ method we can use it in random.sample.

We also fix a bug that yields an infinite loop:

sage: for a in cartesian_product_iterator([ZZ,[]]):
....:     print "hello world"
<INFINITE LOOP>

Apply:

  1. attachment: 14285.patch
  2. attachment: trac_14285_review.patch

CC: @hivert

Component: combinatorics

Author: David Roe

Reviewer: Julian Rueth

Merged: sage-5.9.beta1

Issue created by migration from https://trac.sagemath.org/ticket/14285

@roed314
Copy link
Contributor Author

roed314 commented Mar 16, 2013

Author: David Roe

@roed314 roed314 changed the title Add __len__ and cardinality to cartesian_product_iterator Add __len__ and cardinality to cartesian_product_iterator and CartesianProduct Mar 16, 2013
@saraedum
Copy link
Member

comment:4

Minor issue: The description of the patch has no trac ticket number.

@saraedum
Copy link
Member

comment:5

I'm happy with it if the patchbot is.

@saraedum
Copy link
Member

Reviewer: Julian Rueth

@saraedum

This comment has been minimized.

@roed314
Copy link
Contributor Author

roed314 commented Mar 17, 2013

comment:7

I'm also happy with it once the patchbot approves.

@roed314
Copy link
Contributor Author

roed314 commented Mar 17, 2013

comment:8

Updated to fix doctest failures...

@jdemeyer
Copy link
Contributor

comment:10

On 32-bit systems:

sage -t --long devel/sage/sage/misc/mrange.py
**********************************************************************
File "devel/sage/sage/misc/mrange.py", line 62, in sage.misc.mrange._is_finite
Failed example:
    _is_finite(xrange(10^10))
Exception raised:
    Traceback (most recent call last):
      File "/var/lib/buildbot/build/sage/arando-1/arando_full/build/sage-5.9.beta1/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 459, in _run
        self.execute(example, compiled, test.globs)
      File "/var/lib/buildbot/build/sage/arando-1/arando_full/build/sage-5.9.beta1/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 815, in execute
        exec compiled in globs
      File "<doctest sage.misc.mrange._is_finite[4]>", line 1, in <module>
        _is_finite(xrange(Integer(10)**Integer(10)))
    OverflowError: Python int too large to convert to C long
**********************************************************************

@roed314
Copy link
Contributor Author

roed314 commented Mar 19, 2013

Attachment: 14285.patch.gz

@roed314
Copy link
Contributor Author

roed314 commented Mar 19, 2013

Attachment: trac_14285_review.patch.gz

review patch

@roed314
Copy link
Contributor Author

roed314 commented Mar 19, 2013

comment:11

Fixed.

@jdemeyer
Copy link
Contributor

Merged: sage-5.9.beta1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants