-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
3d dataviz of gas prices vs confirmation time #1749
Conversation
import os | ||
from gas.models import GasProfile | ||
import matplotlib | ||
import random |
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.
F401 'random' imported but unused
import matplotlib | ||
import random | ||
matplotlib.use('Agg') | ||
from numpy import array |
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.
E402 module level import not at top of file
E272 multiple spaces before keyword
import random | ||
matplotlib.use('Agg') | ||
from numpy import array | ||
from mpl_toolkits.mplot3d import axes3d |
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.
E402 module level import not at top of file
F401 'mpl_toolkits.mplot3d.axes3d' imported but unused
matplotlib.use('Agg') | ||
from numpy import array | ||
from mpl_toolkits.mplot3d import axes3d | ||
import matplotlib.pyplot as plt |
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.
E402 module level import not at top of file
from numpy import array | ||
from mpl_toolkits.mplot3d import axes3d | ||
import matplotlib.pyplot as plt | ||
from matplotlib import cm |
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.
E402 module level import not at top of file
F401 'matplotlib.cm' imported but unused
package[key].append(new_pkg) | ||
|
||
clear_cache() | ||
#install_ffmpeg() |
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.
E265 block comment should start with '# '
num_items_to_show_at_a_time = 50 | ||
for j in range(num_items_to_show_at_a_time, len(arr)): | ||
print(j) | ||
key = f"Ethereum Mainnet Gas Tradeoffs\n Gas Prices (x axis) vs Time to Confirm (y axis) vs Time (z axis) \n {keys[j]}" |
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.
E501 line too long (131 > 120 characters)
if invert_colors: | ||
axiscolor = 'white' | ||
ax.spines['bottom'].set_color(axiscolor) | ||
ax.spines['top'].set_color(axiscolor) |
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.
W291 trailing whitespace
ax.set_zlabel('Time To Confirm (min)') | ||
|
||
|
||
X = [] |
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.
E303 too many blank lines (2)
Y = tmp[1] | ||
Z = tmp[2] | ||
color = get_color(j, k, num_items_to_show_at_a_time) | ||
ax.plot_wireframe(array(X), array(Y), array(Z), rstride=10, cstride=10, color=color, alpha=1-(k/num_items_to_show_at_a_time)) |
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.
E501 line too long (141 > 120 characters)
Codecov Report
@@ Coverage Diff @@
## master #1749 +/- ##
==========================================
- Coverage 29.16% 28.84% -0.32%
==========================================
Files 127 128 +1
Lines 9956 10066 +110
Branches 1316 1328 +12
==========================================
Hits 2904 2904
- Misses 6945 7055 +110
Partials 107 107
Continue to review full report at Codecov.
|
@@ -0,0 +1,142 @@ | |||
import datetime | |||
import os | |||
import random |
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.
F401 'random' imported but unused
|
||
|
||
def convert_to_movie(): | ||
command = "ffmpeg -framerate 30 -pattern_type glob -i 'cache/frames/*.jpg' -c:v libx264 -pix_fmt yuv420p cache/out.mp4" |
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.
E501 line too long (123 > 120 characters)
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.
Thoughts on using an ffmpeg wrapper for this like moviepy
or something similar?
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.
either way seems acceptable to me.
import matplotlib | ||
matplotlib.use('Agg') | ||
import matplotlib.pyplot as plt | ||
from mpl_toolkits.mplot3d import axes3d |
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.
F401 'mpl_toolkits.mplot3d.axes3d' imported but unused
@owocki this looks cool. So if I understand correctly, this rotates on mousedrag in 3d space?? |
Sorry. My mistake. |
|
||
|
||
def convert_to_movie(): | ||
command = "ffmpeg -framerate 30 -pattern_type glob -i 'cache/frames/*.jpg' -c:v libx264 -pix_fmt yuv420p cache/out.mp4" |
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.
Thoughts on using an ffmpeg wrapper for this like moviepy
or something similar?
def install_ffmpeg(): | ||
command = 'apt update -y ' | ||
os.system(command) | ||
command = 'apt install ffmpeg libav-tools x264 x265 -y' |
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.
Can we add ffmpeg libav-tools x264 x265
to the dockerfile build steps?
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.
updated
z_angle = 10 | ||
ax.view_init(z_angle, degrees) | ||
|
||
png_file = 'cache/frames/{}.jpg'.format(str(j).rjust(10, '0')) |
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.
Can we update this to use an f-string?
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.
updated
app/retail/templates/gas.html
Outdated
<br> | ||
<video width="640" height="480" controls> | ||
<source src="/static/tmp/gas_price_viz.mp4" type="video/mp4"> | ||
Your browser does not support the video tag. |
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.
Should we wrap this in {% trans "" %}
?
app/retail/templates/gas.html
Outdated
.on('mouseover', function(d) { | ||
var tooltip_msg = '<div>'; | ||
tooltip_msg = `Gas Price: ${d.gas_price}`; | ||
tooltip_msg = tooltip_msg + `<br/>Confirmation time: ${d.confirmation_time} min`; |
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.
Should we wrap the copy throughout in trans
?
|
||
|
||
def convert_to_movie(): | ||
command = "ffmpeg -framerate 30 -pattern_type glob -i 'cache/frames/*.jpg' -c:v libx264 -pix_fmt yuv420p cache/out.mp4" |
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.
E501 line too long (123 > 120 characters)
invert_colors = False | ||
max_gas = 50 | ||
package = {} | ||
for gp in GasProfile.objects.filter(gas_price__lt=max_gas, created_on__gt=timezone.now() - timezone.timedelta(days=7)).order_by('created_on'): |
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.
E501 line too long (150 > 120 characters)
num_items_to_show_at_a_time = 50 | ||
for j in range(num_items_to_show_at_a_time, len(arr)): | ||
print(j) | ||
key = f"Ethereum Mainnet Gas Tradeoffs\n Gas Prices (x axis) vs Time to Confirm (y axis) vs Time (z axis) \n {keys[j]}\n\nMade with <3 at Gitcoin.\nhttps://gitcoin..co/gas" |
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.
E501 line too long (184 > 120 characters)
|
||
|
||
def convert_to_movie(): | ||
command = "ffmpeg -framerate 30 -pattern_type glob -i 'cache/frames/*.jpg' -c:v libx264 -pix_fmt yuv420p cache/out.mp4" |
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.
E501 line too long (123 > 120 characters)
updated per code review |
|
||
|
||
def convert_to_movie(): | ||
command = "ffmpeg -framerate 30 -pattern_type glob -i 'cache/frames/*.jpg' -c:v libx264 -pix_fmt yuv420p cache/out.mp4" |
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.
E501 line too long (123 > 120 characters)
|
||
|
||
def convert_to_movie(): | ||
command = "ffmpeg -framerate 30 -pattern_type glob -i 'cache/frames/*.jpg' -c:v libx264 -pix_fmt yuv420p cache/out.mp4" |
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.
E501 line too long (123 > 120 characters)
linter/tests are passing locally.. hmm |
see the output here
could be cool to put on the gas station, not sure how its gonna perform marketing-wise tho