Skip to content

Commit

Permalink
Corrected format
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottDelbecq committed Feb 6, 2025
1 parent ada64fd commit cb97d08
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions src/fastoad/gui/tests/test_variable_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import shutil
from pathlib import Path

import ipysheet as sh
import pandas as pd
import pytest
from pandas.testing import assert_frame_equal
import ipysheet as sh

from .. import VariableViewer

Expand Down Expand Up @@ -170,48 +170,50 @@ def test_sheet_to_df():
"""
# Create a sample ipysheet Sheet
sheet = sh.sheet(rows=5, columns=4)
sh.cell(0, 0, 'Name')
sh.cell(0, 1, 'Value')
sh.cell(0, 2, 'Unit')
sh.cell(0, 3, 'Description')
sh.cell(1, 0, 'data:geometry:cabin:seats:economical:width')
sh.cell(0, 0, "Name")
sh.cell(0, 1, "Value")
sh.cell(0, 2, "Unit")
sh.cell(0, 3, "Description")
sh.cell(1, 0, "data:geometry:cabin:seats:economical:width")
sh.cell(1, 1, 0.46)
sh.cell(1, 2, 'm')
sh.cell(1, 3, 'width of economical class seats')
sh.cell(2, 0, 'data:geometry:cabin:seats:economical:length')
sh.cell(1, 2, "m")
sh.cell(1, 3, "width of economical class seats")
sh.cell(2, 0, "data:geometry:cabin:seats:economical:length")
sh.cell(2, 1, 0.86)
sh.cell(2, 2, 'm')
sh.cell(2, 3, 'length of economical class seats')
sh.cell(3, 0, 'data:aero:polar:CL')
sh.cell(2, 2, "m")
sh.cell(2, 3, "length of economical class seats")
sh.cell(3, 0, "data:aero:polar:CL")
sh.cell(3, 1, [0.1, 0.2, 0.3])
sh.cell(3, 2, None)
sh.cell(3, 3, 'Lift coefficient')
sh.cell(4, 0, 'data:geometry:propulsion:engine:count')
sh.cell(3, 3, "Lift coefficient")
sh.cell(4, 0, "data:geometry:propulsion:engine:count")
sh.cell(4, 1, 2)
sh.cell(4, 2, None)
sh.cell(4, 3, 'number of engines')
sh.cell(4, 3, "number of engines")

# Convert the sheet to a DataFrame using the _sheet_to_df method
variable_viewer = VariableViewer()
df = variable_viewer._sheet_to_df(sheet)

# Expected DataFrame
expected_df = pd.DataFrame({
'Name': [
'data:geometry:cabin:seats:economical:width',
'data:geometry:cabin:seats:economical:length',
'data:aero:polar:CL',
'data:geometry:propulsion:engine:count'
],
'Value': [0.46, 0.86, [0.1, 0.2, 0.3], 2],
'Unit': ['m', 'm', None, None],
'Description': [
'width of economical class seats',
'length of economical class seats',
'Lift coefficient',
'number of engines'
]
})
expected_df = pd.DataFrame(
{
"Name": [
"data:geometry:cabin:seats:economical:width",
"data:geometry:cabin:seats:economical:length",
"data:aero:polar:CL",
"data:geometry:propulsion:engine:count",
],
"Value": [0.46, 0.86, [0.1, 0.2, 0.3], 2],
"Unit": ["m", "m", None, None],
"Description": [
"width of economical class seats",
"length of economical class seats",
"Lift coefficient",
"number of engines",
],
}
)

# Assert that the DataFrame matches the expected DataFrame
assert_frame_equal(df, expected_df)

0 comments on commit cb97d08

Please sign in to comment.