serJD commited on
Commit
08aba45
1 Parent(s): 714bb14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -60,23 +60,22 @@ def app_function(input_json):
60
  # Parse the input JSON string
61
  inputs = json.loads(input_json)
62
 
63
- # Assuming 'inputs["df_distances"]' is a JSON string of a CSV, use StringIO to convert it to a DataFrame
64
- df_distances = pd.read_csv(StringIO(inputs["df_distances"]))
65
 
66
- # Assuming 'inputs["df_attractiveness"]' and others are already in list format in the JSON
67
  df_attractiveness = pd.Series(inputs["df_attractiveness"])
68
  alpha = inputs["alpha"]
69
  beta = inputs["beta"]
70
  df_capacity = pd.Series(inputs["df_capacity"])
71
 
72
- # Check if 'df_population' is in inputs and convert to Series, else default to None
73
  df_population = pd.Series(inputs["df_population"]) if "df_population" in inputs else None
74
 
75
  iterations = inputs.get("iterations", 5)
76
  crowding_threshold = inputs.get("crowding_threshold", 1.0)
77
 
78
- # Call the dynamic Huff model function with these parameters
79
- # Ensure 'dynamic_huff_model' is defined and ready to accept these parameters
80
  result = dynamic_huff_model(df_distances, df_attractiveness, alpha, beta, df_capacity, df_population, iterations, crowding_threshold)
81
 
82
  # Convert the result DataFrame to a JSON string for output
 
60
  # Parse the input JSON string
61
  inputs = json.loads(input_json)
62
 
63
+ # Convert 'df_distances' from a list of lists into a DataFrame directly
64
+ df_distances = pd.DataFrame(inputs["df_distances"])
65
 
66
+ # 'inputs["df_attractiveness"]' and others are directly usable as lists
67
  df_attractiveness = pd.Series(inputs["df_attractiveness"])
68
  alpha = inputs["alpha"]
69
  beta = inputs["beta"]
70
  df_capacity = pd.Series(inputs["df_capacity"])
71
 
72
+ # Check if 'df_population' is provided and convert to Series
73
  df_population = pd.Series(inputs["df_population"]) if "df_population" in inputs else None
74
 
75
  iterations = inputs.get("iterations", 5)
76
  crowding_threshold = inputs.get("crowding_threshold", 1.0)
77
 
78
+ # Assuming dynamic_huff_model function is correctly defined to accept these parameters
 
79
  result = dynamic_huff_model(df_distances, df_attractiveness, alpha, beta, df_capacity, df_population, iterations, crowding_threshold)
80
 
81
  # Convert the result DataFrame to a JSON string for output