diff --git a/pygm/__init__.py b/pygm/__init__.py index 016fe66..8276486 100644 --- a/pygm/__init__.py +++ b/pygm/__init__.py @@ -1,5 +1,5 @@ __all__ = ['SortedList', 'SortedSet'] -__version__ = '1.0' +__version__ = '1.0.1' __author__ = 'Giorgio Vinciguerra' import os as _os diff --git a/pygm/pygm.cpp b/pygm/pygm.cpp index 294d1db..a90a412 100644 --- a/pygm/pygm.cpp +++ b/pygm/pygm.cpp @@ -272,25 +272,19 @@ template class PGMWrapper : private pgm::PGMIndexlevels_offsets[level_num + 1] - this->levels_offsets[level_num] - 1; } - std::unordered_map segment(size_t level_num, size_t segment_num) { + py::dict segment(size_t level_num, size_t segment_num) { if (level_num >= this->height()) throw std::invalid_argument("level can't be >= index height"); if (segment_num >= num_segments(level_num)) throw std::invalid_argument("segment can't be >= number of segments in level"); - std::unordered_map segment; - segment["epsilon"] = level_num == 0 ? get_epsilon() : get_epsilon_recursive(); - - auto segment_it = this->segments.begin() + this->levels_offsets[level_num]; - for (int sn = segment_num; sn > 0; --sn) { - ++segment_it; - } - - segment["key"] = segment_it->key; - segment["slope"] = segment_it->slope; - segment["intercept"] = segment_it->intercept; - - return segment; + auto &s = this->segments[this->levels_offsets[level_num] + segment_num]; + py::dict out; + out["key"] = s.key; + out["slope"] = s.slope; + out["intercept"] = s.intercept; + out["epsilon"] = level_num == 0 ? get_epsilon() : get_epsilon_recursive(); + return out; } K operator[](size_t i) const { return data[i]; } diff --git a/setup.py b/setup.py index 3033abc..cf25a07 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ import setuptools from setuptools.command.build_ext import build_ext -__version__ = '1.0' +__version__ = '1.0.1' class get_pybind_include(object): @@ -117,7 +117,7 @@ def gcc_sort_key(p): zip_safe=False, classifiers=[ 'License :: OSI Approved :: Apache Software License', - 'Development Status :: 3 - Alpha', + 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Intended Audience :: Information Technology', 'Intended Audience :: Science/Research', @@ -131,6 +131,9 @@ def gcc_sort_key(p): 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Database', 'Topic :: Scientific/Engineering', 'Topic :: Scientific/Engineering :: Artificial Intelligence',