Skip to content

Commit c613aae

Browse files
committed
Finished fixing the docstrings.
1 parent caf3a65 commit c613aae

File tree

22 files changed

+824
-520
lines changed

22 files changed

+824
-520
lines changed

python/python/raphtory/__init__.pyi

Lines changed: 161 additions & 57 deletions
Large diffs are not rendered by default.

python/python/raphtory/node_state/__init__.pyi

Lines changed: 175 additions & 75 deletions
Large diffs are not rendered by default.

python/tests/test_base_install/test_graphql/test_rolling_expanding.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ def test_zero_step():
15381538
graph = Graph()
15391539
create_graph_epoch(graph)
15401540
queries_and_exceptions = []
1541-
zero_exception = "Failed to parse time string: 0 size step is not supported"
1541+
zero_exception = "Failed to parse time string: 0 size step is not supported."
15421542
# graph fail test
15431543
query = """
15441544
{
@@ -2200,8 +2200,8 @@ def test_wrong_window():
22002200
create_graph_epoch(graph)
22012201
queries_and_exceptions = []
22022202
mismatch_exception = "Your window and step must be of the same type: duration (string) or epoch (int)"
2203-
parse_exception = "Failed to parse time string: one of the tokens in the interval string supposed to be a number couldn't be parsed"
2204-
parse_exception2 = "Failed to parse time string: 'monthdas' is not a valid unit"
2203+
parse_exception = "Failed to parse time string: One of the tokens in the interval string supposed to be a number couldn't be parsed."
2204+
parse_exception2 = "Failed to parse time string: 'monthdas' is not a valid unit."
22052205
too_many_exception = "Invalid value for argument \\"
22062206
# graph fail test
22072207
query = """

raphtory-api/src/core/storage/timeindex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ pub trait AsTime: fmt::Debug + Copy + Ord + Eq + Send + Sync + 'static {
4545
/// Converts the timestamp into a UTC DateTime.
4646
///
4747
/// # Returns:
48-
/// * `DateTime`
48+
/// `DateTime`:
4949
///
5050
/// # Raises:
51-
/// * `TimeError`: Returns TimestampError on out-of-range timestamps.
51+
/// `TimeError`: Returns TimestampError on out-of-range timestamps.
5252
fn dt(&self) -> Result<DateTime<Utc>, TimeError> {
5353
let t = self.t();
5454
DateTime::from_timestamp_millis(t).ok_or(TimeError::OutOfRange(t))

raphtory-api/src/core/utils/time.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use std::{convert::Infallible, num::ParseIntError};
1010
pub enum ParseTimeError {
1111
#[error("The interval string doesn't contain a complete number of number-unit pairs.")]
1212
InvalidPairs,
13-
#[error("One of the tokens in the interval string supposed to be a number couldn't be parsed.")]
13+
#[error(
14+
"One of the tokens in the interval string supposed to be a number couldn't be parsed."
15+
)]
1416
ParseInt {
1517
#[from]
1618
source: ParseIntError,
@@ -142,7 +144,8 @@ impl TryIntoTimeNeedsSecondaryIndex for NaiveDateTime {}
142144

143145
impl TryIntoTimeNeedsSecondaryIndex for &str {}
144146

145-
/// Used to handle automatic injection of secondary index if not explicitly provided
147+
/// Used to handle automatic injection of secondary index if not explicitly provided.
148+
/// In many cases, we will want different behaviour if a secondary index was provided or not.
146149
pub enum InputTime {
147150
Simple(i64),
148151
Indexed(i64, usize),
@@ -164,7 +167,7 @@ impl InputTime {
164167
}
165168
}
166169

167-
// Single time input only refers to the i64 component of a TimeIndexEntry (without a secondary index).
170+
/// Single time input only refers to the i64 component of a TimeIndexEntry (no secondary index).
168171
pub trait AsSingleTimeInput {
169172
fn try_into_input_time(self) -> Result<InputTime, ParseTimeError>;
170173
}

raphtory-api/src/python/timeindex.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ impl<'source> FromPyObject<'source> for TimeIndexEntry {
3131
}
3232
}
3333

34-
/// Components that can make a TimeIndexEntry. Extract them from Python as individual components so we can support tuples for TimeIndexEntry
35-
/// They can be used as the secondary index as well.
34+
/// Components that can make a TimeIndexEntry. They can be used as the secondary index as well.
35+
/// Extract them from Python as individual components so we can support tuples for TimeIndexEntry.
3636
#[derive(Debug, Clone, Copy)]
3737
pub struct TimeIndexComponent {
3838
component: i64,
@@ -154,16 +154,19 @@ impl PyTimeIndexEntry {
154154
#[pymethods]
155155
impl PyTimeIndexEntry {
156156
/// Return the UTC datetime representation of this time entry.
157+
///
157158
/// Returns:
158159
/// datetime: The UTC datetime corresponding to this entry's timestamp.
160+
///
159161
/// Raises:
160-
/// TimeError: Returns TimestampError on out-of-range timestamps.
162+
/// TimeError: Returns TimeError on timestamp conversion errors (e.g. out-of-range timestamp).
161163
#[getter]
162164
pub fn dt(&self) -> Result<DateTime<Utc>, TimeError> {
163165
self.time.dt()
164166
}
165167

166168
/// Return the secondary index associated with this time entry.
169+
///
167170
/// Returns:
168171
/// int: The secondary index.
169172
#[getter]
@@ -172,6 +175,7 @@ impl PyTimeIndexEntry {
172175
}
173176

174177
/// Return the Unix timestamp in milliseconds.
178+
///
175179
/// Returns:
176180
/// int: Milliseconds since the Unix epoch.
177181
#[getter]
@@ -180,8 +184,9 @@ impl PyTimeIndexEntry {
180184
}
181185

182186
/// Return this entry as a tuple of (timestamp_ms, secondary_index).
187+
///
183188
/// Returns:
184-
/// tuple[int, int]: (timestamp, secondary_index).
189+
/// tuple[int,int]: (timestamp, secondary_index).
185190
#[getter]
186191
pub fn as_tuple(&self) -> (i64, usize) {
187192
self.time.as_tuple()
@@ -228,8 +233,10 @@ impl PyTimeIndexEntry {
228233
}
229234

230235
/// Create a new TimeIndexEntry.
236+
///
231237
/// Arguments:
232238
/// time (int | float | datetime | str | tuple): The time entry to be created. Pass a tuple/list of two of these components to specify the secondary index as well.
239+
233240
/// Returns:
234241
/// TimeIndexEntry: A new time index entry.
235242
#[staticmethod]

0 commit comments

Comments
 (0)