Skip to content

Commit e9b97f4

Browse files
committed
Merged in package rename and updated imports.
1 parent 4f26bb0 commit e9b97f4

File tree

6 files changed

+36
-32
lines changed

6 files changed

+36
-32
lines changed

google/cloud/vision/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414

1515
"""Google Cloud Vision API package."""
16-
from gcloud.vision.client import Client
16+
from google.cloud.vision.client import Client

google/cloud/vision/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def image(self, image_source):
113113
:type image_source: str or bytes
114114
:param image_source: Byte stream of an image or a GCS URI.
115115
116-
:rtype: :class:`gcloud.vision.image.Image`
116+
:rtype: :class:`google.cloud.vision.image.Image`
117117
:returns: Image instance with the current client attached.
118118
"""
119119
return Image(client=self, image_source=image_source)

google/cloud/vision/face.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"""Face class representing the Vision API's face detection response."""
1616

1717

18-
from gcloud.vision.geometry import BoundsBase
19-
from gcloud.vision.likelihood import Likelihood
20-
from gcloud.vision.geometry import Position
18+
from google.cloud.vision.geometry import BoundsBase
19+
from google.cloud.vision.likelihood import Likelihood
20+
from google.cloud.vision.geometry import Position
2121

2222

2323
class Angles(object):
@@ -31,7 +31,7 @@ def __init__(self, roll, pan, tilt):
3131
def from_api_repr(cls, response):
3232
"""Factory: construct the angles from an Vision API response.
3333
34-
:rtype: :class:`gcloud.vision.face.Angles`
34+
:rtype: :class:`google.cloud.vision.face.Angles`
3535
:returns: An `Angles` instance with data parsed from `response`.
3636
"""
3737
roll = response['rollAngle']
@@ -88,7 +88,7 @@ def from_api_repr(cls, response):
8888
:type response: dict
8989
:param response: Response dictionary representing a face.
9090
91-
:rtype: :class:`gcloud.vision.face.Emotions`
91+
:rtype: :class:`google.cloud.vision.face.Emotions`
9292
:returns: Populated instance of `Emotions`.
9393
"""
9494
joy_likelihood = getattr(Likelihood, response['joyLikelihood'])
@@ -105,7 +105,8 @@ def joy_likelihood(self):
105105
"""Likelihood of joy in detected face.
106106
107107
:rtype: str
108-
:returns: String derived from :class:`gcloud.vision.face.Likelihood`.
108+
:returns: String derived from
109+
:class:`google.cloud.vision.face.Likelihood`.
109110
"""
110111
return self._joy_likelihood
111112

@@ -114,7 +115,8 @@ def sorrow_likelihood(self):
114115
"""Likelihood of sorrow in detected face.
115116
116117
:rtype: str
117-
:returns: String derived from :class:`gcloud.vision.face.Likelihood`.
118+
:returns: String derived from
119+
:class:`google.cloud.vision.face.Likelihood`.
118120
"""
119121
return self._sorrow_likelihood
120122

@@ -123,7 +125,8 @@ def surprise_likelihood(self):
123125
"""Likelihood of surprise in detected face.
124126
125127
:rtype: str
126-
:returns: String derived from :class:`gcloud.vision.face.Likelihood`.
128+
:returns: String derived from
129+
:class:`google.cloud.vision.face.Likelihood`.
127130
"""
128131
return self._surprise_likelihood
129132

@@ -132,7 +135,8 @@ def anger_likelihood(self):
132135
"""Likelihood of anger in detected face.
133136
134137
:rtype: str
135-
:returns: String derived from :class:`gcloud.vision.face.Likelihood`.
138+
:returns: String derived from
139+
:class:`google.cloud.vision.face.Likelihood`.
136140
"""
137141
return self._anger_likelihood
138142

@@ -160,7 +164,7 @@ def from_api_repr(cls, response):
160164
:type response: dict
161165
:param response: Face annotation dict returned from the Vision API.
162166
163-
:rtype: :class:`gcloud.vision.face.Face`
167+
:rtype: :class:`google.cloud.vision.face.Face`
164168
:returns: A instance of `Face` with data parsed from `response`.
165169
"""
166170
angles = Angles.from_api_repr(response)
@@ -182,7 +186,7 @@ def from_api_repr(cls, response):
182186
def angles(self):
183187
"""Accessor to the pan, tilt and roll angles of a Face.
184188
185-
:rtype: :class:`gcloud.vision.face.Angles`
189+
:rtype: :class:`google.cloud.vision.face.Angles`
186190
:returns: Pan, tilt and roll angles of the detected face.
187191
"""
188192

@@ -192,7 +196,7 @@ def angles(self):
192196
def bounds(self):
193197
"""Accessor to the bounding poly information of the detected face.
194198
195-
:rtype: :class:`gcloud.vision.face.Bounds`
199+
:rtype: :class:`google.cloud.vision.face.Bounds`
196200
:returns: An instance of ``Bounds`` which has a list of vertices.
197201
"""
198202
return self._bounds
@@ -210,7 +214,7 @@ def detection_confidence(self):
210214
def emotions(self):
211215
"""Accessor to the possible emotions expressed in the detected face.
212216
213-
:rtype: :class:`gcloud.vision.face.Emotions`
217+
:rtype: :class:`google.cloud.vision.face.Emotions`
214218
:returns: An instance of ``Emotions`` with joy, sorrow, anger, surprise
215219
likelihood.
216220
"""
@@ -220,7 +224,7 @@ def emotions(self):
220224
def fd_bounds(self):
221225
"""Accessor to the skin area bounding poly of the detected face.
222226
223-
:rtype: :class:`gcloud.vision.image.FDBounds`
227+
:rtype: :class:`google.cloud.vision.image.FDBounds`
224228
:returns: An instance of ``FDBounds`` which has a list of vertices.
225229
"""
226230
return self._fd_bounds
@@ -229,17 +233,17 @@ def fd_bounds(self):
229233
def headwear_likelihood(self):
230234
"""Headwear likelihood.
231235
232-
:rtype: :class:`gcloud.vision.face.Likelihood`
236+
:rtype: :class:`google.cloud.vision.face.Likelihood`
233237
:returns: String representing the likelihood based on
234-
:class:`gcloud.vision.face.Likelihood`
238+
:class:`google.cloud.vision.face.Likelihood`
235239
"""
236240
return self._headwear_likelihood
237241

238242
@property
239243
def image_properties(self):
240244
"""Image properties from imaged used in face detection.
241245
242-
:rtype: :class:`gcloud.vision.face.FaceImageProperties`
246+
:rtype: :class:`google.cloud.vision.face.FaceImageProperties`
243247
:returns: ``FaceImageProperties`` object with image properties.
244248
"""
245249
return self._image_properties
@@ -248,7 +252,7 @@ def image_properties(self):
248252
def landmarks(self):
249253
"""Accessor to the facial landmarks detected in a face.
250254
251-
:rtype: :class:`gcloud.vision.face.Landmarks`
255+
:rtype: :class:`google.cloud.vision.face.Landmarks`
252256
:returns: ``Landmarks`` object with facial landmarks as properies.
253257
"""
254258
return self._landmarks
@@ -274,7 +278,7 @@ def __init__(self, blurred_likelihood, underexposed_likelihood):
274278
def from_api_repr(cls, response):
275279
"""Factory: construct image properties from image.
276280
277-
:rtype: :class:`gcloud.vision.face.FaceImageProperties`
281+
:rtype: :class:`google.cloud.vision.face.FaceImageProperties`
278282
:returns: Instance populated with image property data.
279283
"""
280284
blurred_likelihood = getattr(Likelihood,
@@ -290,7 +294,7 @@ def blurred_likelihood(self):
290294
291295
:rtype: str
292296
:returns: String representation derived from
293-
:class:`gcloud.vision.face.Position`.
297+
:class:`google.cloud.vision.face.Position`.
294298
"""
295299
return self._blurred_likelihood
296300

@@ -300,7 +304,7 @@ def underexposed_likelihood(self):
300304
301305
:rtype: str
302306
:returns: String representation derived from
303-
:class:`gcloud.vision.face.Position`.
307+
:class:`google.cloud.vision.face.Position`.
304308
"""
305309
return self._underexposed_likelihood
306310

@@ -365,7 +369,7 @@ def from_api_repr(cls, response_landmark):
365369
:type response_landmark: dict
366370
:param response_landmark: Landmark representation from Vision API.
367371
368-
:rtype: :class:`gcloud.vision.face.Landmark`
372+
:rtype: :class:`google.cloud.vision.face.Landmark`
369373
:returns: Populated instance of `Landmark`.
370374
"""
371375
position = Position.from_api_repr(response_landmark['position'])
@@ -376,7 +380,7 @@ def from_api_repr(cls, response_landmark):
376380
def position(self):
377381
"""Landmark position on face.
378382
379-
:rtype: :class:`gcloud.vision.face.Position`
383+
:rtype: :class:`google.cloud.vision.face.Position`
380384
:returns: Instance of `Position` with landmark coordinates.
381385
"""
382386
return self._position

google/cloud/vision/geometry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def from_api_repr(cls, response_vertices):
2727
:type response_vertices: dict
2828
:param response_vertices: List of vertices.
2929
30-
:rtype: :class:`gcloud.vision.geometry.BoundsBase`
30+
:rtype: :class:`google.cloud.vision.geometry.BoundsBase`
3131
:returns: Instance of BoundsBase with populated verticies.
3232
"""
3333
vertices = []
@@ -61,7 +61,7 @@ def __init__(self, x_coordinate, y_coordinate, z_coordinate):
6161
def from_api_repr(cls, response_position):
6262
"""Factory: construct 3D position from API response.
6363
64-
:rtype: :class:`gcloud.vision.geometry.Position`
64+
:rtype: :class:`google.cloud.vision.geometry.Position`
6565
:returns: `Position` constructed with 3D points from API response.
6666
"""
6767
x_coordinate = response_position['x']

google/cloud/vision/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def detect_faces(self, limit=10):
8787
:param limit: The number of faces to try and detect.
8888
8989
:rtype: list
90-
:returns: List of :class:`gcloud.vision.face.Face`.
90+
:returns: List of :class:`google.cloud.vision.face.Face`.
9191
"""
9292
faces = []
9393
face_detection_feature = Feature(FeatureTypes.FACE_DETECTION, limit)

unit_tests/vision/test_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ def test_face_annotation(self):
6262
client = self._makeOne(project=self.PROJECT, credentials=credentials)
6363
client.connection = _Connection(RETURNED)
6464

65-
from google.cloud.vision.feature import Feature, FeatureTypes
66-
6765
features = [Feature(feature_type=FeatureTypes.FACE_DETECTION,
6866
max_results=3)]
6967
image = client.image(_IMAGE_CONTENT)
@@ -84,7 +82,8 @@ def test_image_with_client(self):
8482

8583
def test_face_detection_from_source(self):
8684
from google.cloud.vision.face import Face
87-
from google.cloud.vision._fixtures import FACE_DETECTION_RESPONSE as RETURNED
85+
from google.cloud.vision._fixtures import FACE_DETECTION_RESPONSE
86+
RETURNED = FACE_DETECTION_RESPONSE
8887
credentials = _Credentials()
8988
client = self._makeOne(project=self.PROJECT, credentials=credentials)
9089
client.connection = _Connection(RETURNED)
@@ -100,7 +99,8 @@ def test_face_detection_from_source(self):
10099

101100
def test_face_detection_from_content(self):
102101
from google.cloud.vision.face import Face
103-
from google.cloud.vision._fixtures import FACE_DETECTION_RESPONSE as RETURNED
102+
from google.cloud.vision._fixtures import FACE_DETECTION_RESPONSE
103+
RETURNED = FACE_DETECTION_RESPONSE
104104
credentials = _Credentials()
105105
client = self._makeOne(project=self.PROJECT, credentials=credentials)
106106
client.connection = _Connection(RETURNED)

0 commit comments

Comments
 (0)