Coder Social home page Coder Social logo

physics-codes / examples Goto Github PK

View Code? Open in Web Editor NEW
198.0 25.0 114.0 2.57 MB

Examples of exercises that accompany Effective Computation in Physics

License: Creative Commons Zero v1.0 Universal

Python 0.52% HTML 99.38% TeX 0.10% Makefile 0.01%

examples's Introduction

examples

Examples of exercises that accompany Effective Computation in Physics

examples's People

Contributors

katyhuff avatar scopatz avatar ttimbers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

examples's Issues

Bokeh example is incompatible with recent versions

The Bokeh example in chapter 7 (Analysis and Visualization) on page 173 is no longer compatible with current versions of Bokeh.

Below is the corrected example and a diff compared with the content of cell [9] in ch08-analysis-and-viz.ipynb:

import numpy as np
# import the Bokeh plotting tools
from bokeh import plotting as bp

# as in the matplotlib example, load decays.csv into a NumPy array
decaydata = np.loadtxt('data/decays.csv',delimiter=",",skiprows=1)

# provide handles for the x and y columns
time = decaydata[:,0]
decays = decaydata[:,1]

# define some output file metadata
bp.output_file("decays.html", title="Experiment 1 Radioactivity")

# create a figure with fun Internet-friendly features (optional)
f = bp.figure(tools="pan,wheel_zoom,box_zoom,reset,previewsave",
              title="Decays", x_axis_label="Time (s)", y_axis_label="Decays (#)" )

# on that figure, create a line plot
f.line(time, decays, color='#1F78B4', legend='Decays per second' )

# additional customization to the figure can be specified separately
f.grid.grid_line_alpha=0.3

# open a browser
bp.show(f)
--- bokeh_old.py	2017-05-04 15:31:54.268924393 -0230
+++ bokeh_new.py	2017-05-04 15:31:02.076925327 -0230
@@ -13,15 +13,15 @@
 bp.output_file("decays.html", title="Experiment 1 Radioactivity")
 
 # create a figure with fun Internet-friendly features (optional)
-bp.figure(tools="pan,wheel_zoom,box_zoom,reset,previewsave")
+f = bp.figure(tools="pan,wheel_zoom,box_zoom,reset,previewsave",
+              title="Decays", x_axis_label="Time (s)", y_axis_label="Decays (#)" )
 
 # on that figure, create a line plot
-bp.line(time, decays, x_axis_label="Time (s)", y_axis_label="Decays (#)",
-     color='#1F78B4', legend='Decays per second')
+f.line(time, decays, color='#1F78B4', legend='Decays per second' )
 
 # additional customization to the figure can be specified separately
-bp.curplot().title = "Decays"
-bp.grid().grid_line_alpha=0.3
+f.grid.grid_line_alpha=0.3
 
 # open a browser
-bp.show()
+bp.show(f)

Signal filtering is slightly off

Page 82 of the First edition of the book.

elif omega >= 0.9 and omega < 1.0:

is better than elif omega > 0.9 and omega < 1.0:

Otherwise signal = 1.0 for omega = 0.9

Error calling ElementaryParticle(spin).hear_me()

Cell [29] in notebook ch06-classes-objects.ipynb gives an error as the (overloaded) constructor of the ElementaryParticle class doesn't create the data attributes initialized bu the generator of the Particle class.

This can be solved by calling Particle.__init__(self) explicitly:

# elementary.py
class ElementaryParticle(Particle):

    roar = "I am an Elementary Particle!"

    def __init__(self, spin):
        Particle.__init__(self)
        self.s = spin
        self.is_fermion = bool(spin % 1.0)
        self.is_boson = not self.is_fermion

No instructions for using this

Chap 1 of the book says to "Read the instructions on [this] site to download the files." but there are no such instructions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.