### Describe the issue: It looks like `np.char.mod` is untested, so we missed it in the review of #25152. ### Reproduce the code example: ```python import numpy as np np.char.mod("%s", np.array(["hello", "world"])) ``` ### Error message: ```shell File ~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/numpy/_core/defchararray.py:412, in mod(a, values) 391 @array_function_dispatch(_mod_dispatcher) 392 def mod(a, values): 393 """ 394 Return (a % i), that is pre-Python 2.6 string formatting 395 (interpolation), element-wise for a pair of array_likes of str (...) 410 411 """ --> 412 return _to_bytes_or_str_array( 413 _vec_string(a, object_, '__mod__', (values,)), a) File ~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/numpy/_core/defchararray.py:70, in _to_bytes_or_str_array(result, output_dtype_like) 68 return result.astype(output_dtype_like.dtype) 69 ret = numpy.asarray(result.tolist()) ---> 70 return ret.astype(type(output_dtype_like.dtype)(_get_num_chars(ret))) AttributeError: 'str' object has no attribute 'dtype' ``` ### Python and NumPy Versions: 2.0.0.dev0+git20231206.6ef3089 3.11.6 (main, Nov 27 2023, 12:13:52) [Clang 15.0.0 (clang-1500.0.40.1)] ### Runtime Environment: _No response_ ### Context for the issue: ping @lysnikolaou
Activity
lysnikolaou commentedon Dec 7, 2023
Actually, all
np.charmethods that have not been converted to ufuncs and return strings have this problem. Opened #25335 to fix it.[-]BUG: `np.char.mod` is broken[/-][+]BUG: ``np.char.mod`` is broken[/+]