Skip to content

Commit

Permalink
Merge branch 'feature/ES-685_getEventIndexBefore_fix' into feature/mi…
Browse files Browse the repository at this point in the history
…nor_fixes
  • Loading branch information
StokesMIDE committed Jun 6, 2024
2 parents 1bab525 + 2d0279b commit ab0ca61
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
exclude:
- os: ubuntu-latest
python-version: '3.6'
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version: 2
build:
os: ubuntu-20.04
tools:
python: "3.8"
python: "3.9"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand Down
14 changes: 7 additions & 7 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ pytz==2021.3
requests==2.26.0
snowballstemmer==2.2.0
soupsieve==2.3.1
Sphinx==4.3.1
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
Sphinx>=5.0.2
sphinxcontrib-applehelp
sphinxcontrib-devhelp
sphinxcontrib-htmlhelp
sphinxcontrib-jsmath
sphinxcontrib-qthelp
sphinxcontrib-serializinghtml
urllib3==1.26.7
22 changes: 18 additions & 4 deletions idelib/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1977,13 +1977,23 @@ def getEventIndexBefore(self, t):
except IndexError:
block = self._data[-1]

if t > block.endTime:
if block.numSamples < 2 or t == block.startTime:
return block.indexRange[0]

elif t > block.endTime:
# Time falls within a gap between blocks
return block.indexRange[-1]

return int(mapRange(t,
block.startTime, block.endTime,
block.indexRange[0], block.indexRange[1]-1))
try:
return int(mapRange(t,
block.startTime, block.endTime,
block.indexRange[0], block.indexRange[1]-1))
except (ValueError, ZeroDivisionError) as err:
# Probably division by zero (block start/end times and/or indices the same)
# Unlikely if block has >1 samples, but catch it anyway.
logger.debug(f'ignoring {type(err).__name__} in getEventIndexBefore() '
f'(probably okay): {err}')
return block.indexRange[0]

# return int((block.indexRange[0] +
# ((t - block.startTime) / self._getBlockSampleTime(blockIdx))))
Expand Down Expand Up @@ -2813,6 +2823,10 @@ def _accessCache(self, start, end, step):
return self._cacheArray[start:end:step]

def _inplaceTime(self, start, end, step, out=None):
""" Generate a series of timestamps between `start` and `end`,
inserted into an existing array (if provided). If `out`
is `None`, a new array is created.
"""
if out is None:
out = np.empty((int(np.ceil((end - start)/step)),))

Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ pytest>=4.6
pytest-xdist[psutil]
mock
pytest-cov
sphinx==5.0.2
sphinx>=5.0.2
scipy;python_version<"3.10"
setuptools
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ def get_version(rel_path):
'pytest-xdist[psutil]',
'mock',
'pytest-cov',
"sphinx==5.0.2",
"sphinx>=5.0.2",
'scipy;python_version<"3.10"',
"setuptools"
]

DOCS_REQUIRES = [
"sphinx==5.0.2",
"sphinx>=5.0.2",
"pydata-sphinx-theme==0.7.2",
"nbsphinx",
]
Expand Down

0 comments on commit ab0ca61

Please sign in to comment.