Ask Your Question

JoalHeagney's profile - activity

2019-10-09 10:40:30 +0200 commented answer list_plot generator

I was hoping that list_plot's biggest memory component was just an image, not a dynamic object. I'm assuming this is not true?

2019-10-09 00:09:52 +0200 received badge  Notable Question (source)
2019-10-09 00:02:55 +0200 asked a question list_plot generator

I have created a python generator that yeilds a list of single values (e.g. like [1,971,15,341,..]) up to some defined length of n,and wanted to plot them in sagemath.

When I pass the generator to list_plot, I get an error as list_plot only accepts lists, tuples and dictionaries.

Is there any way to get the list_plot behaviour from a generator without converting to a list first (To memory-hungry for my purpose)?

If not, I'm planning to request an enhancement to list_plot, if at all possible.

2019-02-03 02:25:39 +0200 received badge  Notable Question (source)
2018-12-22 21:47:10 +0200 received badge  Popular Question (source)
2018-12-09 09:06:30 +0200 asked a question Anyone successfully install rdkit into sagmath?

Rdkit is conda-installed and when you use the official installation instructions, the rdkit goes into the miniconda python library rather than the sagemath python. I have been able to get them together by installing both sage and rdkit using conda, except the conda sage is 8.3, not 8.4.

2017-05-27 01:25:21 +0200 commented question How can I install an R package in Sage Cloud?

This is also covered here: [https://ask.sagemath.org/question/100...]

2017-05-27 01:23:03 +0200 commented answer Can't Install R Packages in Sage

I've also found recently that with sage version 7.6, install.packages won't work unless I specifically set method='wget'. This is using a http mirror, but I don't know if that has anything to do with it.

E.g.

install.packages('automap',method='wget')

Otherwise it complains that it doesn't have a version of that package for the version of R included with sagemath.

E.g.

package ‘automap' is not available (for R version 3.2.4 Revised)

2016-06-28 01:45:15 +0200 received badge  Good Question (source)
2016-04-22 00:48:10 +0200 received badge  Popular Question (source)
2014-12-01 06:05:59 +0200 asked a question swap axes in 2d plot

Hi guys. Just playing around with titration curves in water, which is a remarkably difficult problem to do.

Basically I can derive an equation for volume of base versus pH of solution, and plot it.

However, I'd like to swap the x and y axes.

Or do I have to use implicit_plot? :(

2014-11-10 16:44:41 +0200 received badge  Famous Question (source)
2014-06-29 05:24:31 +0200 received badge  Notable Question (source)
2014-06-29 05:24:31 +0200 received badge  Famous Question (source)
2014-06-29 03:15:12 +0200 marked best answer How to dynamically substitute a variable in a callable function?

Hi guys, this is a little problem I came across a week ago.

I'm trying to define a python function that accepts:
1. a callable sage function (of potentially more than one variable) as the first argument (henceforth called func), and
2. a symbolic variable as the second argument (henceforth called xsub)

My function then needs to define a dummy symbolic variable (t), and substitute xsub with t in func.
I can do this for one variable equations in current 4.8 sagemath, by ignoring the new substitution syntax, but it throws up a depreciation warning (Which I'm assuming will become an error in 5.0).

Here's what my code looks like:

def fracintegral(func,xsub,n,a=0):
    var('t')
    assume(x>a)
    assume(t>a)
    return integrate((x-t)^(n-1)*func(t),t,a,x)

The last line should look something like:

    return integrate((x-t)^(n-1)*func(x=t),t,a,x)
in order to avoid Depreciation Warnings, but this hardcodes x as the variable to be substituted. (Useless if my func is a y function.)

If I try:

    return integrate((x-t)^(n-1)*func(xsub=t),t,a,x)

then substitution of func(x=t) doesn't occur (and the integrate function effectively treats func as a constant with respect to dt).

Trying:

    return integrate((x-t)^(n-1)*func.subs(xsub==t),t,a,x)
doesn't work either, same result as func(xsub=t).

So, any idea how a function can accept a symbolic variable, and dynamically substitute out that variable in a callable function?

2014-06-18 03:15:24 +0200 received badge  Popular Question (source)
2014-05-31 15:23:06 +0200 received badge  Self-Learner (source)
2014-05-21 03:31:50 +0200 answered a question xkcd and matplotlib

Okay, finally have most of an answer.

  1. Install Humor-Sans.ttf in ~/.fonts (You may have to rename it).
  2. Under Linux, the .matplotlib directory lives in ~/.sage. cd into it and remove the fontList.cache

  3. Currently, use of constant-value tick_formatters such as pi, e, sqrt(2) will default back to using the normal font - this is unlikely to have a quick solution as the Humor Sans font is missing several mathematical symbols any way.

2014-05-19 20:09:40 +0200 commented answer xkcd and matplotlib

Hi Antlab. Yup, that's the issue that I found. The problem is that I can't find the .matplotlib on my Linux install, either in the home directory, or in the sage directory.

2014-05-13 05:56:43 +0200 asked a question xkcd and matplotlib

Hi guys. Attempting to use the xkcd graphics feature that has been recently added to matplotlib from within sagemath.

import matplotlib.pyplot
matplotlib.pyplot.xkcd()
plot(sin(x),(x,-pi,pi),ticks=pi/4,tick_formatter=pi)

Matplotlib throws the following warning:

/home/joal/bin/sage-6.2/local/lib/python2.7/site-packages/matplotlib-1.3\ .1-py2.7-linux-x86_64.egg/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['Humor Sans', 'Comic Sans MS'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext]))

I have installed Humor Sans.ttf onto the main system, and into the directory:
/home/joal/bin/sage-6.2/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/mpl-data/fonts/

... but don't know how to reset the matplotlib font cache so matplotlib will pay attention to the new font.


[EDIT]

Okay, seem to have part of the solution - need to verify on a Linux machine this weekend.

EDIT of EDIT
The tricks below don't work on LinuxMint.

The font is recognised in the virtualbox image if it is dumped into:
sage-6.2/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/mpl-data/fonts/
and renamed Humor-Sans.ttf

Then you need to create a .matplotlib folder in the user directory.
mkdir ~/.matplotlib

The concern is that it now that Humor Sans is used for text font, but not for the numbers on the horizontal and vertical axes. Any suggestions, sagers?


[EDIT]

Which turns out to be a consequence of using the pi tick_formatter.

2013-12-26 01:56:51 +0200 answered a question What advantages do Tcl/Tk offer while using sage?

On the other hand, if you want to use R packages, there are a few that depend on tcl/tk themselves (not just the download gui). Ggplot2 comes to mind. Whether you will be able to use the tcl/tk interfaces within these libraries is moot, but they definitely won't compile/install without them.

2013-09-17 11:24:45 +0200 received badge  Favorite Question (source)
2013-09-17 08:07:42 +0200 marked best answer How to dynamically substitute a variable in a callable function?

Are you thinking of something like this?

def fracintegral(func,xsub,n,a=0):
    t = var('t')
    assume(x>a)
    assume(t>a)
    return integrate((x-t)^(n-1)*func.subs({xsub:t}),t,a,x)

which gives a deprecation-free

sage: var("x y")
(x, y)
sage: f1 = function("f", x)
sage: fracintegral(f1, x, 4)
-integrate((t - x)^3*f(t), t, 0, x)
sage: f2 = function("f", x, y)
sage: fracintegral(f2, y, 4)
-integrate((t - x)^3*f(x, t), t, 0, x)
sage: f3(x,y) = x^2+sin(y)
sage: fracintegral(f3, y, 4)
(x, y) |--> 1/4*x^6 + x^3 - 6*x + 6*sin(x)
2013-09-17 08:07:39 +0200 received badge  Nice Question (source)
2013-09-16 09:47:10 +0200 received badge  Teacher (source)
2013-09-16 09:47:10 +0200 received badge  Necromancer (source)
2013-09-15 02:37:54 +0200 received badge  Editor (source)
2013-09-15 02:37:09 +0200 answered a question Can't Install R Packages in Sage

I had these issues when first using the binary versions of sagemath. Installing wouldn't work, and the "include directories are empty" message would pop up in sage -R.

Solved it by using the command: sage -fr to force-rebuild the R package. Make sure you have all the build dependencies for libpng, libjpeg, cairo, etc. installed.

Then I could use install.packages("...") from sage -R, the notebook in R mode, or %r-cell mode with no issues.

Now I use a source build/updated version of sage instead.