Skip to content

Commit

Permalink
[samples] Handle missing pandas dependency gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Jun 9, 2022
1 parent bfd6df0 commit 399142e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Expand Up @@ -7,8 +7,12 @@
Keywords: combustion, 1D flow, flame speed, premixed flame, saving output
"""
import os
import sys
import cantera as ct
import pandas as pd
try:
import pandas as pd
except ImportError:
pd = None

data_directory = "flame_initial_guess_data"
os.makedirs(data_directory, exist_ok=True)
Expand Down Expand Up @@ -89,7 +93,6 @@ def describe(flame):
# Restore the flame via initial guess

print("Load initial guess from CSV file directly")
# f.write_csv(csv_filepath)
gas.TPX = Tin, p, reactants # set the gas T back to the inlet before making new flame
f2 = ct.FreeFlame(gas, width=width)
f2.set_initial_guess(data=csv_filepath)
Expand All @@ -111,6 +114,11 @@ def describe(flame):
f2.set_initial_guess(data=arr2)
describe(f2)

if pd is None:
# skip remaining examples, as optional dependency 'pandas' is not installed
print("All done")
sys.exit()

print("Load initial guess from CSV file via Pandas")
df = pd.read_csv(csv_filepath)
gas.TPX = Tin, p, reactants # set the gas T back to the inlet before making new flame
Expand Down

0 comments on commit 399142e

Please sign in to comment.