Skip to content

Commit

Permalink
Added Linter
Browse files Browse the repository at this point in the history
  • Loading branch information
JBeckwith committed Jun 25, 2024
1 parent 1b7bb47 commit 980db31
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
src: "./src"
jupyter: false
1 change: 1 addition & 0 deletions src/LangevinFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def generate_multiple_molecules(n):
limits = 0
else:
coordinates[n] = single_track[:cutlimit, :]
limits = 1
else:
coordinates[n] = single_track
limits = 1
Expand Down
12 changes: 7 additions & 5 deletions src/MSDFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def DSigma2_OLSF_BootStrap(self, coordinates, dT, R=1./6, n_d=1, maxiter=100, mi
D_err[i], var_err[i] = self.DSigma2_OLSF(new_coordinates, dT, R=R, n_d=n_d)
return np.std(D_err), np.std(var_err)

def DSigma2_OLSF(self, coordinates, dT, R=1./6, n_d=1, maxiter=100, min_points=10):
def DSigma2_OLSF(self, coordinates, dT, R=1./6, n_d=1, maxiter=100, min_points=10, supress_warning=False):
"""
Compute diffusion coefficient estimate, and estimate of the
dynamic localisation error, using the OLSF MSD approach.
Expand Down Expand Up @@ -118,13 +118,14 @@ def DSigma2_OLSF(self, coordinates, dT, R=1./6, n_d=1, maxiter=100, min_points=1
rho = rho[:np.max(np.hstack([pa, pb]))]
if not donea:
A = np.vstack((np.ones(pa[-1]), np.arange(1, pa[-1] + 1))).T
B = rho[:A.shape[0]]
B = np.asarray(rho[:A.shape[0]])
if B.shape[0] != A.shape[0]:
donea = True
doneb = True
D = np.nan
var = np.nan
print('OLSF did not converge in {} iterations'.format(maxiter))
if supress_warning == False:
print('OLSF did not converge in {} iterations'.format(maxiter))
return D, var
X = np.linalg.lstsq(A, B, rcond=None)[0]
aa, ba = X
Expand All @@ -137,13 +138,14 @@ def DSigma2_OLSF(self, coordinates, dT, R=1./6, n_d=1, maxiter=100, min_points=1
pa = np.hstack([pa, newpa])
if not doneb:
A = np.vstack((np.ones(pb[-1]), np.arange(1, pb[-1] + 1))).T
B = rho[:int(pb[-1])]
B = np.asarray(rho[:int(pb[-1])])
if B.shape[0] != A.shape[0]:
donea = True
doneb = True
D = np.nan
var = np.nan
print('OLSF did not converge in {} iterations'.format(maxiter))
if supress_warning == False:
print('OLSF did not converge in {} iterations'.format(maxiter))
return D, var
X = np.linalg.lstsq(A, B, rcond=None)[0]
ab, bb = X
Expand Down
Binary file modified src/__pycache__/LangevinFunctions.cpython-310.pyc
Binary file not shown.
Binary file modified src/__pycache__/MSDFunctions.cpython-310.pyc
Binary file not shown.

0 comments on commit 980db31

Please sign in to comment.