Ask Your Question

Amri's profile - activity

2024-04-06 19:02:55 +0200 received badge  Notable Question (source)
2023-05-13 09:17:21 +0200 received badge  Notable Question (source)
2022-07-15 06:35:24 +0200 received badge  Famous Question (source)
2022-06-01 10:24:48 +0200 received badge  Notable Question (source)
2022-06-01 10:24:48 +0200 received badge  Popular Question (source)
2022-04-02 02:23:43 +0200 received badge  Popular Question (source)
2021-05-23 06:56:39 +0200 commented answer list of random non-zero elements

Nice answer, however, I would not recommend the use of underscore as a counter in the loop. You will not be able to use

2020-12-28 10:51:15 +0200 received badge  Popular Question (source)
2016-11-26 19:17:38 +0200 received badge  Notable Question (source)
2016-11-26 19:17:38 +0200 received badge  Popular Question (source)
2016-08-30 22:26:04 +0200 received badge  Famous Question (source)
2016-08-30 22:26:04 +0200 received badge  Notable Question (source)
2016-08-30 22:26:04 +0200 received badge  Popular Question (source)
2014-12-03 11:26:15 +0200 commented question Unable to build documentation (ValueError: unknown locale: UTF-8)

I get: LC_ALL LC_CTYPE UTF-8 LANG en_IN LANGUAGE en_IN:en

I am using ubuntu 14.04 LTS

2014-12-03 08:13:52 +0200 asked a question Unable to build documentation (ValueError: unknown locale: UTF-8)

When I try to build the sage documentation I get an error. What am I doing wrong? The same error appears when I try

make doc-clean && make

Here is a transcript:

amri@as154:~/sage$ sage -docbuild
Traceback (most recent call last):
  File "/home/amri/sage/src/doc/common/builder.py", line 16, in <module>
    import sphinx.cmdline
  File "/home/amri/sage/local/lib/python2.7/site-packages/Sphinx-1.2.2-py2.7.egg/sphinx/cmdline.py", line 18, in <module>
    from docutils.utils import SystemMessage
  File "/home/amri/sage/local/lib/python2.7/site-packages/docutils/utils/__init__.py", line 20, in <module>
    import docutils.io
  File "/home/amri/sage/local/lib/python2.7/site-packages/docutils/io.py", line 18, in <module>
    from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
  File "/home/amri/sage/local/lib/python2.7/site-packages/docutils/utils/error_reporting.py", line 47, in <module>
    locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
  File "/home/amri/sage/local/lib/python/locale.py", line 543, in getdefaultlocale
    return _parse_localename(localename)
  File "/home/amri/sage/local/lib/python/locale.py", line 475, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
2014-10-31 17:56:08 +0200 commented answer Trouble importing groups from GAP

@vdelecroix Thanks. Am I correct in concluding that wrapping them to Sage objects in such a way that all the methods work uniformly will require quite a bit of work?

2014-10-29 19:25:52 +0200 commented answer Trouble importing groups from GAP

Thanks. So there is no easy way to iterate over isomorphism classes of groups of a given order? I don't really care about their actions. I just need access to methods like centralizer and conjugacy_classes.

2014-10-29 09:22:29 +0200 asked a question Trouble importing groups from GAP

I would like to use groups from the GAP library in Sage; something like:

sage: L = gap.AllGroups(16)
sage: G = PermutationGroup(gap_group = L[1])

and use G in my sage code. But I must be doing something wrong, becuase I get:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-32-14053049143a> in <module>()
----> 1 G = PermutationGroup(gap_group = L[Integer(1)])

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/groups/perm_gps/permgroup.pyc in PermutationGroup(gens, gap_group, domain, canonicalize, category)
    335         raise TypeError("gens must be a tuple, list, or GapElement")
    336     return PermutationGroup_generic(gens=gens, gap_group=gap_group, domain=domain,
--> 337                                     canonicalize=canonicalize, category=category)
    338 
    339 

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/groups/perm_gps/permgroup.pyc in __init__(self, gens, gap_group, canonicalize, domain, category)
    404 
    405         if domain is None:
--> 406             gens = [standardize_generator(x) for x in gens]
    407             domain = set()
    408             for x in gens:

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/groups/perm_gps/permgroup_element.so in sage.groups.perm_gps.permgroup_element.standardize_generator (build/cythonized/sage/groups/perm_gps/permgroup_element.c:3761)()

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/groups/perm_gps/permgroup_element.so in sage.groups.perm_gps.permgroup_element.string_to_tuples (build/cythonized/sage/groups/perm_gps/permgroup_element.c:3362)()

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/misc/sage_eval.pyc in sage_eval(source, locals, cmds, preparse)
    197         return locals['_sage_eval_returnval_']
    198     else:
--> 199         return eval(source, sage.all.__dict__, locals)
    200 
    201 

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/all.pyc in <module>()

NameError: name 'f1' is not defined

What is the correct way to do this?

2014-09-01 15:51:17 +0200 received badge  Nice Question (source)
2014-08-20 08:41:01 +0200 received badge  Organizer (source)
2014-08-20 08:20:47 +0200 answered a question Checklist for submitting a patch to trac

This answer is community wiki; please add your points here (please provide commands/links on how to do this)

  1. run doctests (sage -t filename.py)
  2. build and check documentation (sage -docbuild all html)
  3. add your name to list of authors
2014-08-20 08:17:58 +0200 asked a question Checklist for submitting a patch to trac

I would like to create a checklist that one should go through before submitting a patch to the trac server:

What are the points to be checked before submitting a patch to the trac server?

2014-08-19 12:45:06 +0200 received badge  Student (source)
2014-08-19 07:00:53 +0200 asked a question Trouble building documentation with the development version of Sage

When I run

sage -docbuild reference/groups html

I get

Deleting empty directory /home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/common/static
Deleting empty directory /home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/en/reference/graphs/static
Deleting empty directory /home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/en/reference/graphs/templates
[groups   ] WARNING: intersphinx inventory '/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/output/html/en/reference/game_theory/objects.inv' not fetchable due to <type 'exceptions.IOError'>: [Errno 2] No such file or directory: '/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/output/html/en/reference/game_theory/objects.inv'
[groups   ] WARNING: intersphinx inventory '/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/output/html/en/reference/modfrm_hecketriangle/objects.inv' not fetchable due to <type 'exceptions.IOError'>: [Errno 2] No such file or directory: '/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/output/html/en/reference/modfrm_hecketriangle/objects.inv'
[groups   ] WARNING: intersphinx inventory '/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/output/html/en/reference/repl/objects.inv' not fetchable due to <type 'exceptions.IOError'>: [Errno 2] No such file or directory: '/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/output/html/en/reference/repl/objects.inv'
[groups   ] WARNING: intersphinx inventory '/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/output/html/en/reference/quivers/objects.inv' not fetchable due to <type 'exceptions.IOError'>: [Errno 2] No such file or directory: '/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/output/html/en/reference/quivers/objects.inv'
Error building the documentation.

Note: incremental documentation builds sometimes cause spurious
error messages. To be certain that these are real errors, run
"make doc-clean" first and try again.
Traceback (most recent call last):
  File "/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/common/builder.py", line 1490, in <module>
    getattr(get_builder(name), type)()
  File "/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/common/builder.py", line 714, in _wrapper
    getattr(DocBuilder, build_type)(self, *args, **kwds)
  File "/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/common/builder.py", line 109, in f
    execfile(sys.argv[0])
  File "/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/common/custom-sphinx-build.py", line 210, in <module>
    raise OSError(ERROR_MESSAGE)
OSError: [groups   ] WARNING: intersphinx inventory '/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/output/html/en/reference/game_theory/objects.inv' not fetchable due to <type 'exceptions.IOError'>: [Errno 2] No such file or directory: '/home/amri/myfiles/myfiles/sage-6.0-i686-Linux/src/doc/output/html/en/reference/game_theory/objects.inv'

When I try

make doc-clean

I get

make: *** No rule to make target `doc-clean'.  Stop.

Can someone explain what the problem is, and how to get around it? This was on a clean installation of 6.4.beta0

2014-06-29 03:15:35 +0200 marked best answer How to get a Boolean from the type of an object?

I am trying to define the __init__ of a class, where I would like to support different types of input; in my case the input could be a either a list of pairs or a matrix. How do I write a Boolean function to test which kind of input I have? In the example code, I want to know how I should define the Boolean functions is_a_matrix(A) and is_a_tuple_of_pairs(A) (and of course more generally testing A to be of some other type)

class someclass():
    def __init__(self, A):
        if is_a_matrix(A):
            self._matrix = A
        if is_a_tuple_of_pairs(A):
            self._matrix = somefunction(A)
2013-04-20 09:26:51 +0200 commented question Generating a unique file name for each graph

@fidelbc Thanks for the comments, and bringing MongoDB to my attention.

2013-04-19 06:37:00 +0200 marked best answer Generating a unique file name for each graph

The set of graphs Sage can produce is virtually infinite (depends on your RAM), whereas a hash is a uniformly bounded number. Hence there can not be an injection between them (see e.g. wikipedia).

However, a hash function is assumed to be quite "mixing", so that the probability to get a collision is close to the estimation given by the birthday paradox (see e.g. wikipedia). Hence, unless your graph database is very huge, you can consider that you won't get a collision (or that the number of useless recalculations will be very small).

That said, especially for simple graphs with less than 262143 vertices, there is a compact ASCII representation (which is injective), given by the method .graph6_string():

sage: G = graphs.PetersenGraph()
sage: G.graph6_string()
'IheA@GUAo'

The hash method seems faster.

2013-04-19 06:36:57 +0200 commented answer Generating a unique file name for each graph

Thanks. This was both enlightening and useful.

2013-04-19 05:53:44 +0200 received badge  Editor (source)
2013-04-19 05:52:38 +0200 asked a question Generating a unique file name for each graph

I am writing a function whose input is a graph and some other data. I would like to store the computations that this program does each time it is run in a file with one file for each graph, so that, the next time it is run, it need not recalculate the calculations it has already done. In order to do this, I would like to assign a unique file name to each graph. I was thinking of using the hash function of the combinatorial object constructed from the graph to generate file names: CombinatorialObject(G).__hash__()

I have two questions:

  1. Will this always work (the function taking a graph to this hash is well-defined and injective)?

  2. Is there a better way to do this?

2013-03-26 02:15:40 +0200 marked best answer How to get a Boolean from the type of an object?

For matrices, I don't know, this is a complex topic in Sage. For tuples of pairs, this is pure Python, and I suggest:

def is_a_pair(a):
    return isinstance(a,tuple) and len(a)==2
def is_a_tuple_of_pairs(A):
    if not isinstance(A,tuple):
        return False
    return all (is_a_pair(a) for a in A)

Note that if you accept lists in addition to tuples, you can use:

isinstance(a,(list,tuple))

inside these functions and so on.

2013-03-26 02:15:40 +0200 received badge  Scholar (source)