Skip to content

Commit 3554b13

Browse files
committed
Remove variable-function name conflict and cleanups
1 parent 9f93859 commit 3554b13

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

pybromo/diffusion.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get_seed(seed, ID=0, EID=0):
3838
return seed + EID + 100 * ID
3939

4040

41-
def hash_(x):
41+
def hashfunc(x):
4242
return hashlib.sha1(repr(x).encode()).hexdigest()
4343

4444

@@ -166,7 +166,7 @@ def __init__(self, num_particles, D, box, rs=None, seed=1, particles=None):
166166
self._plist = self._generate(num_particles, D, box, rs)
167167
else:
168168
self._plist = list(particles)
169-
self.rs_hash = hash_(self.init_random_state)[:3]
169+
self.rs_hash = hashfunc(self.init_random_state)[:3]
170170

171171
def add(self, num_particles, D):
172172
"""Add particles with diffusion coefficient `D` at random positions.
@@ -505,8 +505,8 @@ def _open_store(self, store, prefix='', path='./', chunksize=2**19,
505505
attr_params = dict(particles=self.particles.to_json(), box=self.box)
506506
kwargs = dict(path=path, nparams=nparams, attr_params=attr_params,
507507
mode=mode)
508-
store = store(store_fname, **kwargs)
509-
return store
508+
store_obj = store(store_fname, **kwargs)
509+
return store_obj
510510

511511
def open_store_traj(self, path='./', chunksize=2**19, chunkslice='bytes',
512512
mode='w', radial=False):
@@ -711,7 +711,7 @@ def _get_ts_name_mix_core(self, max_rates, populations, bg_rate,
711711
def _get_ts_name_mix(self, max_rates, populations, bg_rate, rs,
712712
hashsize=6):
713713
s = self._get_ts_name_mix_core(max_rates, populations, bg_rate)
714-
return '%s_rs_%s' % (s, hash_(rs.get_state())[:hashsize])
714+
return '%s_rs_%s' % (s, hashfunc(rs.get_state())[:hashsize])
715715

716716
def timestamps_match_pattern(self, pattern):
717717
return [t for t in self.timestamp_names if pattern in t]

pybromo/psflib.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424

2525
def psf_from_pytables(psf_pytables):
26+
"""Load a PSF object (either numeric or gauss) from a pytables array.
27+
"""
2628
if 'kind' not in psf_pytables.attrs:
2729
# old files may not have the `kind` attribute, assume NumericPSF
2830
psf_type = 'numeric'
@@ -48,7 +50,7 @@ def __init__(self, xc=0, yc=0, zc=0, sx=0.2e-6, sy=0.2e-6, sz=0.8e-6, psf_pytabl
4850
arguments.
4951
"""
5052
self.kind = 'gauss'
51-
self.fname = 'gaussian_psf'
53+
self.fname = 'gaussian_psf'
5254
if psf_pytables is not None:
5355
assert psf_pytables.attrs['kind'] == 'gauss'
5456
self.rc, self.s = psf_pytables.read().astype(np.float64)
@@ -89,15 +91,15 @@ def eval_xz(self, x, z):
8991
xc, yc, zc = self.rc
9092
sx, sy, sz = self.s
9193
return exp(-(((x-xc)**2)/(2*sx**2) + ((z-zc)**2)/(2*sz**2)))
92-
94+
9395
def hash(self):
9496
"""Return an hash string computed on the PSF data."""
9597
return hashlib.md5(repr(self).encode()).hexdigest()
9698

9799
def to_hdf5(self, file_handle, parent_node='/'):
98100
"""Store the PSF data in `file_handle` (pytables) in `parent_node`.
99101
100-
The PSF data is stored in an array named `gauss_psf_params` with
102+
The PSF data is stored in an array named `gauss_psf_params` with
101103
shape 2 x 3. Columns are x, y, z coordinates, rows are mean and
102104
standard deviation.
103105
"""

0 commit comments

Comments
 (0)