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
| quicksort=: (($:@(<#[), (=#[), $:@(>#[)) ({~ ?@#)) ^: (1<#) | |
| List =: ?. 10 $100 | |
| echo quicksort List |
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
| ############### | |
| spent = 171.376666667 | |
| tax_rate = .10 | |
| ############### | |
| cost = spent / (1 + tax_rate) | |
| taxed = spent - cost |
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 calculate_taxed_ammount( spent:float, tax_rate:float): | |
| cost = spent / (1 + tax_rate) | |
| taxed = spent - cost | |
| print("Spent: {}\nCost: {}\nTaxed: {}".format(spent, cost, taxed)) | |
| calculate_taxed_ammount( spent = 171.376666667, tax_rate = .10) | |
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 | |
| def create_n_depth_matrix(n: int) -> np.array: | |
| """Function used to generate all binary permutations of length n. | |
| Binary permutations of n=3 for example would include: | |
| [0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1] | |
| Binary permuataions are arranged in a 3d matrix of shape (n, a, b) | |
| such that a*b == (2^n) | |
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
| from functools import reduce | |
| flatten = lambda lst: reduce(lambda l, i: l + flatten(i) if isinstance(i, (list, tuple)) else l + [i], lst, []) | |
| test = [[[[1,0],1],0],1] | |
| print(flatten(test)) | |
| ## Credit https://stackoverflow.com/questions/952914/making-a-flat-list-out-of-list-of-lists-in-python |
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 datacube | |
| import xarray as xr | |
| def export_xarray_to_netcdf(ds:xr.Dataset, path:str): | |
| """ | |
| Exports an xarray.Dataset as a single NetCDF file. | |
| Parameters | |
| ---------- | |
| ds: xarray.Dataset | |
| The Dataset to export. |
OlderNewer