Ask Your Question

PepijnWissing's profile - activity

2023-07-16 07:20:25 +0100 received badge  Famous Question (source)
2022-04-11 19:44:13 +0100 received badge  Notable Question (source)
2020-09-15 07:47:37 +0100 received badge  Popular Question (source)
2019-10-11 13:01:38 +0100 asked a question Adapt the nauty_directg function

Dear reader,

For a research interest, I would like to generate the collection of non-isomorphic digraphs on a given graph, with a given subset of the edges fixed. Naturally, simply generating the full collection using digraphs.nauty_directg() and removing the undesirable members of the obtained collection would be functional, but it's quite the waste of computing time to take this approach. Hence, I was wondering whether I'd be able to get under the hood of the nauty_directg function to create my own adapted version, which simply skips over the orientation of the edges listed in some input argument. Would anyone be able to help me get started with this endeavor?

Best, Pepijn

2019-05-06 16:51:13 +0100 received badge  Scholar (source)
2019-05-01 09:22:08 +0100 commented answer tqdm's "total" parameter bug

Thanks, that'll do it!

2019-04-30 13:04:09 +0100 commented question tqdm's "total" parameter bug

Thanks for your answer, but the "10" isn't the problem; graphs.nauty_geng takes a string argument and returns an Iterable. The issue is related to the other number, which somehow becomes a string in tqdm.

I have replaced my example in response to your suggestion, to make the question more clear.

2019-04-30 11:02:50 +0100 received badge  Editor (source)
2019-04-30 10:57:03 +0100 asked a question tqdm's "total" parameter bug

Due to something in the Sage 8.7 kernel (currently running in CoCalc), the tqdm progress bar crashes when I try to specify its total parameter. According to the documentation, my syntax should be correct. Specifically,

from tqdm import tqdm_notebook as tqdm
for i in tqdm(range(50),total=75):
    print(i)

yields

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-e4e61f3c450b> in <module>()
      1 from tqdm import tqdm_notebook as tqdm
----> 2 for i in tqdm(range(Integer(50)),total=Integer(75)):
      3     print(i)
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/tqdm/__init__.pyc in tqdm_notebook(*args, **kwargs)
     23     """See tqdm._tqdm_notebook.tqdm_notebook for full documentation"""
     24     from ._tqdm_notebook import tqdm_notebook as _tqdm_notebook
---> 25     return _tqdm_notebook(*args, **kwargs)
     26 
     27 
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/tqdm/_tqdm_notebook.pyc in __init__(self, *args, **kwargs)
    215         # Print initial bar state
    216         if not self.disable:
--> 217             self.sp(self.__repr__())  # same as self.refresh without clearing
    218 
    219     def __iter__(self, *args, **kwargs):
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/tqdm/_tqdm.pyc in __repr__(self)
    982 
    983     def __repr__(self):
--> 984         return self.format_meter(**self.format_dict)
    985 
    986     @property
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/tqdm/_tqdm.pyc in format_meter(n, total, elapsed, ncols, prefix, ascii, unit, unit_scale, rate, bar_format, postfix, unit_divisor, **extra_kwargs)
    395             percentage = frac * 100
    396 
--> 397             l_bar += '{0:3.0f}%|'.format(percentage)
    398 
    399             if ncols == 0:
ValueError: Unknown format code 'f' for object of type 'str'

Especially since a similar implementation of tqdm does work in a python 3 sheet, this feels like a minor bug to me. Or am I making some silly mistake?

-- edit: replaced example with a more straightforward one

2019-04-17 10:29:15 +0100 commented answer digraphs.nauty_directg() missing in SageMath 8.6?

Thanks for your answer.

I have tried running the proposed workaround in a SageMath 8.6 Notebook (on a Windows machine), but it still not compiling, with pretty much the same message as before:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-1fca0f327f4f> in <module>()
      1 gen = graphs.nauty_geng("-c 3")
----> 2 dgs = list(sage.graphs.digraph_generators.digraphs.nauty_directg(gen))

AttributeError: DiGraphGenerators instance has no attribute 'nauty_directg'

On another note, the example provided before does run properly in a CoCalc worksheet, which (as far as I can tell) is running Sage 8.7.

2019-04-17 08:43:35 +0100 received badge  Student (source)
2019-04-17 08:18:46 +0100 asked a question digraphs.nauty_directg() missing in SageMath 8.6?

Hello, I recently picked up SageMath to perform digraph computations regarding a research interest. I'm running into a strange issue regarding a function that should exist, judging by the documentation (link at the bottom of this post), but apparently does not. If I attempt to run a small test copied directly from said documentation:

gen = graphs.nauty_geng("-c 3")
dgs = list(digraphs.nauty_directg(gen))

the program fails to compile and yields

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-29-ae6a73f0fd49> in <module>()
      1 gen = graphs.nauty_geng("-c 3")
----> 2 dgs = list(digraphs.nauty_directg(gen))

/opt/sagemath-8.6/local/lib/python2.7/site-packages/sage/misc/lazy_import.pyx in sage.misc.lazy_import.LazyImport.__getattr__ (build/cythonized/sage/misc/lazy_import.c:3536)()
    320             True
    321         """
--> 322         return getattr(self.get_object(), attr)
    323 
    324     # We need to wrap all the slot methods, as they are not forwarded

AttributeError: DiGraphGenerators instance has no attribute 'nauty_directg'

Could anyone tell me whether I'm I making a horrible rookie mistake, or is this functionality is simply missing from SageMath 8.6? Or is there something else at play?

Thanks, Pepijn

Documentation at: http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/digraph_generators.html#sage.graphs.digraph_generators.DiGraphGenerators.nauty_directg