MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / update

Method update

lib/matplotlib/category.py:199–227  ·  view source on GitHub ↗

Map new values to integer identifiers. Parameters ---------- data : iterable of str or bytes Raises ------ TypeError If elements in *data* are neither str nor bytes.

(self, data)

Source from the content-addressed store, hash-verified

197 return True
198
199 def update(self, data):
200 """
201 Map new values to integer identifiers.
202
203 Parameters
204 ----------
205 data : iterable of str or bytes
206
207 Raises
208 ------
209 TypeError
210 If elements in *data* are neither str nor bytes.
211 """
212 data = np.atleast_1d(np.array(data, dtype=object))
213 # check if convertible to number:
214 convertible = True
215 for val in OrderedDict.fromkeys(data):
216 # OrderedDict just iterates over unique values in data.
217 _api.check_isinstance((str, bytes), value=val)
218 if convertible:
219 # this will only be called so long as convertible is True.
220 convertible = self._str_is_convertible(val)
221 if val not in self._mapping:
222 self._mapping[val] = next(self._counter)
223 if data.size and convertible:
224 _log.info('Using categorical units to plot a list of strings '
225 'that are all parsable as floats or dates. If these '
226 'strings should be plotted as numbers, cast to the '
227 'appropriate data type before plotting.')
228
229
230# Register the converter with Matplotlib's unit framework

Callers 5

__init__Method · 0.95
test_updateMethod · 0.95
convertMethod · 0.45
default_unitsMethod · 0.45

Calls 1

_str_is_convertibleMethod · 0.95

Tested by 2

test_updateMethod · 0.76