MCPcopy Create free account
hub / github.com/PyTables/PyTables / array_of_flavor2

Function array_of_flavor2

tables/flavor.py:109–132  ·  view source on GitHub ↗

Get a version of the given `array` in a different flavor. The input `array` must be of the given `src_flavor`, and the returned array will be of the indicated `dst_flavor`. Both flavors may be the same, but it is not guaranteed that the returned array will be the same object as the

(
    array: npt.ArrayLike, src_flavor: FlavorType, dst_flavor: FlavorType
)

Source from the content-addressed store, hash-verified

107
108
109def array_of_flavor2(
110 array: npt.ArrayLike, src_flavor: FlavorType, dst_flavor: FlavorType
111) -> Any | list[Any] | np.ndarray:
112 """Get a version of the given `array` in a different flavor.
113
114 The input `array` must be of the given `src_flavor`, and the
115 returned array will be of the indicated `dst_flavor`. Both
116 flavors may be the same, but it is not guaranteed that the
117 returned array will be the same object as the input one in this
118 case.
119
120 If the conversion is not supported, a ``FlavorError`` is raised.
121
122 """
123 convkey = (src_flavor, dst_flavor)
124 if convkey not in converter_map:
125 raise FlavorError(
126 "conversion from flavor ``%s`` to flavor ``%s`` "
127 "is unsupported or unavailable in this system"
128 % (src_flavor, dst_flavor)
129 )
130
131 convfunc = converter_map[convkey]
132 return convfunc(array)
133
134
135def flavor_to_flavor(

Callers 3

flavor_to_flavorFunction · 0.85
array_as_internalFunction · 0.85
array_of_flavorFunction · 0.85

Calls 1

FlavorErrorClass · 0.85

Tested by

no test coverage detected