pyconvexity 0.5.1__py3-none-any.whl → 0.5.1.post2__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.5.1"
1
+ __version__ = "0.5.1.post2"
@@ -502,7 +502,11 @@ class NetworkSolver:
502
502
  """
503
503
  try:
504
504
  # Extract basic solve information
505
- status = getattr(result, "status", "unknown")
505
+ # PyPSA's result may be a tuple or object, and may not have a status attribute
506
+ raw_status = getattr(result, "status", None)
507
+ if raw_status is None:
508
+ raw_status = "unknown"
509
+
506
510
  objective_value = getattr(network, "objective", None)
507
511
 
508
512
  # Convert PyPSA result to dictionary format
@@ -510,12 +514,34 @@ class NetworkSolver:
510
514
 
511
515
  # Determine success based on multiple criteria
512
516
  success = self._determine_solve_success(
513
- result, network, status, objective_value
517
+ result, network, raw_status, objective_value
514
518
  )
519
+
520
+ # Update status to reflect the determined success
521
+ # This ensures database and API consumers get meaningful status values
522
+ if success:
523
+ # If we determined success, set status to "optimal" unless we have better info
524
+ if raw_status in ["optimal", "feasible"]:
525
+ status = raw_status
526
+ elif hasattr(result, "termination_condition"):
527
+ term_condition = str(result.termination_condition).lower()
528
+ if "optimal" in term_condition:
529
+ status = "optimal"
530
+ else:
531
+ status = "feasible" # Solved successfully but not necessarily optimal
532
+ else:
533
+ status = "optimal" # Default for successful solves
534
+ else:
535
+ # If solve failed, use raw status or "failed"
536
+ if raw_status not in ["unknown", "", None]:
537
+ status = raw_status
538
+ else:
539
+ status = "failed"
515
540
 
516
541
  solve_result = {
517
542
  "success": success,
518
- "status": status,
543
+ "status": status, # Now contains meaningful status instead of "unknown"
544
+ "raw_status": raw_status, # Keep original PyPSA status for debugging
519
545
  "solve_time": solve_time,
520
546
  "solver_name": solver_name,
521
547
  "run_id": run_id,
@@ -589,6 +589,16 @@ class TimeAxisModifier:
589
589
  # Get time bounds for the new time axis
590
590
  new_start_timestamp = new_periods[0].timestamp
591
591
  new_end_timestamp = new_periods[-1].timestamp
592
+
593
+ # Calculate the duration of one new period in seconds
594
+ # This is needed to properly include all original data within the last new period
595
+ new_period_duration_seconds = new_resolution_minutes * 60
596
+
597
+ # The end timestamp represents the START of the last period, not its end.
598
+ # To include all original data that falls within the last period,
599
+ # we need to extend the end boundary by the period duration (minus 1 second
600
+ # to avoid including the start of the next period).
601
+ effective_end_timestamp = new_end_timestamp + new_period_duration_seconds - 1
592
602
 
593
603
  logger.debug(
594
604
  f"Original data: {len(original_values)} points, "
@@ -598,6 +608,10 @@ class TimeAxisModifier:
598
608
  f"New time range: {new_periods[0].formatted_time} to "
599
609
  f"{new_periods[-1].formatted_time}"
600
610
  )
611
+ logger.debug(
612
+ f"Effective end timestamp for slicing: {effective_end_timestamp} "
613
+ f"(added {new_period_duration_seconds}s period duration)"
614
+ )
601
615
 
602
616
  # Find the slice of original data that falls within the new time range
603
617
  start_idx = 0
@@ -609,9 +623,10 @@ class TimeAxisModifier:
609
623
  start_idx = i
610
624
  break
611
625
 
612
- # Find end index - last period <= new_end_timestamp
626
+ # Find end index - last period <= effective_end_timestamp
627
+ # Use effective_end_timestamp to include all data within the last new period
613
628
  for i in range(len(original_periods) - 1, -1, -1):
614
- if original_periods[i].timestamp <= new_end_timestamp:
629
+ if original_periods[i].timestamp <= effective_end_timestamp:
615
630
  end_idx = i + 1 # +1 because slice end is exclusive
616
631
  break
617
632
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyconvexity
3
- Version: 0.5.1
3
+ Version: 0.5.1.post2
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=Prol-EntlU_jWLR3D55ZRYqkLnenLnt5cXVc_NT1cI4,5934
2
- pyconvexity/_version.py,sha256=eZ1bOun1DDVV0YLOBW4wj2FP1ajReLjbIrGmzN7ASBw,22
2
+ pyconvexity/_version.py,sha256=NzwicjWvX-oujWpkElhba_Uhu9tnA3prazJglxgYyRM,28
3
3
  pyconvexity/dashboard.py,sha256=7x04Hr-EwzTAf-YJdHzfV83Gf2etltwtzwh_bCYJ5lk,8579
4
4
  pyconvexity/timeseries.py,sha256=QdKbiqjAlxkJATyKm2Kelx1Ea2PsAnnCYfVLU5VER1Y,11085
5
5
  pyconvexity/core/__init__.py,sha256=gdyyHNqOc4h9Nfe9u6NA936GNzH6coGNCMgBvvvOnGE,1196
@@ -34,14 +34,14 @@ pyconvexity/solvers/pypsa/batch_loader.py,sha256=ZgOcZqMnMS3TOYTq2Ly2O4cuwhNNAic
34
34
  pyconvexity/solvers/pypsa/builder.py,sha256=1ZU68Wtl_jQSXHzspKQDkR6bxAVU1nKvPfnPUl0aO3k,23256
35
35
  pyconvexity/solvers/pypsa/clearing_price.py,sha256=HdAk7GPfJFVI4t6mL0zQGEOMAvuyfpl0yNCnah1ZGH0,29164
36
36
  pyconvexity/solvers/pypsa/constraints.py,sha256=20WliFDhPQGMAsS4VOTU8LZJpsFpLVRHpNsZW49GTcc,16397
37
- pyconvexity/solvers/pypsa/solver.py,sha256=pNI9ch0vO5q-8mWc3RHTscWB_ymj4s2lVJQ_e2nbzHY,44417
37
+ pyconvexity/solvers/pypsa/solver.py,sha256=JcjIv9yU3YhEDUN4kllRe2NP6y56LD_LBlymHGWDflc,45806
38
38
  pyconvexity/solvers/pypsa/storage.py,sha256=nbONOBnunq3tyexa5yDUsT9xdxieUfrqhoM76_2HIGg,94956
39
39
  pyconvexity/transformations/__init__.py,sha256=JfTk0b2O3KM22Dcem2ZnNvDDBmlmqS2X3Q_cO0H3r44,406
40
40
  pyconvexity/transformations/api.py,sha256=t_kAAk9QSF1YTlrTM7BECd_v08jUgXVV6e9iX2M0aAg,3694
41
- pyconvexity/transformations/time_axis.py,sha256=VyQPp09PyIr7IlxoKPeZCMkHPKPcIhI9ap_6kCyzjyk,28362
41
+ pyconvexity/transformations/time_axis.py,sha256=Cr_H-FozXLQno4n6jMSZCTj3M4h7tGpsuqGcMW2qghY,29322
42
42
  pyconvexity/validation/__init__.py,sha256=VJNZlFoWABsWwUKktNk2jbtXIepH5omvC0WtsTS7o3o,583
43
43
  pyconvexity/validation/rules.py,sha256=GiNadc8hvbWBr09vUkGiLLTmSdvtNSeGLFwvCjlikYY,9241
44
- pyconvexity-0.5.1.dist-info/METADATA,sha256=DUDViqyeOCBaSihifxoHTu7P4tjBms1JU90L3jGdbxc,4967
45
- pyconvexity-0.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
46
- pyconvexity-0.5.1.dist-info/top_level.txt,sha256=wFPEDXVaebR3JO5Tt3HNse-ws5aROCcxEco15d6j64s,12
47
- pyconvexity-0.5.1.dist-info/RECORD,,
44
+ pyconvexity-0.5.1.post2.dist-info/METADATA,sha256=QhPbcPges-IW8J6QabgcVwvouxNrPwrkDe21sDT3yls,4973
45
+ pyconvexity-0.5.1.post2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
46
+ pyconvexity-0.5.1.post2.dist-info/top_level.txt,sha256=wFPEDXVaebR3JO5Tt3HNse-ws5aROCcxEco15d6j64s,12
47
+ pyconvexity-0.5.1.post2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5