Skip to content

Commit b094d0c

Browse files
committed
Refactor DCM class methods for clarity and update version to 0.1.6
1 parent 3214a93 commit b094d0c

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

dcm/dcm.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,13 @@ def from_dataframe(cls, df: pd.DataFrame, name: str) -> "Self":
591591
else:
592592
raise ValueError("DataFrame must have exactly one row or column")
593593

594-
series = pd.Series(df.values.flatten(), index=index, name=name)
594+
values = df.values.flatten()
595+
if index and isnan(index[0]):
596+
index_name = ""
597+
index = index[1:]
598+
values = values[1:]
599+
600+
series = pd.Series(values, index=index, name=name)
595601
series.index.name = index_name
596602
return cls(
597603
name=name,
@@ -1174,7 +1180,7 @@ def load_from_excel(
11741180
"""
11751181
return (
11761182
self.load_maps(maps_path)
1177-
.load_lines(curves_path)
1183+
.load_curves(curves_path)
11781184
.load_parameters(parameters_path)
11791185
.load_parameter_blocks(parameter_blocks_path)
11801186
)
@@ -1195,7 +1201,7 @@ def load_maps(self, excel_path: PathOrReadable) -> "Self":
11951201
self.maps[char_map.name] = char_map
11961202
return self
11971203

1198-
def load_lines(self, excel_path: PathOrReadable) -> "Self":
1204+
def load_curves(self, excel_path: PathOrReadable) -> "Self":
11991205
with _open_stream(excel_path) as excel_file:
12001206
if isinstance(excel_file, Exception):
12011207
return self
@@ -1211,6 +1217,10 @@ def load_lines(self, excel_path: PathOrReadable) -> "Self":
12111217
self.curves[char_line.name] = char_line
12121218
return self
12131219

1220+
@property
1221+
def load_lines(self) -> Callable[[PathOrReadable], "Self"]:
1222+
return self.load_curves
1223+
12141224
def load_parameter_blocks(self, excel_path: PathOrReadable) -> "Self":
12151225
with _open_stream(excel_path) as excel_file:
12161226
if isinstance(excel_file, Exception):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "python-dcm"
3-
version = "0.1.5"
3+
version = "0.1.6"
44
description = "A high-performance Python package for handling ETAS DCM(Data Conversion Format) files used in engine calibration tools like INCA, MDA, EHANDBOOK, and CANape."
55
authors = ["c0sogi <dcas@naver.com>"]
66
license = "MIT"

0 commit comments

Comments
 (0)