Skip to content

Commit

Permalink
lint blacked
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-fournier-rsg authored and jpn-- committed Feb 8, 2024
1 parent 0d69abb commit 6b3a90c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions activitysim/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@


def si_units(x, kind="B", digits=3, shift=1000):

# nano micro milli kilo mega giga tera peta exa zeta yotta
tiers = ["n", "µ", "m", "", "K", "M", "G", "T", "P", "E", "Z", "Y"]

Expand Down Expand Up @@ -342,7 +341,6 @@ def assign_in_place(df, df2):
# this is a hack fix for a bug in pandas.update
# github.com/pydata/pandas/issues/4094
for c, old_dtype in zip(common_columns, old_dtypes):

# if both df and df2 column were same type, but result is not
if (old_dtype == df2[c].dtype) and (df[c].dtype != old_dtype):
try:
Expand Down Expand Up @@ -376,19 +374,18 @@ def assign_in_place(df, df2):
def reindex_if_series(values, index):
if index is not None:
return values

if isinstance(values, pd.Series):
assert len(set(values.index).intersection(index)) == len(index)

if all(values.index != index):
return values.reindex(index=index)
return values.reindex(index=index)


def df_from_dict(values, index=None):

# If value object is a series and has out of order index, reindex it
values = {k: reindex_if_series(v, index) for k, v in values.items()}
values = {k: reindex_if_series(v, index) for k, v in values.items()}

df = pd.DataFrame.from_dict(values)
if index is not None:
df.index = index
Expand Down

0 comments on commit 6b3a90c

Please sign in to comment.