Skip to content

Commit d49116b

Browse files
committed
Add implementation of dpnp.ndarray.tolist method
1 parent 6b8ea9e commit d49116b

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

dpnp/dpnp_array.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,34 @@ def to_device(self, device, /, *, stream=None):
20132013
return dpnp_array._create_from_usm_ndarray(usm_res)
20142014

20152015
# 'tobytes',
2016-
# 'tofile',
2016+
2017+
def tofile(self, fid, sep="", format=""):
2018+
"""
2019+
Writes the array to a file as text or binary (default).
2020+
2021+
For full documentation refer to :obj:`numpy.ndarray.tofile`.
2022+
2023+
Parameters
2024+
----------
2025+
fid : {file. str, path}
2026+
An open file object, or a string containing a filename.
2027+
sep : str, optional
2028+
Separator between array items for text output. If ``""`` (empty),
2029+
a binary file is written.
2030+
2031+
Default: ``""``.
2032+
format : str, optional
2033+
Format string for text file output (when non-empty `sep` is passed).
2034+
Each entry in the array is formatted to text by first converting it
2035+
to the closest Python type, and then using ``format % item``. If
2036+
``""`` (empty), no formatting is used while converting to the
2037+
string.
2038+
2039+
Default: ``""``.
2040+
2041+
"""
2042+
2043+
self.asnumpy().tofile(fid, sep=sep, format=format)
20172044

20182045
def tolist(self):
20192046
"""

0 commit comments

Comments
 (0)