Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DEP: Issue FutureWarning when malformed records detected.#10558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
DEP: Issue FutureWarning when malformed records detected.
Currently records specified as lists of lists instead of lists of tuplesare caught and fixed up in fromrecords. Unfortunately, the detection isfailing due to various fixes in the records module. The failure isworked around by generalizing the detection. A FutureWarning that suchrecord specifications will result in an error in the future is alsoemitted.Fixes#10344.
  • Loading branch information
@charris
charris committedFeb 9, 2018
commit6df6987f9f39f401352c040f8efb599f6b230eb8
9 changes: 8 additions & 1 deletionnumpy/core/records.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,7 @@

import sys
import os
import warnings

from . import numeric as sb
from . import numerictypes as nt
Expand DownExpand Up@@ -677,7 +678,7 @@ def fromrecords(recList, dtype=None, shape=None, formats=None, names=None,

try:
retval = sb.array(recList, dtype=descr)
except TypeError: # list of lists instead of list of tuples
except(TypeError, ValueError):
if (shape is None or shape == 0):
shape = len(recList)
if isinstance(shape, (int, long)):
Expand All@@ -687,6 +688,12 @@ def fromrecords(recList, dtype=None, shape=None, formats=None, names=None,
_array = recarray(shape, descr)
for k in range(_array.size):
_array[k] = tuple(recList[k])
# list of lists instead of list of tuples ?
# 2018-02-07, 1.14.1
warnings.warn(
"fromrecords expected a list of tuples, may have received a list "
"of lists instead. In the future that will raise an error",
FutureWarning, stacklevel=2)
return _array
else:
if shape is not None and retval.shape != shape:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp