Re: [sage-devel] Fwd: [sage-trac] #26795: Some memory leaks

2018-12-03 Thread Jori Mäntysalo

On Mon, 3 Dec 2018, Dima Pasechnik wrote:

An expert in Cython/Python classes needed: __destruct__ is not called 
for a reason I don't understand.


[ Resolution: Should have been __dealloc__ ]

I grepped the source, and this was the only __destruct__(). Of course 
there might be other misnamed methods. By


egrep -R 'def __d[^ (]+' src/sage -o --no-filename | colrm 1 4 | sort | uniq -c 
| sort -rn

I found only __delete__, but that seems not to be like this one was. (Btw, 
why schemes/elliptic_curves/ell_tate_curve.py has __delta() etc, not 
_delta() and so?)


Here is again the test code I used:


 > {{{
 > import gc
 >
 > i = 0
 > GG = graphs()
 > _ = next(GG); _ = next(GG);
 > for P in GG:
 >     if i > 2: break
 >     if i % 1000 == 0:
 >         _ = gc.collect()
 >         print get_memory_usage(), P.order()
 >     i += 1
 >     _ = P.convexity_properties()
 > }}}


I did some other tests, and found no more leaks. It may make sense to run 
this in a more systematic way after leaks in MILP interface has been 
resolved. And it's not a bad idea to do similar tests in, say, matrix 
functions over finite field etc.


--
Jori Mäntysalo

Re: [sage-devel] Re: Memory leak in poset dimension()

2018-12-03 Thread Jori Mäntysalo

On Mon, 3 Dec 2018, Dima Pasechnik wrote:


please post the test you use.


import gc

i = 0
for P in Posets(8):
if i % 1000 == 0:
gc.collect()
print get_memory_usage()
i += 1
_ = P.dimension()

--
Jori Mäntysalo

Re: [sage-devel] Re: Memory leak in poset dimension()

2018-12-02 Thread Jori Mäntysalo

On Sun, 2 Dec 2018, Dima Pasechnik wrote:


do you still see it with https://trac.sagemath.org/ticket/26795 ?


Yes, it is still there.

--
Jori Mäntysalo

[sage-devel] Analyzing [pc]ython code for memory leaks

2018-12-02 Thread Jori Mäntysalo

What tools are available for static code analysis in Python/Cython?

For example for every bitset_init(SOMETHING, ...) there must be a 
bitset_free(SOMETHING). A tool could check the code assuming that every 
expression in if-clause is either true or false, and look if there is a 
path where the function ends without bitset_free. I suppose that someone 
has already done something like that.


--
Jori Mäntysalo


[sage-devel] Memory leak in poset dimension()

2018-12-01 Thread Jori Mäntysalo

This shows a leak:

i = 0
for P in Posets(8):
if i % 1000 == 0:
gc.collect()
print get_memory_usage()
i += 1
_ = P.dimension()

To compare, width() and height() does not seem to leak.

--
Jori Mäntysalo


Re: [sage-devel] Re: Other memory leaks

2018-12-01 Thread Jori Mäntysalo

On Sat, 1 Dec 2018, 'Martin R' via sage-devel wrote:


I confirm that the following leaks:


I created https://trac.sagemath.org/ticket/26795 for this and similar.

--
Jori Mäntysalo

[sage-devel] Other memory leaks

2018-12-01 Thread Jori Mäntysalo
For example PS_all_new_cells in 
src/sage/groups/perm_gps/partn_ref/data_structures.pyx contains 
bitset_init(scratch, n) but there is no bitset_free(scratch) anywhere. 
Does that mean that the function leaks memory?


Then, in src/sage/graphs/independent_sets.pyx the class IndependentSets 
seems to have a __dealloc__() thas does NOT contain 
bitset_free(current_set) and so I guess we have exactly same problem that 
in breadth_first_search() we are just correcting.


As a counter-example, in src/sage/graphs/weakly_chordal.pyx there is 
function is_long_hole_free() containing


bitset_init(dense_graph, n * n)
if ...:
bitset_free(dense_graph)
return ...
bitset_free(dense_graph)
return ...

so that seems to be correct.

I found these by

egrep -R -o 'bitset_init\([[:alnum:].]+,|bitset_free\([[:alnum:].]+' src/sage  
| less

but I suppose that there are better tools for this.

--
Jori Mäntysalo


Re: [sage-devel] memory problem

2018-12-01 Thread Jori Mäntysalo

On Sat, 1 Dec 2018, 'Martin R' via sage-devel wrote:


https://trac.sagemath.org/ticket/26794


I don't think that this is critical. The user never gets wrong answers 
because of this.


Anyways, needs to be corrected. This is cython thing, not python. I'm not 
familiar with cython, so maybe someone else should look at this. OTOH I 
suppose this is an easy one, just add a destructor function (whatever it 
is called in cython).


Harder one is to search for other similar bugs.

--
Jori Mäntysalo

Re: [sage-devel] memory problem

2018-11-30 Thread Jori Mäntysalo

On Fri, 30 Nov 2018, 'Martin R' via sage-devel wrote:


It seems to me that the following does NOT leak.

def check_bad4(n):
        P = HasseDiagram(dig)
        for i in range(n):
            x = P.breadth_first_search(i)


You don't stop the search in first match, so the memory will be freed. Try 
addin break after P.breadth_first_search(i).


--
Jori Mäntysalo

Re: [sage-devel] memory problem

2018-11-30 Thread Jori Mäntysalo

On Wed, 28 Nov 2018, 'Martin R' via sage-devel wrote:

Can you confirm that running check_bad3 above allocates memory without 
limits?


Confirmed.


I got it: breadth_first_search (used in HasseDiagram.is_lequal) leaks.

if I use breadth_first_search(i, distance=self.cardinality()) instead, the leak 
is gone.


That function starts with

# Preferably use the Cython implementation
if neighbors is None and . . . distance is None and . . .

so the problem must be in

for v in self._backend.breadth_first_search(start, 
ignore_direction=ignore_direction):
yield v

This goes to src/sage/graphs/base/c_graph.pyx cdef class Search_iterator, 
which has


def __next__(self):
. . .
cdef bitset_t seen
. . .
def __init__
. . .
bitset_init(self.seen,
. . .
def __next__(self):
. . .
while self.stack:
. . .
break
else:
bitset_free(self.seen)
raise StopIteration

So, now when there is no reference to Search_iterator any more, should 
Cython automatically clean up the space taken, or should there be an 
explicit destructor?


--
Jori Mäntysalo

Re: [sage-devel] memory problem

2018-11-28 Thread Jori Mäntysalo

On Wed, 28 Nov 2018, 'Martin R' via sage-devel wrote:


Thank you for looking into this.  I think the problem exists also for the
following code, however only for n = 8:


I did some other tests too, but only got confused. Hasse diagrams are just 
graphs, I think -- they are not derived from UniqueRepresentation.


Can this be a bug in Python? Maybe we can make quick modification to 
digraph code so that we can create posets with Py3-compiled Sage, and test 
that. But all of this is above my knowledge. :=(


--
Jori Mäntysalo


Re: [sage-devel] memory problem

2018-11-28 Thread Jori Mäntysalo

On Sun, 25 Nov 2018, 'Martin R' via sage-devel wrote:


I still think that there is something odd going on.  I do not understand the 
following:
def check(n):
    while True:
        for P in Posets(n):
            Q = P.with_bounds()
            x = Q.moebius_function(Q.bottom(), Q.top())
        print get_memory_usage()


The code can be made a little shorter:

def check(n):
while True:
for P in Posets(n):
x = P._hasse_diagram.moebius_function(0, n-1)
print get_memory_usage()

It still has the same error limit, i.e. check(6) works but check(7) does 
not. I played a little with the code, and gc.collect() does not seem to 
make anything. After a little more I got


AttributeError: 'FinitePoset_with_category' object has no attribute 
'_hasse_diagram'

from the code!

I reset the notebook and tried

def check(n):
while True:
i = 0
for P in Posets(n):
x = P._hasse_diagram.moebius_function(0, n-1)
i += 1
if i > 2000:
break
print get_memory_usage()

and still get memory leak. But with i > 1000 it works. So it's not about 
size of poset but the number of them.


Weird.

--
Jori Mäntysalo


Re: [sage-devel] memory problem

2018-11-24 Thread Jori Mäntysalo

On Sat, 24 Nov 2018, 'Martin R' via sage-devel wrote:


I am running a big, but simple computation and running out of memory, but do
not understand why.  I am pretty sure that the problem is in the computation
of the moebius function.


moebius_function() uses _moebius_function_values, which means that the 
result is implicitly cached.


--
Jori Mäntysalo

[sage-devel] @rename_keyword without ticket number

2018-11-23 Thread Jori Mäntysalo
There are, in 21 different files, 31 @rename_keyword statements without a 
trac number.


Could we fix them, and if so, is it possible to always require the ticket 
number, i.e. deprecation-parameter?


--
Jori Mäntysalo


Re: [sage-devel] Jupyterhub kernel and SAGE_ROOT

2018-11-16 Thread Jori Mäntysalo

On Fri, 16 Nov 2018, Luca De Feo wrote:


and maybe 10 of them will be heavy duty users. Then maybe 500 may
be users in some random course, or checking just one computation etc.


500 hundred simultaneous connections may also be a bit too much,
depending on how powerful your server is.


I guess that 50 simultaneous connection will be the maximum. The use might 
be, for example, a course on graph theory having mandatory but trivial 
exercise about SageMath graph functions.


--
Jori Mäntysalo

Re: [sage-devel] Jupyterhub kernel and SAGE_ROOT

2018-11-16 Thread Jori Mäntysalo

On Mon, 5 Nov 2018, Luca De Feo wrote:


Packagers have already solved it for various distributions, so, if you
don't need a Sage version compiled from sources, you can have a
working Sage + JupyterHub setup using the system packages with no
further hacks.


How fast will new SageMath versions be packaged? I suppose that fast 
enought, and those needing the bleeding edge version can compile it 
themself.



I have a blog post on the whole process of setting up JupyterHub using
Docker Compose (spoiler: it's easy):

 https://opendreamkit.org/2018/10/17/jupyterhub-docker/


Seems interesting. Here we will have about 35,000 theoretically possible 
users, and maybe 10 of them will be heavy duty users. Then maybe 500 may 
be users in some random course, or checking just one computation etc.


I have no previous experience on containers, but I guess they are here to 
stay and I should learn them.


--
Jori Mäntysalo

Re: [sage-devel] Jupyterhub kernel and SAGE_ROOT

2018-11-05 Thread Jori Mäntysalo

On Mon, 5 Nov 2018, Enrique Artal wrote:


For me it works adding "env": { "SAGE_ROOT": "where_SAGE_ROOT_is" } in
kernel.json


Thanks, seems to be much better solution.

Now, what is the best practise for upgrading Sage? Jupyterhub makes it 
easy to have several kernels installed, but there is no real "big" and 
"small" releases of SageMath. Hence it makes no sense to have "Sage 8.x 
-serie" and "Sage 9.x -serie" in parallel. Can we have something like 
"Sage" having newest as default, and explicit versions available for 
advanced users?


With SageNB I have just installed new version. If something brokes for 
some user, then it brokes -- there are deprecation warnings that hopefully 
helps.


--
Jori Mäntysalo

Re: [sage-devel] Jupyterhub kernel and SAGE_ROOT

2018-11-05 Thread Jori Mäntysalo

On Mon, 5 Nov 2018, François Bissey wrote:


I’d be curious about that, but yes that may be off-list.


Of course if I can make a good step-by-step manual, then I will write 
about that in this list.


--
Jori Mäntysalo

Re: [sage-devel] Jupyterhub kernel and SAGE_ROOT

2018-11-04 Thread Jori Mäntysalo

On Mon, 5 Nov 2018, François Bissey wrote:


Didn’t we have that conversation a couple of months ago?
The message here comes from this section of code in sage-env



else
   # No idea what SAGE_ROOT should be...
   echo >&2 "Error: You must set the SAGE_ROOT environment variable or run this"
   echo >&2 "script from the SAGE_ROOT or SAGE_ROOT/local/bin/ directory."
   return 1


OK, so I just hardcoded this by commenting out return 1 and putting

NEW_SAGE_ROOT=/home/jupkernelit/sage-8.4

instead. Now it at works, including graphich. Sorry for the noise.

Now it's time for polyamory, i.e. getting also shibboleth ready. But that 
will be off-topic for this list.


--
Jori Mäntysalo

[sage-devel] Jupyterhub kernel and SAGE_ROOT

2018-11-04 Thread Jori Mäntysalo
I am trying to marry SageMath and Jupyterhub. I think I got them engaged, 
but the wedding night has a problem:


Error: You must set the SAGE_ROOT environment variable or run this
script from the SAGE_ROOT or SAGE_ROOT/local/bin/ directory.
Error setting environment variables by sourcing 
'/home/jupkernelit/sage-8.4/local/bin/sage-env';
possibly contact sage-devel (see 
http://groups.google.com/group/sage-devel)


First I think that I just set SAGE_ROOT in the command line before 
jupytehub-command, set it with export-command, or put it to /etc/profile. 
They all failed, so jupyterhub seems to ignore environment.


What next?

--
Jori Mäntysalo


Re: [sage-devel] Re: Make and html docs

2018-10-23 Thread Jori Mäntysalo

On Tue, 23 Oct 2018, Eric Gourgoulhon wrote:


  I just downloaded 8.4 and ran make. Makefile says "The default
  target
  ("all") builds Sage and the whole (HTML) documentation.", but
  actually
  plain "make" just compiled the binary, not docs. Can someone
  confirm this?


I do *not* confirm this: for me the following

git clone https://github.com/sagemath/sage.git
cd sage
MAKE="make -j8" make

did build Sage 8.4 and the whole documentation.
This is on Ubuntu 18.04.


OK. I downloaded the package (with browser, not with git), run "make" 
without -j, and I have Ubuntu 18.04 LTS which is, IIRC, former Ubuntu 
14.04 upgraded twice.


And now after make dist-clean it compiled also manuals and everything is 
up and running. Let's suppose this was a heisenbug.


--
Jori Mäntysalo

[sage-devel] Make and html docs

2018-10-23 Thread Jori Mäntysalo
I just downloaded 8.4 and ran make. Makefile says "The default target 
("all") builds Sage and the whole (HTML) documentation.", but actually 
plain "make" just compiled the binary, not docs. Can someone confirm this?


(I also got error with building docs when running "make all". Now "make 
doc-clean" done and "make all" running again.)


--
Jori Mäntysalo


Re: [sage-devel] Re: Remove sagenb documentation from the reference manual?

2018-10-21 Thread Jori Mäntysalo

On Sun, 14 Oct 2018, François Bissey wrote:

I am impressed by the number of persons I see still using the legacy 
notebook.


The whole math department of university of Canterbury (New Zealand) where
I work for starter. They have heaps of legacy notebooks.


University of Tampere has used legacy notebook for teaching -- a teacher 
has special account for a course, and students share notebooks with that 
account.


But I am figuring out how to set up Jupyterhub with Shibboleth and have 
SageMath as a kernel for that. Currently I have gotten SageMath to be seen 
as a kernel, but it fails to start.


--
Jori Mäntysalo

[sage-devel] Pinging about modular decomposition of graphs

2018-09-20 Thread Jori Mäntysalo

Just to ping... Anyone looking at https://trac.sagemath.org/ticket/25872 ?

Working modular decomposition => working decomposition of poset ("converse 
of lexicographic sum") => optimizations for the jump number etc.


--
Jori Mäntysalo


[sage-devel] Profiling subfunction

2018-09-19 Thread Jori Mäntysalo
%lprun is a nice tool that shows how much time each line of the function 
uses. But can I do profiling for an internal function defined inside outer 
function?


--
Jori Mäntysalo


Re: [sage-devel] Re: Py3, sorting vertices of graph

2018-09-06 Thread Jori Mäntysalo

On Thu, 6 Sep 2018, John H Palmieri wrote:


Also not ideal, but you could first try u < v, and if that fails, catch the
error and use str(u) < str(v).


But we can have Graph({'1': [1]}) and so not total order for str() of 
vertices.


--
Jori Mäntysalo

[sage-devel] Py3, sorting vertices of graph

2018-08-30 Thread Jori Mäntysalo

What is the situation with sorting of graph vertices in Python 3?

Currently one can not, for example, create a poset with Py3. This comes 
down to 42 < 'xyz', which raises exception in Py3, but returns either True 
or False in Py2. Comparison is used in sorted(), which is used in 
.vertices() for (di)graphs.


It is trivial to try sort vertices, and when failed, return them in an 
arbitrary order, but I don't know what would be broken then.


--
Jori Mäntysalo


Re: [sage-devel] Re: New code to generate finite lattices

2018-08-26 Thread Jori Mäntysalo

On Sat, 25 Aug 2018, 'Martin R' via sage-devel wrote:


That would be great!  (in particular, if it's fast :-)


Seems to be fast. First step would be that someone test the code with Mac 
OS X and Cygwin.


(Of course the slowest part is converting data to Sage. So if we want to 
generate, say, planar lattices, it is much faster if we do the filtering 
in C-phase. For graded, semimodular and modular lattices we could even 
make the generating part in C.)


--
Jori Mäntysalo

[sage-devel] New code to generate finite lattices

2018-08-25 Thread Jori Mäntysalo
Might be of interest to some that there is now a GPLv3 code for 
generating finite lattices. Paper is at


https://arxiv.org/pdf/1609.08255.pdf

code can be downloaded from

https://bitbucket.org/vgebhardt/unlabelled-lattices/downloads/

and it can be used for example like

from sage.combinat.posets.lattices import FiniteLatticePoset
from sage.categories.finite_lattice_posets import FiniteLatticePosets

import subprocess
def generate_lattices(n):  # Add check for the argument etc.


cmd=["/SOME/PATH/vgebhardt-unlabelled-lattices-367022714ef8/UnlabelledLattices"]
args=[str(n)]
sp=subprocess.Popen(cmd+args, shell=False, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
reader=iter(lambda: sp.stdout.read(n*(n-1)/2+1), '')
while True:
S=reader.next()[:-1]
yield FiniteLatticePoset(DiGraph([range(n), lambda a, b: a < b and 
S[b*(b-1)/2+a]=='1']), category=FiniteLatticePosets())

I think someone, like me, should make an optional package from this.

--
Jori Mäntysalo


Re: [sage-devel] Re: Two-vertex graphs and is_prime()

2018-07-10 Thread Jori Mäntysalo

On Tue, 10 Jul 2018, david.coud...@inria.fr wrote:


A clique is a "series" module in the modular decomposition because its 
complement is not connected.
See the survey https://arxiv.org/pdf/0912.1457
* A module is of type parallel if G is not connected but its complement it
* A module is of type series if G is connected but its complement is not. In 
particular, a clique gives a series module

It is also written in the paper that the smallest prime graph is the P4.

sage: [graphs.PathGraph(i).is_prime() for i in range(5)]
[True, True, False, False, True]


I think the question is similar to asking if number 1 is prime. Directly 
by definition given in the doc there can not be a non-prime graph of at 
most 2 vertices, as there can't be nontrivial module. (Assuming that 
"trivial" means empty subset, single element or the whole graph.)


Anyways, I left this for others to decide.

--
Jori Mäntysalo


Re: [sage-devel] Re: How parallel should @parallel be?

2018-07-09 Thread Jori Mäntysalo

On Mon, 9 Jul 2018, John H Palmieri wrote:


I would also expect it to run as many threads as my laptop has
cores (+ hyperthreading if available).


This makes sense for single-user machines, but the current default was 
implemented because it was deemed safer on machines used by multiple 
users.


Then there is a need for better maintainer on the machine.

Also, limiting number of CPU cores is the most less efective restriction. 
Timesharing works very well in any case; much more problematic is program 
that eats memory or just runs heavy I/O.


--
Jori Mäntysalo

Re: [sage-devel] How parallel should @parallel be?

2018-07-09 Thread Jori Mäntysalo

On Mon, 9 Jul 2018, Julian Rüth wrote:


The question is: What is a good default for things such as @parallel when
SAGE_NUM_THREADS has not been set? I think that 1 is not a good one. The
actual number of cores/threads on a system probably isn't either on servers
with lots of cores. At some point we had `min(8, number of threads)` which
appears reasonable to me.


I would suppose that by default Sage uses all cores (or one core); all 
other limits are artificial.


(But Sage doc should contain a little page telling how to use timeout, 
taskset and ulimit commands on some common Linux distribution. Maybe also 
a link to page telling about cgroups and even about at-command.)


--
Jori Mäntysalo

[sage-devel] Two-vertex graphs and is_prime()

2018-07-08 Thread Jori Mäntysalo
Graph({1:[2]}).is_prime() returns False, and the documentation says "A 
graph is prime if all its modules are trivial (i.e. empty, all of the 
graph or singletons)".


Is this an error, or are the two-element graphs by convention classified 
as prime graphs?


--
Jori Mäntysalo


[sage-devel] Bug: Neighbors of a vertex in an immutable digraph

2018-06-10 Thread Jori Mäntysalo
Maybe this should be mentioned in the list, as this is quite a basic 
function:


sage: DiGraph({0: [1]}, immutable=False).neighbors(1)
[0]
sage: DiGraph({0: [1]}, immutable=True).neighbors(1)
[]

The ticket is https://trac.sagemath.org/ticket/25550 and I am not planning 
to work on it at least for now.


--
Jori Mäntysalo


Re: [sage-devel] random_element and randtest_element

2018-06-07 Thread Jori Mäntysalo

On Wed, 6 Jun 2018, Travis Scrimshaw wrote:


Heisenfailures are very difficult to debug: One run, doctests fail. You make
a small tweak (one that changes the random seed), which you think fixes the
issue, and then tests pass. However, if it is a random test, then you have
no idea if you have fixed the problem or not.


True, we should somehow save the random seed used and give it with a 
failure notice.


I have done something to help random testing:

sage: from sage.tests.finite_poset import test_finite_lattice
sage: L = posets.RandomLattice(10, 0.98)
sage: test_finite_lattice(L) is None  # Long time
True

We could check, for example, that matrix AB is invertible iff both A and B 
are, and so on.


 * * *

Another thing, should we try to classify bugs we found? I mean that could 
we get insight of places to look for possible other bugs?


--
Jori Mäntysalo

Re: [sage-devel] Enhancements for unit-distance graphs

2018-04-25 Thread Jori Mäntysalo

On Wed, 25 Apr 2018, Ewan Davies wrote:


The Moser spindle is important as a small (7 vertex) unit distance graph
that is not 3-colorable, and is included in sage's smallgraphs.py. But the
embedding given there is not the unit distance embedding! I think this
should be corrected, and have appropriate code.


Maybe. OTOH also the Petersen graph is unit distance graph, but it already 
has a nice drawing. A graph may have several different "nice" properties 
such that a single drawing can not show them all.



Secondly, the Golomb graph is another small unit distance graph which is not
3-colorable. I would like to submit a function for smallgraphs.py that lets
this be a named graph in sage.


Good idea, but first check that it is not already included with some other 
name.


You may also want to add a function to recognize unit distance graphs.

--
Jori Mäntysalo

Re: [sage-devel] Re: Moving sagenb worksheets

2018-04-24 Thread Jori Mäntysalo

On Tue, 24 Apr 2018, Dima Pasechnik wrote:


did you try copying the whole ~/.sage/ directory over?


I am quite sure that it would work.

I was actually hoping that this could be a spring cleaning -- mail to 
everyone about the new server, and instructions on how to copy 
worksheet(s).


There is no easy way in SageNB to handle users, like grouping them to 
courses and deleting accounts that are not marked as being "staff"-group 
etc. Even deleting a user does not delete worksheets.


--
Jori Mäntysalo

Re: [sage-devel] Re: Moving sagenb worksheets

2018-04-24 Thread Jori Mäntysalo

On Tue, 24 Apr 2018, kcrisman wrote:


  However, the Download All Active -link does not work. Is there any
  workaround to make it work? And yes, I know that there is no active
  development, but this would make it possible to move data from a server to
  another.

I think if you click on the buttons on the left and then "Download" it 
should work, at least for small numbers of worksheets (I don't know what 
N=small, though).


Thanks, this helps a little. It seems that N=2 is too much if the 
worksheets are large, but at least N=5 worked with small ones. So I guess 
the problem is somehow some memory exhausting(?).


--
Jori Mäntysalo

[sage-devel] Moving sagenb worksheets

2018-04-23 Thread Jori Mäntysalo
Sometimes SageNB gives internal error 500 but works, like when publishing 
a worksheet.


However, the Download All Active -link does not work. Is there any 
workaround to make it work? And yes, I know that there is no active 
development, but this would make it possible to move data from a server to 
another.


--
Jori Mäntysalo


Re: [sage-devel] Nauty as a default generator for graphs

2018-03-12 Thread Jori Mäntysalo

On Fri, 9 Mar 2018, David Roe wrote:


Will I break something if I change graphs(n) without any
additional parameter to use nauty?


It did the change at https://trac.sagemath.org/ticket/24951


Sounds good to me.  You might add an algorithm keyword to the graphs
function, which defaults to nauty.


Not sure... It can be done with property=lambda _: True. I think that 
mostly algorithm-keyword should have a meaning -- there should be a 
situation where someone would prefer one over the other.


On Fri, 9 Mar 2018, 'Martin R' via sage-devel wrote:

Besides, it would also be supercool to have a class Graphs analogous to 
the class Posets, and have the cardinality of the first few layers built 
in (analogous to Posets(16).cardinality())


I am not sure about that. What should be the meaning of, say "g in 
graphs(10)" or "g in graphs"?


--
Jori Mäntysalo


[sage-devel] Nauty as a default generator for graphs

2018-03-08 Thread Jori Mäntysalo
It is much faster to say sum(1 for _ in graphs.nauty_geng(7)) than sum(1 
for _ in graphs(7)), and after #19919 we have nauty as a standard package.


Will I break something if I change graphs(n) without any additional 
parameter to use nauty? A user really needing the old code could then say
graphs(n, property=lambda x: True). I think that Sage documentation makes 
no promise at all about the order in which graphs are generated.


--
Jori Mäntysalo


Re: [sage-devel] Whitespace patchbombs

2018-02-20 Thread Jori Mäntysalo
How are merge conflicts handled, and is there any use for priority-flag on 
trac? It would make sense that lower priority tickets would be merged 
after more important ones.


--
Jori Mäntysalo


Re: [sage-devel] Problems with posets

2018-01-23 Thread Jori Mäntysalo

Victor, a kind of followup: https://trac.sagemath.org/ticket/24584

I think we should add is_extension() to posets, and then maybe functions 
to list "minimal extensions" and "minimal un-extensions" (right term for 
that?) of a poset. I think that the last one is just a way to remove a 
covering relation. With those we could have principal upper and lower sets 
of a power poset, i.e. an extensions poset you asked.


--
Jori Mäntysalo


Re: [sage-devel] Re: Example graphs and show()

2018-01-19 Thread Jori Mäntysalo

On Fri, 19 Jan 2018, Dima Pasechnik wrote:

I think it does matter for the user: in EXAMPLES one should put examples 
useful for the user, and G.show() is more flexible, e.g. one can do  
G.show(method="js") to show G in the browser.


True, but is it meaningfull to say for most graphs that this-and-this-too 
can be shown with .show()? I see no added value to the user.


--
Jori Mäntysalo

Re: [sage-devel] Re: Example graphs and show()

2018-01-18 Thread Jori Mäntysalo

On Wed, 17 Jan 2018, Travis Scrimshaw wrote:

I don't think plot, unlike show, actually goes through and does the 
rendering of the image and discards the result. However, I could be 
wrong about this.


You were right. After

perl -e 's/(G|g)\.show\(\)/_=\1.plot()/g;' -p -i.bak 
src/sage/graphs/generators/platonic_solids.py

the test time dropped from 3,5 to 0,5 seconds.


However, the output of the plot should be something that says
how many graphics objects, which generally should not change.


True.

Should it be on TESTS or in EXAMPLES?

--
Jori Mäntysalo

Re: [sage-devel] Re: Example graphs and show()

2018-01-17 Thread Jori Mäntysalo

On Wed, 17 Jan 2018, Travis Scrimshaw wrote:


It might be better to do the plot() instead as that returns a graphics object, 
and I believe is
faster (but I have no quantitative evidence of this).


I don't think so. There is no real canvas where show() could draw in test 
mode, so the time should be exactly the same as plot(). And then, is even 
plot() usefull as an example?


--
Jori Mäntysalo

[sage-devel] Example graphs and show()

2018-01-16 Thread Jori Mäntysalo
Many examples at graph_generators.py use show() as an example of use. What 
you think about this? It tests that plotting of the graph does not return 
an error, but nothing more. And it will take time, not that much but 
cutting the testing time would not be a bad idea.


--
Jori Mäntysalo


[sage-devel] Authentication by shibboleth

2018-01-16 Thread Jori Mäntysalo
Does anyone here currently adminstrate a Sagemath installation having 
shibboleth as the main authentication?


--
Jori Mäntysalo


Re: [sage-devel] Problems with posets

2018-01-15 Thread Jori Mäntysalo

On Mon, 15 Jan 2018, Victor Porton wrote:

Are you sure? I think I need non-automorphism permutations. Automorphism 
by definition maps a Hasse diagram into itself, while I need to map it 
into other diagrams, not into itself.


True, but I think that the converse should be doable by automorphism 
group ("permutations divided by  automorphism").



I say that a poset A is greater than the poset B if and only if:

For every x, y: if x<=y in B-order then if x<=y in A-order.


This is called 'extension' of a poset, see 
http://planetmath.org/extensionofaposet . Mostly linear extensions are 
studied, and I think there is not (yet) a program in Sage to list 
extensions of a poset.


Actually listing all extensions of an antichain would be exactly all 
labeled posets. Maybe I should think about implementing this.



By the way, can anyone give me CPU power of a supercomputer for free?


Try to make a paper together with someone in Finland... 1000 CPU hours 
is automatically available here for any researcher in any university, 
more by asking.


(There was error, 1 CPU hours is the right value.)


I am an amateur researcher. It is hard for me to find a research partner.


OK. For that I don't have good suggestions.

However I saved money on an UPS, so in the case if electricity 
disconnects or something happens with my Linux I would need start anew.


If you don't want to make a code that can save temporary results you can 
just install some virtualization software (VirtualBox is my favorite in 
desktop), install Sage inside the virtual machine, and then make snapshots 
of the virtual machine sometimes. You can even make it automatic, see 
https://www.techrepublic.com/article/how-to-automate-virtualbox-snapshots-with-the-vboxmanage-command/


--
Jori Mäntysalo

Re: [sage-devel] (Proposed feature) Enumerate all labeled posets

2018-01-15 Thread Jori Mäntysalo

On Mon, 15 Jan 2018, Victor Porton wrote:


I need to enumerate all labeled (that is NOT up-to-isomorphism) posets of N
elements.
The algorithm is here: https://stackoverflow.com/a/48270680/856090


No, that paper gives "method to construct pairwise non-isomorphic posets", 
i.e. up-to-isomorphism.


Btw, just extending poset by adding a new maximal element covering all 
possible subsets of maximal elements will give you all posets having 1, 2, 
..., n as a linear extension. That is not enought?


--
Jori Mäntysalo

Re: [sage-devel] Problems with posets

2018-01-14 Thread Jori Mäntysalo

On Mon, 15 Jan 2018, Victor Porton wrote:


So I have no tool to enumerate not up-to-isomorphism :-(


At least you can re-compute OEIS serie A001035 by

[sum(sum(factorial(i)/P.hasse_diagram().automorphism_group(return_group=False, 
order=True)) for P in Posets(i)) for i in range(6)]


so I guess the right direction is to use automorphism group of the Hasse 
diagram. A digraph d can be translated to poset just by Poset(d).



Another issue: I need only posets greater than a certain fixed poset


Please give an example. What would be a poset "greater" than, say, 
posets.DiamondPoset(5)?



By the way, can anyone give me CPU power of a supercomputer for free?


Try to make a paper together with someone in Finland... 1000 CPU hours is 
automatically available here for any researcher in any university, more by 
asking.


--
Jori Mäntysalo

Re: [sage-devel] country-wide Jupyter cloud computing service in Canada

2017-12-24 Thread Jori Mäntysalo

On Sat, 23 Dec 2017, Dima Pasechnik wrote:


https://medium.com/@pimsmath/canadians-land-on-jupyter-ef5872720420


Seems to be what Finnish IT Center for Science (CSC) does here:
https://research.csc.fi/notebooks?p_p_id=56_INSTANCE_KEGCKxncnP4s_p_lifecycle=0_p_state=normal_p_mode=view_p_col_id=column-3_p_col_count=1

"With power user rights on the system you can customise your own 
notebooks. Lecturers can e.g. create ready-made course notebooks with 
required applications, datasets and exercises."


--
Jori Mäntysalo

[sage-devel] Meaning of edge_labels in canonical_label()

2017-12-18 Thread Jori Mäntysalo
Using edge_labels=True in canonical_label() of graph seems to work, i.e. 
canonization transforms isomorphism to equality. Also the parameter does 
*something*, it is not ignored.


But what is the meaning of it? For partition-parameter the meaning is 
clear (but not clearly documented).


--
Jori Mäntysalo


Re: [sage-devel] Re: About solve(x*abs(x)==1, x)

2017-12-13 Thread Jori Mäntysalo

On Wed, 13 Dec 2017, rjf wrote:


how much of Sage are you using?  If you arejust using Sage as a front end to 
Maxima, maybe
you should just use Maxima.


I don't use. I was asked about this by a man who teaches course about 
"Computer programs for mathematics and statistics". And he is not happy 
about this.


--
Jori Mäntysalo


[sage-devel] About solve(x*abs(x)==1, x)

2017-12-13 Thread Jori Mäntysalo

This has been discussed earlier, but I was again asked about this:

sage: solve(x*abs(x)==1, x)
[x == (1/abs(x))]
sage: solve([x*abs(x)==1, x==x], x)
[[x == 1]]

And yes, to_poly_solve=True can be used. But this is annoying to teach and 
gives bad impression of Sage. Is there any plans to make this better?


--
Jori Mäntysalo


Re: [sage-devel] Re: SageNB and ldap packages

2017-12-12 Thread Jori Mäntysalo

On Tue, 12 Dec 2017, Dima Pasechnik wrote:


Have you tested against a real LDAP server?


Yes. It works.


Could you comment on https://github.com/sagemath/sagenb/issues/177 
rather than here? 


OK, I'll continue there.

--
Jori Mäntysalo

Re: [sage-devel] Re: SageNB and ldap packages

2017-12-12 Thread Jori Mäntysalo

On Mon, 11 Dec 2017, Dima Pasechnik wrote:


why would you bother with easy_install at all? All these packages you need
are installable with pip.

I am now trying to summarise what you did
here: https://github.com/sagemath/sagenb/issues/177
Please have a look and check.


I do not know if "./sage -i openssl" and/or "./sage -pip install 
pyopenssl" is needed. As for easy_install I just tried different options.


I think that now we know what commands are sufficient to have LDAP. I am 
not sure if we know what are necessary commands.


--
Jori Mäntysalo


Re: [sage-devel] Re: SageNB and ldap packages

2017-12-11 Thread Jori Mäntysalo

On Mon, 11 Dec 2017, Jori Mantysalo wrote:

But there is something wrong with those settings. I must test against a known 
good server.


...and now it works on a test machine. I must still test that on real 
server, where I had to say pip uninstall, pip install and sage -b to get 
ldap settings to show.


--
Jori Mäntysalo


Re: [sage-devel] Re: SageNB and ldap packages

2017-12-11 Thread Jori Mäntysalo

On Sun, 10 Dec 2017, Dima Pasechnik wrote:


On my installation, thes files don't exist:
$ ls  local/lib/python2.7/site-packages/ldap/
__init__.py  __init__.pyc  mock.py  mock.pyc  server.py  server.pyc

Confusingly, pip also has a package called python-ldap; if I do
./sage --pip install python-ldap
then I get that ldap/filter.py files indeed.
But do we need it?


If I just make Sage and then as admin go to Notebook Settings there is no 
ldap settings at all -- of course not.


"./sage -i openssl" did not add that, so next I run "./sage -pip install 
pyopenssl" with no help.


Now, both "./sage -sh"+"easy_install python-ldap" and "./sage --pip 
install python-ldap" gives an error about missing lber.h. So, I ran
"apt-get install libldap2-dev" as root. After that there was sasl/sasl.h 
missing, so I ran "apt-get install libsasl2-dev". Now I was able to run 
"./sage -sh"+"easy_install python-ldap".


But still no settings for ldap. So, next "./sage --pip install 
python-ldap". And here we are! Now there is ldap settings available.


Now, I tested with settings

Enable LDAP Authentication: On
LDAP URI: ldap://ldap.forumsys.com:389/
Bind DN: cn=read-only-admin,dc=example,dc=com
Bind Password: password
Use GSSAPI instead of Bind DN/Password: Off
Base DN: ou=mathematicians,dc=example,dc=com
Username Attribute (i.e. cn, uid or userPrincipalName): uid
Query timeout (seconds): 5

But there is something wrong with those settings. I must test against a 
known good server.


--
Jori Mäntysalo

Re: [sage-devel] Re: SageNB and ldap packages

2017-12-10 Thread Jori Mäntysalo

On Sun, 10 Dec 2017, Dima Pasechnik wrote:


How do I reproduce your error?


You need a working LDAP server for that. Maybe this works: 
https://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/


I'll continue with this tomorrow.

--
Jori Mäntysalo

Re: [sage-devel] Re: SageNB and ldap packages

2017-12-10 Thread Jori Mäntysalo

On Sun, 10 Dec 2017, Dima Pasechnik wrote:


Could you locate the python file this command is in?


$ fgrep 'import strf_secs' -R .
./local/lib/python2.7/site-packages/ldap/filter.py:from ldap.functions import 
strf_secs
./local/lib/python3.6/site-packages/python_ldap-3.0.0b1-py3.6-linux-x86_64.egg/ldap/filter.py:from
 ldap.functions import strf_secs
./local/lib64/python2.7/site-packages/ldap/filter.py:from ldap.functions import 
strf_secs
./local/lib64/python3.6/site-packages/python_ldap-3.0.0b1-py3.6-linux-x86_64.egg/ldap/filter.py:from
 ldap.functions import strf_secs

--
Jori Mäntysalo


Re: [sage-devel] Re: SageNB and ldap packages

2017-12-09 Thread Jori Mäntysalo

On Sat, 9 Dec 2017, kcrisman wrote:


  >       After some trying I ended up with line
  >
  >       from ldap.functions import strf_secs

Hmm, what was your previous Sage instance?


Version 8.0.


Did you conceivably compile Sage using Py3?


Just did normal make.

Dima wrote:

It's probably coming from one of (non-standard ?) python packages you 
have installed.


True, I installed some optional packages (gap_database, dot2tex etc.). But 
I don't get that -- how those affect login on SageNB?


--
Jori Mäntysalo

Re: [sage-devel] Re: SageNB and ldap packages

2017-12-09 Thread Jori Mäntysalo

On Fri, 8 Dec 2017, William Stein wrote:


CoCalc also support sharing notebooks (and latex documents and pretty
much any type of files) within a group, with realtime multiuser
editing.  That's what the "Add people to project" section of project
settings enables.


Ah, good. So let's test. I didn't found INSTALL.md, so I just read the end 
of https://github.com/sagemathinc/cocalc and npm run install-all ends to


npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: 
fsevents@1.1.3
npm ERR! Linux 4.4.0-98-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! node-sass@4.7.2 install: `node scripts/install.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the node-sass@4.7.2 install script 'node scripts/install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-sass package,
npm ERR! not with npm itself.

But propably this was wrong path anyways?

--
Jori Mäntysalo

Re: [sage-devel] Re: SageNB and ldap packages

2017-12-08 Thread Jori Mäntysalo

On Fri, 8 Dec 2017, William Stein wrote:


I know. But there is still no notebook sharing in other choises, and that is
what are used here for teaching.


CoCalc has a completely new server for notebook sharing, which we just
wrote in the last month.


It is for publishing notebooks to the world, not for sharing a notebook 
within a group (or to a teacher).



I've been working on interface coding fulltime most of the last 5 years.


One would think that many other can make interface, but quite few people 
are capable of adding some number theory parts to Sage...


--
Jori Mäntysalo

Re: [sage-devel] Re: SageNB and ldap packages

2017-12-08 Thread Jori Mäntysalo

On Fri, 8 Dec 2017, Dima Pasechnik wrote:


  How to set up SageNB with LDAP to SageMath 8.1?

  After some trying I ended up with line

  from ldap.functions import strf_secs


I've no idea where this comes from, it's not in the current sagenb code,
as far as I can tell.
(I didn't try looking too hard, but ldap.functions seems to be something Python 
3-only...)


As always, I started by downloading the stable version and compiled from 
scratch. So it should be there, or otherwise there are ghosts in the 
server.


--
Jori Mäntysalo

Re: [sage-devel] Re: SageNB and ldap packages

2017-12-08 Thread Jori Mäntysalo

On Fri, 8 Dec 2017, Maarten Derickx wrote:


Maybe not a direct answer to your question. But if you plan on setting up an 
ldap authenticated sage
server these days and you are planning on actually maintaining it for some time 
in the future, I
would not go the SageNB way, since SageNB is not really being actively 
developed anymore.


I know. But there is still no notebook sharing in other choises, and that 
is what are used here for teaching.


Of course offloading interface coding is the Right Thing(tm) to do. 
William just made too good work with SageNB at the beginning, it's hard 
for other to implement it all. :=)


--
Jori Mäntysalo

[sage-devel] SageNB and ldap packages

2017-12-08 Thread Jori Mäntysalo

How to set up SageNB with LDAP to SageMath 8.1?

After some trying I ended up with line

from ldap.functions import strf_secs

trying to give an error message but even ending with

ImportError: cannot import name LDAPError

i.e. error in error reporting. I was able to install SageNB such that it 
either says that my password is wrong or give 500 Internal error, so I 
suppose that most parts of the system are working.


--
Jori Mäntysalo


Re: [sage-devel] Re: Issue with quick start

2017-12-05 Thread Jori Mäntysalo

On Mon, 4 Dec 2017, Dima Pasechnik wrote:

Mind you, some components of Sage have versions of the same command in 
two different English spellings, e.g. GAP has Center() and Centre().


But the Sage source code itseself contains only one "centre", in 
documentation of src/sage/groups/perm_gps/permgroup_named.py.


I would like to see only one spelling, i.e. no color and colour etc, but 
that has been discussed earlier without ending to a common view.


--
Jori Mäntysalo

Re: [sage-devel] Python3 comparing, an idea about deprecation

2017-11-06 Thread Jori Mäntysalo

On Mon, 6 Nov 2017, Jeroen Demeyer wrote:

Speaking of comparisons and graphs: we'll need to fix 
https://trac.sagemath.org/ticket/22349 too at some point.


Uh... There are propably at least 1000 doctest that needs to correct.

And mmezzarobba is right: "in interactive use - - people want to see the 
vertices, edges, etc. listed in an order that makes the output easy to 
read - -".


--
Jori Mäntysalo

Re: [sage-devel] Python3 comparing, an idea about deprecation

2017-11-06 Thread Jori Mäntysalo

On Mon, 6 Nov 2017, Jeroen Demeyer wrote:

Is it possible to run min(L) in Python2 and at the same time check if 
it could be run in Python3 for given L?


That depends mostly on what arguments you give to min().

4) A mixture of the above


What I was thinking is something like

g = Graph([(1,2,'a'), (1,2,'b'), (1,2,1), (1,2,2)], format='list_of_edges', 
multiedges=True)
g.allow_multiple_edges(False, keep_label='min')

which is architechture-dependent, either will have an edge with label 1 or 
with label 'a'. In Python3 this will raise an exception. So I guess this 
is case 4 in your list.


--
Jori Mäntysalo

[sage-devel] Python3 comparing, an idea about deprecation

2017-11-05 Thread Jori Mäntysalo
Is it possible to run min(L) in Python2 and at the same time check if it 
could be run in Python3 for given L?


Reason: allow_multiple_edges() on generic_graph.py and keep_label='min' 
(or 'max'), can we have a nice deprecation?


--
Jori Mäntysalo


[sage-devel] Forbidden parameter combinations for a function

2017-10-31 Thread Jori Mäntysalo
I think that Sage should raise an exception if the user explicitly asks 
for a cat that barks or a dog that says meow, even with parameter 
silent=True. If you don't agree, complain at ticket #19517.


(I.e. always raise when algorithm='bliss' and Bliss not installed, even 
when Bliss could not be used anyway.)


--
Jori Mäntysalo


Re: [sage-devel] Trac: getting logged out instantly

2017-10-30 Thread Jori Mäntysalo

On Mon, 30 Oct 2017, Erik Bray wrote:


OK, the common source of problems might be my university network.



Hard to imagine--maybe the university network has a proxy that is
stripping/corrupting some request and/or response headers?


Not at all that strange to me. Just three weeks ago we changed some 
routes, and then about 10 percent of students could not anymore upload 
files bigger than about 100 kilobytes to some of our servers. Somehow a 
"university router" (big one) and "department router" (small one) did not 
like each other.


Still I do not know what exactly happened. Maybe some tcp fragmentation 
thing, timings, or some other things.


--
Jori Mäntysalo

[sage-devel] Workaround for ipython build hang

2017-10-23 Thread Jori Mäntysalo
There is #24088 already in positive_review. But as a sidenote: I was able 
to compile Sage with many, many rounds. So here is a workaround to those 
seeing an error from ipython in compilation:


until make; do echo Duh. Another try.; done

--
Jori Mäntysalo


Re: [sage-devel] Re: Graphs: Hamiltonian path vs. cycle

2017-10-18 Thread Jori Mäntysalo

On Wed, 18 Oct 2017, David Coudert wrote:

But anyways, I found more. is_eulerian(path=True) will return either 
False OR an Eulerian path. This seems to be clearly wrong.


It is not a correct behavior. This method should have a parameter 
`certificate`, default to False. When certificate is True, it returns a 
pair boolean and certificate (see e.g., is_tree).


Sounds reasonable. But then what to do to eulerian_circuit()? There could 
be a function to count or list eulerian circuits too (a problem in #P, 
says Wikipedia).


What's more, is_eulerian(path=True) returns True when the graph has an 
Eulerian path BUT has not Eulerian cycle. Is this normal use in graph 
theory?


This is not consistent with the definition: “a graph has an Eulerian 
path if and only if exactly zero or two vertices have odd degree".


True. But it is useful function to have shorcut for 
"g.has_eulerian_path() and not g.has_eulerian_circuit()"?


 * * *

I think we have a clear consensus on two things: 1) is_* -function shall 
return either a Boolean or a pair where first element is a Boolean, and as 
I said before, 2) function related to Hamiltonian path/cycle shall be 
similar to those related to Eulerian path/cycle.


--
Jori Mäntysalo

Re: [sage-devel] Re: Graphs: Hamiltonian path vs. cycle

2017-10-18 Thread Jori Mäntysalo

On Sat, 14 Oct 2017, Jori Mantysalo wrote:

Just read Wikipedia page and found the term "traversable". It seems to 
be less common than semi-eulerian... But a suggestion based on this: 
Let's make four functions


- is_eulerian
- is_traversable
- is_hamiltonian
- is_traceable

Crosslink is_eulerian <-> is_traversable and is_hamiltonian <-> is_traceable.


I did not get any answer to this.

But anyways, I found more. is_eulerian(path=True) will return either False 
OR an Eulerian path. This seems to be clearly wrong.


What's more, is_eulerian(path=True) returns True when the graph has an 
Eulerian path BUT has not Eulerian cycle. Is this normal use in graph 
theory?


--
Jori Mäntysalo

Re: [sage-devel] Re: Graphs: Hamiltonian path vs. cycle

2017-10-14 Thread Jori Mäntysalo

On Sat, 14 Oct 2017, david.coud...@inria.fr wrote:


It seems that "traceable graph" is more common (by googling), but then it
seems very natural to have is_eulerian/is_semi_eulerian and
is_hamiltonian/is_semi_hamiltonian. Opinions?


We can do that, but first we have to agree on the definitions for both 
eulerian/hamiltonian path/cycle, etc. Then we can clean the situation 
and add required deprecation warning.


Just read Wikipedia page and found the term "traversable". It seems to be 
less common than semi-eulerian... But a suggestion based on this: Let's 
make four functions


- is_eulerian
- is_traversable
- is_hamiltonian
- is_traceable

Crosslink is_eulerian <-> is_traversable and is_hamiltonian <-> 
is_traceable.


To all four add certificate-option with obvious meaning.

To docstring of is_traversable add mention about the term "semi-eulerian", 
and the same for is_traceable / "semi-hamiltonian".


Later get back to functions hamiltonian_cycle() etc.

--
Jori Mäntysalo

Re: [sage-devel] Re: Graphs: Hamiltonian path vs. cycle

2017-10-14 Thread Jori Mäntysalo

On Sat, 14 Oct 2017, david.coud...@inria.fr wrote:


I took some more time to thought about the will of unifying these behaviors 
(which is a good idea) and I now
believe  it is not a good idea to use the same method / term to check if the 
graph has a hamiltonian cycle
or a hamiltonian path. Doing so, we are making methods more complicated and 
introduce confusion. For
instance, the 'backtrack' algorithm is for path only, so why should it be 
associated to a method for
checking if the graph has a hamiltonian cycle ?


OK, but then I suggest we also add is_semi_eulerian() and deprecate 
path-parameter in is_eulerian().



The Wikipedia page about Hamiltonian graphs gives the following definitionsr:
 *  A graph that contains a Hamiltonian cycle is called a Hamiltonian graph.
 *  A graph that contains a Hamiltonian path is called a traceable graph.


Common names should always be mentioned as aliases in the docstring.

It seems that "traceable graph" is more common (by googling), but then it 
seems very natural to have is_eulerian/is_semi_eulerian and 
is_hamiltonian/is_semi_hamiltonian. Opinions?



Furthermore, one can also find in some articles the notion of "semi-hamiltonian 
graph": A graph is
semi-hamiltonian if it contains a hamiltonian path but no hamiltonian cycle.


Duh. And then there is the concept of hypohamiltonian.

--
Jori Mäntysalo

Re: [sage-devel] python3 status

2017-10-13 Thread Jori Mäntysalo

On Fri, 13 Oct 2017, Frédéric Chapoton wrote:


Cool, no ? Or maybe nobody cares ?


Cool, yes!

--
Jori Mäntysalo

[sage-devel] Re: Graphs: Hamiltonian path vs. cycle

2017-10-13 Thread Jori Mäntysalo

More generally relating on this...

I think that currently we have

1) Deterministic function to find the longest path of a graph.
2) "Usually fast" randomized function to find the longest path.

Is this true? And what about functions to find longest cycle or to check 
if the graph is Hamiltonian? A function to list all Hamiltonian 
paths/cycles?


Anyways, from 1 we can make a function to use for 
is_hamiltonian(path=True), and with 2 we could have 
is_hamiltonian(path=True, algorithm='randomized') or so.


Actually we have hamiltonian_cycle(algorithm='backtrack') that uses 
randomized algorithm. It feels slightly odd -- to me "backtrack" sounds 
like a deterministic function. And hamiltonian_path(algorithm='backtrack') 
tries to find longest path by randomized algorithm, and returns what it 
found -- i.e. not necessarily a Hamiltonian path.


I think it would be natural to have

is_hamiltonian(path=False, algorithm=None, certificate=False)

so that path=True would check if the graph is semi-Hamiltonian, 
algorithm='randomized' would use the randomized algorithm which could give 
false negatives, and certificate=True would give either (True, Cycle/Path) 
or (False, None) as output.


But I am not an expert, so maybe graph theorists have something to say 
about this.


--
Jori Mäntysalo


[sage-devel] Is the empty graph cograph

2017-10-12 Thread Jori Mäntysalo

Should the empty graph be defined as cograph?

It can not be made from 1-vertex graphs by disjoint union and 
complementation, so it is not. OTOH it has no induced subgraph isomorphic 
to 4-vertex path, and it is the comparibility graph of the empty poset, so 
it kind of is.


--
Jori Mäntysalo


Re: [sage-devel] On (di)graph generation

2017-10-12 Thread Jori Mäntysalo

On Thu, 12 Oct 2017, David Coudert wrote:

Many authors avoid the empty graph (see e.g., the excellent book "Graph 
Theory with Applications" by Bondy and Murty) as there are no consensus 
on its properties. Should it be considered connected ? biconnected ? 
hamiltonian ? minor-free ? transitively reduced ?


True, and there has been a discussion about is_tree in this list.

Anyways, different parts of Sage should use same definitions.

--
Jori Mäntysalo

Re: [sage-devel] On (di)graph generation

2017-10-12 Thread Jori Mäntysalo
(There is #24004 with positive_review, so I code changes should be thinked 
after next beta.)


On Wed, 11 Oct 2017, Robert Miller wrote:


  4) When is augment='edges' usefull? Is

One reason it is useful:

You can use the argument "property" to restrict to a subclass of graphs. This 
argument takes a function and
filters the output by testing against this property. If this property is 
preserved under vertex deletion, then
using augment='vertices' will give you all graphs satisfying the property. 
Similarly for edges. If the property
is not preserved as described, then you may be missing some.


Yes, that's why I asked about properties like that.

But I already found an example where augment='edges' could be used: 
property=lambda g: g.size() < n, where n is small number; it will work 
with augment='vertices', but is slower.


Also, if you use augment="edges" you get graphs on exactly N vertices, 
and if you use augment="vertices" you get graphs on ≤ N vertices.


Yes, just as I wrote in message starting this thread. And it seems quite 
unlogical.


For any particular family of graphs it is likely there are faster ways 
to do it - for example we have a method of generating iso-classes of 
trees in constant time per tree. This is meant to be a useful 
general-purpose generator.


True.

--
Jori Mäntysalo

Re: [sage-devel] On (di)graph generation

2017-10-11 Thread Jori Mäntysalo

On Wed, 11 Oct 2017, David Joyner wrote:

1) list(graphs.nauty_geng(0)) gives empty list, whereas Sage knows a 
graph of 0 vertices. Can someone ask McKay to handle this special case 
too?



Wouldn't it be easier to simply catch that case in the nauty_geng method?


Could be done, but needs some string processing, as the argument is given 
as a string to nauty. And anyways, isn't this a corner-case bug?


2) Is there an example of graph property that holds after deleting any 
vertex but not necessarily after deleting an edge? Or the converse?


Completeness, if you start with a complete graph, is preserved if you 
delete a vertex but not if you delete an edge. 


True. But it is propably not what one will generate orderly...

--
Jori Mäntysalo

[sage-devel] On (di)graph generation

2017-10-10 Thread Jori Mäntysalo
1) list(graphs.nauty_geng(0)) gives empty list, whereas Sage knows a graph 
of 0 vertices. Can someone ask McKay to handle this special case too?


2) Is there an example of graph property that holds after deleting any 
vertex but not necessarily after deleting an edge? Or the converse?


3) Currently graphs(...) has parameters vertices and augment. With 
graphs(n, augment='edges') it generates all n-vertex graphs, whereas 
graphs(n, augment='vertices') generates all graphs of 0, 1, ..., n 
vertices. Would it be more logical to have parameters max_vertices and 
min_vertices?


4) When is augment='edges' usefull? Is

sum(sum(1 for _ in graphs(i, augment='edges')) for i in range(9))

faster in someone's computer than

sum(1 for _ in graphs(8, augment='vertices'))

?

--
Jori Mäntysalo


Re: [sage-devel] Re: Graphs: Hamiltonian path vs. cycle

2017-10-10 Thread Jori Mäntysalo

On Tue, 10 Oct 2017, Dima Pasechnik wrote:

I cannot think of a reason other than different authors/reviewers, 
different weather, different amount of coffee... :-)


Haha. I opened #24003 for this, but will wait some days to see if there 
will be more comments.


--
Jori Mäntysalo

[sage-devel] Graphs: Hamiltonian path vs. cycle

2017-10-10 Thread Jori Mäntysalo

Try

g = graphs.StarGraph(3)
print(g.hamiltonian_path())
print(g.hamiltonian_cycle())

Is there a reason for this? If not, which way we should correct it?

(#23994 is waiting for a review, will also depend on this.)

--
Jori Mäntysalo


Re: [sage-devel] Re: From SageNB to jupyter

2017-09-19 Thread Jori Mäntysalo

On Thu, 7 Sep 2017, Dima Pasechnik wrote:


did you see
this:https://benjamin-hackl.at/2016/01/16/jupyterhub-with-sagemath-kernel/

It seems that all of the requirements you list are there...


Not sharing notebooks, but it seems that it has been done later:

https://github.com/jupyterhub/hubshare/issues/15

Maybe I wait for this to stabilize and then try to install all parts and 
see if it works.


--
Jori Mäntysalo

Re: [sage-devel] Security in sage (was How much do we support optional packages)

2017-09-18 Thread Jori Mäntysalo

On Fri, 15 Sep 2017, William Stein wrote:


Good idea.  And if anybody does write in here, please precisely define your
security/threat model before writing anything else...  since otherwise the
discussion is worthless.


This is very much theoretical.

But suppose that we use Sage to compute a Hamiltonian path of given graph 
and have our own www-page for inputting the graph. Now, if there is a bug 
in .hamiltonian_path(), it may lead to a security break.


So about every program can be a security problem. For example there has 
been a bug in "bc" in some Linux distribution. And I have used bc as an 
example of using xinetd to make a simple listener for telnet connections. 
Fortunately the bug was corrected before my example.


--
Jori Mäntysalo

Re: [sage-devel] Re: How much do we support optional packages.

2017-09-15 Thread Jori Mäntysalo

On Wed, 13 Sep 2017, Jeroen Demeyer wrote:


What would security even mean for a mathematics program?


I think it could be possible to use Sage as a part of teaching program, 
i.e. have it as a part of automatic checking of some exercises. If so, a 
bug in Sage could -- at least in theory -- lead a compromise to the 
server.


--
Jori Mäntysalo

Re: [sage-devel] Re: From SageNB to jupyter

2017-09-08 Thread Jori Mäntysalo

On Thu, 7 Sep 2017, Volker Braun wrote:


You can share worksheets just by uploading them to github, for example:


Isn't that publishing worksheet, not sharing?

--
Jori Mäntysalo

[sage-devel] Re: From SageNB to jupyter

2017-09-07 Thread Jori Mäntysalo

On Thu, 7 Sep 2017, Dima Pasechnik wrote:


What exactly are you missing from jupyter nb, or jupyter hub, or some version 
of SMC
people managed to get running on their intranets?


I don't actually know; SageNB has just been a working piece of software.

What we need is

- User management from LDAP or Shibboleth, so that everyone with an 
account on them can just sign in to Sage.

- Local user accounts too.
- Security, so that a user A can not see worksheets for user B.
- Importing SageNB worksheet to a new system worksheet.

--
Jori Mäntysalo

Re: [sage-devel] Re: SageNB, publishing and error 500

2017-09-06 Thread Jori Mäntysalo

On Wed, 6 Sep 2017, kcrisman wrote:


I suspect perhaps 
https://github.com/sagemath/sagenb/commit/9dd5c0f8c783de7cb0ae21c9f445ab8260b5a0ac
 is the culprit, and
put something on #432 to the author of that change.  It seems like the kind of 
thing that might happen when a module is
updated, as that change did, though I could be barking up the wrong tree too.  
Thanks for pursuing this.


Another question: Can I downgrade SageNB when waiting correction for this 
bug? Is so, how?


--
Jori Mäntysalo

[sage-devel] Re: SageNB, publishing and error 500

2017-09-05 Thread Jori Mäntysalo

Kcrisman said to check logs. Here they are:

Traceback (most recent call last):

  File 
"/home/jm58660/sage/local/lib/python2.7/site-packages/flask/app.py", line 
1475, in full_dispatch_request

rv = self.dispatch_request()

  File 
"/home/jm58660/sage/local/lib/python2.7/site-packages/flask/app.py", line 
1461, in dispatch_request

return self.view_functions[rule.endpoint](**req.view_args)

  File 
"/home/jm58660/sage/local/lib/python2.7/site-packages/sagenb/flask_version/decorators.py", 
line 22, in wrapper

return f(*args, **kwds)

  File 
"/home/jm58660/sage/local/lib/python2.7/site-packages/sagenb/flask_version/worksheet.py", 
line 51, in wrapper

return f(username, id, **kwds)

  File 
"/home/jm58660/sage/local/lib/python2.7/site-packages/sagenb/flask_version/worksheet.py", 
line 140, in wrapper

return f(*args, **kwds)

  File 
"/home/jm58660/sage/local/lib/python2.7/site-packages/sagenb/flask_version/worksheet.py", 
line 879, in worksheet_publish

print worksheet_publish.url_for(worksheet)

  File 
"/home/jm58660/sage/local/lib/python2.7/site-packages/sagenb/flask_version/worksheet.py", 
line 147, in wc_url_for

return url_for(f.__name__, *args, **kwds)

  File 
"/home/jm58660/sage/local/lib/python2.7/site-packages/flask/helpers.py", 
line 312, in url_for

return appctx.app.handle_url_build_error(error, endpoint, values)

  File 
"/home/jm58660/sage/local/lib/python2.7/site-packages/flask/app.py", line 
1641, in handle_url_build_error

reraise(exc_type, exc_value, tb)

  File 
"/home/jm58660/sage/local/lib/python2.7/site-packages/flask/helpers.py", 
line 305, in url_for

force_external=external)

  File 
"/home/jm58660/sage/local/lib/python2.7/site-packages/werkzeug/routing.py", 
line 1758, in build


raise BuildError(endpoint, values, method, self)
BuildError: Could not build url for endpoint 'worksheet_publish' with 
values ['id', 'username']. Did you mean 'worksheet.worksheet_publish' 
instead?


I have tried to grep the source, but without help.

 * * *

However, this seems to be documented bug already:

https://github.com/sagemath/sagenb/issues/432

--
Jori Mäntysalo


Re: [sage-devel] RFC: Draft blog post on Sage for Windows

2017-08-31 Thread Jori Mäntysalo

On Thu, 31 Aug 2017, Jeroen Demeyer wrote:

the main problem is that 32-bit Windows applications have a user address 
space limited to just 2 GB (or 3 GB with a special boot flag). This is in 
fact not enough to fit all of Sage into memory at once.


Is this still true by default with PAE enabled?

Do you know how this compares to 32-bit Linux? I would expect a similar limit 
there.


Isn't that just CONFIG_PAGE_OFFSET, which defaults to 3GB, but can be 
changed when configuring kernel before compilation (at least manually, 
I think that make menuconfig has only options for 2 GB and 3 GB)?


--
Jori Mäntysalo

Re: [sage-devel] Re: Random testing for finite lattices

2017-08-30 Thread Jori Mäntysalo

On Wed, 30 Aug 2017, Travis Scrimshaw wrote:


  What if we add tests of, say, random graphs to this file? Or
  should we
  have basically one function in one file?

It doesn't have to necessarily be one function, but I think it would be good
to keep it closer to one specific type of object (at least, I think of
posets as being very different from (random) graphs).


OK. I made this as finite_poset.py, so we can add other poset code here 
too. Later we could have graph.py for both undirected and directed graphs 
and so on.



 I should have said _test_* method, but any method that starts like that
will be run by the TestSuite. See categories/sets_cat.py or
categories/semigroups.py for example.


That seems to a different thing. What I suggest is mostly cross-checking 
over functions: if L.is_distributive() != L.dual().is_distributive(), then 
either is_distributive() is broken or dual() is broken, but we don't know 
which one.


--
Jori Mäntysalo

Re: [sage-devel] Re: Random testing for finite lattices

2017-08-30 Thread Jori Mäntysalo

On Wed, 30 Aug 2017, Travis Scrimshaw wrote:


Looks good (other than call the file something like "lattice_tests.py").


What if we add tests of, say, random graphs to this file? Or should we 
have basically one function in one file?


Now to fully flush it out. Once all the tests are in there, we can see 
how many of them are better lifted to the category of 
FiniteLattticePosets as _tests_* methods.


I think I didn't understood. Categories of posets ja lattices contains 
just few functions. A PoC code?


--
Jori Mäntysalo

Re: [sage-devel] Re: Random testing for finite lattices

2017-08-30 Thread Jori Mäntysalo

On Wed, 30 Aug 2017, Travis Scrimshaw wrote:


  So the use would be something like

  sage: from some.place.tests import test_finite_lattice
  sage: for L in big_list_of_random_lattices:
  sage:     test_finite_lattice(L)
  sage: print("All OK")



Yes, but I would not do the print().


I made https://trac.sagemath.org/ticket/23754 to see if I understood this 
right.



  > This could also be used as a function to run timing benchmarks
  on Sage
  > as well.

  Not really, as some tests take so much more time. But they could
  find a
  bug-like time regression in some specific function

It would have to be done manually (at least at present, there are some
people who are [strongly?] interested in having a benchmark framework for
Sage). However, it still could help.


For a Posets.BooleanLattice(6) it takes 3 milliseconds to see if the 
lattice is modular, and maybe 2 seconds to see if it is isoform. So, if 
running time of is_modular() raises by factor of 10, it would just mean 
that the combined time would raise from 2,003 seconds to 2,030 seconds. 
Hence this is only useful for a) very pathological regression or b) 
smaller regression that happens in some slow function.


--
Jori Mäntysalo

Re: [sage-devel] Re: Random testing for finite lattices

2017-08-30 Thread Jori Mäntysalo

On Wed, 23 Aug 2017, Travis Scrimshaw wrote:


Thank you for doing this. Do you want to add this as a file into the
$SAGE_SRC/sage/tests? How long does it take to run these tests on your
system?



Since they are around 1 second, you could add the test code to our tests folder with one 
to a few "generic" examples
marked with "# long time". That way anyone who wants to run more stress testing 
can easily do so (as opposed to, e.g.,
posting the code on your homepage).


So the use would be something like

sage: from some.place.tests import test_finite_lattice
sage: for L in big_list_of_random_lattices:
sage: test_finite_lattice(L)
sage: print("All OK")

?

This could also be used as a function to run timing benchmarks on Sage 
as well.


Not really, as some tests take so much more time. But they could find a 
bug-like time regression in some specific function -- if something very 
odd happens and for example is_modular() takes a minute instead of few 
milliseconds, it would be noticed.


--
Jori Mäntysalo

Re: [sage-devel] Re: SageNB, publishing and error 500

2017-08-29 Thread Jori Mäntysalo

On Fri, 25 Aug 2017, kcrisman wrote:


But see that 
https://github.com/sagemath/sagenb/commit/7bff646746bfad908a431621eedeb55296594d85
 fixes something similar
to this, I am guessing, based on https://stackoverflow.com/a/25496041/782821   
In
fact, https://github.com/sagemath/sagenb/issues/420 seems very similar indeed.  
So we seem to have forgotten some of
those, somehow.  

Probably one of the instances in /flask_version/worksheet.py - you could check 
in the full error log you are getting.


I tried to read the log and the source code. No help. I guess there is 
something more dynamic going, not something that could be corrected by 
changing href="foo" to href=".foo".


Would be nice if Someone Else(tm) could check this.

--
Jori Mäntysalo

  1   2   3   4   5   6   >