Skip to content

Commit

Permalink
Merge pull request #286 from jonwright/master
Browse files Browse the repository at this point in the history
Fixups
  • Loading branch information
jonwright authored Jun 18, 2024
2 parents e7e48a8 + 04f4524 commit 575c331
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 10 deletions.
1 change: 1 addition & 0 deletions ImageD11/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ def assigntorings(self):
)
logging.info("Shape of scoring matrix", self.gvr.shape)
self.gvflat = np.ascontiguousarray(self.gvr, float) # Makes it contiguous
self.gv = np.ascontiguousarray(self.gv, float)
# in memory, hkl fast index

def friedelpairs(self, filename):
Expand Down
18 changes: 18 additions & 0 deletions ImageD11/sinograms/lima_segmenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from ImageD11.sinograms import dataset
import ImageD11.cImageD11


try:
from bslz4_to_sparse import chunk2sparse
except ImportError:
Expand Down Expand Up @@ -434,6 +435,23 @@ def setup_slurm_array(dsname, dsgroup="/", pythonpath=None):
logging.info("wrote " + sbat)
return sbat

def sbatchlocal(fname, cores=None):
"""
Execute a grid batch job on the local machine
Loops over the array submission for you
"""
import concurrent.futures
if cores is None:
cores = ImageD11.cImageD11.cores_available()
lines = open(fname,'r').readlines()
for line in lines:
if line.find('--array=')>=0:
start, end = line.split('=')[-1].split('-')
commands = [ 'SLURM_ARRAY_TASK_ID=%d bash %s > %s_%d.log'%(i, fname, fname, i )
for i in range(int(start), int(end)) ]
with concurrent.futures.ThreadPoolExecutor(max_workers = cores) as pool:
for _ in pool.map( os.system, commands ):
pass

def setup(
dsname,
Expand Down
18 changes: 11 additions & 7 deletions ImageD11/sinograms/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,13 +955,17 @@ def main(dsfilename, sparsefile=None, pksfile=None, options={}):
options["nproc"] = max(1, nscans - 1)
print("Nscans", nscans)
print("Options", options)
peaks, ks, P, rmem = goforit(ds, sparsefile, options) # ds.omega is passed here
t("%d label and pair" % (len(rmem.pk_props[0])))
if "save_overlaps" in options and options["save_overlaps"]:
rmem.save(pksfile + "_mat.h5", rc=True)
t("cache")
cc = rmem.find_uniq()
t("%s connected components" % (str(cc[0])))
if nscans > 1:
peaks, ks, P, rmem = goforit(ds, sparsefile, options) # ds.omega is passed here
t("%d label and pair" % (len(rmem.pk_props[0])))
if "save_overlaps" in options and options["save_overlaps"]:
rmem.save(pksfile + "_mat.h5", rc=True)
t("cache")
cc = rmem.find_uniq()
t("%s connected components" % (str(cc[0])))
else:
# single scan. Skips a lot of hassle.
rmem = pks_table_from_scan(sparsefile, ds, 0)
rmem.save(pksfile)
t("write hdf5")
except Exception as e:
Expand Down
4 changes: 3 additions & 1 deletion ImageD11/sparseframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ def __init__( self, hname, scan, start = 0, n=None,
for name in self.names:
if name in grp:
setattr( self, name, grp[name][s:e] )
if 'intensity' in self.names:
self.intensity = self.intensity.astype(np.float32)
# pointers into this scan
self.nnz = nnz[start:end]
self.ipt = nnz_to_pointer( self.nnz )
Expand Down Expand Up @@ -327,7 +329,7 @@ def lmlabel(self, threshold = 0, countall=True, smooth=True ):
if smooth:
self.signal = np.empty( self.intensity.shape, np.float32 )
else:
self.signal = self.intensity
self.signal = self.intensity.astype(np.float32)
# temporary workspaces
npxmax = self.nnz.max()
vmx = np.zeros( npxmax, np.float32 )
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install:
- "set TMPDIR=C:\\tmp"
- python -c "import sys; print(sys.executable, sys.version)"
- python -m pip install --upgrade pip setuptools
- python -m pip install pytest numpy
- python -m pip install pytest 'numpy<2'
- python -m pip install --ignore-installed certifi --upgrade-strategy only-if-needed --only-binary=h5py --only-binary=scipy --only-binary=hdf5plugin .


Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,16 @@ requires = ["setuptools",
"six",
"wheel",
"numpy; python_version=='2.7'",
# There is no way to compile for versions < 1.25 and up to 2.
# See https://numpy.org/doc/2.0/dev/depending_on_numpy.html
#
# This gives you all versions < 2.0
"oldest-supported-numpy; python_version>='3.0'" ]
#
# This gives all versions > 1.25
# "numpy>=2.0.0rc1; python_version>='3.0'" ]
#
# As usual, the dependencies are not ready.
# pin numpy < 2 for now.
#
build-backend = "setuptools.build_meta"
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def build_extension(self, ext):

minimal = [ # can't compile without this
"six",
"numpy",
'numpy ; python_version < "3"',
# Until the dependencies are ready
'numpy<2 ; python_version >= "3"',
"setuptools",
]

Expand Down

0 comments on commit 575c331

Please sign in to comment.