enthought

How to avoid circular dependencies when setting Properties?

China☆狼群 提交于 2019-12-02 00:42:23
问题 This is a design principle question for classes dealing with mathematical/physical equations where the user is allowed to set any parameter upon which the remaining are being calculated. In this example I would like to be able to let the frequency be set as well while avoiding circular dependencies. For example: from traits.api import HasTraits, Float, Property from scipy.constants import c, h class Photon(HasTraits): wavelength = Float # would like to do Property, but that would be circular?

How to avoid circular dependencies when setting Properties?

眉间皱痕 提交于 2019-12-01 21:37:31
This is a design principle question for classes dealing with mathematical/physical equations where the user is allowed to set any parameter upon which the remaining are being calculated. In this example I would like to be able to let the frequency be set as well while avoiding circular dependencies. For example: from traits.api import HasTraits, Float, Property from scipy.constants import c, h class Photon(HasTraits): wavelength = Float # would like to do Property, but that would be circular? frequency = Property(depends_on = 'wavelength') energy = Property(depends_on = ['wavelength, frequency

Python Enthought Canopy: multiprocessing not working

北城余情 提交于 2019-12-01 14:48:12
I've been trying multiprocessing with enthought canopy (Windows 8). I tried the following example: import multiprocessing nProcesses=3 def worker(): """worker function""" print "working" return if __name__ == '__main__': jobs = [] for i in range(nProcesses): p = multiprocessing.Process(target=worker) jobs.append(p) p.start() close to a copypaste of examples you find online... The processes are created but seem to do nothing. No printing of "working". I run my file (main.py) from the environment provided by Canopy (IDLE I think) but I do not copy those lines in the interpreter, I run the whole

Python Enthought Canopy: multiprocessing not working

ε祈祈猫儿з 提交于 2019-12-01 13:29:28
问题 I've been trying multiprocessing with enthought canopy (Windows 8). I tried the following example: import multiprocessing nProcesses=3 def worker(): """worker function""" print "working" return if __name__ == '__main__': jobs = [] for i in range(nProcesses): p = multiprocessing.Process(target=worker) jobs.append(p) p.start() close to a copypaste of examples you find online... The processes are created but seem to do nothing. No printing of "working". I run my file (main.py) from the

Using matplotlib.animation inside a function in Canopy [duplicate]

寵の児 提交于 2019-12-01 12:21:05
问题 This question already has answers here : python matplotlib: unable to call FuncAnimation from inside a function (3 answers) Closed 5 years ago . The following script produces a simple animation of a traveling sine wave when executed using the %run statement in Canopy 1.4.1: import numpy as np from matplotlib import pyplot as plt from matplotlib import animation def animator(): fig = plt.figure() ax = plt.axes(xlim=(0, 2), ylim=(-2, 2)) line, = ax.plot([], [], lw=2) def init(): line.set_data([

Multiple kernels in Enthought Canopy

假如想象 提交于 2019-12-01 09:14:13
I previously worked with the EPD Python distribution using its Qt-console, where one of the most useful features was easily having multiple kernels in multiple tabs, when doing several calculations simultaneously. I recently got the "new" Enthought Canopy, which somehow tries to emulate MatLab, which might not be bad perse. Here comes the problem: How do I get multiple tabs with separated kernels with Canopy? For completeness, I am running Canopy 1.1.0 on Ubuntu-Gnome 13.04. The Canopy GUI application does not yet support multiple kernels. However, just like with EPD, you can run QtConsole,

How to check whether I have IPython installed on my machine and what sequence to install these libraries?

偶尔善良 提交于 2019-12-01 08:16:15
I need to use python for a machine learning course and I also need to install some external libraries. I'm a bit confused as to what the correct order is for installation of everything as I've heard the paths can get messed up if done incorrectly. Here is what I need: Python version 2.7 IPython The libraries available inside this package by enthought So 1st step is to see whether I have python installed Yes: I have this version AM@~ >python Python 2.7.2 (default, Jun 20 2012, 16:23:33) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin Type "help", "copyright",

How to check whether I have IPython installed on my machine and what sequence to install these libraries?

喜欢而已 提交于 2019-12-01 06:27:49
问题 I need to use python for a machine learning course and I also need to install some external libraries. I'm a bit confused as to what the correct order is for installation of everything as I've heard the paths can get messed up if done incorrectly. Here is what I need: Python version 2.7 IPython The libraries available inside this package by enthought So 1st step is to see whether I have python installed Yes: I have this version AM@~ >python Python 2.7.2 (default, Jun 20 2012, 16:23:33) [GCC 4

How to substitute symbol for matrix using symPy and numPy

孤街醉人 提交于 2019-12-01 02:19:35
问题 I'm trying to substitute two symbols in my equation for the matrix form of each of them. I created a commutator function which formed my expression: t, vS, = sy.symbols('t, vS', commutative = False) hS = t + vS eta = myComm(t,hS) dHs = myComm(eta,hS) print dHs.expand() yielding the correct expression I want: 2*t*vS*t + t*vS**2 - t**2*vS - 2*vS*t*vS - vS*t**2 + vS**2*t So now I wish to substitute the symbols t and vS with matrices, however when using subs I get an error, "unhashable type:

Can't upgrade matplotlib in Ubuntu 12.04 with Canopy installed

天涯浪子 提交于 2019-11-30 22:10:15
I'm trying to upgrade matplotlib in Ubuntu 12.04 . When I run the command: sudo pip install --upgrade matplotlib I get this error: Downloading/unpacking matplotlib Running setup.py egg_info for package matplotlib The required version of distribute (>=0.6.28) is not available, and can't be installed while this script is running. Please install a more recent version first, using 'easy_install -U distribute'. (Currently using distribute 0.6.24dev-r0 (/usr/lib/python2.7/dist-packages)) Complete output from command python setup.py egg_info: The required version of distribute (>=0.6.28) is not