| calc_missing_rate |
Ran ran on a synthesized input |
WenjieDu/PyGrinder/pygrinder/utils.py code served (permissive licence) · get_code("c387775b4e946319") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float64, ndim 0, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
import pandas as pd
import torch
torch.manual_seed(0)
# Create test data with some missing values
np.random.seed(0)
# NumPy array with NaN values
X_numpy = np.random.randn(4, 3)
X_numpy[0, 1] = np.nan
X_numpy[2, 0] = np.nan
# PyTorch tensor with NaN values
X_torch = torch.randn(4, 3)
X_torch[1, 2] = float('nan')
# Pandas DataFrame with NaN values
X_df = pd.DataFrame(np.random.randn(4, 3))
X_df.loc[0, 0] = np.nan
X_df.loc[3, 2] = np.nan
ARGS = {
"X": X_numpy,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| fill_and_get_mask_numpy |
Ran ran on a synthesized input |
WenjieDu/PyGrinder/pygrinder/utils.py code served (permissive licence) · get_code("be9c47491cf28500") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
# Create a small numpy array with some NaN values for testing
np.random.seed(0)
X = np.random.randn(4, 3).astype(np.float32)
# Introduce some NaN values
X[0, 1] = np.nan
X[2, 0] = np.nan
ARGS = {
"X": X,
"nan": 0
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple, ndim 3, dtype family float — a tuple output has no array shape of its own; none is stated
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| load_electricity |
Ran ran on a synthesized input |
WenjieDu/TSDB/tsdb/loading_funcs/electricity_load_diagrams.py code served (permissive licence) · get_code("4c2d6549dc6192b6") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import os
import tempfile
import pandas as pd
# Create a temporary directory and a minimal CSV file that matches the expected format
temp_dir = tempfile.mkdtemp()
file_path = os.path.join(temp_dir, 'LD2011_2014.txt')
# Create a minimal CSV file with semicolon separator and comma as decimal
# The function expects index_col=0 (first column as index), sep=';', decimal=','
data_content = """2011-01-01 00:00:00;1,1;2,2;3,3
2011-01-01 01:00:00;1,5;2,5;3,5
2011-01-01 02:00:00;1,9;2,9;3,9
"""
with open(file_path, 'w') as f:
f.write(data_content)
ARGS = {
'local_path': temp_dir
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| load_physionet2019 |
Ran ran on a synthesized input |
WenjieDu/TSDB/tsdb/loading_funcs/physionet_2019.py code served (permissive licence) · get_code("17dc28cf1e81c1d5") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import os
import tempfile
import pandas as pd
# Create a temporary directory structure that mimics PhysioNet2019
temp_dir = tempfile.mkdtemp()
# Create training and training_setB subdirectories
training_dir = os.path.join(temp_dir, 'training')
training_setB_dir = os.path.join(temp_dir, 'training_setB')
os.makedirs(training_dir, exist_ok=True)
os.makedirs(training_setB_dir, exist_ok=True)
# Create sample PSV files for training directory
for i in range(2):
filename = os.path.join(training_dir, f'record_{i}.psv')
df = pd.DataFrame({
'Time': ['00:00:00', '01:00:00'],
'HR': [72, 75],
'O2Sat': [98, 97],
'Age': [45, 50],
'Gender': ['M', 'F'],
'Unit1': [1, 0],
'Unit2': [0, 1],
'HospAdmTime': ['2020-01-01', '2020-01-02']
})
df.to_csv(filename, sep='|', index=False)
# Create sample PSV files for training_setB directory
for i in range(2):
filename = os.path.join(training_setB_dir, f'record_b_{i}.psv')
df = pd.DataFrame({
'Time': ['00:00:00', '01:00:00'],
'HR': [68, 70],
'O2Sat': [99, 98],
'Age': [55, 60],
'Gender': ['F', 'M'],
'Unit1': [0, 1],
'Unit2': [1, 0],
'HospAdmTime': ['2020-02-01', '2020-02-02']
})
df.to_csv(filename, sep='|', index=False)
ARGS = {
'local_path': temp_dir
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| load_solar_alabama |
Ran ran on a synthesized input |
WenjieDu/TSDB/tsdb/loading_funcs/solar_alabama.py code served (permissive licence) · get_code("296f0ae78e1d6218") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import os
import tempfile
import pandas as pd
# Create a temporary directory and a mock solar_AL.txt file
temp_dir = tempfile.mkdtemp()
solar_file_path = os.path.join(temp_dir, 'solar_AL.txt')
# Create mock solar data with 137 columns
mock_data = pd.DataFrame([[i + j for j in range(137)] for i in range(52560)])
mock_data.to_csv(solar_file_path, index=False, header=False)
ARGS = {
'local_path': temp_dir
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| mar_logistic |
Ran ran on a synthesized input |
WenjieDu/PyGrinder/pygrinder/missing_at_random/mar_logistic.py code served (permissive licence) · get_code("0acbf327de305441") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
torch.manual_seed(0)
# Create a small 2D array without missing values
# Shape: (n_steps=2, n_features=4)
X_np = np.random.randn(2, 4).astype(np.float32)
# Parameters for mar_logistic
obs_rate = 0.5 # proportion of variables without missing values used for fitting
missing_rate = 0.3 # proportion of missing values to generate
ARGS = {
'X': X_np,
'obs_rate': obs_rate,
'missing_rate': missing_rate
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, scipy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ndarray, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| masked_fill |
Ran ran on a synthesized input |
WenjieDu/PyGrinder/pygrinder/utils.py code served (permissive licence) · get_code("f7e622c5263d482f") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
torch.manual_seed(0)
# Test with torch.Tensor
X_torch = torch.randn(2, 4)
mask_torch = torch.tensor([[True, False, True, False], [False, True, False, True]])
val = -999.0
ARGS = {
'X': X_torch,
'mask': mask_torch,
'val': val
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| mcar |
Ran ran on a synthesized input |
WenjieDu/PyGrinder/pygrinder/missing_completely_at_random/mcar.py code served (permissive licence) · get_code("fb4e5ad29f4f697b") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
import torch
torch.manual_seed(0)
np.random.seed(0)
# Create a small numpy array with some data
X_numpy = np.array([[1.0, 2.0, 3.0, 4.0],
[5.0, 6.0, 7.0, 8.0]], dtype=np.float32)
# Create a small torch tensor with some data
X_torch = torch.tensor([[1.0, 2.0, 3.0, 4.0],
[5.0, 6.0, 7.0, 8.0]], dtype=torch.float32)
# Test with numpy array
ARGS = {
'X': X_numpy,
'p': 0.3
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ndarray, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| mnar_nonuniform |
Ran ran on a synthesized input |
WenjieDu/PyGrinder/pygrinder/missing_not_at_random/mnar_nonuniform.py code served (permissive licence) · get_code("008e5ae15e11bf75") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
import torch
torch.manual_seed(0)
# Create small test data
N, T, D = 2, 3, 4
X_numpy = np.random.randn(N, T, D)
X_numpy[0, 0, 0] = np.nan # Add some NaN values
X_numpy[1, 1, 1] = np.nan
X_torch = torch.from_numpy(np.random.randn(N, T, D)).float()
X_torch[0, 0, 0] = float('nan')
X_torch[1, 1, 1] = float('nan')
# Test case 1: _mnar_nonuniform_numpy with default probabilities
ARGS_numpy_default = {
'X': X_numpy,
'p': 0.3,
'pre_replacement_probabilities': None,
'increase_factor': 0.5
}
# Test case 2: _mnar_nonuniform_numpy with pre-defined probabilities
pre_replacement_probs_numpy = np.array([0.2, 0.3, 0.25, 0.35])
ARGS_numpy_predefined = {
'X': X_numpy,
'p': 0.3,
'pre_replacement_probabilities': pre_replacement_probs_numpy,
'increase_factor': 0.5
}
# Test case 3: _mnar_nonuniform_torch with default probabilities
ARGS_torch_default = {
'X': X_torch,
'p': 0.3,
'pre_replacement_probabilities': None,
'increase_factor': 0.5
}
# Test case 4: _mnar_nonuniform_torch with pre-defined probabilities
pre_replacement_probs_torch = torch.tensor([0.2, 0.3, 0.25, 0.35])
ARGS_torch_predefined = {
'X': X_torch,
'p': 0.3,
'pre_replacement_probabilities': pre_replacement_probs_torch,
'increase_factor': 0.5
}
# Primary test arguments for _mnar_nonuniform_numpy
ARGS = ARGS_numpy_default
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple — a tuple output has no array shape of its own; none is stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| mnar_t |
Ran ran on a synthesized input |
WenjieDu/PyGrinder/pygrinder/missing_not_at_random/mnar_t.py code served (permissive licence) · get_code("59291e54a11baca1") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 3, dtype family float, shape (2, 3, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
torch.manual_seed(0)
# Create a small test tensor: (n_s=2, n_l=3, n_c=4)
# representing 2 samples, 3 time steps, 4 channels
X_torch = torch.randn(2, 3, 4)
# Create corresponding numpy array
X_numpy = np.random.randn(2, 3, 4).astype(np.float32)
# Add some original NaN values to test that they're preserved
X_numpy[0, 1, 0] = np.nan
X_torch[0, 1, 0] = torch.nan
ARGS = {
"X": X_numpy,
"cycle": 20,
"pos": 10,
"scale": 3,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ndarray, ndim 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 4) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| mnar_x |
Ran ran on a synthesized input |
WenjieDu/PyGrinder/pygrinder/missing_not_at_random/mnar_x.py code served (permissive licence) · get_code("febb233722fe951f") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 3, dtype family float, shape (2, 3, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
torch.manual_seed(0)
# Create a small test array with shape (n_s, n_l, n_c) = (2, 3, 4)
# n_s = number of samples, n_l = sequence length, n_c = number of channels
X_numpy = np.random.randn(2, 3, 4).astype(np.float32)
# Add some NaN values to simulate existing missing data
X_numpy[0, 1, 2] = np.nan
X_numpy[1, 0, 0] = np.nan
X_torch = torch.from_numpy(X_numpy.copy()).float()
ARGS = {
"X": X_numpy,
"offset": 0.5,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ndarray, ndim 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 4) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| rdo |
Ran ran on a synthesized input |
WenjieDu/PyGrinder/pygrinder/randomly_drop_observations/rdo.py code served (permissive licence) · get_code("2435a99e193e1ccb") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (3, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
import torch
torch.manual_seed(0)
np.random.seed(0)
# Create a small numpy array with some values and some NaNs
X_numpy = np.array([
[1.0, 2.0, np.nan, 4.0],
[5.0, np.nan, 7.0, 8.0],
[9.0, 10.0, 11.0, 12.0]
], dtype=np.float32)
# Create a small torch tensor with some values and some NaNs
X_torch = torch.tensor([
[1.0, 2.0, float('nan'), 4.0],
[5.0, float('nan'), 7.0, 8.0],
[9.0, 10.0, 11.0, 12.0]
], dtype=torch.float32)
# Test with numpy array
ARGS = {
'X': X_numpy,
'p': 0.3
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ndarray, ndim 2, dtype family float, shape (3, 4) — shape (3, 4) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| to_time_series |
Ran ran on a synthesized input |
WenjieDu/TSDB/tsdb/loading_funcs/ucr_uea_datasets.py code served (permissive licence) · get_code("f0b7cb4933ae55df") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (4, 1) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
def to_time_series(ts, remove_nans=False):
"""Transforms a time series so that it fits the format used in ``tslearn``
models.
Parameters
----------
ts : array-like
The time series to be transformed.
remove_nans : bool (default: False)
Whether trailing NaNs at the end of the time series should be removed
or not
Returns
-------
np.ndarray of shape (sz, d)
The transformed time series. This is always guaraneteed to be a new
time series and never just a view into the old one.
Examples
--------
>>> to_time_series([1, 2])
array([[1.],
[2.]])
>>> to_time_series([1, 2, np.nan])
array([[ 1.],
[ 2.],
[nan]])
>>> to_time_series([1, 2, np.nan], remove_nans=True)
array([[1.],
[2.]])
See Also
--------
to_time_series_dataset : Transforms a dataset of time series
"""
ts_out = np.array(ts, copy=True)
if ts_out.ndim <= 1:
ts_out = ts_out.reshape((-1, 1))
if ts_out.dtype != float:
ts_out = ts_out.astype(float)
if remove_nans:
ts_out = ts_out[:ts_size(ts_out)]
return ts_out
def ts_size(ts):
"""Returns actual time series size.
Final timesteps that have `NaN` values for all dimensions will be removed
from the count. Infinity and negative infinity ar considered valid time
series values.
Parameters
----------
ts : array-like
A time series.
Returns
-------
int
Actual size of the time series.
Examples
--------
>>> ts_size([1, 2, 3, np.nan])
3
>>> ts_size([1, np.nan])
1
>>> ts_size([np.nan])
0
>>> ts_size([[1, 2],
... [2, 3],
... [3, 4],
... [np.nan, 2],
... [np.nan, np.nan]])
4
>>> ts_size([np.nan, 3, np.inf, np.nan])
3
"""
ts_ = to_time_series(ts)
sz = ts_.shape[0]
while sz > 0 and np.all(np.isnan(ts_[sz - 1])):
sz -= 1
return sz
# Test cases for to_time_series
ts_1d = [1.0, 2.0, 3.0, 4.0]
ts_2d = [[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]
ts_with_nan = [1.0, 2.0, np.nan, 4.0]
ts_only_nan = [np.nan, np.nan]
ARGS = {
"ts": ts_1d,
"remove_nans": False
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ndarray, ndim 2, dtype family float, shape (4, 1) — shape (4, 1) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| ts_size |
Ran ran on a synthesized input |
WenjieDu/TSDB/tsdb/loading_funcs/ucr_uea_datasets.py code served (permissive licence) · get_code("5a2504beb4fe7332") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
def ts_size(ts):
"""Returns actual time series size.
Final timesteps that have `NaN` values for all dimensions will be removed
from the count. Infinity and negative infinity ar considered valid time
series values.
Parameters
----------
ts : array-like
A time series.
Returns
-------
int
Actual size of the time series.
Examples
--------
>>> ts_size([1, 2, 3, np.nan])
3
>>> ts_size([1, np.nan])
1
>>> ts_size([np.nan])
0
>>> ts_size([[1, 2],
... [2, 3],
... [3, 4],
... [np.nan, 2],
... [np.nan, np.nan]])
4
>>> ts_size([np.nan, 3, np.inf, np.nan])
3
"""
def to_time_series(ts, remove_nans=False):
ts_out = np.array(ts, copy=True)
if ts_out.ndim <= 1:
ts_out = ts_out.reshape((-1, 1))
if ts_out.dtype != float:
ts_out = ts_out.astype(float)
if remove_nans:
ts_out = ts_out[:ts_size(ts_out)]
return ts_out
ts_ = to_time_series(ts)
sz = ts_.shape[0]
while sz > 0 and np.all(np.isnan(ts_[sz - 1])):
sz -= 1
return sz
# Test with a simple time series that has trailing NaNs
test_ts = [1.0, 2.0, 3.0, np.nan, np.nan]
ARGS = {
"ts": test_ts
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| load_beijing_air_quality |
Not yet run unverified (harvested, no recorded run) |
WenjieDu/TSDB/tsdb/loading_funcs/beijing_multisite_air_quality.py code served (permissive licence) · get_code("36bd8913a719f1c2") How it ran |
| load_ett |
Not yet run unverified (harvested, no recorded run) |
WenjieDu/TSDB/tsdb/loading_funcs/electricity_transformer_temperature.py code served (permissive licence) · get_code("70cbb47704b5ab59") How it ran |
| load_italy_air_quality |
Not yet run unverified (harvested, no recorded run) |
WenjieDu/TSDB/tsdb/loading_funcs/italy_air_quality.py code served (permissive licence) · get_code("407ad127c5ac9922") How it ran |
| load_pems_traffic |
Not yet run unverified (harvested, no recorded run) |
WenjieDu/TSDB/tsdb/loading_funcs/pems_traffic.py code served (permissive licence) · get_code("48ae4f71825e2b97") How it ran |
| load_physionet2012 |
Not yet run unverified (harvested, no recorded run) |
WenjieDu/TSDB/tsdb/loading_funcs/physionet_2012.py code served (permissive licence) · get_code("48578be846b208a2") How it ran |
| load_tsqa |
Not yet run unverified (harvested, no recorded run) |
WenjieDu/TSDB/tsdb/loading_funcs/tsqa.py code served (permissive licence) · get_code("8fd5c31a4a061aa0") How it ran |
| load_ucr_uea_dataset |
Not yet run unverified (harvested, no recorded run) |
WenjieDu/TSDB/tsdb/loading_funcs/ucr_uea_datasets.py code served (permissive licence) · get_code("4661eb132334f7b3") How it ran |