Ask Your Question

paragon's profile - activity

2021-01-11 13:43:40 +0200 received badge  Popular Question (source)
2020-09-05 01:03:34 +0200 received badge  Popular Question (source)
2020-04-12 16:55:35 +0200 received badge  Taxonomist
2019-06-25 22:16:15 +0200 received badge  Notable Question (source)
2018-09-08 00:39:43 +0200 received badge  Good Question (source)
2018-06-25 16:50:19 +0200 received badge  Famous Question (source)
2018-03-06 17:14:33 +0200 received badge  Notable Question (source)
2018-01-27 20:25:33 +0200 received badge  Famous Question (source)
2018-01-17 11:06:46 +0200 received badge  Popular Question (source)
2017-09-18 01:47:44 +0200 received badge  Nice Question (source)
2017-09-12 18:52:48 +0200 commented answer Sage pip not compatible with PyPI

I'm using a MacBook with OS X 10.12.5. Apparently it doesn't come with SSL support: https://github.com/saghul/pythonz/iss.... I have now installed opensll and rebuild sage 8.0. I still get the same error. At least I know that it is a problem with my computer and not with sage.

2017-09-07 22:20:02 +0200 received badge  Commentator
2017-09-07 22:20:02 +0200 commented answer Sage pip not compatible with PyPI

Thank you! This is what I was hoping for. But unfortunately it didn't fix the problem (see edit).

2017-09-07 07:13:34 +0200 asked a question Sage pip not compatible with PyPI

I want to make a PyPI package for sage, similar to

https://pypi.python.org/pypi/darmonpo...

or

https://pypi.python.org/pypi/surface_...

that can be installed by anyone by typing one line. But trying these out, the installation instructions don't work! I get an error:

$~/SageMath/sage -pip install surface_dynamics
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting surface_dynamics
  Could not fetch URL https://pypi.python.org/simple/surface-dynamics/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not find a version that satisfies the requirement surface_dynamics (from versions: )
No matching distribution found for surface_dynamics

I believe that it is because sage is using pip 8.x, and a later version is required for PyPI. If I try installing surface_dynamics with using pip 9.01, it downloads it (but gives an error later because it is not in sage), so I do think the version is a problem.

I just updated to sage 8.0. Is this planning to be fixed soon? If there is a workaround for me, I guess that is nice, but it defeats the purpose of getting my code hosted on PyPI if I still have to give the users complicated instructions.

Or maybe my sage installation is broken? Do others get the same error?

EDIT: In light of eric_g's answer, I tried installing the developer version of 8.1. Indeed the sage pip is now 9.01, but the same error persists. So I guess my theory about the versions is wrong. It must be something else funny with the sage pip?

2017-08-24 08:45:53 +0200 commented answer Should I / how should I make an optional sage package?

This looks like it might be a good way to go if I can figure it out.

2017-08-23 12:37:22 +0200 received badge  Nice Question (source)
2017-08-22 22:49:01 +0200 asked a question Should I / how should I make an optional sage package?

I've written some code in sage that implements the strata algebra of the moduli spaces of curves as a sage ring. I hope it will be useful to others. I think that a good way to share it would be to make it an optional, (or perhaps experimental?) sage package.

Is this a good thing to do?

If so, what are the steps?

My code is all in .sage files, but I could easily turn it into .py files if that is better.

2017-04-29 01:04:19 +0200 received badge  Popular Question (source)
2017-04-28 22:42:00 +0200 asked a question Power series with coeffs in SymmetricFunctions()

The following gives an error:

sym = SymmetricFunctions(QQ)
R.<t> = PowerSeriesRing(sym)

saying that base_ring is not a commutative ring. I can check sym.categories(), and indeed it is not, but I think it should be. Is there an easy way to make this work?

Thanks!

2017-04-05 20:08:51 +0200 commented answer How to extract exponents from a monomial in a FreeAlgebra

Perfect! It is hidden pretty deep, I would not have found that.

2017-04-05 01:37:03 +0200 asked a question How to extra exponents from a FreeAlgebra element

I want something like this, or a way to get the equivalent information:

sage: S.<X,Y> = FreeAlgebra(QQ)
sage: m = X*Y*X^2
sage: m.my_exponents_function()
[(X,1),(Y,1),(X,2)]

or

sage: m.my_factor_function()
[X,Y,X,X]

would be as good or maybe better.

How can I get that information? I've looked over the available methods and can't seem to find anything. This is easy to do with Polynomial Rings.

I guess I could parse the string representation, but shouldn't there be a better way?

2017-04-05 01:34:43 +0200 asked a question How to extract exponents from a monomial in a FreeAlgebra

I want something like this, or a way to get the equivalent information:

sage: S.<X,Y> = FreeAlgebra(QQ)
sage: m = X*Y*X^2
sage: m.my_exponents_function()
[(X,1),(Y,1),(X,2)]

or

sage: m.my_factor_function()
[X,Y,X,X]

would be as good or maybe better.

How can I get that information? I've looked over the available methods and can't seem to find anything. This is easy to do with Polynomial Rings.

I guess I could parse the string representation, but shouldn't there be a better way?

2017-03-20 13:07:55 +0200 received badge  Popular Question (source)
2017-02-13 20:56:50 +0200 received badge  Famous Question (source)
2015-11-29 23:19:53 +0200 received badge  Famous Question (source)
2014-06-29 03:15:15 +0200 marked best answer How to get a list of monomials of a given degree

Is there a nice way to get all monomials of a given degree in a multivariable polynomial ring?

For example I want to input x,y,3 and get

x^3, x^2y, xy^2, y^3.

I think I could code it myself with not too much work, but it seems like something that might already have a nice method.

2014-06-29 03:14:51 +0200 marked best answer Cannot convert int to sage.rings.integer.Integer

I created a minimal example in the file bad.py

from sage.all import *

j = 0
m = matrix(3,3)
m.insert_row(j, [1,1,1])

Then from sage:

sage: load bad.py
TypeError: Cannot convert int to sage.rings.integer.Integer

I think I can see an easy workaround, I can wrap all the 1's in Integer() (or change the name of the file to .sage so the preparser does it), but why is that necessary? Is this a bug? Why would sage not be able to convert int to Integer? Isn't that a pretty obvious conversion?

2014-06-29 03:14:49 +0200 marked best answer how to organize multifile project

I am working on a project to do some computations for a specialized theory. Currently, we have several files that define different objects that have various dependencies on each other. Currently, I have a file named "attachall.sage" that looks like

attach "poly.sage"

attach "util2.sage"

attach "quasihomogeneous.sage"

attach "FJRW.sage"

attach "algebra.sage"

etc. Then when I want to do some computations, I do

sage: load attachall.sage

sage: #do stuff with the objects

It works fine, I guess, but doesn't seem particularly clean-- it seems like there should be a preferred way to do this. Should I use python's import? But then I would have to re-preparse every time I changed the source, and have potentially annoying bugs if someone forgot to re-preparse after changing a file. Or should I look into making a spkg? I don't really know a lot about that and I'd like to keep it simple.

Eventually we'd like to be able to share this code with other groups.

Does anyone have any thoughts?

2013-10-09 11:00:36 +0200 received badge  Notable Question (source)
2013-08-17 02:43:46 +0200 received badge  Popular Question (source)
2013-08-12 18:20:49 +0200 marked best answer injecting names into global namespace doesn't work with doctest

sage.misc.misc.inject_variable might be your friend.

2013-08-12 18:20:45 +0200 commented answer injecting names into global namespace doesn't work with doctest

Thank you! It is my friend!

2013-08-12 17:39:10 +0200 asked a question injecting names into global namespace doesn't work with doctest

Here is a minimal example of the problem I am running into. I have a file "MyClass.py":

class MyClass(object):
    def __init__(self,subscript):
        self.subscript = subscript

    def __repr__(self):
        return "MyClass " + str(self.subscript)

def make_MyClass(n):
    """
    Creates n MyClass instances and assigns them to to variables A0, ..., A(n-1).

    Examples::

        sage: make_MyClass(3)
        sage: A0
        MyClass 0
        sage: A2
        MyClass 2
        sage: A1.subscript
        1
    """
    for i in range(n):
        globals()["A" + str(i)] = MyClass(i)

If I doctest it, I get NameError: name 'A0' is not defined, but if I just load the file and type in the commands, it works how I want it to. It must be something about how globals() interacts with doctest.

I know it is possible to make this work, because for example the function var does something like this. I tried looking at the var.pyx source, but it looks like they are doing the same thing as me. (There is a comment about globals() being the reason that it had to be Cython. I tried making the example above a pyx, but that didn't seem to help.)

2013-07-17 00:37:36 +0200 received badge  Notable Question (source)
2013-03-10 21:21:03 +0200 received badge  Notable Question (source)
2012-12-05 11:07:33 +0200 received badge  Popular Question (source)
2012-09-20 13:19:47 +0200 marked best answer how to organize multifile project

I think if the source files are still changing, then staying with attach seems like a good idea. Once the source is stable, you can import everything using python's import -- to get this to work you just need a blank file __init__.py, and a file all.py listing what to import (maybe you don't need every function from every file). Taking a look at subdirectories of the Sage development directory will make this obvious. And you can also take a look at the python modules reference if you want, although it doesn't quite agree with what Sage seems to be doing.

In the meantime, the following will also work to attach all the .sage files in the current directory (although I don't really think it's much better than what you've been doing):

import glob
to_attach = glob.glob('./*.sage')
for f in to_attach:
    attach(f)