Skip to content

Commit

Permalink
Fix deprecation warnings about logger.warn and missing sort=False
Browse files Browse the repository at this point in the history
Fix pandas deprecation warnings
  • Loading branch information
coroa committed Oct 2, 2018
1 parent 2f9fa60 commit 04cc02c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pypsa/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def add(self, class_name, name, **kwargs):

#This guarantees that the correct attribute type is maintained
obj_df = pd.DataFrame(data=[static_attrs.default],index=[name],columns=static_attrs.index)
new_df = cls_df.append(obj_df)
new_df = cls_df.append(obj_df, sort=False)

setattr(self, self.components[class_name]["list_name"], new_df)

Expand Down
4 changes: 2 additions & 2 deletions pypsa/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,13 +929,13 @@ def import_from_pandapower_net(network, net):
"q_set" : -(net.sgen.scaling*net.sgen.q_kvar).values/1e3,
"bus" : net.bus.name.loc[net.sgen.bus].values,
"control" : "PQ"},
index=net.sgen.name)))
index=net.sgen.name)), sort=False)

d["Generator"] = pd.concat((d["Generator"],pd.DataFrame({"control" : "Slack",
"p_set" : 0.,
"q_set" : 0.,
"bus" : net.bus.name.loc[net.ext_grid.bus].values},
index=net.ext_grid.name.fillna("External Grid"))))
index=net.ext_grid.name.fillna("External Grid"))), sort=False)

d["Bus"].loc[net.bus.name.loc[net.ext_grid.bus].values,"v_mag_pu_set"] = net.ext_grid.vm_pu.values

Expand Down
2 changes: 1 addition & 1 deletion pypsa/opf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ def network_lopf_solve(network, snapshots=None, formulation="angles", solver_opt
extract_optimisation_results(network, snapshots, formulation,
free_pyomo='pyomo' in free_memory)
elif status == "warning" and termination_condition == "other":
logger.warn("WARNING! Optimization might be sub-optimal. Writing output anyway")
logger.warning("WARNING! Optimization might be sub-optimal. Writing output anyway")
extract_optimisation_results(network, snapshots, formulation,
free_pyomo='pyomo' in free_memory)
else:
Expand Down
8 changes: 4 additions & 4 deletions pypsa/pf.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def newton_raphson_sparse(f, guess, dfdx, x_tol=1e-10, lim_iter=100):
logger.debug("Error at iteration %d: %f", n_iter, diff)

if diff > x_tol:
logger.warn("Warning, we didn't reach the required tolerance within %d iterations, error is at %f. See the section \"Troubleshooting\" in the documentation for tips to fix this. ", n_iter, diff)
logger.warning("Warning, we didn't reach the required tolerance within %d iterations, error is at %f. See the section \"Troubleshooting\" in the documentation for tips to fix this. ", n_iter, diff)
elif not np.isnan(diff):
converged = True

Expand Down Expand Up @@ -548,7 +548,7 @@ def find_slack_bus(sub_network):
gens = sub_network.generators()

if len(gens) == 0:
logger.warn("No generators in sub-network {}, better hope power is already balanced".format(sub_network.name))
logger.warning("No generators in sub-network {}, better hope power is already balanced".format(sub_network.name))
sub_network.slack_generator = None
sub_network.slack_bus = sub_network.buses_i()[0]

Expand Down Expand Up @@ -633,7 +633,7 @@ def calculate_B_H(sub_network,skip_pre=False):


if np.isnan(b).any():
logger.warn("Warning! Some series impedances are zero - this will cause a singularity in LPF!")
logger.warning("Warning! Some series impedances are zero - this will cause a singularity in LPF!")
b_diag = csr_matrix((b, (r_[:len(b)], r_[:len(b)])))

#incidence matrix
Expand Down Expand Up @@ -699,7 +699,7 @@ def calculate_Y(sub_network,skip_pre=False):
calculate_dependent_values(sub_network.network)

if sub_network.network.sub_networks.at[sub_network.name,"carrier"] != "AC":
logger.warn("Non-AC networks not supported for Y!")
logger.warning("Non-AC networks not supported for Y!")
return

branches = sub_network.branches()
Expand Down

0 comments on commit 04cc02c

Please sign in to comment.