-
-
Notifications
You must be signed in to change notification settings - Fork 32
Add basic stubs for some class attributes #9
Changes from 1 commit
d9063b9
f6efbfd
cf16064
b814fac
59bd6bc
5bffb72
eac85ff
d6c586c
3cc8475
c84c9bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ class dtype: | |
alignment: int | ||
byteorder: str | ||
char: str | ||
descr: List[Tuple[str, str]] | ||
descr: List[Union[Tuple[str, str], Tuple[str, str, Tuple[int, ...]]]] | ||
fields: Optional[Mapping[str, Union[Tuple[dtype, int], Tuple[dtype, int, str]]]] | ||
flags: int | ||
hasobject: bool | ||
|
@@ -26,7 +26,7 @@ class dtype: | |
subdtype: Optional[Tuple[dtype, Tuple[int, ...]]] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It isn't documented, but |
||
|
||
def newbyteoder(self, new_order:str = ...): dtype | ||
def newbyteorder(self, new_order: str = ...): dtype | ||
|
||
str: builtins.str | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've segregated this here so that the other There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add this as a comment in the code |
||
type: builtins.type | ||
|
@@ -35,10 +35,10 @@ class dtype: | |
def base(self) -> dtype: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why this is a property vs. an attribute for everything else? Does mypy care about the difference? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Properties can't be assigned to unless they have a setter. With this stub, if you had There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, in that case we should also convert most of the other attributes into readonly properties. |
||
|
||
|
||
_dtype = dtype # for ndarray type | ||
_dtype_class = dtype # for ndarray type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this have a duplicate name? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Otherwise mypy gets confused when you to type the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you fix it with an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know exactly how mypy handles circular imports, but I suspect that importing a module from itself would not work. |
||
|
||
|
||
class flagsobj: | ||
class _flagsobj: | ||
aligned: bool | ||
behaved: bool | ||
c_contiguous: bool | ||
|
@@ -72,9 +72,9 @@ class flatiter: | |
class ndarray: | ||
T: ndarray | ||
data: memoryview | ||
dtype: _dtype | ||
flags: flagsobj | ||
flat: Any | ||
dtype: _dtype_class | ||
flags: _flagsobj | ||
flat: flatiter | ||
imag: ndarray | ||
real: ndarray | ||
size: int | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the final
title
field can have any type, so it should probably be keyed asAny
instead ofstr
: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.dtype.fields.html#numpy.dtype.fields