This file contains hidden or 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
print("Timing cython multiplication:\n") | |
start = time.time() | |
python_result = multiplication.cython_multiplication(a, b, c, 2000, 2000) | |
end = time.time() | |
print(end - start) |
This file contains hidden or 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
typedef struct {<-------------------------immutable key value data store to iterate over given array | |
PyObject_HEAD | |
int nd_m1;<------------------------number of dimensions in array minus 1 | |
npy_intp index;<-------------------counter for element that iterator is at | |
npy_intp size;<--------------------number of elements in array | |
npy_intp coords[NPY_MAXDIMS];<-----the N-dimensional location of the current element | |
npy_intp dims_m1[NPY_MAXDIMS];<----number of elements along each dimension minus 1 | |
npy_intp strides[NPY_MAXDIMS];<----number of bytes separating the elements in each dimension | |
npy_intp backstrides[NPY_MAXDIMS];<number of bytes to subtract to return to beginning of dimension | |
npy_intp factors[NPY_MAXDIMS];<----for converting from 1D index to N-dimensional coords in 1D arrays |
This file contains hidden or 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
/*NUMPY_API | |
* Get MultiIterator from array of Python objects and any additional | |
* | |
* PyObject **mps -- array of PyObjects | |
* int n - number of PyObjects in the array | |
* int nadd - number of additional arrays to include in the iterator. | |
* | |
* Returns a multi-iterator object. | |
*/ | |
NPY_NO_EXPORT PyObject * |
This file contains hidden or 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
def total_density(image): | |
return image.sum(axis=1).sum() |
This file contains hidden or 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
def horizontal_asymmetry(image): | |
left, right = np.hsplit(image, 2) | |
right_flipped = np.flip(right, axis=1) | |
return np.sum(left - right_flipped) ** 2 | |
def vertical_asymmetry(image): | |
top, bottom = np.vsplit(image, 2) | |
bottom_flipped = np.flip(bottom, axis=0) | |
return np.sum(top - bottom_flipped) ** 2 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 numpy as np | |
import pandas as pd | |
from dask import dataframe as dd | |
from dask.multiprocessing import get | |
from multiprocessing import cpu_count | |
num_cores = cpu_count() | |
from datetime import date | |
def extract_procedure_features(physician_procedures): | |
one_hot_procedures = pd.get_dummies(physician_procedures.procedure_code, prefix='procedure') |
This file contains hidden or 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 numpy as np | |
import pandas as pd | |
from datetime import date | |
def extract_procedure_features(physician_procedures): | |
one_hot_procedures = pd.get_dummies(physician_procedures.procedure_code, prefix='procedure') | |
dummied_procedures = pd.concat([physician_procedures.number_of_patients, one_hot_procedures], axis=1) | |
def numerize(row): | |
return np.asarray(row.number_of_patients) * np.asarray(row) |
This file contains hidden or 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
echo "gem 'devise'" >> Gemfile # Or edit Gemfile and add line: gem 'devise' | |
bundle install # Fetch and install the gems | |
rails generate devise:install # Creates config file, etc. | |
rails generate devise user # Create model class, routes, etc. | |
rake db:migrate # Create user table | |
rails generate devise:views users # Creates (minimal) views | |
# Code sample courtesy of launch school: https://launchschool.com/blog/how-to-use-devise-in-rails-for-authentication |