PEtab-dev / PEtab-dev/libpetab-python
Should unspecified optional strings be the empty string or NaN?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
At the moment, there can be NaNs (after pd.read_csv) in optional PEtab string columns, such as observableNames, that, if interpreted as a string, are converted to the string literal 'nan'.
>>> import numpy as np
>>> str(np.nan)
'nan'
An issue can occur in the AMICI plotting functions. This issue can be fixed by replacing
elif model.getObservableNames()[iy] != '':
with
elif model.getObservableNames()[iy] in ['', 'nan']:
to correctly identify unspecified observable names. However, testing for the string 'nan' seems unintuitive, and this fix might cause another issue if an observable is named 'nan'.
Here's a solution, which could be implemented in PEtab, and might resolve the issue in AMICI.
$ cat test_str.csv
observableId observableName
a_id a_name
b_id
>>> import pandas as pd
>>> df1 = pd.read_csv('test_str.csv', sep='\t')
>>> df2 = pd.read_csv('test_str.csv', sep='\t')
>>> df2['observableName'] = df2['observableName'].fillna('')
>>> df1
observableId observableName
0 a_id a_name
1 b_id NaN
>>> df2
observableId observableName
0 a_id a_name
1 b_id
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the PEtab optional string-column handling described in the issue and the affected entry point in AMICI's python/amici/plotting.py at line 81. Decide how unspecified values should be represented without confusing a literal 'nan' name, then verify the behavior across parsing and plotting integration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100