-
Notifications
You must be signed in to change notification settings - Fork 3
Commit by inagaki #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fujiisoup
wants to merge
6
commits into
master
Choose a base branch
from
style_discussion
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6d71572
Commit by inagaki
fujiisoup cc93464
Fix by inagaki
fujiisoup da2800d
Another commit by fujii
fujiisoup 6c283a5
Add readme
fujiisoup f483287
First commit for jupyter-notebook chapter.
fujiisoup 03fd930
Merge pull request #2 from PlasmaLib/jupyter
fujiisoup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[cod] | ||
|
|
||
| # C extensions | ||
| *.so | ||
|
|
||
| # Distribution / packaging | ||
| .Python | ||
| env/ | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
|
|
||
| # PyInstaller | ||
| # Usually these files are written by a python script from a template | ||
| # before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
| *.manifest | ||
| *.spec | ||
|
|
||
| # Installer logs | ||
| pip-log.txt | ||
| pip-delete-this-directory.txt | ||
|
|
||
| # Unit test / coverage reports | ||
| htmlcov/ | ||
| .tox/ | ||
| .coverage | ||
| .coverage.* | ||
| .cache | ||
| nosetests.xml | ||
| coverage.xml | ||
| *,cover | ||
|
|
||
| # Translations | ||
| *.mo | ||
| *.pot | ||
|
|
||
| # Django stuff: | ||
| *.log | ||
|
|
||
| # Sphinx documentation | ||
| docs/_build/ | ||
|
|
||
| # PyBuilder | ||
| target/ | ||
|
|
||
| # Emacs backups | ||
| *~ | ||
|
|
||
| # Pycharm IDE directory | ||
| .idea | ||
|
|
||
| # IPython Notebooks | ||
| */.ipynb_checkpoints | ||
|
|
||
| # Ipython just for testing | ||
| archive_notebooks | ||
|
|
||
| # svg files | ||
| *.svg | ||
|
|
||
| # memo for codeship setting | ||
| codeship_settings.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| import numpy as np | ||
| import scipy.integrate as desol | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| def predator_prey(f, t, a, b, c, d): | ||
| # | ||
| # dx/dt = ax - bxy | ||
| # dy/dt = cxy - dy | ||
| # | ||
| # f[0] - x: Population of prey | ||
| # f[1] - y: Population of predetor | ||
| # t - Time | ||
| # a,b,c,d - Control parameters | ||
| # | ||
| return [a*f[0]-b*f[0]*f[1], c*f[0]*f[1]-d*f[1]] | ||
|
|
||
|
|
||
| #model | ||
| #eq1 = r"$\frac{dx}{dt} = ax - bxy$" | ||
| #eq2 = r"$\frac{dy}{dt} = cxy - dy$" | ||
| eq1 = r"$dx/dt = ax - bxy$" | ||
| eq2 = r"$dy/dt = cxy - dy$" | ||
|
|
||
| #input parameters | ||
| a = 1.0 | ||
| b = 1.0 | ||
| c = 1.0 | ||
| d = 1.0 | ||
| header = r"$a={0:.1f}, b={1:.1f}, c={2:.1f}, d={3:.1f}$".format(a, b, c, d) | ||
|
|
||
| #initial condition | ||
| f0 = [1.0, 0.1] | ||
|
|
||
| #independent variable | ||
| nt = 1000 | ||
| tmax = 30.0 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PythonのスタイルガイドPEP8では、イコールの位置を揃えない、というふうになっています。 |
||
| dt = tmax/nt | ||
|
||
| t = dt*np.arange(nt) | ||
|
|
||
| f = desol.odeint(predator_prey, f0, t, args=(a,b,c,d)) | ||
|
|
||
| #plot | ||
| prey = f[:,0] | ||
| predator = f[:,1] | ||
|
|
||
| fig = plt.figure() | ||
| ax = fig.add_axes([0.15, 0.1, 0.8, 0.8]) | ||
| ax.plot(t, prey, color='r', label=r"$x$: prey") | ||
| ax.plot(t, predator, color='b', label=r"$y$: predator") | ||
| handles, labels = ax.get_legend_handles_labels() | ||
| ax.legend(handles, labels, loc='best') | ||
| ax.text(21, 2.7, eq1, fontsize=16) | ||
| ax.text(21, 2.5, eq2, fontsize=16) | ||
| ax.set_xlabel("Time") | ||
| ax.set_ylabel("Population") | ||
| ax.set_title(header) | ||
| plt.show() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
関数やクラスのコメントは3連のダブルコーテーションで囲う法が良いと思います。
そうすると
function.__docs__にセットされるので。https://pep8-ja.readthedocs.io/ja/latest/#id22