From bf0090affc87b1c9dfcce914d4bf50e9cbbd85bd Mon Sep 17 00:00:00 2001 From: joncrall Date: Sun, 5 Nov 2023 19:13:11 -0500 Subject: [PATCH 1/3] Start branch for 0.7.7 --- CHANGELOG.md | 5 ++++- ndsampler/__init__.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd3f6bb..efb7dd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,10 @@ This changelog follows the specifications detailed in: [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), although we have not yet reached a `1.0.0` release. -## Version 0.7.6 - Unreleased +## Version 0.7.7 - Unreleased + + +## Version 0.7.6 - Released 2023-11-05 ## Version 0.7.5 - Released 2023-09-30 diff --git a/ndsampler/__init__.py b/ndsampler/__init__.py index 726133d..3021b19 100644 --- a/ndsampler/__init__.py +++ b/ndsampler/__init__.py @@ -2,7 +2,7 @@ mkinit ~/code/ndsampler/ndsampler/__init__.py --diff mkinit ~/code/ndsampler/ndsampler/__init__.py -w """ -__version__ = '0.7.6' +__version__ = '0.7.7' from ndsampler.utils.util_misc import (HashIdentifiable,) -- GitLab From a3393d91abd276a24cf89438d1cafe3b7bf887e2 Mon Sep 17 00:00:00 2001 From: joncrall Date: Fri, 17 Nov 2023 15:00:26 -0500 Subject: [PATCH 2/3] Fix docs --- docs/source/conf.py | 25 ++++++++++++++++++++----- ndsampler/coco_sampler.py | 27 ++++++++++++++++++++++----- pyproject.toml | 1 + requirements/docs.txt | 1 + requirements/tests.txt | 2 +- 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 651a453..519bb60 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -163,6 +163,9 @@ autoclass_content = 'both' # autoapi_dirs = [f'../../src/{modname}'] # autoapi_keep_files = True +# References: +# https://stackoverflow.com/questions/21538983/specifying-targets-for-intersphinx-links-to-numpy-scipy-and-matplotlib + intersphinx_mapping = { # 'pytorch': ('http://pytorch.org/docs/master/', None), 'python': ('https://docs.python.org/3', None), @@ -181,10 +184,20 @@ intersphinx_mapping = { 'scriptconfig': ('https://scriptconfig.readthedocs.io/en/latest/', None), 'rich': ('https://rich.readthedocs.io/en/latest/', None), + 'numpy': ('https://numpy.org/doc/stable/', None), + 'sympy': ('https://docs.sympy.org/latest/', None), + 'scikit-learn': ('https://scikit-learn.org/stable/', None), + 'pandas': ('https://pandas.pydata.org/docs/', None), + 'matplotlib': ('https://matplotlib.org/stable/', None), + 'pytest': ('https://docs.pytest.org/en/latest/', None), + 'platformdirs': ('https://platformdirs.readthedocs.io/en/latest/', None), + + 'timerit': ('https://timerit.readthedocs.io/en/latest/', None), + 'progiter': ('https://progiter.readthedocs.io/en/latest/', None), + 'dateutil': ('https://dateutil.readthedocs.io/en/latest/', None), # 'pytest._pytest.doctest': ('https://docs.pytest.org/en/latest/_modules/_pytest/doctest.html', None), # 'colorama': ('https://pypi.org/project/colorama/', None), - # 'numpy': ('http://docs.scipy.org/doc/numpy/', None), # 'cv2' : ('http://docs.opencv.org/2.4/', None), # 'h5py' : ('http://docs.h5py.org/en/latest/', None) } @@ -337,8 +350,10 @@ class PatchedPythonDomain(PythonDomain): """ def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode): # TODO: can use this to resolve references nicely - # if target.startswith('ub.'): - # target = 'ubelt.' + target[3] + if target.startswith('ub.'): + target = 'ubelt.' + target[3] + if target.startswith('xdoc.'): + target = 'xdoctest.' + target[3] return_value = super(PatchedPythonDomain, self).resolve_xref( env, fromdocname, builder, typ, target, node, contnode) return return_value @@ -545,8 +560,8 @@ class GoogleStyleDocstringProcessor: # import xdev # xdev.embed() - RENDER_IMAGES = 1 - if RENDER_IMAGES: + render_doc_images = 1 + if render_doc_images: # DEVELOPING if any('REQUIRES(--show)' in line for line in lines): # import xdev diff --git a/ndsampler/coco_sampler.py b/ndsampler/coco_sampler.py index b9f44ae..ccb4e4b 100644 --- a/ndsampler/coco_sampler.py +++ b/ndsampler/coco_sampler.py @@ -824,7 +824,20 @@ class CocoSampler(abstract_sampler.AbstractSampler, util_misc.HashIdentifiable, if target is None: raise ValueError('The target dictionary must be specified') + verbose_ndsample = target.get('verbose_ndsample', False) target_ = self._infer_target_attributes(target, **kwargs) + if verbose_ndsample: + print('Load Sample:') + print('target_ = {}'.format(ub.urepr(target_, nl=1))) + print('Load Sample Inferred:') + inferred_lines = [] + for k in target_: + v1 = target.get(k, None) + v2 = target_.get(k, None) + if v1 != v2: + inferred_lines.append(f'* {k}: {v1} -> {v2}') + print('\n'.join(inferred_lines)) + sample = self._load_slice(target_) if with_annots or ub.iterable(with_annots): @@ -1196,12 +1209,13 @@ class CocoSampler(abstract_sampler.AbstractSampler, util_misc.HashIdentifiable, if data_dims is None: _req_real_slice = requested_slice _req_extra_pad = [(0, 0), (0, 0)] + resolved_slice = requested_slice else: _req_real_slice, _req_extra_pad = kwarray.embed_slice(requested_slice, data_dims) - resolved_slice = tuple([ - slice(s.start - p_lo, s.stop + p_hi, s.step) - for s, (p_lo, p_hi) in zip(_req_real_slice, _req_extra_pad) - ]) + resolved_slice = tuple([ + slice(s.start - p_lo, s.stop + p_hi, s.step) + for s, (p_lo, p_hi) in zip(_req_real_slice, _req_extra_pad) + ]) channels = target_.get('channels', ub.NoParam) @@ -1717,7 +1731,10 @@ class CocoSampler(abstract_sampler.AbstractSampler, util_misc.HashIdentifiable, sample_box: kwimage.Boxes = params['sample_tlbr'] offset = params['offset'] data_dims = params['data_dims'] - space_dims = data_dims[-2:] + if data_dims is not None: + space_dims = data_dims[-2:] + else: + space_dims = None coco_dset = self.dset kp_classes = self.kp_classes diff --git a/pyproject.toml b/pyproject.toml index 0132ee8..4526424 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,6 +15,7 @@ ci_cpython_versions = ["3.6", "3.7", "3.8", "3.9", "3.10"] author = "Jon Crall" author_email = "jon.crall@kitware.com" description = "Fast sampling from large images" +render_doc_images = 1 url = "https://gitlab.kitware.com/computer-vision/ndsampler" license = "Apache 2" dev_status = "beta" diff --git a/requirements/docs.txt b/requirements/docs.txt index 57d0dab..6b3ca62 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -6,3 +6,4 @@ sphinx-autoapi >= 1.8.4 Pygments >= 2.9.0 myst_parser >= 0.18.0 sphinx-reredirects >= 0.0.1 +xdoctest >= 1.1.2 diff --git a/requirements/tests.txt b/requirements/tests.txt index 5fec1f6..adf8d1f 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,5 +1,5 @@ pytest >= 6.2.4 coverage >= 5.2.1 -xdoctest >= 0.15.6 +xdoctest >= 1.1.2 pytest-cov >= 2.12.1 ; python_version >= '3.6.0' pytest-cov >= 2.0.0, < 2.6.0 ; python_version < '3.6.0' -- GitLab From fec3711149557bc45879bac3d8026cdd6f27b4d4 Mon Sep 17 00:00:00 2001 From: joncrall Date: Fri, 17 Nov 2023 15:35:41 -0500 Subject: [PATCH 3/3] wip --- requirements/docs.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/docs.txt b/requirements/docs.txt index 6b3ca62..b14165e 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -7,3 +7,4 @@ Pygments >= 2.9.0 myst_parser >= 0.18.0 sphinx-reredirects >= 0.0.1 xdoctest >= 1.1.2 +kwplot >= 0.4.15 -- GitLab