Skip to content

Commit b276d03

Browse files
authored
Merge pull request #1 from vpython/master
Pull from master
2 parents 023a843 + eb99b4f commit b276d03

File tree

8 files changed

+25
-16
lines changed

8 files changed

+25
-16
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ var/
2828

2929
!vpython/lib
3030

31+
# Notebook stuff
32+
.ipynb_checkpoints
33+
3134
# PyInstaller
3235
# Usually these files are written by a python script from a template
3336
# before PyInstaller builds the exe, so as to inject date/other infos into it.

Demos/RotatingBoxes.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
"source": [
108108
"from vpython import *\n",
109109
"scene = canvas() # This is needed in Jupyter notebook and lab to make programs easily rerunnable\n",
110-
"from time import clock\n",
111110
"\n",
112111
"N = 10\n",
113112
"\n",

Demos_no_notebook/HardSphereGas.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from vpython import *
2-
from time import clock
32

43
# Hard-sphere gas.
54

@@ -48,7 +47,7 @@
4847
p = []
4948
apos = []
5049
pavg = sqrt(2*mass*1.5*k*T) # average kinetic energy p**2/(2mass) = (3/2)kT
51-
50+
5251
for i in range(Natoms):
5352
x = L*random()-L/2
5453
y = L*random()-L/2
@@ -152,24 +151,24 @@ def checkCollisions():
152151

153152
# Update all positions
154153
for i in range(Natoms): Atoms[i].pos = apos[i] = apos[i] + (p[i]/mass)*dt
155-
154+
156155
# Check for collisions
157156
hitlist = checkCollisions()
158157

159-
158+
160159
for i in range(Natoms):
161160
loc = apos[i]
162161
if abs(loc.x) > L/2:
163162
if loc.x < 0: p[i].x = abs(p[i].x)
164163
else: p[i].x = -abs(p[i].x)
165-
164+
166165
if abs(loc.y) > L/2:
167166
if loc.y < 0: p[i].y = abs(p[i].y)
168167
else: p[i].y = -abs(p[i].y)
169-
168+
170169
if abs(loc.z) > L/2:
171170
if loc.z < 0: p[i].z = abs(p[i].z)
172171
else: p[i].z = -abs(p[i].z)
173-
172+
174173
timer = clock()-timer
175174
print(timer)

Demos_no_notebook/qt.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from vpython import *
2+
set_browser(type='pyqt')
3+
b = box()
4+
scene.caption = "A box should appear in the window above"

JupyterPythonDemos.zip

19 Bytes
Binary file not shown.

vpython/no_notebook.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ def onClose(self, wasClean, code, reason):
249249
raise RuntimeError('The pyqt browser cannot be used on Windows. '
250250
'Please use the default browser instead by '
251251
'removing set_browser("pyqt") from your code.')
252+
elif sys.version_info.major == 3 and sys.version_info.minor >= 8:
253+
raise RuntimeError('The pyqt browser cannot be used on Python 3.8. '
254+
'Please use the default browser instead by '
255+
'removing set_browser("pyqt") from your code.')
252256

253257

254258
def start_Qapp(port):

vpython/rate_control.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import time
2-
try:
3-
_clock = time.perf_counter # time.clock is deprecated in Python 3.3, gone in 3.8
4-
except:
5-
_clock = time.clock
2+
3+
_clock = time.perf_counter
4+
5+
66
_tick = 1/60
77

88
#import platform

vpython/vpython.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from math import sqrt, tan, pi
77

88
import time
9-
try:
10-
clock = time.perf_counter # time.clock is deprecated in Python 3.3, gone in 3.8
11-
except:
12-
clock = time.clock
9+
10+
# vpython provides clock in its namespace
11+
clock = time.perf_counter
12+
1313
import sys
1414
from . import __version__, __gs_version__
1515
from ._notebook_helpers import _isnotebook

0 commit comments

Comments
 (0)