molssi-education / python_scripting_cms Goto Github PK
View Code? Open in Web Editor NEWPython Data and Scripting course for computational chemists
Home Page: https://molssi-education.github.io/python_scripting_cms
License: Other
Python Data and Scripting course for computational chemists
Home Page: https://molssi-education.github.io/python_scripting_cms
License: Other
Hi, thank you for the tutorial. I just have a suggestion on the use of elif
clause instead of just if
clause in this block:
https://github.com/MolSSI-Education/python_scripting_cms/edit/gh-pages/_episodes/02-file_parsing.md#L256-L268
...
for line in saptlines:
if 'Electrostatics ' in line:
electro_line = line
important_lines.append(electro_line)
if 'Exchange ' in line:
exchange_line = line
important_lines.append(exchange_line)
if 'Induction ' in line:
induction_line = line
important_lines.append(induction_line)
if 'Dispersion ' in line:
dispersion_line = line
important_lines.append(dispersion_line)
...
We never introduce **
syntax for raising to a power, but use it in a distance calculation exercise.
I think we may want to decouple the functions lesson from the geometry analysis project. It is extremely unlikely that students will have completed this project by the time we reach this lesson, and we don't want to confuse them with too much code. Decoupling this would be very easy, and we can add the geometry analysis part of the lesson at the end.
In the current lesson (03-multiple_files), we are using the glob
module. However, in Python 3.4 and above, there is another strategy that is arguably a "better practice". The pathlib
library can be used in Python 3.4 and above. It has a glob
function, and can also be used to manipulate file paths.
In this case, instead of this code block:
import glob
filenames = glob.glob('outfiles/*.out')
print(filenames)
We would have
import pathlib
current_dir = Path('.', 'outfiles')
filenames = current_dir.glob('*.out')
print(list(filenames))
This addresses a second issue with the current code. The line filenames = glob.glob('outfiles/*.out')
is not compatible with Windows because of the /
character (Windows uses a \
). Before the filepath
library, this would have been fixed using os.path
. However, the code block using pathlib
should fix this issue.
We may consider having a section on working with file paths, as I imagine that many of the attendees will use Windows. It is also very common for people to hard code in file paths, when this can lead to problems later.
Read more here:
http://blog.danwin.com/using-python-3-pathlib-for-managing-filenames-and-directories/
The lesson on functions contains an example with a benzene.xyz file, however I never added this to the repository. We should skip this example for now, but add for later workshops. For SETCA, we could consider having it as a gist
Here are some suggested improvements from the introduction lesson, based on me working through it (May 2, 2019)
Need to emphasize that when slicing a list, the first element is included, but the last is not. ie energy_kcal[0:2]
accesses element 0
up to (but not including) 2
.
Emphasize immutability when demonstrating that you can multiply particular elements of a list (conversion to kJ from kcal example)
Include exercise on grabbing a particular element of a list.
Emphasize importance of colon in for
loop. Perhaps add exercise where colon is not included with error message to get students to figure out what is wrong.
"If you are comparing strings, not numbers, you use different logic operators like is, in, or is not. We will see these types of logic operators used in our next lesson."
^This isn't quite correct. We still use ==
with strings. In Python, is
is used to check if things are the same object, while ==
is used to check if objects have the same value.
The exercise at the end of the lesson then uses is
to check data types. We need to think about this with the explanation of is
, etc
Exercise: "Calculate the average of each row of data. You don’t want to include the frame numbers in the average. Make a new list of the average of each row."
I think discarding the frame numbers in the exercise might be confusing for those following along. Since it's in an exercise, I can see it being something people might miss, as they might make new data instead of overwriting the variable, or skip the first column in another way.
For example, this was my solution:
avg_list = []
for row in data:
avg_list.append(np.mean(row[1:]))
Here, I haven't discarded the frame numbers, so the following code block is different for me.
I think we should extend analysis with tabular data - perhaps show them other functions like max
and min
and move plotting to its own lesson. There is a lot more we can show them in plotting. I'll be doing a PR soon that fleshes out options for plotting. However, we could show them types of plots besides line plots (scatter, bar, etc).
The variables in the plotting lesson need to be updated for consistency with the other lessons
Currently in the lessons when we import numpy and matplotlib, we are using the full names. I think it gets pretty cumbersome to type matplotlib.pyplot
every time we want to use this library. We can introduce common abbreviations for imports such as
import numpy as np
import matplotlib.pyplot as plt
This way, they are typing plt.xlabel('Simluation Frame')
instead of matplotlib.pyplot.xlabel('Simluation Frame')
, for example.
Hi,
I would like to suggest the use of context-manager (with
statement) for the open, read and write file, specifically for this 03-multiple_files.md
Khoi Van
In episode 4 ("Working with Tabular Data"), they work with a preprocessed distances file.
I think we should consider showing images/information about the data. For example, it might give them better context if we show them the trajectory and what the measurements are in VMD. Then they can directly see how this would relate to their research instead of just working with numbers.
We could also include in another link directions for generating the data themselves (not something we would go over in the workshop).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.