stan-dev / stan-dev/math

Inconsistent error handling

Open
#1,468 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Description

Error handling is not consistent between different mathematical functions. Most primitive functions only call std implementation and return NaN in case of invalid input. Some check for invalid input and throw exceptions.

Example

stan::math::log() directely calls std::log(). So any negative argument results in NaN return value.

stan::math::log1p() checks if its argument is less than -1 and throws std::domain_error if it is.

Expected Output

Consistent error handling.

Current Version:

v3.0.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the invalid-input behavior of stan::math::log() and stan::math::log1p(), then review the issue discussion for any agreed consistency rule. Done means the mathematical functions follow a clearly defined, consistent error-handling policy.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.