scipp / scipp/scippneutron

Should we use 64 bit float to represent event weights, instead of 32 bit?

Open
#349 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
6
Forks
4
Avg merge
6d 13h
Merged PRs (30d)
5

Description

scn.load and scn.load_nexus currently use float32 to repsent the event weights. These all default to 1.0 so this is fine. However, when summing events later the user may encounter a surprising precision loss.

We should carefully consider the tradeoff between risk for bugs and memory use. Reduction operations use double precision for intermediate values so many problems are avoided. Nevertheless final results can be affected significantly. For example:

import numpy as np
np.float32(75893996)

gives 75894000.

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 examining the scn.load and scn.load_nexus entry points and the later reduction operations that consume event weights. Compare the precision and memory implications of float32 and float64, including the example in the issue, and determine what tests or validation would demonstrate that the chosen representation avoids significant final-result loss.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.