On Tuesday, April 21, 2020 at 5:26:00 PM UTC-7, Dima Pasechnik wrote: > > On Wed, Apr 22, 2020 at 2:56 AM k2wagle <archi...@gmail.com <javascript:>> > wrote: > > > > Tried this just now, getting the same error. Open a ticket please. > > This error is already in Sage 9.0 - and this is an example from the > manual! > > It's quite alarming that our doctests let it through, as it never > showed in doctests, and > indeed if I do > > ./sage -tp --verbose src/sage/graphs/hypergraph_generators.py > > I see in particular > ----------------------------------- > Trying (line 218): H = hypergraphs.UniformRandomUniform(52, 3, 17) > Expecting nothing > ok [0.01 s] > Trying (line 219): H > Expecting: > Incidence structure with 52 points and 17 blocks > ok [0.00 s] > ------------------------------------- > > as if it works. >
Maybe it is working: maybe there is something in the doctesting framework that makes it work somehow. If I put obviously failing doctests in that file immediately before and after these lines, those failures are caught. It's very strange. To fix this particular problem, do something like: diff --git a/src/sage/graphs/hypergraph_generators.py b/src/sage/graphs/hypergraph_generators.py index aa3d5e3988..679ddea5ce 100644 --- a/src/sage/graphs/hypergraph_generators.py +++ b/src/sage/graphs/hypergraph_generators.py @@ -262,7 +262,7 @@ class HypergraphGenerators(): raise ValueError("the uniformity should be an integer") all_edges = Subsets(vertices, uniformity) try: - edges = sample(all_edges, m) + edges = sample(set(all_edges), m) except OverflowError: raise OverflowError("binomial({}, {}) too large to be treated".format(n, k)) except ValueError: > > > > > > > On Tuesday, 21 April 2020 23:56:45 UTC+5:30, Vipul Gupta wrote: > >> > >> On running the example given here in the documentation of > `UniformRandomUniform` method. > >> It is raising the following error. > >> > >> sage: H = hypergraphs.UniformRandomUniform(52, 3, 17) > >> > --------------------------------------------------------------------------- > >> TypeError Traceback (most recent call > last) > >> <ipython-input-1-56df6490a66e> in <module>() > >> ----> 1 H = hypergraphs.UniformRandomUniform(Integer(52), Integer(3), > Integer(17)) > >> > >> > /home/vipul/sage/local/lib/python3.7/site-packages/sage/graphs/hypergraph_generators.py > > in UniformRandomUniform(self, n, k, m) > >> 263 all_edges = Subsets(vertices, uniformity) > >> 264 try: > >> --> 265 edges = sample(all_edges, m) > >> 266 except OverflowError: > >> 267 raise OverflowError("binomial({}, {}) too large to > be treated".format(n, k)) > >> > >> /home/vipul/sage/local/lib/python3.7/site-packages/sage/misc/prandom.py > in sample(population, k) > >> 178 [357009070, 558990255, 196187132, 752551188, 85926697, > 954621491, 624802848] > >> 179 """ > >> --> 180 return _pyrand().sample(population, k) > >> 181 > >> 182 def random(): > >> > >> /home/vipul/sage/local/lib/python3.7/random.py in sample(self, > population, k) > >> 315 population = tuple(population) > >> 316 if not isinstance(population, _Sequence): > >> --> 317 raise TypeError("Population must be a sequence or > set. For dicts, use list(d).") > >> 318 randbelow = self._randbelow > >> 319 n = len(population) > >> > >> TypeError: Population must be a sequence or set. For dicts, use > list(d). > >> > >> > >> > >> Can somebody please point out if I am doing something wrong. > >> Or Should I open a ticket on trac server regarding this, so that this > defect can be solved. > >> > >> Regards > >> Vipul Gupta > >> > >> > >> > > -- > > You received this message because you are subscribed to the Google > Groups "sage-devel" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to sage-...@googlegroups.com <javascript:>. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/sage-devel/91e34011-914d-44e3-abab-da02254238b5%40googlegroups.com. > > > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/1293aa2e-0adb-4d1f-b32a-8a36cf633385%40googlegroups.com.