Skip to content

Commit

Permalink
black fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskoenig committed Oct 4, 2020
1 parent 87d81c2 commit b7f946f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
49 changes: 34 additions & 15 deletions src/sbmlsim/plot/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,19 @@

# The colors in the default property cycle have been changed
# to the category10 color palette used by Vega and d3 originally developed at Tableau.
DEFAULT_COLORS = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']
DEFAULT_COLORS = [
"#1f77b4",
"#ff7f0e",
"#2ca02c",
"#d62728",
"#9467bd",
"#8c564b",
"#e377c2",
"#7f7f7f",
"#bcbd22",
"#17becf",
]


class BasePlotObject(object):
"""Base class for plotting objects."""
Expand Down Expand Up @@ -73,6 +85,7 @@ def to_dict(self):
def __repr__(self):
return self.color


@dataclass
class Line(object):
type: LineType
Expand All @@ -81,9 +94,9 @@ class Line(object):

def to_dict(self):
return {
'type': self.type,
'color': self.color,
'thickness': self.thickness,
"type": self.type,
"color": self.color,
"thickness": self.thickness,
}


Expand All @@ -97,11 +110,11 @@ class Marker(object):

def to_dict(self):
return {
'size': self.size,
'type': self.type,
'fill': self.fill,
'line_color': self.line_color,
'line_thickness': self.line_thickness,
"size": self.size,
"type": self.type,
"fill": self.fill,
"line_color": self.line_color,
"line_thickness": self.line_thickness,
}


Expand Down Expand Up @@ -591,15 +604,19 @@ def add_curve(self, curve: Curve):
# inject default colors if no colors provided
color = Style.parse_color(
color=DEFAULT_COLORS[curve.order % len(DEFAULT_COLORS)],
alpha=curve.kwargs.get("alpha", 1.0)
alpha=curve.kwargs.get("alpha", 1.0),
)
style = curve.style # type: Style
if (style.line.type != LineType.NONE) and (not style.line.color):
style.line.color = color
logger.warning(f"'{self.sid}.{curve.sid}': undefined line color set to: {color}")
logger.warning(
f"'{self.sid}.{curve.sid}': undefined line color set to: {color}"
)
if (style.marker.type != MarkerType.NONE) and (not style.marker.fill):
style.marker.fill = color
logger.error(f"'{self.sid}.{curve.sid}': undefined marker fill set to: {color}")
logger.error(
f"'{self.sid}.{curve.sid}': undefined marker fill set to: {color}"
)

self.curves.append(curve)

Expand Down Expand Up @@ -644,7 +661,7 @@ def add_data(
count: Union[int, str] = None,
dataset: str = None,
task: str = None,
label: str="__yid__",
label: str = "__yid__",
single_lines=False,
dim_reduction=None,
**kwargs,
Expand All @@ -664,8 +681,10 @@ def add_data(
"a curve use 'label=None' instead."
)
if label == "__yid__":
logger.warning("No label provided on curve, using default label 'yid'. "
"To not plot a label use 'label=None'")
logger.warning(
"No label provided on curve, using default label 'yid'. "
"To not plot a label use 'label=None'"
)

# experiment to resolve data
experiment = self.experiment
Expand Down
2 changes: 1 addition & 1 deletion src/sbmlsim/plot/plotting_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_scale(axis):
ridx = subplot.row - 1
cidx = subplot.col - 1
ax = fig.add_subplot(
gs[ridx: ridx + subplot.row_span, cidx : cidx + subplot.col_span]
gs[ridx : ridx + subplot.row_span, cidx : cidx + subplot.col_span]
) # type: plt.Axes

plot = subplot.plot
Expand Down

0 comments on commit b7f946f

Please sign in to comment.