Skip to content
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

Merged
merged 6 commits into from
Jul 15, 2018
Merged

3d dataviz of gas prices vs confirmation time #1749

merged 6 commits into from
Jul 15, 2018

Conversation

owocki
Copy link
Contributor

@owocki owocki commented Jul 15, 2018

see the output here

could be cool to put on the gas station, not sure how its gonna perform marketing-wise tho

@ghost ghost assigned owocki Jul 15, 2018
@ghost ghost added the in progress label Jul 15, 2018
import os
from gas.models import GasProfile
import matplotlib
import random

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

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

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

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

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()

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]}"

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)

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 = []

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))

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
Copy link

codecov bot commented Jul 15, 2018

Codecov Report

Merging #1749 into master will decrease coverage by 0.31%.
The diff coverage is 0%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
app/dashboard/gas_views.py 33.96% <ø> (ø) ⬆️
app/gas/management/commands/output_gas_viz.py 0% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eed26fd...863cf1c. Read the comment docs.

@@ -0,0 +1,142 @@
import datetime
import os
import random

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"

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)

Copy link
Contributor

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?

Copy link
Contributor Author

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

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

@SaptakS
Copy link
Contributor

SaptakS commented Jul 15, 2018

@owocki this looks cool. So if I understand correctly, this rotates on mousedrag in 3d space??

@SaptakS SaptakS closed this Jul 15, 2018
@ghost ghost removed the in progress label Jul 15, 2018
@SaptakS SaptakS reopened this Jul 15, 2018
@ghost ghost assigned SaptakS Jul 15, 2018
@ghost ghost added the in progress label Jul 15, 2018
@SaptakS
Copy link
Contributor

SaptakS commented Jul 15, 2018

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"
Copy link
Contributor

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'
Copy link
Contributor

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?

Copy link
Contributor Author

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'))
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

<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.
Copy link
Contributor

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 "" %} ?

.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`;
Copy link
Contributor

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"

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'):

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"

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"

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)

@owocki
Copy link
Contributor Author

owocki commented Jul 15, 2018

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"

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"

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)

@owocki
Copy link
Contributor Author

owocki commented Jul 15, 2018

linter/tests are passing locally.. hmm

@owocki owocki merged commit 4e07d96 into master Jul 15, 2018
@ghost ghost removed the in progress label Jul 15, 2018
@thelostone-mc thelostone-mc deleted the kevin/dataviz3 branch December 28, 2018 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants