Skip to content

Commit 94bcf34

Browse files
committed
attempt fix
1 parent 05cf17a commit 94bcf34

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

ultraplot/colors.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
from numbers import Integral, Number
2424
from xml.etree import ElementTree
2525

26-
import matplotlib.cm as mcm
2726
import matplotlib as mpl
27+
import matplotlib.cm as mcm
2828
import matplotlib.colors as mcolors
2929
import numpy as np
3030
import numpy.ma as ma
@@ -44,12 +44,12 @@ def _cycle_handler(value):
4444

4545
rc.register_handler("cycle", _cycle_handler)
4646

47-
from .internals import ic # noqa: F401
4847
from .internals import (
4948
_kwargs_to_args,
5049
_not_none,
5150
_pop_props,
5251
docstring,
52+
ic, # noqa: F401
5353
inputs,
5454
warnings,
5555
)
@@ -910,11 +910,12 @@ def _warn_or_raise(descrip, error=RuntimeError):
910910
# NOTE: This appears to be biggest import time bottleneck! Increases
911911
# time from 0.05s to 0.2s, with numpy loadtxt or with this regex thing.
912912
delim = re.compile(r"[,\s]+")
913-
data = [
914-
delim.split(line.strip())
915-
for line in open(path)
916-
if line.strip() and line.strip()[0] != "#"
917-
]
913+
with open(path) as f:
914+
data = [
915+
delim.split(line.strip())
916+
for line in f
917+
if line.strip() and line.strip()[0] != "#"
918+
]
918919
try:
919920
data = [[float(num) for num in line] for line in data]
920921
except ValueError:
@@ -966,7 +967,8 @@ def _warn_or_raise(descrip, error=RuntimeError):
966967
# Read hex strings
967968
elif ext == "hex":
968969
# Read arbitrary format
969-
string = open(path).read() # into single string
970+
with open(path) as f:
971+
string = f.read() # into single string
970972
data = REGEX_HEX_MULTI.findall(string)
971973
if len(data) < 2:
972974
return _warn_or_raise("Failed to find 6-digit or 8-digit HEX strings.")

ultraplot/ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def subplots(*args, **kwargs):
226226
_parse_figsize(kwargs)
227227
rc_kw, rc_mode = _pop_rc(kwargs)
228228
kwsubs = _pop_props(kwargs, "patch") # e.g. 'color'
229-
kwsubs.update(_pop_params(kwargs, pfigure._add_subplots))
229+
kwsubs.update(_pop_params(kwargs, pfigure.Figure._add_subplots))
230230
kwsubs.update(_pop_params(kwargs, pgridspec.GridSpec._update_params))
231231
for sig in paxes.Axes._format_signatures.values():
232232
kwsubs.update(_pop_params(kwargs, sig))

0 commit comments

Comments
 (0)