Config
pynapple.core.config
This module deals with package configurations. For now it includes only warning configurations.
PynappleConfig
A class to hold configuration settings for pynapple.
This class includes all configuration settings that control the behavior of pynapple. It offers a structured way to access and modify settings.
Examples:
>>> import pynapple as nap
>>> import jax.numpy as jnp
>>> t = jnp.arange(3)
>>> print(t)
Array([0, 1, 2], dtype=int32)
>>> # Suppress warnings when converting a non-numpy array to numpy array
>>> nap.config.nap_config.suppress_conversion_warnings = True
>>> nap.Ts(t=t)
Time (s)
0.0
1.0
2.0
shape: 3
>>> # Restore to defaults
>>> nap.config.nap_config.restore_defaults()
>>> nap.Ts(t=t)
/mnt/home/gviejo/pynapple/pynapple/core/time_series.py:151: UserWarning: Converting 't' to n
umpy.array. The provided array was of type 'ArrayImpl'.
warnings.warn(
Time (s)
0.0
1.0
2.0
shape: 3
Attributes:
Name | Type | Description |
---|---|---|
suppress_conversion_warnings |
boolean
|
Determines whether to suppress warnings when automatically converting non-NumPy array-like objects to NumPy arrays. This is useful for users who frequently work with array-like objects from other libraries (e.g., JAX, TensorFlow) and prefer not to receive warnings for automatic conversions. Defaults to False, which means warnings will be shown. |
suppress_time_index_sorting_warnings |
boolean
|
Control the warning raised when passing a non-sorted array for time index. It can be useful to catch data where timestamps are not properly sorted before using pynapple. |
time_index_precision |
int
|
Precision for the time index is set to nanoseconds. It's a fixed parameter in pynapple and cannot be changed. |
Source code in pynapple/core/config.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
time_index_precision
property
Precision for the time index
Returns:
Type | Description |
---|---|
Int
|
Parameter for the |
suppress_conversion_warnings
property
writable
Gets or sets the suppression state for conversion warnings. When set to True, warnings for automatic conversions of non-NumPy array-like objects or pynapple objects to NumPy arrays are suppressed. Ensures that only boolean values are assigned.
suppress_time_index_sorting_warnings
property
writable
Gets or sets the suppression state for sorting time index. When set to True, warnings for sorting are suppressed. Ensures that only boolean values are assigned.
restore_defaults
Set all configuration settings to their default values.
This method can be used to easily set/reset the configuration state of pynapple to its initial, default configuration.