pyoframe 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl

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.
pyoframe/_version.py CHANGED
@@ -1,7 +1,14 @@
1
1
  # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
3
 
4
- __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
5
12
 
6
13
  TYPE_CHECKING = False
7
14
  if TYPE_CHECKING:
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
9
16
  from typing import Union
10
17
 
11
18
  VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
12
20
  else:
13
21
  VERSION_TUPLE = object
22
+ COMMIT_ID = object
14
23
 
15
24
  version: str
16
25
  __version__: str
17
26
  __version_tuple__: VERSION_TUPLE
18
27
  version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
19
30
 
20
- __version__ = version = '0.2.0'
21
- __version_tuple__ = version_tuple = (0, 2, 0)
31
+ __version__ = version = '0.2.1'
32
+ __version_tuple__ = version_tuple = (0, 2, 1)
33
+
34
+ __commit_id__ = commit_id = None
pyoframe/core.py CHANGED
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- import warnings
4
3
  from abc import ABC, abstractmethod
5
4
  from typing import (
6
5
  TYPE_CHECKING,
@@ -1148,16 +1147,22 @@ class Constraint(ModelElementWithId):
1148
1147
  except KeyError:
1149
1148
  setter = self._model.poi.set_constraint_raw_attribute
1150
1149
 
1150
+ constr_type = (
1151
+ poi.ConstraintType.Quadratic
1152
+ if self.lhs.is_quadratic
1153
+ else poi.ConstraintType.Linear
1154
+ )
1155
+
1151
1156
  if self.dimensions is None:
1152
1157
  for key in self.data.get_column(CONSTRAINT_KEY):
1153
- setter(poi.ConstraintIndex(poi.ConstraintType.Linear, key), name, value)
1158
+ setter(poi.ConstraintIndex(constr_type, key), name, value)
1154
1159
  else:
1155
1160
  for key, value in (
1156
1161
  self.data.join(value, on=self.dimensions, how="inner")
1157
1162
  .select(pl.col(CONSTRAINT_KEY), pl.col(col_name))
1158
1163
  .iter_rows()
1159
1164
  ):
1160
- setter(poi.ConstraintIndex(poi.ConstraintType.Linear, key), name, value)
1165
+ setter(poi.ConstraintIndex(constr_type, key), name, value)
1161
1166
 
1162
1167
  @unwrap_single_values
1163
1168
  def _get_attribute(self, name):
@@ -1169,21 +1174,16 @@ class Constraint(ModelElementWithId):
1169
1174
  except KeyError:
1170
1175
  getter = self._model.poi.get_constraint_raw_attribute
1171
1176
 
1172
- with (
1173
- warnings.catch_warnings()
1174
- ): # map_elements without return_dtype= gives a warning
1175
- warnings.filterwarnings(
1176
- action="ignore", category=pl.exceptions.MapWithoutReturnDtypeWarning
1177
- )
1178
- return self.data.with_columns(
1179
- pl.col(CONSTRAINT_KEY)
1180
- .map_elements(
1181
- lambda v_id: getter(
1182
- poi.ConstraintIndex(poi.ConstraintType.Linear, v_id), name
1183
- )
1184
- )
1185
- .alias(col_name)
1186
- ).select(self.dimensions_unsafe + [col_name])
1177
+ constr_type = (
1178
+ poi.ConstraintType.Quadratic
1179
+ if self.lhs.is_quadratic
1180
+ else poi.ConstraintType.Linear
1181
+ )
1182
+
1183
+ ids = self.data.get_column(CONSTRAINT_KEY).to_list()
1184
+ attr = [getter(poi.ConstraintIndex(constr_type, v_id), name) for v_id in ids]
1185
+ data = self.data.with_columns(pl.Series(attr).alias(col_name))
1186
+ return data.select(self.dimensions_unsafe + [col_name])
1187
1187
 
1188
1188
  def on_add_to_model(self, model: "Model", name: str):
1189
1189
  super().on_add_to_model(model, name)
@@ -1546,17 +1546,10 @@ class Variable(ModelElementWithId, SupportsMath, SupportPolarsMethodMixin):
1546
1546
  except KeyError:
1547
1547
  getter = self._model.poi.get_variable_raw_attribute
1548
1548
 
1549
- with (
1550
- warnings.catch_warnings()
1551
- ): # map_elements without return_dtype= gives a warning
1552
- warnings.filterwarnings(
1553
- action="ignore", category=pl.exceptions.MapWithoutReturnDtypeWarning
1554
- )
1555
- return self.data.with_columns(
1556
- pl.col(VAR_KEY)
1557
- .map_elements(lambda v_id: getter(poi.VariableIndex(v_id), name))
1558
- .alias(col_name)
1559
- ).select(self.dimensions_unsafe + [col_name])
1549
+ ids = self.data.get_column(VAR_KEY).to_list()
1550
+ attr = [getter(poi.VariableIndex(v_id), name) for v_id in ids]
1551
+ data = self.data.with_columns(pl.Series(attr).alias(col_name))
1552
+ return data.select(self.dimensions_unsafe + [col_name])
1560
1553
 
1561
1554
  def _assign_ids(self):
1562
1555
  kwargs = dict(domain=self.vtype.to_poi())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyoframe
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Blazing fast linear program interface
5
5
  Author-email: Bravos Power <dev@bravospower.com>
6
6
  License-Expression: MIT
@@ -1,15 +1,15 @@
1
1
  pyoframe/__init__.py,sha256=YswFUwm6GX98dXeT99hqxWqYWLELS71JZf1OpT1kvCg,619
2
2
  pyoframe/_arithmetic.py,sha256=agJm2Sl4EjEG7q4n2YHka4mGfCQI3LjOXLaW6oCfGiQ,17222
3
- pyoframe/_version.py,sha256=iB5DfB5V6YB5Wo4JmvS-txT42QtmGaWcWp3udRT7zCI,511
3
+ pyoframe/_version.py,sha256=vYqoJTG51NOUmYyL0xt8asRK8vUT4lGAdal_EZ59mvw,704
4
4
  pyoframe/constants.py,sha256=WBCmhunavNVwJcmg9ojnA6TVJCLSrgWVE4YKZnhZNz4,4192
5
- pyoframe/core.py,sha256=kK-eMI7teakAAG4JjOiwRBsCgNJIlOxR0b4JOUlQHs4,67239
5
+ pyoframe/core.py,sha256=fjCu4eY7QJSFvVfCNtMq-o_spoo76FWO4AviCssHGoo,66925
6
6
  pyoframe/model.py,sha256=a7pEwagVxHC1ZUMr8ifO4n0ca5Ways3wip-Wps0rlcg,14257
7
7
  pyoframe/model_element.py,sha256=YmAdx4yM5irGTiZ5uQmDa-u05QdFKngIFy8qNnogvzo,5911
8
8
  pyoframe/monkey_patch.py,sha256=9IfS14G6IPabmM9z80jzi_D4Rq0Mdx5aUCA39Yi2tgE,2044
9
9
  pyoframe/objective.py,sha256=PBWxj30QkFlsvY6ijZ6KjyKdrJARD4to0ieF6GUqaQU,3238
10
10
  pyoframe/util.py,sha256=dHIwAyyD9wn36yM8IOlrboTGUGA7STq3IBTxfYSOPjU,13480
11
- pyoframe-0.2.0.dist-info/licenses/LICENSE,sha256=u_Spw4ynlwTMRZeCX-uacv_hBU547pBygiA6d2ONNV4,1074
12
- pyoframe-0.2.0.dist-info/METADATA,sha256=GTwsHP14u5Zwb1E4pnjyeCS9-0DVmLXjNlo3ebZiSbw,3607
13
- pyoframe-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
- pyoframe-0.2.0.dist-info/top_level.txt,sha256=10z3OOJSVLriQ0IrFLMH8CH9zByugPWolqhlHlkNjV4,9
15
- pyoframe-0.2.0.dist-info/RECORD,,
11
+ pyoframe-0.2.1.dist-info/licenses/LICENSE,sha256=u_Spw4ynlwTMRZeCX-uacv_hBU547pBygiA6d2ONNV4,1074
12
+ pyoframe-0.2.1.dist-info/METADATA,sha256=_rmMdRjfEkv-1xn9UkjVubVxNUqSKgluVmXz7nSaRnA,3607
13
+ pyoframe-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ pyoframe-0.2.1.dist-info/top_level.txt,sha256=10z3OOJSVLriQ0IrFLMH8CH9zByugPWolqhlHlkNjV4,9
15
+ pyoframe-0.2.1.dist-info/RECORD,,