Gurobi / gurobipy-pandas

Convenience wrapper for building optimization models from pandas data
https://gurobipy-pandas.readthedocs.io
Apache License 2.0
90 stars 15 forks source link

Make conscious decision on method name style #18

Closed rluce closed 2 years ago

rluce commented 2 years ago

We use lowerCamelCase (because gurobipy does?), but PEP8 suggests words_with_underscores. What does Pandas do? What should we do here?

simonbowly commented 2 years ago

Pandas always uses snake case for functions (value_counts, is_unique, sort_values, etc, etc). I'd favour snake case if possible, but we can live with the inconsistency with gurobipy?

Some mixing and matching between the accessors and plain gurobipy calls is inevitable. For example this mixture might look a bit odd:

m = Model()
df = data.grb.pd_add_vars(m, ...)
df.grb.pd_add_constrs(m, ...)
m.setObjective(df['y'].sum())
m.setParam('Method', 3)
m.optimize()
simonbowly commented 2 years ago

On the other hand, mixing styles in method chains looks worse:

df = (
    data
    .drop_duplicates(...)
    .grb.pdAddVars(m, ...)
    .sort_values(...)
)

Maybe snake case is better, since it's the accepted python style and matches pandas calls in method chains. It might also help to make the distinction clearer between gurobipy and gurobipy-pandas API calls so we avoid confusion between the different method signatures.

rluce commented 2 years ago

OK I think this means: We go for snake_case.

simonbowly commented 2 years ago

Done with fcf7658...f6e8c25