sage

An algorithm for randomly generating integer partitions of a particular length, in Python?

放肆的年华 提交于 2019-11-30 05:27:30
问题 I've been using the random_element() function provided by SAGE to generate random integer partitions for a given integer ( N ) that are a particular length ( S ). I'm trying to generate unbiased random samples from the set of all partitions for given values of N and S . SAGE's function quickly returns random partitions for N (i.e. Partitions(N).random_element() ). However, it slows immensely when adding S (i.e. Partitions(N,length=S).random_element() ). Likewise, filtering out random

武汉光迅科技Java笔试题

谁说胖子不能爱 提交于 2019-11-29 16:59:48
1.Java中的override和overload的区别? override(重写):指子类继承父类,重写父类中的方法。 overload(重载):指用一个类中,方法名相同,传参个数不同、参数类型不同、传参顺序不同的方法,与方法返回类型无关。 2.什么是值传递什么是引用传递? 值传递 :传递的是存储单元中的内容,而非地址或者引用! 引用传递 :引用传递是指在调用函数时将实际参数的地址传递到函数中,那么在函数中对参数所进行的修改,将影响到实际参数。 Java中只有按值传递,没有按引用传递! 3.创建线程有几种方式?你喜欢哪一种,为什么? 创建线程有三种方法: 1.继承Thread类,重写run方法; 2.实现Runnable的方法; 3.使用ExecutorService、Callable、Future实现有返回结果的多线程; 但多数时间我们实现Runnable,因为java支持多实现,但不支持多继承。 4.ES是什么?简述他的优点。 ES(Elasticsearch)是一个基于Lucene的搜索服务器。 ES是分布式的不需要其他组件,分发是实时的; ES实时搜索非常快; ES处理多租户不需要特殊配置,学习成本较低; 5.简述你所知道的mysql的分库分表方案? 垂直拆分 垂直分表 也就是“大表拆小表”,基于列字段进行的。一般是表中的字段较多,将不常用的, 数据较大,长度较长

iPython: Manipulate-like command

梦想与她 提交于 2019-11-29 00:56:26
问题 In Wolfram Mathematica, I can interactively modify the value of a parameter by using the Manipulate[] command. For example, Manipulate[n, {n, 1, 20}] shows a slider through which is possible to vary the value of n . Is there any simple way (i.e. something like a magic or a decorator, like in SAGE) to achieve the same result in the IPython notebook? 回答1: Update This was added in IPython 2.0 (released Apr 1, 2014), it's called Interactive Widgets and works in web notebooks. Original answer This

Launch Pycharm from command line (terminal)

家住魔仙堡 提交于 2019-11-28 08:00:34
I want to try out PyCharm for sage mathematics development. Normally I run eclipse to do sage development, but now I want to try it with PyCharm. To launch eclipse with sage environment variables, in command line I normally do the following: sage -sh cd /path/to/eclipse ./eclipse The first line loads the sage environment variables, the remainder launches eclipse. How can I do the same thing for pyCharm? (note I am using a Mac and Ubuntu for sage development; the commands above are agnostic to both OSes) Link 1 is close to the solution I am looking for, however I cannot find a pyCharm.sh

SciPy Create 2D Polygon Mask

自作多情 提交于 2019-11-27 06:41:10
I need to create a numpy 2D array which represents a binary mask of a polygon, using standard Python packages. input: polygon vertices, image dimensions output: binary mask of polygon (numpy 2D array) (Larger context: I want to get the distance transform of this polygon using scipy.ndimage.morphology.distance_transform_edt.) Can anyone show me how to do this? The answer turns out to be quite simple: import numpy from PIL import Image, ImageDraw # polygon = [(x1,y1),(x2,y2),...] or [x1,y1,x2,y2,...] # width = ? # height = ? img = Image.new('L', (width, height), 0) ImageDraw.Draw(img).polygon

Launch Pycharm from command line (terminal)

允我心安 提交于 2019-11-27 05:46:35
问题 I want to try out PyCharm for sage mathematics development. Normally I run eclipse to do sage development, but now I want to try it with PyCharm. To launch eclipse with sage environment variables, in command line I normally do the following: sage -sh cd /path/to/eclipse ./eclipse The first line loads the sage environment variables, the remainder launches eclipse. How can I do the same thing for pyCharm? (note I am using a Mac and Ubuntu for sage development; the commands above are agnostic to

SciPy Create 2D Polygon Mask

与世无争的帅哥 提交于 2019-11-26 12:06:52
问题 I need to create a numpy 2D array which represents a binary mask of a polygon, using standard Python packages. input: polygon vertices, image dimensions output: binary mask of polygon (numpy 2D array) (Larger context: I want to get the distance transform of this polygon using scipy.ndimage.morphology.distance_transform_edt.) Can anyone show me how to do this? 回答1: The answer turns out to be quite simple: import numpy from PIL import Image, ImageDraw # polygon = [(x1,y1),(x2,y2),...] or [x1,y1

实验三:数据更新和视图操作

大城市里の小女人 提交于 2019-11-26 06:40:35
1.创建表student create table student( sno varchar2(20) primary key, sname varchar2(20), ssex varchar2(10), sdept varchar2(20), sage number ); 2.将一个新学生元组插入到表 student (学号:200815128;姓名:陈冬;性别:男;所在系:计算机学院;年龄:18 岁) insert into student(sno, sname, ssex, sdept, sage) values('200815128', '李东', '男', '计算机学院', 18); 3.创建表dept_sage create table dept_sage( sdept varchar2(20), avg_age number ); 4.计算学生的平均年龄,插入dept_sage表 insert into dept_sage(sdept, avg_age) select sdept, avg(sage) from student group by sdept; 5.将学生 200815128 的年龄改为 22 岁 update student set sage = 22 where sno = '200815128'; 6.创建表sc create table sc(