Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation of random.uniform to reflect data type conversion behavior #3013

Merged
merged 2 commits into from
Jun 4, 2021

Conversation

jantonguirao
Copy link
Contributor

Signed-off-by: Joaquin Anton janton@nvidia.com

Why we need this PR?

Pick one, remove the rest

  • It adds an explanatory note to random.Uniform documentation, regarding data type conversion

What happened in this PR?

Fill relevant points, put NA otherwise. Replace anything inside []

  • What solution was applied:
    Documentation was extended
  • Affected modules and functionalities:
    random.Uniform
  • Key points relevant for the review:
    NA
  • Validation and testing:
    NA
  • Documentation (including examples):
    NA

JIRA TASK: [NA]

@jantonguirao jantonguirao changed the title Update documentation of random.uniform to reflect data type conversion behavior. Update documentation of random.uniform to reflect data type conversion behavior Jun 2, 2021
@awolant awolant self-assigned this Jun 2, 2021
Copy link
Contributor

@klecki klecki left a comment

Choose a reason for hiding this comment

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

Styling detail, otherwise ok.

This argument is mutually exclusive with ``values``.)code",
This argument is mutually exclusive with ``values``.

Warning: When specifying an integer type as ``dtype``, the generated numbers can go outside
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use the .. warning:: and .. note:: boxes from rst?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we clamp. I think this is the last thing I would expect TBH.

Copy link
Contributor

@klecki klecki Jun 2, 2021

Choose a reason for hiding this comment

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

There are one more Warning and Note.

Signed-off-by: Joaquin Anton <janton@nvidia.com>
@jantonguirao
Copy link
Contributor Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2432816]: BUILD STARTED

Comment on lines 71 to 72

Warning: When specifying an integer type as ``dtype``, the generated numbers can go outside
Copy link
Contributor

Choose a reason for hiding this comment

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

As above.


.. warning::
When specifying an integer type as ``dtype``, the generated numbers can go outside
the specified range, due to rounding.
Copy link
Contributor

Choose a reason for hiding this comment

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

the generated numbers can go outside the specified range

Can't we clamp? It is a bit unexpected.

Copy link
Contributor Author

@jantonguirao jantonguirao Jun 2, 2021

Choose a reason for hiding this comment

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

So the RNG work like that, you generate the number in whatever is the natural type for the distribution, in this case float. Then if the user request the output data type to be a different type, we just ConvertSat(...). It's equivalent to doing fn.cast( fn.random.uniform(...), dtype=...), the numbers when converted to an integer data type, can go outside of the float range that was specified for the distribution. If the user needs a continuous distribution, it doesn't make much sense to request dtype to be an integer data type, I'd say.

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sense.

This argument is mutually exclusive with ``values``.)code",
This argument is mutually exclusive with ``values``.

Warning: When specifying an integer type as ``dtype``, the generated numbers can go outside
Copy link
Contributor

Choose a reason for hiding this comment

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

Warning -> .. warning::?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

R"code(Output data type.)code", nullptr);
R"code(Output data type.

Note: The generated numbers are converted to the output data type, rounding and clamping if necessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

.. note::?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Signed-off-by: Joaquin Anton <janton@nvidia.com>
@jantonguirao
Copy link
Contributor Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2432989]: BUILD STARTED

@klecki klecki self-assigned this Jun 2, 2021
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2432989]: BUILD PASSED

@jantonguirao jantonguirao merged commit 7012c31 into NVIDIA:main Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants