Skip to content

Clean up _scalar.pyx#2917

Merged
toslunar merged 1 commit intocupy:masterfrom
niboshi:clean-scalar
Jan 8, 2020
Merged

Clean up _scalar.pyx#2917
toslunar merged 1 commit intocupy:masterfrom
niboshi:clean-scalar

Conversation

@niboshi
Copy link
Copy Markdown
Member

@niboshi niboshi commented Jan 7, 2020

Cleans up _scalar.pyx/pxd.

  • Previously, convert_scalar() returned different types of objects depending on a flag. This is confusing because the return type is obscure.
  • Unifies CScalar's various creation functions into static methods CScalar.from_xxx().

@niboshi niboshi added the cat:code-fix Code refactoring that do not change behavior label Jan 7, 2020
@niboshi
Copy link
Copy Markdown
Member Author

niboshi commented Jan 7, 2020

You might as well review #2918 altogether as it's based on this PR.

Copy link
Copy Markdown
Member

@toslunar toslunar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

cdef CScalar from_int32(int32_t value)

@staticmethod
cdef CScalar from_numpy_scalar_with_dtype(object x, object dtype)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:
These methods are still considered as private because the class CScalar is in a private module and Cython "cannot call a static method on an instance variable".
https://github.com/cython/cython/blob/3dc2b9dfc23638fbef2558d619709b5235d5df08/Cython/Compiler/ExprNodes.py#L5619-L5624

@toslunar
Copy link
Copy Markdown
Member

toslunar commented Jan 8, 2020

Jenkins, test this please.

@pfn-ci-bot
Copy link
Copy Markdown
Collaborator

Successfully created a job for commit 0b6113b:

@chainer-ci
Copy link
Copy Markdown
Member

Jenkins CI test (for commit 0b6113b, target branch master) succeeded!

@toslunar toslunar added this to the v8.0.0a1 milestone Jan 8, 2020
@toslunar toslunar changed the title Clean up _scalar.pyx Clean up _scalar.pyx Jan 8, 2020
@toslunar toslunar merged commit 5a9b208 into cupy:master Jan 8, 2020
@niboshi niboshi deleted the clean-scalar branch January 8, 2020 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:code-fix Code refactoring that do not change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants