Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/tensorflow/python/data/experimental/ops/random_ops.py: 85%

20 statements  

« prev     ^ index     » next       coverage.py v7.4.0, created at 2024-01-03 07:57 +0000

1# Copyright 2017 The TensorFlow Authors. All Rights Reserved. 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14# ============================================================================== 

15"""Datasets for random number generators.""" 

16import functools 

17 

18from tensorflow.python import tf2 

19from tensorflow.python.data.ops import dataset_ops 

20from tensorflow.python.data.ops import random_op 

21from tensorflow.python.util import deprecation 

22from tensorflow.python.util.tf_export import tf_export 

23 

24 

25# TODO(b/260143413): Migrate users to `tf.data.Dataset.random`. 

26@deprecation.deprecated(None, "Use `tf.data.Dataset.random(...)`.") 

27@tf_export("data.experimental.RandomDataset", v1=[]) 

28class RandomDatasetV2(random_op._RandomDataset): # pylint: disable=protected-access 

29 """A `Dataset` of pseudorandom values.""" 

30 

31 

32@deprecation.deprecated(None, "Use `tf.data.Dataset.random(...)`.") 

33@tf_export(v1=["data.experimental.RandomDataset"]) 

34class RandomDatasetV1(dataset_ops.DatasetV1Adapter): 

35 """A `Dataset` of pseudorandom values.""" 

36 

37 @functools.wraps(RandomDatasetV2.__init__) 

38 def __init__(self, seed=None): 

39 wrapped = RandomDatasetV2(seed) 

40 super(RandomDatasetV1, self).__init__(wrapped) 

41 

42 

43if tf2.enabled(): 

44 RandomDataset = RandomDatasetV2 

45else: 

46 RandomDataset = RandomDatasetV1