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
subroutine grid_output(this, filename, other) | |
class(mesh) :: this | |
class(cell), optional, intent(in) :: other | |
character(len=20), intent(in) :: filename | |
integer :: tag, ip, L(3), nodes, s(3), icom(3), ip_new, gcom(3), lp(3), i | |
tag = 33423 | |
L = this%L | |
nodes = this%nodes |
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
""" | |
creates a decorator that allows to call functions parameterless without empty brackets. | |
@author: phydev.github.io | |
date: Sunday, 20 october 2019 02:20 | |
""" | |
def without_brackets(function): | |
""" | |
function that will be used as decorator for calling functions without using brackets | |
:param function: any function without arguments |
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
builtin_print(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) | |
{ | |
static const char * const _keywords[] = {"sep", "end", "file", "flush", 0}; | |
static struct _PyArg_Parser _parser = {"|OOOp:print", _keywords, 0}; | |
PyObject *sep = NULL, *end = NULL, *file = NULL; | |
int flush = 0; | |
int i, err; | |
if (kwnames != NULL && | |
!_PyArg_ParseStackAndKeywords(args + nargs, 0, kwnames, &_parser, |
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
""" | |
allen-cahn.jl | |
integration of the allen-cahn equation from the phase-field formalism using convolutions | |
@author: phydev.github.io | |
License: GNU GPL v3 | |
""" | |
# importing external packages | |
using DSP # digital signal processing package | |
using Plots |
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 trajpy.trajpy as tj | |
import trajpy.traj_generator as tjg | |
trajectory = 'anomalous' | |
r = np.zeros((250, 4)) | |
n_steps = 250 | |
n_samples = 5000 | |
dt = 1.0 | |
D = 100. |
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 numpy as np | |
def center_of_mass(rho, L, ndim=2): | |
""" | |
:param rho: array N x M | |
:param L: array with the grid dimensions np.array([Lx, Ly]) | |
:param ndim: number of dimensions | |
:return com: center of mass | |
""" | |
com, volume = np.zeros((ndim)), 0.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
""" | |
Convert sklearn dataset into pandas DataFrame object. | |
Source: https://stackoverflow.com/a/46379878/5059616 | |
""" | |
import numpy as np | |
import pandas as pd | |
from sklearn import datasets |
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
""" | |
Computes the set of features for each .dat file in PATH, | |
then loads a random forest classifier and predicts if the | |
trajectory is confined, normal, anomalous or superdiffusive. | |
The output is given inside PATH as a yyyy-mm-dd.csv file. | |
@phydev | |
""" | |
import os |
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
def train_test_split_tensors(X, y, **options): | |
""" | |
encapsulation for the sklearn.model_selection.train_test_split function | |
in order to split tensors objects and return tensors as output | |
:param X: tensorflow.Tensor object | |
:param y: tensorflow.Tensor object | |
:dict **options: typical sklearn options are available, such as test_size and train_size | |
""" |
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
""" | |
LASSO regression (L1 regularization) with gradient descent | |
TODO: estimate intercept | |
phydev.github.io | |
""" | |
def predict(X, beta): | |
""" | |
predict the regression | |
""" |
OlderNewer