MCPcopy Create free account
hub / github.com/numpy/numpy / english_upper

Function english_upper

numpy/core/code_generators/generate_umath.py:228–254  ·  view source on GitHub ↗

Apply English case rules to convert ASCII strings to all upper case. This is an internal utility function to replace calls to str.upper() such that we can avoid changing behavior with changing locales. In particular, Turkish has distinct dotted and dotless variants of the Latin letter

(s)

Source from the content-addressed store, hash-verified

226 bytes(string.ascii_uppercase, "ascii"))
227
228def english_upper(s):
229 """ Apply English case rules to convert ASCII strings to all upper case.
230
231 This is an internal utility function to replace calls to str.upper() such
232 that we can avoid changing behavior with changing locales. In particular,
233 Turkish has distinct dotted and dotless variants of the Latin letter "I" in
234 both lowercase and uppercase. Thus, "i".upper() != "I" in a "tr" locale.
235
236 Parameters
237 ----------
238 s : str
239
240 Returns
241 -------
242 uppered : str
243
244 Examples
245 --------
246 >>> from numpy.lib.utils import english_upper
247 >>> s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'
248 >>> english_upper(s)
249 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'
250 >>> english_upper('')
251 ''
252 """
253 uppered = s.translate(UPPER_TABLE)
254 return uppered
255
256
257#each entry in defdict is a Ufunc object.

Callers 3

generate_umath.pyFile · 0.70
make_arraysFunction · 0.70
make_ufuncsFunction · 0.70

Calls 1

translateMethod · 0.80

Tested by

no test coverage detected