pyconvexity 0.3.8.post6__py3-none-any.whl → 0.4.0__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.

Potentially problematic release.


This version of pyconvexity might be problematic. Click here for more details.

pyconvexity/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.3.8post6"
1
+ __version__ = "0.4.0"
@@ -12,49 +12,85 @@ from pyconvexity.models.components import (
12
12
  )
13
13
 
14
14
  from pyconvexity.models.attributes import (
15
- set_static_attribute, set_timeseries_attribute, get_attribute, delete_attribute
15
+ set_static_attribute, set_timeseries_attribute, get_attribute, delete_attribute,
16
+ get_timeseries, get_timeseries_metadata
16
17
  )
17
18
 
18
19
  from pyconvexity.models.network import (
19
20
  create_network, get_network_info, get_network_time_periods, list_networks,
20
- create_carrier, list_carriers, get_network_config, set_network_config,
21
+ create_carrier, get_network_config, set_network_config,
21
22
  get_component_counts, get_master_scenario_id, resolve_scenario_id,
22
23
  get_first_network, get_network_by_name
23
24
  )
24
25
 
25
26
  # Import from new modules
26
27
  from pyconvexity.models.scenarios import (
27
- list_scenarios as list_scenarios_new,
28
- get_scenario_by_name, get_scenario_by_id, get_master_scenario
28
+ list_scenarios,
29
+ get_scenario_by_name, get_scenario_by_id, get_master_scenario,
30
+ Scenario
29
31
  )
30
32
 
31
33
  from pyconvexity.models.results import (
32
- get_solve_results, get_yearly_results
34
+ get_solve_results, get_yearly_results,
35
+ SolveResults, YearlyResults
33
36
  )
34
37
 
35
38
  from pyconvexity.models.carriers import (
36
- list_carriers as list_carriers_new,
37
- get_carrier_by_name, get_carrier_by_id, get_carrier_colors
39
+ list_carriers,
40
+ get_carrier_by_name, get_carrier_by_id, get_carrier_colors,
41
+ Carrier
38
42
  )
39
43
 
40
- # Try to import old scenarios functions if they exist
41
- try:
42
- from pyconvexity.models.scenarios_old import (
43
- create_scenario, list_scenarios as list_scenarios_old,
44
- get_scenario, delete_scenario
45
- )
46
- # Use old functions as primary for backward compatibility
47
- list_scenarios_primary = list_scenarios_old
48
- except ImportError:
49
- # Old module doesn't exist, use new functions
50
- list_scenarios_primary = list_scenarios_new
51
- # Create dummy functions for backward compatibility
52
- def create_scenario(*args, **kwargs):
53
- raise NotImplementedError("create_scenario not yet implemented in new API")
54
- def get_scenario(*args, **kwargs):
55
- return get_scenario_by_id(*args, **kwargs)
56
- def delete_scenario(*args, **kwargs):
57
- raise NotImplementedError("delete_scenario not yet implemented in new API")
44
+ # Backward compatibility aliases
45
+ def get_scenario(conn, scenario_id):
46
+ """Backward compatible alias for get_scenario_by_id."""
47
+ return get_scenario_by_id(conn, scenario_id)
48
+
49
+ def create_scenario(conn, network_id, name, description=None, is_master=False):
50
+ """
51
+ Create a new scenario.
52
+
53
+ Args:
54
+ conn: Database connection
55
+ network_id: Network ID
56
+ name: Scenario name
57
+ description: Optional description
58
+ is_master: Whether this is the master scenario (will demote existing master)
59
+
60
+ Returns:
61
+ Scenario ID
62
+ """
63
+ cursor = conn.execute("""
64
+ INSERT INTO scenarios (network_id, name, description, is_master)
65
+ VALUES (?, ?, ?, ?)
66
+ """, (network_id, name, description, is_master))
67
+
68
+ scenario_id = cursor.lastrowid
69
+ return scenario_id
70
+
71
+ def delete_scenario(conn, scenario_id):
72
+ """
73
+ Delete a scenario (cannot delete master scenario).
74
+
75
+ Args:
76
+ conn: Database connection
77
+ scenario_id: Scenario ID to delete
78
+
79
+ Raises:
80
+ ValidationError: If trying to delete master scenario or scenario doesn't exist
81
+ """
82
+ from pyconvexity.core.errors import ValidationError
83
+
84
+ # Check if it's a master scenario
85
+ scenario = get_scenario_by_id(conn, scenario_id)
86
+ if scenario.is_master:
87
+ raise ValidationError("Cannot delete master scenario")
88
+
89
+ # Delete the scenario
90
+ cursor = conn.execute("DELETE FROM scenarios WHERE id = ?", (scenario_id,))
91
+
92
+ if cursor.rowcount == 0:
93
+ raise ValidationError(f"Scenario with ID {scenario_id} not found")
58
94
 
59
95
  __all__ = [
60
96
  # Component operations
@@ -65,6 +101,7 @@ __all__ = [
65
101
 
66
102
  # Attribute operations
67
103
  "set_static_attribute", "set_timeseries_attribute", "get_attribute", "delete_attribute",
104
+ "get_timeseries", "get_timeseries_metadata",
68
105
 
69
106
  # Network operations
70
107
  "create_network", "get_network_info", "get_network_time_periods", "list_networks",
@@ -73,15 +110,15 @@ __all__ = [
73
110
  "get_first_network", "get_network_by_name",
74
111
 
75
112
  # Scenario operations (backward compatible)
76
- "create_scenario", "list_scenarios_primary", "get_scenario", "delete_scenario",
77
- "list_scenarios_new", "get_scenario_by_name", "get_scenario_by_id", "get_master_scenario",
113
+ "create_scenario", "list_scenarios", "get_scenario", "delete_scenario",
114
+ "get_scenario_by_name", "get_scenario_by_id", "get_master_scenario",
115
+ "Scenario",
78
116
 
79
117
  # Results operations
80
118
  "get_solve_results", "get_yearly_results",
119
+ "SolveResults", "YearlyResults",
81
120
 
82
121
  # Carrier operations
83
- "list_carriers_new", "get_carrier_by_name", "get_carrier_by_id", "get_carrier_colors",
122
+ "get_carrier_by_name", "get_carrier_by_id", "get_carrier_colors",
123
+ "Carrier",
84
124
  ]
85
-
86
- # Expose primary list_scenarios for convenience
87
- list_scenarios = list_scenarios_primary
@@ -422,9 +422,7 @@ class NetworkSolver:
422
422
  # Removed MSK_DPAR_INTPNT_TOL_INFEAS - was 1000x tighter than other tolerances!
423
423
  'MSK_IPAR_NUM_THREADS': 0, # Use all available cores (0 = auto)
424
424
  'MSK_IPAR_PRESOLVE_USE': 2, # Aggressive presolve (match Gurobi Presolve=2)
425
- 'MSK_IPAR_PRESOLVE_LINDEP_USE': 1, # Linear dependency check
426
425
  'MSK_DPAR_MIO_REL_GAP_CONST': 0.05, # Match Gurobi 5% MIP gap
427
- 'MSK_IPAR_MIO_NODE_OPTIMIZER': 4, # Use interior-point for MIP nodes
428
426
  'MSK_IPAR_MIO_ROOT_OPTIMIZER': 4, # Use interior-point for MIP root
429
427
  'MSK_DPAR_MIO_MAX_TIME': 36000, # Max time 10 hour
430
428
  }
@@ -458,7 +456,6 @@ class NetworkSolver:
458
456
  'MSK_IPAR_NUM_THREADS': 0, # Use all available cores (0 = automatic)
459
457
  'MSK_IPAR_PRESOLVE_USE': 1, # Force presolve
460
458
  'MSK_DPAR_MIO_REL_GAP_CONST': 0.05, # Match Gurobi 5% MIP gap (was 1e-6)
461
- 'MSK_IPAR_MIO_NODE_OPTIMIZER': 1, # Use dual simplex for MIP nodes (1 = MSK_OPTIMIZER_DUAL_SIMPLEX)
462
459
  'MSK_IPAR_MIO_ROOT_OPTIMIZER': 1, # Use dual simplex for MIP root
463
460
  'MSK_DPAR_MIO_MAX_TIME': 36000, # Max time 10 hour (safety limit)
464
461
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyconvexity
3
- Version: 0.3.8.post6
3
+ Version: 0.4.0
4
4
  Summary: Python library for energy system modeling and optimization with PyPSA
5
5
  Author-email: Convexity Team <info@convexity.com>
6
6
  License: MIT
@@ -1,5 +1,5 @@
1
1
  pyconvexity/__init__.py,sha256=eiAFroO4n-z8F0jTLpJgBIO7vtSxu9ovu3G2N-qqpUo,4783
2
- pyconvexity/_version.py,sha256=jO5GlIb68CD0eDfWJLp-lwidoi1UzGwf4_unGDQim90,27
2
+ pyconvexity/_version.py,sha256=42STGor_9nKYXumfeV5tiyD_M8VdcddX7CEexmibPBk,22
3
3
  pyconvexity/timeseries.py,sha256=4p1Tdpa1otqDvCq2zppA4tw660sF_XWb8Xobib-cCms,11340
4
4
  pyconvexity/core/__init__.py,sha256=MgVa5rrRWIi2w1UI1P4leiBntvHeeOPv0Thm0DEXBHo,1209
5
5
  pyconvexity/core/database.py,sha256=M02q4UkJqAPeTXuwng9I7kHm16reJ7eq7wccWxnhE5I,15227
@@ -7,11 +7,8 @@ pyconvexity/core/errors.py,sha256=HhrrOOEBJrzyB56_pmqh3NWvX6uHqWWNkdE5XM16rYI,28
7
7
  pyconvexity/core/types.py,sha256=LkB49qklA-9ObI0br0IazfVxvWvYzQrYMdwzrqqAMYQ,11335
8
8
  pyconvexity/data/README.md,sha256=-tyDHVjqzfWbVvgM4yYYx8cysmgvFXI6plVQNxSHBmo,3156
9
9
  pyconvexity/data/__init__.py,sha256=BrgC3LGSlReLbC0EpM6UxywwUHxRvts379CvZFE0qWU,514
10
- pyconvexity/data/__pycache__/__init__.cpython-313.pyc,sha256=F2XXlQZlN5aoFmi7Ar1B3RW-DZjIUqp81fr3zNsPxpY,617
11
10
  pyconvexity/data/loaders/__init__.py,sha256=6xPtOmH2n1mNby7ZjA-2Mk9F48Q246RNsyMnCnJ6gwA,60
12
11
  pyconvexity/data/loaders/cache.py,sha256=nnz8bV3slSehOT0alexFga9tM1XoJqWHBGqaXvz132U,7299
13
- pyconvexity/data/loaders/__pycache__/__init__.cpython-313.pyc,sha256=AuT3aXy3v5gssxdD1_CBaKqNAVmDt6GBwFSyAe3jHow,265
14
- pyconvexity/data/loaders/__pycache__/cache.cpython-313.pyc,sha256=9_xMQN6AciMzbzhCmWAzvEKRXfRINmfRsO8Dyg0_CUQ,9804
15
12
  pyconvexity/data/schema/01_core_schema.sql,sha256=2kkEevAhXJtNnC-wca2bnyw0m11mjheh4g9MPZpwBAc,20865
16
13
  pyconvexity/data/schema/02_data_metadata.sql,sha256=oOfwa3PLY2_8rxKDD4cpDeqP5I_PdahcF8m6cSKStJM,10732
17
14
  pyconvexity/data/schema/03_validation_data.sql,sha256=1rKFi9y6jQ2OnfH32jnIKnZ5WtB8eG43hz0OVJhwn3w,58325
@@ -19,14 +16,12 @@ pyconvexity/data/schema/04_scenario_schema.sql,sha256=sL4PySJNHIthXsnoJ2T5pdXUbp
19
16
  pyconvexity/data/schema/migrate_add_geometries.sql,sha256=ljTz2ZIvfRkHCjJiUbZJr7PvUxPv3UeLl3ADb9U7dWc,2710
20
17
  pyconvexity/data/sources/__init__.py,sha256=Dn6_oS7wB-vLjMj2YeXlmIl6hNjACbicimSabKxIWnc,108
21
18
  pyconvexity/data/sources/gem.py,sha256=Ft2pAYsWe1V9poRge2Q4xdNt15XkG-USSR0XR9KFmsY,14935
22
- pyconvexity/data/sources/__pycache__/__init__.cpython-313.pyc,sha256=9x5FyLxmTE5ZRaEFNSF375KBd_rDLY6pGHGSWPpcxxA,313
23
- pyconvexity/data/sources/__pycache__/gem.cpython-313.pyc,sha256=VA7v6miTbKJcSMwKElsRKwuyGP3ek95O3ALa133Lx_U,14476
24
19
  pyconvexity/io/__init__.py,sha256=glGzXBRGHROrTS8xe-RTGyRQUgsaksafxXVt9GpW63E,803
25
20
  pyconvexity/io/excel_exporter.py,sha256=pjgvTs5vq9K61mNOVutEzaH5Zx4FgrDG4Xc_YmXhE5o,48483
26
21
  pyconvexity/io/excel_importer.py,sha256=M7YcBqKUVzOMoR5HN-v8M2UnZgHRfhqgXBMUVD10-IQ,56898
27
22
  pyconvexity/io/netcdf_exporter.py,sha256=AMM-uXBj8sh86n5m57aZ6S7LulAyIx_HM-eM-26BrWQ,7428
28
23
  pyconvexity/io/netcdf_importer.py,sha256=nv4CYYqnbCBeznwCU_JGBMTbg-BGNpXKlsqbu2R8fTU,72152
29
- pyconvexity/models/__init__.py,sha256=N8YqEntbF5NrxIgUk1Knj9FiOzmMtD5Kywc6THJVeFk,3528
24
+ pyconvexity/models/__init__.py,sha256=2HMICM5WX1h0MzxGHkKwUrsc5Tm1-P1Yl_PA0OFmyFI,4309
30
25
  pyconvexity/models/attributes.py,sha256=LTvYF0hl56HeLjS8ZVocZWLhbLRTNhmZ5gUKxf93eSE,18254
31
26
  pyconvexity/models/carriers.py,sha256=-nmasYvsaUeYPY1B0QdzfF_eph2HUFb5n3KF3CFd-YI,3700
32
27
  pyconvexity/models/components.py,sha256=wWRdX6vErZrQhhLTnHBLDOnkmLjbHY2e9J9ITZJi3F8,18287
@@ -39,11 +34,11 @@ pyconvexity/solvers/pypsa/api.py,sha256=si2VAvotQKk-hcNtT3bIWV0CE4EzSER94mxehPFm
39
34
  pyconvexity/solvers/pypsa/batch_loader.py,sha256=eQb8B11akQYtH3aK93WAOoXEI-ktk4imATw9gaYDNR4,13547
40
35
  pyconvexity/solvers/pypsa/builder.py,sha256=WrimcBvG4mNFLTrLq7131Ku0AXY_0oRKxfI81ywc5Cs,24460
41
36
  pyconvexity/solvers/pypsa/constraints.py,sha256=qosBSNe0pr4va4dMmQFM-ifJCNGAkhS1R2gerNmhaiQ,16266
42
- pyconvexity/solvers/pypsa/solver.py,sha256=7jaksRKMaQuFYWb7Pl7rw7Pu0kO5DPysQX2JtWdUbBc,72074
37
+ pyconvexity/solvers/pypsa/solver.py,sha256=YHj-qF_a2A9KdsJDQMXO2Iwl7vNjyeFK5pKsVK0RTEI,71761
43
38
  pyconvexity/solvers/pypsa/storage.py,sha256=T-0qEryiEy_8G4KiscPoiiWvTPd_OGqpLczW0_Xm85E,87331
44
39
  pyconvexity/validation/__init__.py,sha256=_6SVqXkaDFqmagub_O064Zm_QIdBrOra-Gvvbo9vM4I,549
45
40
  pyconvexity/validation/rules.py,sha256=6Kak12BVfUpjmgB5B7Wre55eGc5e1dvIdFca-vN-IFI,9296
46
- pyconvexity-0.3.8.post6.dist-info/METADATA,sha256=fKPUW65mNFxOCENHZuic30W1bbph8wORCzM56uFoP-U,4886
47
- pyconvexity-0.3.8.post6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
- pyconvexity-0.3.8.post6.dist-info/top_level.txt,sha256=wFPEDXVaebR3JO5Tt3HNse-ws5aROCcxEco15d6j64s,12
49
- pyconvexity-0.3.8.post6.dist-info/RECORD,,
41
+ pyconvexity-0.4.0.dist-info/METADATA,sha256=JrDbolmH3ouwn3xQL03Ij7yQRiwIxGF20cGTEZVUC3E,4880
42
+ pyconvexity-0.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
+ pyconvexity-0.4.0.dist-info/top_level.txt,sha256=wFPEDXVaebR3JO5Tt3HNse-ws5aROCcxEco15d6j64s,12
44
+ pyconvexity-0.4.0.dist-info/RECORD,,