ipython

How to display a graph in ipython notebook

耗尽温柔 提交于 2021-02-04 17:51:07
问题 Trying to do some plotting in SymPy - As per this video I have written : from sympy.plotting import plot, plot_parametric e = sin(2*sin(x**3)) plot(e, (x, 0, 5)); But after evaling that cell I don't get any output? There isn't an error or anything, it just doesn't display anything. Another test : from sympy import * from sympy.plotting import plot, plot_parametric import math import numpy as np import pandas as pd import matplotlib.pyplot as plt expr = x**2 + sqrt(3)*x - Rational(1, 3) lf =

Nature盘点:从Fortran、arXiv到AlexNet,这些代码改变了科学界

落爺英雄遲暮 提交于 2021-02-04 17:48:41
点击上方“ 迈微AI研习社 ”,选择“ 星标★ ”公众号 重磅干货,第一时间送达 从 Fortran 编译器到 arXiv 预印本库、AlexNet,这些计算机代码和平台改变了科学界。 2019 年,「事件视界望远镜」团队拍下了第一张黑洞照片。这张照片并非传统意义上的照片,而是计算得来的——将美国、墨西哥、智利、西班牙和南极多台射电望远镜捕捉到的数据进行数学转换。该团队公开了所用代码,使科学社区可以看到,并基于此做进一步的探索。 而这逐渐成为一种普遍模式。从天文学到动物学,每一个伟大的现代科学发现背后都有计算机的身影。斯坦福大学计算生物学家、2013 年诺贝尔化学奖获得主 Michael Levitt 表示,现在的笔记本电脑在内存和时钟速度方面是 1967 年其实验室计算机的一万倍。「今天,我们拥有大量算力。但问题是,这仍然需要人类的思考。」 如果没有能够处理研究问题的软件以及知道如何编写和使用软件的研究人员,计算机再强大也是无用。「现在的研究与软件紧密相关,软件已经渗透到科研的方方面面。」软件可持续性研究所(Software Sustainability Institute)负责人 Neil Chue Hong 如是说。 最近,Nature 上的一篇文章试图揭示科学发现背后的重要代码,正是它们在过去几十年中改变了科研领域。这篇文章介绍了对科学界带来重大影响的十个软件工具

Nature盘点:从Fortran、arXiv到AlexNet,这些代码改变了科学界

泪湿孤枕 提交于 2021-02-04 14:17:51
点击上方“ 迈微AI研习社 ”,选择“ 星标★ ”公众号 重磅干货,第一时间送达 从 Fortran 编译器到 arXiv 预印本库、AlexNet,这些计算机代码和平台改变了科学界。 2019 年,「事件视界望远镜」团队拍下了第一张黑洞照片。这张照片并非传统意义上的照片,而是计算得来的——将美国、墨西哥、智利、西班牙和南极多台射电望远镜捕捉到的数据进行数学转换。该团队公开了所用代码,使科学社区可以看到,并基于此做进一步的探索。 而这逐渐成为一种普遍模式。从天文学到动物学,每一个伟大的现代科学发现背后都有计算机的身影。斯坦福大学计算生物学家、2013 年诺贝尔化学奖获得主 Michael Levitt 表示,现在的笔记本电脑在内存和时钟速度方面是 1967 年其实验室计算机的一万倍。「今天,我们拥有大量算力。但问题是,这仍然需要人类的思考。」 如果没有能够处理研究问题的软件以及知道如何编写和使用软件的研究人员,计算机再强大也是无用。「现在的研究与软件紧密相关,软件已经渗透到科研的方方面面。」软件可持续性研究所(Software Sustainability Institute)负责人 Neil Chue Hong 如是说。 最近,Nature 上的一篇文章试图揭示科学发现背后的重要代码,正是它们在过去几十年中改变了科研领域。这篇文章介绍了对科学界带来重大影响的十个软件工具

python做中学(六)os.getcwd() 的用法

为君一笑 提交于 2021-02-01 11:57:04
概述 os.getcwd() 方法用于返回当前工作目录。 语法 getcwd() 方法语法格式如下: os . getcwd () 参数 无 返回值 返回当前进程的工作目录。 实例 以下实例演示了 getcwd() 方法的使用: 1 # !/usr/bin/python 2 # -*- coding: UTF-8 -*- 3 4 import os, sys 5 6 # 切换到 "/var/www/html" 目录 7 os.chdir( " /igihub/ipython/base/file_handle " ) 8 9 # 打印当前目录 10 print ( " 当前工作目录 : %s " % os.getcwd()) 11 12 # 打开 "/tmp" 13 fd = os.open( " /ipython/base " , os.O_RDONLY ) 14 15 # 使用 os.fchdir() 方法修改目录 16 os.fchdir(fd) 17 18 # 打印当前目录 19 print ( " 当前工作目录 : %s " % os.getcwd()) 20 21 # 关闭文件 22 os.close( fd )     用的时候,记得把路径换成你所需要的就行了。 参考: 1 https://www.runoob.com/python/os-getcwd.html 来源:

Problem with running Kernel in IPython console

落花浮王杯 提交于 2021-01-30 02:37:18
问题 I have a problem with the Spyder software of Python(version 4.0.1) regarding the running kernels in the IPython Console. Accordingly, I have tried many ways to resolve the issue like running some commands in Anaconda prompt or set the settings to the default mode. I even updated the version of my anaconda and the spyder. Nevertheless, nothing has been changed and the issue still exists. This is the error I am receiving: Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib

IPython magic-command %notebook does not work when spaces are present in path (Google Colab)

前提是你 提交于 2021-01-29 08:51:05
问题 In jupyter-lab I can use the magic command %notebook $output_file_path to save the history notebook as a jupyter notebook. When I am working with Google Colab (mounting Google Drive) the path of my notebook folder is something like: root_path = 'gdrive/My Drive/Colab Notebooks/my_working_folder/' The problem is that, as I try to save the notebook history, the space between "My" and "Drive" makes the magic command fail output_file_path = 'gdrive/My Drive/Colab Notebooks/my_working_folder/nb

In IPython, can extensions handle kernel interrupts?

北城余情 提交于 2021-01-29 04:51:15
问题 I'm writing an IPython extension with cell magics that call out to another executable via pexpect . It keeps this executable running in the background for the life of the kernel. Is there a hook somewhere so that I can send this subprocess Ctrl-C when a kernel interrupt is raised (eg, the "Interrupt Kernel" menu option in the IPython Notebook)? 回答1: Reposting as an answer: IPython interrupts the kernel by sending a SIGINT, the same signal that's fired when you press Ctrl-C in a terminal. So,

In IPython, can extensions handle kernel interrupts?

寵の児 提交于 2021-01-29 04:39:16
问题 I'm writing an IPython extension with cell magics that call out to another executable via pexpect . It keeps this executable running in the background for the life of the kernel. Is there a hook somewhere so that I can send this subprocess Ctrl-C when a kernel interrupt is raised (eg, the "Interrupt Kernel" menu option in the IPython Notebook)? 回答1: Reposting as an answer: IPython interrupts the kernel by sending a SIGINT, the same signal that's fired when you press Ctrl-C in a terminal. So,

Pandas dataframe - move rows from one dataframe to another

南楼画角 提交于 2021-01-29 04:04:41
问题 I have a python pandas dataframe that has 3 rows in it: Name Time count AAA 5:45 5 BBB 13:01 8 CCC 11:16 3 I am trying to loop through this dataframe and if the count is greater than 5, i have to populate that row to a new dataframe. I know the count is 2 from a function as only 2 rows are greater than 5. I tried the below code but it is not working. Any help would be appreciated. for i in range(2): if(row['Occurences'] >= 5 ): df6.loc[i] = [df4['MachineName'], df4['DateTime'], df4['Count']]

“'int' object is not iterable” in while

本秂侑毒 提交于 2021-01-28 20:24:51
问题 def rect_extend(x): m, n = 1 while 1 < x: m = m + 1 n = n + 1 return m, n This simple function returns: 'int' object is not iterable error in iPython. I don't know why it does this, while function doesn't work - condition seems to be true . ( while 's condition was simplified on purpose; original code doesn't have it) 回答1: I think you want m = 1 n = 1 or m = n = 1 instead of m, n = 1 . This (sequence unpacking)[http://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences]: x, y