Skip to content

Conversation

@dan-zheng
Copy link
Contributor

  • Define version and versionInfo computed properties on PythonInterface
    for convenience.
  • Define labelless failable initializers from PythonObject
    (representing numpy.ndarray) to ShapedArray and Tensor.
    • A labelless initializer was not created for Array because Array is
      always one-dimensional, so the nature of the conversion is semantically bigger.

- Define `version` and `versionInfo` computed properties on `PythonInterface`
  for convenience.
- Define labelless failable initializers from `PythonObject`
  (representing `numpy.ndarray`) to `ShapedArray` and `Tensor`.
  - A labelless initializer was not created for `Array` because `Array` is
    always one-dimensional, so the conversion is semantically more significant.
    Users can use the labelled `Array(numpyArray:)` initalizer.
@dan-zheng dan-zheng added the tensorflow This is for "tensorflow" branch PRs. label Jan 25, 2019
@dan-zheng dan-zheng requested a review from rxwei January 25, 2019 01:21
// Creates a `ShapedArray` instance from the given `PythonObject` if it is a
// `numpy.ndarray` instance with a matching scalar datatype.
public init?(_ pythonObject: PythonObject) {
self.init(numpyArray: pythonObject)
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's not a numpy array, we should load it as a (potentially multi-dimensional) python array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Added TODO comments in 49f70e4.

@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow

@rxwei
Copy link
Contributor

rxwei commented Jan 25, 2019

@swift-ci please test tensorflow Linux

3 similar comments
@rxwei
Copy link
Contributor

rxwei commented Jan 25, 2019

@swift-ci please test tensorflow Linux

@rxwei
Copy link
Contributor

rxwei commented Jan 25, 2019

@swift-ci please test tensorflow Linux

@rxwei
Copy link
Contributor

rxwei commented Jan 25, 2019

@swift-ci please test tensorflow Linux

@rxwei
Copy link
Contributor

rxwei commented Jan 25, 2019

@swift-ci please test tensorflow

@dan-zheng dan-zheng force-pushed the improve-python-usability branch from 3a8f057 to 4100d28 Compare January 28, 2019 08:09
`init?(numpy:)` is a bit shorter than the previous `init?(numpyArray:)`.
Using a labelless initializer is problematic because it causes type inference
problems due to implicit conversions.
@dan-zheng dan-zheng force-pushed the improve-python-usability branch from 4100d28 to db4625e Compare January 28, 2019 08:59
@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow

1 similar comment
@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow

@dan-zheng dan-zheng merged commit dc2c825 into swiftlang:tensorflow Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tensorflow This is for "tensorflow" branch PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants