core-lens 0.1.dev154__tar.gz → 0.1.dev155__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/PKG-INFO +1 -1
- core_lens-0.1.dev155/src/core_lens/__main__.py +36 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/_version.py +2 -2
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/base/namespaces/stats.py +17 -44
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_main.py +5 -1
- core_lens-0.1.dev154/src/core_lens/__main__.py +0 -14
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.github/ISSUE_TEMPLATE/blank-proposal.yaml +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.github/ISSUE_TEMPLATE/bug-report.yaml +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.github/ISSUE_TEMPLATE/feature-request.yaml +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.github/pull_request_template.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.github/workflows/ci.yml +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.github/workflows/gh-pages.yml +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.github/workflows/pre-release.yml +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.github/workflows/release.yml +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.gitignore +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.gitmessage +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.pre-commit-config.yaml +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/.python-version +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/CONTRIBUTING.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/LICENSE +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/README.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/SKILLS.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/benchmarks/README.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/benchmarks/bench_aoi.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/benchmarks/bench_export.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/benchmarks/bench_polars_utils.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/benchmarks/bench_result.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/benchmarks/bench_schema.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/benchmarks/bench_season.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/benchmarks/bench_spatial.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/benchmarks/bench_view.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/benchmarks/run_all.sh +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/Makefile +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/make.bat +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/source/concepts.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/source/conf.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/source/export.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/source/index.rst +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/source/intro.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/source/logging.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/source/plots.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/source/plugins.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/source/queries.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/source/quickstart.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/docs/source/stats.md +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/examples/demo_mws.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/examples/demo_tehsil.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/hooks/mypy.sh +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/hooks/no-parquet-outside-fixtures.sh +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/hooks/pytest.sh +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/pyproject.toml +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/__init__.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/aoi.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/base/__init__.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/base/entity.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/base/namespaces/__init__.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/base/namespaces/plot.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/base/result.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/base/view.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/entities/__init__.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/entities/mws.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/entities/tehsil.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/entities/waterbody.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/export/__init__.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/export/formats.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/py.typed +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/schema/__init__.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/schema/detection.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/schema/profile.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/utils/__init__.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/utils/paths.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/utils/polars_utils.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/utils/season.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/src/core_lens/utils/spatial.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/fixtures/generate_fixtures.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/conftest.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_aoi.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_entities.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_entity.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_export.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_plot.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_polars_utils.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_profile.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_result.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_schema_detection.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_schema_profile.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_season.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_season_config.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_spatial.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_stats.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/tests/unit/test_view.py +0 -0
- {core_lens-0.1.dev154 → core_lens-0.1.dev155}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: core-lens
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.dev155
|
|
4
4
|
Summary: Query, analyse, and visualise CoreStack's microwatershed and Earth science data through a clean, composable Python API.
|
|
5
5
|
Project-URL: Homepage, https://github.com/ApoorvaKashyap/core-lens
|
|
6
6
|
Project-URL: Issues, https://github.com/ApoorvaKashyap/core-lens/issues
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from . import __version__
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def hello() -> str:
|
|
5
|
+
hello_str = """Hello from core-lens!
|
|
6
|
+
|
|
7
|
+
The following primary capabilities are available:
|
|
8
|
+
- AoI: Construct Area of Interest queries (e.g., `AoI(district="Godda")`)
|
|
9
|
+
- Result: Lazy evaluation and computation graph materialisation
|
|
10
|
+
|
|
11
|
+
Analytics (via `result.stats`):
|
|
12
|
+
- anomaly(): Timeseries and cross-sectional anomaly detection
|
|
13
|
+
- change(): Absolute, percentage, and trend changes over time
|
|
14
|
+
- similarity(): Multi-feature similarity search across entities
|
|
15
|
+
- test(): Statistical hypothesis testing
|
|
16
|
+
- correlate(): Feature correlation analysis
|
|
17
|
+
|
|
18
|
+
Visualisation (via `result.plot`):
|
|
19
|
+
- choropleth(): Interactive Lonboard spatial mapping
|
|
20
|
+
- timeseries(): Temporal data visualisation
|
|
21
|
+
- scatter(): Scatter plots for variable comparison
|
|
22
|
+
- distribution(): Histograms and density plots
|
|
23
|
+
- correlation(): Correlation heatmaps between variables
|
|
24
|
+
- heatmap(): 2D density/binned heatmaps
|
|
25
|
+
- matrix(): Scatter matrix/pair plots
|
|
26
|
+
"""
|
|
27
|
+
return hello_str
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def version() -> str:
|
|
31
|
+
return str(__version__)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if __name__ == "__main__":
|
|
35
|
+
print(hello())
|
|
36
|
+
print(f"Version: {version()}")
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.1.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 1, '
|
|
21
|
+
__version__ = version = '0.1.dev155'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 'dev155')
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -489,18 +489,24 @@ class StatsNamespace:
|
|
|
489
489
|
)
|
|
490
490
|
|
|
491
491
|
if method in (ChangeMethod.ABSOLUTE, ChangeMethod.PERCENTAGE):
|
|
492
|
+
join_keys = [key]
|
|
493
|
+
if "season" in df.columns:
|
|
494
|
+
join_keys.append("season")
|
|
495
|
+
|
|
492
496
|
from_df = (
|
|
493
497
|
df.filter(pl.col(year_col) == from_period)
|
|
494
|
-
.select([
|
|
498
|
+
.select(join_keys + [column])
|
|
495
499
|
.rename({column: "value_from"})
|
|
496
500
|
)
|
|
497
501
|
to_df = (
|
|
498
502
|
df.filter(pl.col(year_col) == to_period)
|
|
499
|
-
.select([
|
|
503
|
+
.select(join_keys + [column])
|
|
500
504
|
.rename({column: "value_to"})
|
|
501
505
|
)
|
|
502
|
-
joined = from_df.join(to_df, on=
|
|
506
|
+
joined = from_df.join(to_df, on=join_keys, how="inner").with_columns(
|
|
503
507
|
[
|
|
508
|
+
pl.lit(from_period).alias("year_from").cast(pl.Int32),
|
|
509
|
+
pl.lit(to_period).alias("year_to").cast(pl.Int32),
|
|
504
510
|
(pl.col("value_to") - pl.col("value_from")).alias("change"),
|
|
505
511
|
(
|
|
506
512
|
(pl.col("value_to") - pl.col("value_from"))
|
|
@@ -859,12 +865,9 @@ class StatsNamespace:
|
|
|
859
865
|
df = self._r.df()
|
|
860
866
|
key = self._r.key_cols[0]
|
|
861
867
|
|
|
862
|
-
min_year: int | None = None
|
|
863
|
-
max_year: int | None = None
|
|
864
|
-
|
|
865
868
|
# --- Build feature DataFrame ------------------------------------------
|
|
866
869
|
# Universe of entity keys from result.data.
|
|
867
|
-
feat = df.select([key])
|
|
870
|
+
feat = df.select([key])
|
|
868
871
|
|
|
869
872
|
for col_name, spec in columns.items():
|
|
870
873
|
if spec is None:
|
|
@@ -884,23 +887,6 @@ class StatsNamespace:
|
|
|
884
887
|
resolution_str, filter_dict = spec
|
|
885
888
|
filter_dict = dict(filter_dict) if filter_dict else {}
|
|
886
889
|
|
|
887
|
-
if "year" in filter_dict:
|
|
888
|
-
yr = filter_dict["year"]
|
|
889
|
-
y0: int | None = None
|
|
890
|
-
y1: int | None = None
|
|
891
|
-
|
|
892
|
-
if isinstance(yr, (list, tuple)) and len(yr) >= 2:
|
|
893
|
-
y0, y1 = int(yr[0]), int(yr[1])
|
|
894
|
-
elif isinstance(yr, int):
|
|
895
|
-
y0, y1 = yr, yr
|
|
896
|
-
|
|
897
|
-
if y0 is not None:
|
|
898
|
-
if min_year is None or y0 < min_year:
|
|
899
|
-
min_year = y0
|
|
900
|
-
if y1 is not None:
|
|
901
|
-
if max_year is None or y1 > max_year:
|
|
902
|
-
max_year = y1
|
|
903
|
-
|
|
904
890
|
entity = self._r.entity
|
|
905
891
|
path: str | None
|
|
906
892
|
if resolution_str == "static":
|
|
@@ -1026,26 +1012,13 @@ class StatsNamespace:
|
|
|
1026
1012
|
dists[tidx] = float("inf") # exclude target itself
|
|
1027
1013
|
top_idx = np.argsort(dists)[:top_n]
|
|
1028
1014
|
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
max_year = int(cast(int, yr_max))
|
|
1037
|
-
|
|
1038
|
-
output_dict: dict[str, Any] = {
|
|
1039
|
-
key: [ids[i] for i in top_idx],
|
|
1040
|
-
"similarity_score": [float(1.0 / (1.0 + dists[i])) for i in top_idx],
|
|
1041
|
-
"rank": list(range(1, len(top_idx) + 1)),
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
if min_year is not None and max_year is not None:
|
|
1045
|
-
output_dict["year_from"] = [min_year] * len(top_idx)
|
|
1046
|
-
output_dict["year_to"] = [max_year] * len(top_idx)
|
|
1047
|
-
|
|
1048
|
-
data = pl.DataFrame(output_dict)
|
|
1015
|
+
data = pl.DataFrame(
|
|
1016
|
+
{
|
|
1017
|
+
key: [ids[i] for i in top_idx],
|
|
1018
|
+
"similarity_score": [float(1.0 / (1.0 + dists[i])) for i in top_idx],
|
|
1019
|
+
"rank": list(range(1, len(top_idx) + 1)),
|
|
1020
|
+
}
|
|
1021
|
+
)
|
|
1049
1022
|
metadata: dict[str, Any] = {
|
|
1050
1023
|
"method": method.value if method is not None else None,
|
|
1051
1024
|
"target": target,
|
|
@@ -8,7 +8,11 @@ def test_version() -> None:
|
|
|
8
8
|
def test_hello() -> None:
|
|
9
9
|
from core_lens.__main__ import hello
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
msg = hello()
|
|
12
|
+
assert msg.startswith("Hello from core-lens!")
|
|
13
|
+
assert "AoI: Construct Area of Interest queries" in msg
|
|
14
|
+
assert "Analytics (via `result.stats`):" in msg
|
|
15
|
+
assert "Visualisation (via `result.plot`):" in msg
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
def test_version_type() -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|