Skip to content

Commit 6a1ec9d

Browse files
standardize arg check
1 parent fed63d6 commit 6a1ec9d

File tree

1 file changed

+26
-26
lines changed
  • packages/python/plotly/plotly/express

1 file changed

+26
-26
lines changed

Diff for: packages/python/plotly/plotly/express/_core.py

+26-26
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,10 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
400400
if hover_is_dict and not attr_value[col]:
401401
continue
402402
if col in [
403-
args.get("x", None),
404-
args.get("y", None),
405-
args.get("z", None),
406-
args.get("base", None),
403+
args.get("x"),
404+
args.get("y"),
405+
args.get("z"),
406+
args.get("base"),
407407
]:
408408
continue
409409
try:
@@ -1286,8 +1286,8 @@ def build_dataframe(args, constructor):
12861286

12871287
# now we handle special cases like wide-mode or x-xor-y specification
12881288
# by rearranging args to tee things up for process_args_into_dataframe to work
1289-
no_x = args.get("x", None) is None
1290-
no_y = args.get("y", None) is None
1289+
no_x = args.get("x") is None
1290+
no_y = args.get("y") is None
12911291
wide_x = False if no_x else _is_col_list(df_input, args["x"])
12921292
wide_y = False if no_y else _is_col_list(df_input, args["y"])
12931293

@@ -1314,9 +1314,9 @@ def build_dataframe(args, constructor):
13141314
if var_name in [None, "value", "index"] or var_name in df_input:
13151315
var_name = "variable"
13161316
if constructor == go.Funnel:
1317-
wide_orientation = args.get("orientation", None) or "h"
1317+
wide_orientation = args.get("orientation") or "h"
13181318
else:
1319-
wide_orientation = args.get("orientation", None) or "v"
1319+
wide_orientation = args.get("orientation") or "v"
13201320
args["orientation"] = wide_orientation
13211321
args["wide_cross"] = None
13221322
elif wide_x != wide_y:
@@ -1347,7 +1347,7 @@ def build_dataframe(args, constructor):
13471347
if constructor in [go.Scatter, go.Bar, go.Funnel] + hist2d_types:
13481348
if not wide_mode and (no_x != no_y):
13491349
for ax in ["x", "y"]:
1350-
if args.get(ax, None) is None:
1350+
if args.get(ax) is None:
13511351
args[ax] = df_input.index if df_provided else Range()
13521352
if constructor == go.Bar:
13531353
missing_bar_dim = ax
@@ -1371,7 +1371,7 @@ def build_dataframe(args, constructor):
13711371
)
13721372

13731373
no_color = False
1374-
if type(args.get("color", None)) == str and args["color"] == NO_COLOR:
1374+
if type(args.get("color")) == str and args["color"] == NO_COLOR:
13751375
no_color = True
13761376
args["color"] = None
13771377
# now that things have been prepped, we do the systematic rewriting of `args`
@@ -1787,17 +1787,17 @@ def infer_config(args, constructor, trace_patch, layout_patch):
17871787
args[other_position] = None
17881788

17891789
# If both marginals and faceting are specified, faceting wins
1790-
if args.get("facet_col", None) is not None and args.get("marginal_y", None):
1790+
if args.get("facet_col") is not None and args.get("marginal_y") is not None:
17911791
args["marginal_y"] = None
17921792

1793-
if args.get("facet_row", None) is not None and args.get("marginal_x", None):
1793+
if args.get("facet_row") is not None and args.get("marginal_x") is not None:
17941794
args["marginal_x"] = None
17951795

17961796
# facet_col_wrap only works if no marginals or row faceting is used
17971797
if (
1798-
args.get("marginal_x", None) is not None
1799-
or args.get("marginal_y", None) is not None
1800-
or args.get("facet_row", None) is not None
1798+
args.get("marginal_x") is not None
1799+
or args.get("marginal_y") is not None
1800+
or args.get("facet_row") is not None
18011801
):
18021802
args["facet_col_wrap"] = 0
18031803

@@ -1984,7 +1984,7 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
19841984
row = m.val_map[val]
19851985
else:
19861986
if (
1987-
args.get("marginal_x", None) is not None # there is a marginal
1987+
args.get("marginal_x") is not None # there is a marginal
19881988
and trace_spec.marginal != "x" # and we're not it
19891989
):
19901990
row = 2
@@ -2068,10 +2068,10 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
20682068
nrows = math.ceil(ncols / facet_col_wrap)
20692069
ncols = min(ncols, facet_col_wrap)
20702070

2071-
if args.get("marginal_x", None) is not None:
2071+
if args.get("marginal_x") is not None:
20722072
nrows += 1
20732073

2074-
if args.get("marginal_y", None) is not None:
2074+
if args.get("marginal_y") is not None:
20752075
ncols += 1
20762076

20772077
fig = init_figure(
@@ -2118,7 +2118,7 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la
21182118

21192119
# Build column_widths/row_heights
21202120
if subplot_type == "xy":
2121-
if args.get("marginal_x", None) is not None:
2121+
if args.get("marginal_x") is not None:
21222122
if args["marginal_x"] == "histogram" or ("color" in args and args["color"]):
21232123
main_size = 0.74
21242124
else:
@@ -2127,11 +2127,11 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la
21272127
row_heights = [main_size] * (nrows - 1) + [1 - main_size]
21282128
vertical_spacing = 0.01
21292129
elif facet_col_wrap:
2130-
vertical_spacing = args.get("facet_row_spacing", None) or 0.07
2130+
vertical_spacing = args.get("facet_row_spacing") or 0.07
21312131
else:
2132-
vertical_spacing = args.get("facet_row_spacing", None) or 0.03
2132+
vertical_spacing = args.get("facet_row_spacing") or 0.03
21332133

2134-
if args.get("marginal_y", None) is not None:
2134+
if args.get("marginal_y") is not None:
21352135
if args["marginal_y"] == "histogram" or ("color" in args and args["color"]):
21362136
main_size = 0.74
21372137
else:
@@ -2140,18 +2140,18 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la
21402140
column_widths = [main_size] * (ncols - 1) + [1 - main_size]
21412141
horizontal_spacing = 0.005
21422142
else:
2143-
horizontal_spacing = args.get("facet_col_spacing", None) or 0.02
2143+
horizontal_spacing = args.get("facet_col_spacing") or 0.02
21442144
else:
21452145
# Other subplot types:
21462146
# 'scene', 'geo', 'polar', 'ternary', 'mapbox', 'domain', None
21472147
#
21482148
# We can customize subplot spacing per type once we enable faceting
21492149
# for all plot types
21502150
if facet_col_wrap:
2151-
vertical_spacing = args.get("facet_row_spacing", None) or 0.07
2151+
vertical_spacing = args.get("facet_row_spacing") or 0.07
21522152
else:
2153-
vertical_spacing = args.get("facet_row_spacing", None) or 0.03
2154-
horizontal_spacing = args.get("facet_col_spacing", None) or 0.02
2153+
vertical_spacing = args.get("facet_row_spacing") or 0.03
2154+
horizontal_spacing = args.get("facet_col_spacing") or 0.02
21552155

21562156
if facet_col_wrap:
21572157
subplot_labels = [None] * nrows * ncols

0 commit comments

Comments
 (0)