polytope-python 1.0.14__tar.gz → 1.0.16__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. {polytope-python-1.0.14/polytope_python.egg-info → polytope-python-1.0.16}/PKG-INFO +1 -1
  2. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/backends/datacube.py +17 -13
  3. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_cyclic/datacube_cyclic.py +1 -1
  4. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_type_change/datacube_type_change.py +6 -1
  5. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/engine/hullslicer.py +2 -1
  6. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/shapes.py +7 -2
  7. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/utility/combinatorics.py +0 -16
  8. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/utility/exceptions.py +1 -1
  9. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/utility/list_tools.py +19 -0
  10. polytope-python-1.0.16/polytope_feature/version.py +1 -0
  11. {polytope-python-1.0.14 → polytope-python-1.0.16/polytope_python.egg-info}/PKG-INFO +1 -1
  12. polytope-python-1.0.14/polytope_feature/version.py +0 -1
  13. {polytope-python-1.0.14 → polytope-python-1.0.16}/LICENSE +0 -0
  14. {polytope-python-1.0.14 → polytope-python-1.0.16}/MANIFEST.in +0 -0
  15. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/__init__.py +0 -0
  16. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/__init__.py +0 -0
  17. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/backends/__init__.py +0 -0
  18. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/backends/fdb.py +0 -0
  19. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/backends/mock.py +0 -0
  20. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/backends/xarray.py +0 -0
  21. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/datacube_axis.py +0 -0
  22. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/index_tree_pb2.py +0 -0
  23. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/tensor_index_tree.py +0 -0
  24. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/__init__.py +0 -0
  25. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_cyclic/__init__.py +0 -0
  26. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_mappers/__init__.py +0 -0
  27. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_mappers/datacube_mappers.py +0 -0
  28. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/__init__.py +0 -0
  29. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/healpix.py +0 -0
  30. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/healpix_nested.py +0 -0
  31. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/local_regular.py +0 -0
  32. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/octahedral.py +0 -0
  33. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/reduced_ll.py +0 -0
  34. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/regular.py +0 -0
  35. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_merger/__init__.py +0 -0
  36. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_merger/datacube_merger.py +0 -0
  37. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_reverse/__init__.py +0 -0
  38. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_reverse/datacube_reverse.py +0 -0
  39. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_transformations.py +0 -0
  40. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/transformations/datacube_type_change/__init__.py +0 -0
  41. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/datacube/tree_encoding.py +0 -0
  42. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/engine/__init__.py +0 -0
  43. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/engine/engine.py +0 -0
  44. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/options.py +0 -0
  45. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/polytope.py +0 -0
  46. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/utility/__init__.py +0 -0
  47. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/utility/geometry.py +0 -0
  48. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_feature/utility/profiling.py +0 -0
  49. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_python.egg-info/SOURCES.txt +0 -0
  50. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_python.egg-info/dependency_links.txt +0 -0
  51. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_python.egg-info/not-zip-safe +0 -0
  52. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_python.egg-info/requires.txt +0 -0
  53. {polytope-python-1.0.14 → polytope-python-1.0.16}/polytope_python.egg-info/top_level.txt +0 -0
  54. {polytope-python-1.0.14 → polytope-python-1.0.16}/pyproject.toml +0 -0
  55. {polytope-python-1.0.14 → polytope-python-1.0.16}/requirements.txt +0 -0
  56. {polytope-python-1.0.14 → polytope-python-1.0.16}/setup.cfg +0 -0
  57. {polytope-python-1.0.14 → polytope-python-1.0.16}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: polytope-python
3
- Version: 1.0.14
3
+ Version: 1.0.16
4
4
  Summary: Polytope datacube feature extraction library
5
5
  Home-page: https://github.com/ecmwf/polytope
6
6
  Author: ECMWF
@@ -79,19 +79,23 @@ class Datacube(ABC):
79
79
  for axis_name in final_axis_names:
80
80
  self.fake_axes.append(axis_name)
81
81
  # if axis does not yet exist, create it
82
-
83
- # first need to change the values so that we have right type
84
- values = transformation.change_val_type(axis_name, values)
85
- if self._axes is None or axis_name not in self._axes.keys():
86
- DatacubeAxis.create_standard(axis_name, values, self)
87
- # add transformation tag to axis, as well as transformation options for later
88
- setattr(self._axes[axis_name], has_transform[transformation_type_key.name], True) # where has_transform is
89
- # a factory inside datacube_transformations to set the has_transform, is_cyclic etc axis properties
90
- # add the specific transformation handled here to the relevant axes
91
- # Modify the axis to update with the tag
92
-
93
- if transformation not in self._axes[axis_name].transformations: # Avoids duplicates being stored
94
- self._axes[axis_name].transformations.append(transformation)
82
+ if transformation.change_val_type(axis_name, values) is not None:
83
+ # first need to change the values so that we have right type
84
+ values = transformation.change_val_type(axis_name, values)
85
+ if self._axes is None or axis_name not in self._axes.keys():
86
+ DatacubeAxis.create_standard(axis_name, values, self)
87
+ # add transformation tag to axis, as well as transformation options for later
88
+ setattr(self._axes[axis_name], has_transform[transformation_type_key.name], True)
89
+ # where has_transform is a factory inside datacube_transformations to set the has_transform, is_cyclic
90
+ # etc axis properties add the specific transformation handled here to the relevant axes
91
+ # Modify the axis to update with the tag
92
+
93
+ if transformation not in self._axes[axis_name].transformations: # Avoids duplicates being stored
94
+ self._axes[axis_name].transformations.append(transformation)
95
+ else:
96
+ # Means we have an unsliceable axis since we couln't transform values to desired type
97
+ if self._axes is None or axis_name not in self._axes.keys():
98
+ DatacubeAxis.create_standard(axis_name, values, self)
95
99
 
96
100
  def _add_all_transformation_axes(self, options, name, values):
97
101
  for transformation_type_key in options.transformations:
@@ -1,7 +1,7 @@
1
1
  import math
2
2
  from copy import deepcopy
3
3
 
4
- from ....utility.combinatorics import unique
4
+ from ....utility.list_tools import unique
5
5
  from ..datacube_transformations import DatacubeAxisTransformation
6
6
 
7
7
 
@@ -25,6 +25,8 @@ class DatacubeAxisTypeChange(DatacubeAxisTransformation):
25
25
 
26
26
  def change_val_type(self, axis_name, values):
27
27
  return_idx = [self._final_transformation.transform_type(val) for val in values]
28
+ if None in return_idx:
29
+ return None
28
30
  return_idx.sort()
29
31
  return return_idx
30
32
 
@@ -61,7 +63,10 @@ class TypeChangeStrToInt(DatacubeAxisTypeChange):
61
63
  self._new_type = new_type
62
64
 
63
65
  def transform_type(self, value):
64
- return int(value)
66
+ try:
67
+ return int(value)
68
+ except ValueError:
69
+ return None
65
70
 
66
71
  def make_str(self, value):
67
72
  values = []
@@ -9,9 +9,10 @@ from ..datacube.backends.datacube import Datacube
9
9
  from ..datacube.datacube_axis import UnsliceableDatacubeAxis
10
10
  from ..datacube.tensor_index_tree import TensorIndexTree
11
11
  from ..shapes import ConvexPolytope
12
- from ..utility.combinatorics import argmax, argmin, group, tensor_product, unique
12
+ from ..utility.combinatorics import group, tensor_product
13
13
  from ..utility.exceptions import UnsliceableShapeError
14
14
  from ..utility.geometry import lerp
15
+ from ..utility.list_tools import argmax, argmin, unique
15
16
  from .engine import Engine
16
17
 
17
18
 
@@ -1,10 +1,13 @@
1
1
  import copy
2
2
  import math
3
+ import warnings
3
4
  from abc import ABC, abstractmethod
4
5
  from typing import List
5
6
 
6
7
  import tripy
7
8
 
9
+ from .utility.list_tools import unique
10
+
8
11
  """
9
12
  Shapes used for the constructive geometry API of Polytope
10
13
  """
@@ -60,11 +63,13 @@ class ConvexPolytope(Shape):
60
63
 
61
64
  # This is the only shape which can slice on axes without a discretizer or interpolator
62
65
  class Select(Shape):
63
- """Matches several discrete value"""
66
+ """Matches several discrete values"""
64
67
 
65
68
  def __init__(self, axis, values, method=None):
66
69
  self.axis = axis
67
- self.values = values
70
+ self.values = unique(values)
71
+ if len(self.values) != len(values):
72
+ warnings.warn("Duplicate request values were removed")
68
73
  self.method = method
69
74
 
70
75
  def axes(self):
@@ -46,19 +46,3 @@ def validate_axes(actual_axes, test_axes):
46
46
  raise AxisNotFoundError(ax)
47
47
 
48
48
  return True
49
-
50
-
51
- def unique(points):
52
- points.sort()
53
- points = [k for k, _ in itertools.groupby(points)]
54
- return points
55
-
56
-
57
- def argmin(points):
58
- amin = min(range(len(points)), key=points.__getitem__)
59
- return amin
60
-
61
-
62
- def argmax(points):
63
- amax = max(range(len(points)), key=points.__getitem__)
64
- return amax
@@ -13,7 +13,7 @@ class AxisOverdefinedError(PolytopeError, KeyError):
13
13
  self.axis = axis
14
14
  self.message = (
15
15
  f"Axis {axis} is overdefined. You have used it in two or more input polytopes which"
16
- f"cannot form a union (because they span different axes)."
16
+ f" cannot form a union (because they span different axes)."
17
17
  )
18
18
 
19
19
 
@@ -1,3 +1,6 @@
1
+ import itertools
2
+
3
+
1
4
  def bisect_left_cmp(arr, val, cmp):
2
5
  left = -1
3
6
  r = len(arr)
@@ -20,3 +23,19 @@ def bisect_right_cmp(arr, val, cmp):
20
23
  else:
21
24
  r = e
22
25
  return r
26
+
27
+
28
+ def unique(points):
29
+ points.sort()
30
+ points = [k for k, _ in itertools.groupby(points)]
31
+ return points
32
+
33
+
34
+ def argmin(points):
35
+ amin = min(range(len(points)), key=points.__getitem__)
36
+ return amin
37
+
38
+
39
+ def argmax(points):
40
+ amax = max(range(len(points)), key=points.__getitem__)
41
+ return amax
@@ -0,0 +1 @@
1
+ __version__ = "1.0.16"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: polytope-python
3
- Version: 1.0.14
3
+ Version: 1.0.16
4
4
  Summary: Polytope datacube feature extraction library
5
5
  Home-page: https://github.com/ecmwf/polytope
6
6
  Author: ECMWF
@@ -1 +0,0 @@
1
- __version__ = "1.0.14"