import rasterio
import numpy as np
mars = rasterio.open('Mars_MGS_MOLA_DEM_mosaic_global_463m.tif')
mars = mars.read()
print(mars.shape)
print(np.amin(mars[0]))
This file contains 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
import time | |
import numpy as np | |
rscores = np.random.randint(1, 100, size=100000010) | |
s = time.time() | |
mean_failed = (rscores[rscores < 70]).mean() | |
print(mean_failed) |
This file contains 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
import time | |
import numpy as np | |
rscores = np.random.randint(1, 100, size=100000010) | |
s = time.time() | |
cfailed = 0 | |
sfailed = 0 | |
for score in rscores: |
This file contains 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
import time | |
import numpy as np | |
s = time.time() | |
tsum = np.sum(np.arange(100000000)) | |
print(f'Sum: {tsum}') | |
print(f'Duration: {time.time() - s} seconds') |
This file contains 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
import time | |
s = time.time() | |
tsum = sum(range(100000000)) | |
print(f'Sum: {tsum}') | |
print(f'Sum/range: {time.time() - s} seconds') |
This file contains 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
import time | |
s = time.time() | |
tsum = 0 | |
for i in range(100000000): tsum += i | |
print(f'Sum: {tsum}') | |
print(f'For loop: {time.time() - s} seconds') |
This file contains 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
import matplotlib.pyplot as plt | |
fig, ax = plt.subplots() | |
fig.set_size_inches(14, 7) | |
ax.imshow(mars[0], cmap="viridis") | |
ax.axis('off') | |
plt.show() |
This file contains 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
const touchSupported = () => { | |
(‘ontouchstart’ in window || window.DocumentTouch && document instanceof window.DocumentTouch); | |
} | |
console.log(touchSupported()); // Result: If touch event is supported, it will return True, otherwise it will return False |
This file contains 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
const elementIsInFocus = (el) => (el === document.activeElement); | |
elementIsInFocus(anyElement) // Result: If it is in focus, it will return True, otherwise it will return False |
This file contains 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
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches | |
console.log(isDarkMode) // Result: True or False |
NewerOlder