Skip to content

Add tsm Python module#410

Draft
Grufoony wants to merge 9 commits intomainfrom
tsm
Draft

Add tsm Python module#410
Grufoony wants to merge 9 commits intomainfrom
tsm

Conversation

@Grufoony
Copy link
Collaborator

No description provided.

to_folium_map as to_folium_map,
)

from .tsm import TSM as TSM

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Import alias does not rename original package Warning

Import alias does not rename original package
@@ -0,0 +1 @@
from .tsm import TSM as TSM

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing module docstring Warning

Missing module docstring
@@ -0,0 +1 @@
from .tsm import TSM as TSM

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Import alias does not rename original package Warning

Import alias does not rename original package
@@ -0,0 +1,204 @@
from __future__ import annotations

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing module docstring Warning

Missing module docstring
# helpers
# ------------------------------------------------------------------
@property
def _group_cols(self) -> list[str]:

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Value 'list' is unsubscriptable Warning

Value 'list' is unsubscriptable
to_folium_map as to_folium_map,
)

from .tsm import TSM as TSM

Check warning

Code scanning / Prospector (reported by Codacy)

Import alias does not rename original package (useless-import-alias) Warning

Import alias does not rename original package (useless-import-alias)
to_folium_map as to_folium_map,
)

from .tsm import TSM as TSM

Check warning

Code scanning / Prospector (reported by Codacy)

'.tsm.TSM' imported but unused (F401) Warning

'.tsm.TSM' imported but unused (F401)
@@ -0,0 +1 @@
from .tsm import TSM as TSM

Check warning

Code scanning / Prospector (reported by Codacy)

Import alias does not rename original package (useless-import-alias) Warning

Import alias does not rename original package (useless-import-alias)
@@ -0,0 +1 @@
from .tsm import TSM as TSM

Check warning

Code scanning / Prospector (reported by Codacy)

'.tsm.TSM' imported but unused (F401) Warning

'.tsm.TSM' imported but unused (F401)
# helpers
# ------------------------------------------------------------------
@property
def _group_cols(self) -> list[str]:

Check warning

Code scanning / Prospector (reported by Codacy)

Value 'list' is unsubscriptable (unsubscriptable-object) Warning

Value 'list' is unsubscriptable (unsubscriptable-object)
@@ -0,0 +1 @@
from .tsm import TSM as TSM

Check warning

Code scanning / Pylint (reported by Codacy)

Missing module docstring Warning

Missing module docstring
@@ -0,0 +1,204 @@
from __future__ import annotations

Check warning

Code scanning / Pylint (reported by Codacy)

No name 'annotations' in module 'future' Warning

No name 'annotations' in module '__future__'
@@ -0,0 +1,204 @@
from __future__ import annotations

Check warning

Code scanning / Pylint (reported by Codacy)

Missing module docstring Warning

Missing module docstring
"""

def __init__(
self,

Check warning

Code scanning / Pylint (reported by Codacy)

Wrong hanging indentation before block (add 4 spaces). Warning

Wrong hanging indentation before block (add 4 spaces).
# helpers
# ------------------------------------------------------------------
@property
def _group_cols(self) -> list[str]:

Check warning

Code scanning / Pylint (reported by Codacy)

Value 'list' is unsubscriptable Warning

Value 'list' is unsubscriptable
# public API
# ------------------------------------------------------------------
def clusterize(
self,

Check warning

Code scanning / Pylint (reported by Codacy)

Wrong hanging indentation before block (add 4 spaces). Warning

Wrong hanging indentation before block (add 4 spaces).
# ------------------------------------------------------------------
def clusterize(
self,
min_vehicles: int = 5,

Check warning

Code scanning / Pylint (reported by Codacy)

Wrong hanging indentation before block (add 4 spaces). Warning

Wrong hanging indentation before block (add 4 spaces).
def clusterize(
self,
min_vehicles: int = 5,
gap_factor: float = 3.0,

Check warning

Code scanning / Pylint (reported by Codacy)

Wrong hanging indentation before block (add 4 spaces). Warning

Wrong hanging indentation before block (add 4 spaces).
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.21%. Comparing base (f51a2fe) to head (8b79593).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #410   +/-   ##
=======================================
  Coverage   87.21%   87.21%           
=======================================
  Files          52       52           
  Lines        6428     6428           
  Branches      714      714           
=======================================
  Hits         5606     5606           
  Misses        803      803           
  Partials       19       19           
Flag Coverage Δ
unittests 87.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -0,0 +1,2 @@
from .tsm import TSM as TSM
from .tsm import _get_or_create_spark

Check warning

Code scanning / Prospector (reported by Codacy)

'.tsm._get_or_create_spark' imported but unused (F401) Warning

'.tsm._get_or_create_spark' imported but unused (F401)
from pathlib import Path
from typing import Dict, Optional

from pyspark.sql import DataFrame, SparkSession, Window

Check warning

Code scanning / Prospector (reported by Codacy)

Unable to import 'pyspark.sql' (import-error) Warning

Unable to import 'pyspark.sql' (import-error)
from typing import Dict, Optional

from pyspark.sql import DataFrame, SparkSession, Window
import pyspark.sql.functions as F

Check warning

Code scanning / Prospector (reported by Codacy)

Unable to import 'pyspark.sql.functions' (import-error) Warning

Unable to import 'pyspark.sql.functions' (import-error)
import pyspark.sql.functions as F


def _get_or_create_spark(

Check warning

Code scanning / Prospector (reported by Codacy)

Too many arguments (6/5) (too-many-arguments) Warning

Too many arguments (6/5) (too-many-arguments)
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pylint (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@@ -0,0 +1,2 @@
from .tsm import TSM as TSM
from .tsm import _get_or_create_spark

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Trailing whitespace Warning

Trailing whitespace
import pyspark.sql.functions as F


def _get_or_create_spark(

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Too many arguments (6/5) Warning

Too many arguments (6/5)
.config("spark.executor.memory", executor_memory) \
.config("spark.sql.shuffle.partitions", str(shuffle_partitions)) \
.config("spark.sql.adaptive.enabled", str(adaptive_enabled).lower()) \
.config("spark.sql.adaptive.coalescePartitions.enabled", str(adaptive_coalesce_enabled).lower()) \

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (106/100) Warning

Line too long (106/100)
column_mapping: Optional[Dict[str, str]] = None,
) -> None:
if column_mapping is not None:
df = data

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "df" doesn't conform to snake_case naming style Warning

Variable name "df" doesn't conform to snake_case naming style
df = data
for src, eng in column_mapping.items():
if src in df.columns:
df = df.withColumnRenamed(src, eng)

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "df" doesn't conform to snake_case naming style Warning

Variable name "df" doesn't conform to snake_case naming style
)
if intermediates:
self._result_intratimes = df.drop("new_cluster").drop("prev_timestamp")

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Trailing whitespace Warning

Trailing whitespace
F.try_divide(F.col("num_vehicles"), F.col("cluster_len_km") * F.col("n_lanes")),
).withColumn(
"flow",
F.try_divide(F.col("num_vehicles") * 3.6e3, F.col("cluster_dt_s") * F.col("n_lanes")),

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (102/100) Warning

Line too long (102/100)
If :meth:`clusterize` has not been called yet.
"""
if self._result_intratimes is None:
raise RuntimeError("Call .clusterize() with intermediates=True before accessing .result_intratimes")

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (112/100) Warning

Line too long (112/100)
return self._result_intratimes

@property
def df(self) -> DataFrame:

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Attribute name "df" doesn't conform to snake_case naming style Warning

Attribute name "df" doesn't conform to snake_case naming style
rows = self._result.count()
else:
rows = self._df.count()
return f"TSM(status={status}, rows={rows})" No newline at end of file

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Final newline missing Warning

Final newline missing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants