-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are methods from calcium available in python-flint 0.5.x? #126
Comments
Instead of |
It would definitely be good to add calcium wrappers in pytho-flint if anyone is interested in working on that. |
I am not sure if this helps me. I had a simple method written for the GAP system which turns Cyclotomic numbers into LaTeX expressions with the help of Calcium: PYTHONPATH := Filename(DirectoriesSystemPrograms(), "python3");
PYCALCIUM_DIRECTORY := Directory("~/Repositories/calcium/pycalcium"); # 0.4.0
InstallGlobalFunction(LaTeXStringCyclotomic, function (q)
local input, str, output, pycode;
input := InputTextString(String(q));
str := "";
output := OutputTextString(str, true);
pycode := "import sys; from pyca import qqbar,Exp,Pi,I;";
pycode := Concatenation(pycode, "E = lambda n: Exp(2*Pi*I/n);");
pycode := Concatenation(pycode, "print(qqbar(eval(sys.stdin.read().replace('^', '**'))).fexpr().latex(), end='')");
Process( PYCALCIUM_DIRECTORY, PYTHONPATH, input, output, [ "-c", pycode ] );
return str;
end); which can be used as following in GAP:
|
This works:
More directly, you could do:
|
@fredrik-johansson Thanks for your help. Yes, this works as expected with Flint 3.1.0 without python-flint: I have updated my GAP code accordingly: PYTHONPATH := Filename(DirectoriesSystemPrograms(), "python3");
PYTHON_FLINT3_DIRECTORY := Directory("~/Repositories/flint-3.1.0/src/python");
InstallGlobalFunction(LaTeXStringCyclotomic, function (q)
local input, str, output, pycode;
input := InputTextString(String(q));
str := "";
output := OutputTextString(str, true);
pycode := "import sys; from flint_ctypes import *;";
pycode := Concatenation(pycode, "E = lambda n: (qqbar(2) / n).exp_pi_i();");
pycode := Concatenation(pycode, "print(qqbar(eval(sys.stdin.read().replace('^', '**'))).fexpr().latex(), end='')");
Process( PYTHON_FLINT3_DIRECTORY, PYTHONPATH, input, output, [ "-c", pycode ] );
return str;
end); Should I close this issue? |
Looks like there is no other open issue about wrapping calcium in python-flint, so may as well leave it open if you don't mind! |
On the current main branch and also the 0.7.0a5 prerelease there is some very limited access to calcium via the newly added generic rings module: In [10]: from flint.types import _gr
In [11]: CA = _gr.gr_complex_ca_ctx.new()
In [12]: CA(2).sqrt() + 1
Out[12]: 2.41421 {a+1 where a = 1.41421 [a^2-2=0]}
In [13]: pi = CA('pi')
In [14]: pi**2 - 1
Out[14]: 8.86960 {a^2-1 where a = 3.14159 [Pi]} This is very incomplete and not well tested though. Also I would expect the interface to change in future. Also the documentation for python-flint has been updated here: |
I have used Calcium 0.4 and its python interface pycalcium/pyca.
Now it does not work anymore since macOS homebrew updated my Flint installation from 2.x to 3.x to which it was linked.
Since the documentation of Flint 3 says Arb and Calcium are merged into Flint, maybe the Python wrapper for Calcium has been merged into python-flint.
I have installed the current release of python-flint to pypi and try to see if I can access methods from Calcium
But I am struggling to check this.
The documentation of python-flint does not seem to be updated since the merge of Arb and Calcium into Flint:
https://fredrikj.net/python-flint/ (says version 0.3.0 from 2018)
The text was updated successfully, but these errors were encountered: