DiamondLightSource / DiamondLightSource/httomo

Revise where `xp` should and shouldn't be used

Open
#403 0 comments 0 reactions 0 assignees View on GitHub
minor refactor
Dominant language
Python
Stars
10
Forks
5
Avg merge
5d 17h
Merged PRs (30d)
1

Description

The `xp` variable was introduced to deal with places where either `numpy` or `cupy` would work.

However, over time, the usage of `xp` has crept into places where what is being accessed would _not_ work if `xp = numpy`. I think it would be better to not overly rely on `xp` where possible, so combing through the repo and weeding out unnecessary/incorrect uses of it would be helpful.

## Two examples

1. using `xp.cuda.runtime.getDeviceCount()` will not work if `xp = numpy`

https://github.com/DiamondLightSource/httomo/blob/b28c2c3cdb2e2e086c9937b02a2aa563ca848941/httomo/method_wrappers/generic.py#L128-L131

2. using `xp.cuda.Event()` will not work if `xp = numpy`

https://github.com/DiamondLightSource/httomo/blob/b28c2c3cdb2e2e086c9937b02a2aa563ca848941/httomo/utils.py#L271-L276

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.