Skip to content

Commit 597172e

Browse files
committed
fix merge
1 parent a9c19b6 commit 597172e

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

linopy/common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ def set_int_index(series: pd.Series) -> pd.Series:
4242
"""
4343
Convert string index to int index.
4444
"""
45+
4546
if not series.empty and not pd.api.types.is_integer_dtype(series.index):
4647
cutoff = count_initial_letters(str(series.index[0]))
47-
series.index = series.index.str[cutoff:].astype(int)
48+
try:
49+
series.index = series.index.str[cutoff:].astype(int)
50+
except ValueError:
51+
series.index = series.index.str.replace(".*#", "", regex=True).astype(int)
4852
return series
4953

5054

linopy/solvers.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import sys
1616
from abc import ABC, abstractmethod
1717
from pathlib import Path
18-
from typing import TYPE_CHECKING, Callable, Sequence
18+
from typing import TYPE_CHECKING, Callable
1919

2020
import numpy as np
2121
import pandas as pd
@@ -133,17 +133,6 @@
133133
)
134134

135135

136-
def set_int_index(series: Series) -> Series:
137-
"""
138-
Convert string index to int index.
139-
"""
140-
try:
141-
series.index = series.index.str[1:].astype(int)
142-
except ValueError as _:
143-
series.index = series.index.str.replace(".*#", "", regex=True).astype(int)
144-
return series
145-
146-
147136
# using enum to match solver subclasses with names
148137
class SolverName(enum.Enum):
149138
CBC = "cbc"

0 commit comments

Comments
 (0)