ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 23 Feb 2021 23:40:29 +0100How to make Sage use OpenSSL installed in /opt/local/{bin, lib,include}https://ask.sagemath.org/question/54790/how-to-make-sage-use-openssl-installed-in-optlocalbin-libinclude/MacOS Catalina 10.15.7. Seemingly no way to get Sage binary to recognize installed OpenSSL (I'm not taking about the screwed-up version of LibreSSL that MacOS is coming with now).
I have Python3{7,8,9} installed in /opt/local via Macports. OpenSSL-1.1.1i installed the same way (/opt/local). Everything works fine.
How do I get Sage to **use** the packages already installed, instead of, e.g., downloading its own copy of Python?
Barring that, what do I need to download to build Sage.app from sources, so it can link with a normal OpenSSL, and maybe use a normal Python?MouseMon, 21 Dec 2020 03:04:33 +0100https://ask.sagemath.org/question/54790/Python kernel seriously slower than SageMath kernelhttps://ask.sagemath.org/question/55851/python-kernel-seriously-slower-than-sagemath-kernel/Hi, I just found the Python kernel is seriously slower than the SageMath one.
This was the snippet to reproduce:
# intersection profiling with Python session
from sage.all import *
def run(num):
cube = (polytopes.cube() * 37 / 45).change_ring(QQ)
for i in range(num):
hspace = Polyhedron(ieqs=[[1/2, 1/(i+1), 0, 0]]).change_ring(QQ)
intersection = hspace.intersection(cube)
%timeit run(100)
The timing for SageMath kernel is `1 loop, best of 5: 186 ms per loop`, while that for Python is `1 loop, best of 5: 7.07 s per loop`. With this snippet I think no variable was cached. I also cprofiled a stand-alone .py file with the same lines (expect the `%timeit` line), whose timing is close to the Python kernel. Any idea what could cause this huge performance difference?
[Image which kernel to use](https://ibb.co/DYg6f7F)zhaiyuTue, 23 Feb 2021 23:40:29 +0100https://ask.sagemath.org/question/55851/How can you import C++ code into a Jupyter notebook?https://ask.sagemath.org/question/49922/how-can-you-import-c-code-into-a-jupyter-notebook/ I have a c++ function that I would like to use with Jupyter. I'd like to be able to call it from the main python thread. A minimal example would be something like the following:
#begin c code definition
#include <vector>
#include <iostream>
void printout(std::vector<int> input){
std::vector<int>::iterator start;
std::vector<int>::iterator end;
end=input.end();
for (start=input.begin();start!=end;++start){
std::cout<< *start;
}
std::cout<< std::endl;
}
int main(){
std::vector<int> sample{1,2,3};
printout(sample);
return 0;
}
#switch back to python
printout((1,2,3))
I don't particularly need to call the function or run the main thread in C++, the main() is included to show how this function would be used in the C++ context. Broadly, I want something like the reverse of CythonizejdoolittFri, 14 Feb 2020 16:58:02 +0100https://ask.sagemath.org/question/49922/import CSV in python using jupyter notebook on cocalc cloudhttps://ask.sagemath.org/question/38546/import-csv-in-python-using-jupyter-notebook-on-cocalc-cloud/I want to import this [CVS file](https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data) in my python script with the commands:
url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']
dataset = pandas.read_csv(url, names=names)
The problem is that it returns this error message:
---------------------------------------------------------------------------
URLError Traceback (most recent call last)
<ipython-input-21-45b1e7974739> in <module>()
32 url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
33 names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']
---> 34 dataset = pandas.read_csv(url, names=names)
/projects/sage/sage-7.6/local/lib/python2.7/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
653 skip_blank_lines=skip_blank_lines)
654
--> 655 return _read(filepath_or_buffer, kwds)
656
657 parser_f.__name__ = name
/projects/sage/sage-7.6/local/lib/python2.7/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
390 compression = _infer_compression(filepath_or_buffer, compression)
391 filepath_or_buffer, _, compression = get_filepath_or_buffer(
--> 392 filepath_or_buffer, encoding, compression)
393 kwds['compression'] = compression
394
/projects/sage/sage-7.6/local/lib/python2.7/site-packages/pandas/io/common.py in get_filepath_or_buffer(filepath_or_buffer, encoding, compression)
184 if _is_url(filepath_or_buffer):
185 url = str(filepath_or_buffer)
--> 186 req = _urlopen(url)
187 content_encoding = req.headers.get('Content-Encoding', None)
188 if content_encoding == 'gzip':
/projects/sage/sage-7.6/local/lib/python/urllib2.pyc in urlopen(url, data, timeout, cafile, capath, cadefault, context)
152 else:
153 opener = _opener
--> 154 return opener.open(url, data, timeout)
155
156 def install_opener(opener):
/projects/sage/sage-7.6/local/lib/python/urllib2.pyc in open(self, fullurl, data, timeout)
427 req = meth(req)
428
--> 429 response = self._open(req, data)
430
431 # post-process response
/projects/sage/sage-7.6/local/lib/python/urllib2.pyc in _open(self, req, data)
445 protocol = req.get_type()
446 result = self._call_chain(self.handle_open, protocol, protocol +
--> 447 '_open', req)
448 if result:
449 return result
/projects/sage/sage-7.6/local/lib/python/urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
405 func = getattr(handler, meth_name)
406
--> 407 result = func(*args)
408 if result is not None:
409 return result
/projects/sage/sage-7.6/local/lib/python/urllib2.pyc in https_open(self, req)
1239 def https_open(self, req):
1240 return self.do_open(httplib.HTTPSConnection, req,
-> 1241 context=self._context)
1242
1243 https_request = AbstractHTTPHandler.do_request_
/projects/sage/sage-7.6/local/lib/python/urllib2.pyc in do_open(self, http_class, req, **http_conn_args)
1196 except socket.error, err: # XXX what error?
1197 h.close()
-> 1198 raise URLError(err)
1199 else:
1200 try:
URLError: <urlopen error [Errno 110] Connection timed out>
What's the problem?
How could I solve?
I use a free account on CoCalc.
If it takes time to upload and so not enough for my free account, how I can upload the file as worksheet and link it? What will be the link in the URL specification?
ThankspspWed, 16 Aug 2017 16:40:27 +0200https://ask.sagemath.org/question/38546/python 2 kernel keeps dyinghttps://ask.sagemath.org/question/37544/python-2-kernel-keeps-dying/ I have SageMath 7.3 installed from binaries and 7.6 compiled from source on my debian linux system, but in both, the python 2 kernel keeps dying when I use it in jupyter. It just dies, restarts, dies etc., making it entirely unusable. Did anyone experience this problem before? What could I do to get it to run? Thanks for your help!stanTue, 09 May 2017 09:01:26 +0200https://ask.sagemath.org/question/37544/