gla-data 0.1.1__tar.gz → 0.1.2__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.
Files changed (36) hide show
  1. {gla_data-0.1.1 → gla_data-0.1.2}/.gitignore +2 -1
  2. gla_data-0.1.2/PKG-INFO +109 -0
  3. gla_data-0.1.2/README.md +93 -0
  4. {gla_data-0.1.1 → gla_data-0.1.2}/pyproject.toml +2 -2
  5. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/census.py +10 -1
  6. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/cli.py +19 -0
  7. {gla_data-0.1.1 → gla_data-0.1.2}/tests/test_census_dwellings.py +37 -0
  8. gla_data-0.1.2/tests/test_cli.py +19 -0
  9. gla_data-0.1.1/PKG-INFO +0 -43
  10. gla_data-0.1.1/README.md +0 -27
  11. gla_data-0.1.1/tests/test_placeholder.py +0 -6
  12. {gla_data-0.1.1 → gla_data-0.1.2}/.copier-answers.yml +0 -0
  13. {gla_data-0.1.1 → gla_data-0.1.2}/.env.example +0 -0
  14. {gla_data-0.1.1 → gla_data-0.1.2}/.github/workflows/ci.yml +0 -0
  15. {gla_data-0.1.1 → gla_data-0.1.2}/.github/workflows/publish.yml +0 -0
  16. {gla_data-0.1.1 → gla_data-0.1.2}/pixi.lock +0 -0
  17. {gla_data-0.1.1 → gla_data-0.1.2}/pixi.toml +0 -0
  18. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/__init__.py +2 -2
  19. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/_arcgis.py +0 -0
  20. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/_cache.py +0 -0
  21. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/_ons.py +0 -0
  22. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/_schemas.py +0 -0
  23. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/_ukds.py +0 -0
  24. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/catalogue.py +0 -0
  25. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/config.py +0 -0
  26. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/geography.py +0 -0
  27. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/py.typed +0 -0
  28. {gla_data-0.1.1 → gla_data-0.1.2}/src/gla_data/transforms.py +0 -0
  29. {gla_data-0.1.1 → gla_data-0.1.2}/tests/__init__.py +0 -0
  30. {gla_data-0.1.1 → gla_data-0.1.2}/tests/conftest.py +0 -0
  31. {gla_data-0.1.1 → gla_data-0.1.2}/tests/test_aggregate.py +0 -0
  32. {gla_data-0.1.1 → gla_data-0.1.2}/tests/test_boundaries.py +0 -0
  33. {gla_data-0.1.1 → gla_data-0.1.2}/tests/test_catalogue.py +0 -0
  34. {gla_data-0.1.1 → gla_data-0.1.2}/tests/test_crosswalk.py +0 -0
  35. {gla_data-0.1.1 → gla_data-0.1.2}/tests/test_geography_lookup.py +0 -0
  36. {gla_data-0.1.1 → gla_data-0.1.2}/uv.lock +0 -0
@@ -33,7 +33,8 @@ outputs/
33
33
  .DS_Store
34
34
  Thumbs.db
35
35
 
36
- # Plan docs — internal working notes, not part of the shipped project
36
+ # Plan docs and Claude instructions — internal, not part of the shipped project
37
37
  PLAN*.md
38
38
  WORKPLAN.md
39
39
  DESIGN.md
40
+ CLAUDE.md
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.4
2
+ Name: gla-data
3
+ Version: 0.1.2
4
+ Summary: Shared tools for loading, transforming, and visualising the GLA datasets used in City Data analysis.
5
+ Author-email: Conor Dempsey <conor.dempsey@london.gov.uk>
6
+ License: MIT
7
+ Requires-Python: >=3.12
8
+ Requires-Dist: geopandas>=1.0
9
+ Requires-Dist: pandas>=2.2
10
+ Requires-Dist: pandera>=0.32.1
11
+ Requires-Dist: pyarrow>=24.0.0
12
+ Requires-Dist: pydantic-settings
13
+ Requires-Dist: requests>=2.32
14
+ Requires-Dist: typer>=0.26.8
15
+ Description-Content-Type: text/markdown
16
+
17
+ # gla-data
18
+
19
+ Shared tools for loading, transforming, and visualising the GLA datasets used in City Data analysis.
20
+
21
+ ## Installation
22
+
23
+ ### Global install (CLI)
24
+
25
+ To install `gla-data` globally so the `gla-data` CLI is available anywhere in your terminal, use `uv tool`:
26
+
27
+ ```bash
28
+ uv tool install gla-data
29
+ ```
30
+
31
+ Normally `pixi global install` would be the preferred approach, but it does not yet support PyPI packages — so `uv tool` is the right choice for now.
32
+
33
+ If you don't have `uv` installed, you can install it via pixi:
34
+
35
+ ```bash
36
+ pixi global install uv
37
+ ```
38
+
39
+ ### pip
40
+
41
+ ```bash
42
+ pip install gla-data
43
+ ```
44
+
45
+ ### pixi
46
+
47
+ ```bash
48
+ pixi add gla-data
49
+ ```
50
+
51
+ Pixi pulls geospatial dependencies (geopandas, pyproj, etc.) from conda-forge, which provides reliable pre-built binaries across all platforms and Python versions.
52
+
53
+ ## Usage
54
+
55
+ ### Python API
56
+
57
+ ```python
58
+ import gla_data
59
+
60
+ # Load 2021 LSOA boundaries for London
61
+ lsoa_gdf = gla_data.load_boundaries(geography='lsoa', year=2021)
62
+
63
+ # Load census dwelling counts
64
+ dwellings_2021 = gla_data.load_census_dwellings(year=2021)
65
+ dwellings_2011 = gla_data.load_census_dwellings(year=2011)
66
+
67
+ # Crosswalk 2011 dwelling counts onto 2021 LSOA boundaries
68
+ dwellings_2011_xw = gla_data.crosswalk(
69
+ dwellings_2011,
70
+ from_year=2011,
71
+ to_year=2021,
72
+ value_cols=['dwellings_total'],
73
+ )
74
+
75
+ # Load an OA → LSOA geography lookup
76
+ lookup = gla_data.load_geography_lookup(year=2021, smallest_geography='oa')
77
+
78
+ # Aggregate OA-level data up to LSOA level
79
+ lsoa_totals = gla_data.aggregate(
80
+ df,
81
+ from_geography='oa',
82
+ to_geography='lsoa',
83
+ value_cols=['count'],
84
+ year=2021,
85
+ )
86
+ ```
87
+
88
+ ### CLI
89
+
90
+ The package installs a `gla-data` command. Run `catalogue` to list all available datasets:
91
+
92
+ ```bash
93
+ gla-data catalogue
94
+ ```
95
+
96
+ This prints a table of every dataset, the function used to load it, a description, and its access tier (public/S3).
97
+
98
+ ## Development
99
+
100
+ ```bash
101
+ git clone <repo-url>
102
+ cd gla-data
103
+ pixi install
104
+
105
+ pixi run test # run tests
106
+ pixi run lint # check code style
107
+ pixi run format # auto-format
108
+ pixi run typecheck # type checking
109
+ ```
@@ -0,0 +1,93 @@
1
+ # gla-data
2
+
3
+ Shared tools for loading, transforming, and visualising the GLA datasets used in City Data analysis.
4
+
5
+ ## Installation
6
+
7
+ ### Global install (CLI)
8
+
9
+ To install `gla-data` globally so the `gla-data` CLI is available anywhere in your terminal, use `uv tool`:
10
+
11
+ ```bash
12
+ uv tool install gla-data
13
+ ```
14
+
15
+ Normally `pixi global install` would be the preferred approach, but it does not yet support PyPI packages — so `uv tool` is the right choice for now.
16
+
17
+ If you don't have `uv` installed, you can install it via pixi:
18
+
19
+ ```bash
20
+ pixi global install uv
21
+ ```
22
+
23
+ ### pip
24
+
25
+ ```bash
26
+ pip install gla-data
27
+ ```
28
+
29
+ ### pixi
30
+
31
+ ```bash
32
+ pixi add gla-data
33
+ ```
34
+
35
+ Pixi pulls geospatial dependencies (geopandas, pyproj, etc.) from conda-forge, which provides reliable pre-built binaries across all platforms and Python versions.
36
+
37
+ ## Usage
38
+
39
+ ### Python API
40
+
41
+ ```python
42
+ import gla_data
43
+
44
+ # Load 2021 LSOA boundaries for London
45
+ lsoa_gdf = gla_data.load_boundaries(geography='lsoa', year=2021)
46
+
47
+ # Load census dwelling counts
48
+ dwellings_2021 = gla_data.load_census_dwellings(year=2021)
49
+ dwellings_2011 = gla_data.load_census_dwellings(year=2011)
50
+
51
+ # Crosswalk 2011 dwelling counts onto 2021 LSOA boundaries
52
+ dwellings_2011_xw = gla_data.crosswalk(
53
+ dwellings_2011,
54
+ from_year=2011,
55
+ to_year=2021,
56
+ value_cols=['dwellings_total'],
57
+ )
58
+
59
+ # Load an OA → LSOA geography lookup
60
+ lookup = gla_data.load_geography_lookup(year=2021, smallest_geography='oa')
61
+
62
+ # Aggregate OA-level data up to LSOA level
63
+ lsoa_totals = gla_data.aggregate(
64
+ df,
65
+ from_geography='oa',
66
+ to_geography='lsoa',
67
+ value_cols=['count'],
68
+ year=2021,
69
+ )
70
+ ```
71
+
72
+ ### CLI
73
+
74
+ The package installs a `gla-data` command. Run `catalogue` to list all available datasets:
75
+
76
+ ```bash
77
+ gla-data catalogue
78
+ ```
79
+
80
+ This prints a table of every dataset, the function used to load it, a description, and its access tier (public/S3).
81
+
82
+ ## Development
83
+
84
+ ```bash
85
+ git clone <repo-url>
86
+ cd gla-data
87
+ pixi install
88
+
89
+ pixi run test # run tests
90
+ pixi run lint # check code style
91
+ pixi run format # auto-format
92
+ pixi run typecheck # type checking
93
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gla-data"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "Shared tools for loading, transforming, and visualising the GLA datasets used in City Data analysis."
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }
@@ -49,7 +49,7 @@ disallow_untyped_defs = false
49
49
  disallow_incomplete_defs = false
50
50
 
51
51
  [tool.bumpversion]
52
- current_version = "0.1.1"
52
+ current_version = "0.1.2"
53
53
  commit = true
54
54
  tag = true
55
55
 
@@ -25,10 +25,19 @@ _EXCEL_KWARGS = {
25
25
 
26
26
 
27
27
  def _fetch_census_dwellings(year: int) -> pd.DataFrame:
28
- """Download and normalise the raw UKDS census dwellings file for the given year."""
28
+ """Download the raw UKDS census dwellings
29
+ file for the given year and normalise it."""
29
30
  kwargs = _EXCEL_KWARGS.get(year, {})
30
31
  raw = _ukds.fetch(f"census_dwellings_{year}", **kwargs)
32
+ return _clean_census_dwellings(raw, year)
31
33
 
34
+
35
+ def _clean_census_dwellings(raw: pd.DataFrame, year: int) -> pd.DataFrame:
36
+ """Select and rename the raw UKDS columns into the public schema for a given year.
37
+
38
+ Pure and deterministic — no I/O — so it can be unit-tested directly with an
39
+ in-memory fixture, without mocking ``_ukds.fetch``.
40
+ """
32
41
  cols = _RAW_COLUMNS[year]
33
42
  code_col = f"LSOA{str(year)[2:]}CD"
34
43
 
@@ -1,5 +1,7 @@
1
1
  """Command-line interface for gla_data."""
2
2
 
3
+ from typing import Annotated
4
+
3
5
  import typer
4
6
  from rich.console import Console
5
7
  from rich.table import Table
@@ -11,6 +13,23 @@ app = typer.Typer(
11
13
  )
12
14
 
13
15
 
16
+ def _version_callback(value: bool) -> None:
17
+ if value:
18
+ typer.echo(gla_data.__version__)
19
+ raise typer.Exit()
20
+
21
+
22
+ @app.callback()
23
+ def main_callback(
24
+ version: Annotated[
25
+ bool,
26
+ typer.Option("--version", "-V", callback=_version_callback, is_eager=True,
27
+ help="Show version and exit."),
28
+ ] = False,
29
+ ) -> None:
30
+ pass
31
+
32
+
14
33
  @app.command()
15
34
  def catalogue() -> None:
16
35
  """List all datasets available in gla_data."""
@@ -5,6 +5,7 @@ import pytest
5
5
 
6
6
  import gla_data
7
7
  import gla_data._cache as cache_module
8
+ from gla_data.census import _clean_census_dwellings
8
9
 
9
10
  # ---------------------------------------------------------------------------
10
11
  # Fixtures
@@ -31,6 +32,42 @@ def fake_dwellings_2011():
31
32
  )
32
33
 
33
34
 
35
+ # ---------------------------------------------------------------------------
36
+ # Pure transform (no I/O, no mocking needed)
37
+ # ---------------------------------------------------------------------------
38
+
39
+
40
+ def test_clean_census_dwellings_2021_selects_and_renames():
41
+ raw = pd.DataFrame(
42
+ {
43
+ "Lower layer Super Output Areas Code": ["E01000001", "E01000002"],
44
+ "Observation": [1079, 1178],
45
+ "Some Other Column": ["x", "y"],
46
+ }
47
+ )
48
+
49
+ result = _clean_census_dwellings(raw, year=2021)
50
+
51
+ assert list(result.columns) == ["LSOA21CD", "dwellings_total"]
52
+ assert result["LSOA21CD"].tolist() == ["E01000001", "E01000002"]
53
+ assert result["dwellings_total"].tolist() == [1079, 1178]
54
+
55
+
56
+ def test_clean_census_dwellings_2011_selects_and_renames():
57
+ raw = pd.DataFrame(
58
+ {
59
+ "GEO_CODE": ["E01000001", "E01000002"],
60
+ "Dwellings : Total\\ Dwellings - Unit : Dwellings": [950, 1050],
61
+ }
62
+ )
63
+
64
+ result = _clean_census_dwellings(raw, year=2011)
65
+
66
+ assert list(result.columns) == ["LSOA11CD", "dwellings_total"]
67
+ assert result["LSOA11CD"].tolist() == ["E01000001", "E01000002"]
68
+ assert result["dwellings_total"].tolist() == [950, 1050]
69
+
70
+
34
71
  # ---------------------------------------------------------------------------
35
72
  # Validation (no network calls)
36
73
  # ---------------------------------------------------------------------------
@@ -0,0 +1,19 @@
1
+ """Tests for the gla_data command-line interface."""
2
+
3
+ from typer.testing import CliRunner
4
+
5
+ from gla_data.cli import app
6
+
7
+ runner = CliRunner()
8
+
9
+
10
+ def test_catalogue_command_exits_cleanly():
11
+ result = runner.invoke(app, ["catalogue"])
12
+ assert result.exit_code == 0
13
+
14
+
15
+ def test_catalogue_command_lists_implemented_datasets():
16
+ result = runner.invoke(app, ["catalogue"])
17
+ assert "Census Dwellings" in result.output
18
+ assert "load_census_dwel" in result.output
19
+ assert "ONS Boundaries" in result.output
gla_data-0.1.1/PKG-INFO DELETED
@@ -1,43 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: gla-data
3
- Version: 0.1.1
4
- Summary: Shared tools for loading, transforming, and visualising the GLA datasets used in City Data analysis.
5
- Author-email: Conor Dempsey <conor.dempsey@london.gov.uk>
6
- License: MIT
7
- Requires-Python: >=3.12
8
- Requires-Dist: geopandas>=1.0
9
- Requires-Dist: pandas>=2.2
10
- Requires-Dist: pandera>=0.32.1
11
- Requires-Dist: pyarrow>=24.0.0
12
- Requires-Dist: pydantic-settings
13
- Requires-Dist: requests>=2.32
14
- Requires-Dist: typer>=0.26.8
15
- Description-Content-Type: text/markdown
16
-
17
- # gla-data
18
-
19
- Shared tools for loading, transforming, and visualising the GLA datasets used in City Data analysis.
20
-
21
- ## Installation
22
-
23
- Add `gla-data` as a PyPI dependency in your `pixi.toml`:
24
-
25
- ```toml
26
- [pypi-dependencies]
27
- gla-data = ">=0.1"
28
- ```
29
-
30
- Then run `pixi install`. Pixi pulls geospatial dependencies (geopandas, pyproj, etc.) from conda-forge, which provides reliable pre-built binaries across all platforms and Python versions.
31
-
32
- ## Development
33
-
34
- ```bash
35
- git clone <repo-url>
36
- cd gla-data
37
- pixi install
38
-
39
- pixi run test # run tests
40
- pixi run lint # check code style
41
- pixi run format # auto-format
42
- pixi run typecheck # type checking
43
- ```
gla_data-0.1.1/README.md DELETED
@@ -1,27 +0,0 @@
1
- # gla-data
2
-
3
- Shared tools for loading, transforming, and visualising the GLA datasets used in City Data analysis.
4
-
5
- ## Installation
6
-
7
- Add `gla-data` as a PyPI dependency in your `pixi.toml`:
8
-
9
- ```toml
10
- [pypi-dependencies]
11
- gla-data = ">=0.1"
12
- ```
13
-
14
- Then run `pixi install`. Pixi pulls geospatial dependencies (geopandas, pyproj, etc.) from conda-forge, which provides reliable pre-built binaries across all platforms and Python versions.
15
-
16
- ## Development
17
-
18
- ```bash
19
- git clone <repo-url>
20
- cd gla-data
21
- pixi install
22
-
23
- pixi run test # run tests
24
- pixi run lint # check code style
25
- pixi run format # auto-format
26
- pixi run typecheck # type checking
27
- ```
@@ -1,6 +0,0 @@
1
- # Replace this file with real tests as you add functions to the package.
2
- import gla_data
3
-
4
-
5
- def test_package_importable():
6
- assert gla_data.__version__ is not None
File without changes
File without changes
File without changes
File without changes
@@ -8,9 +8,9 @@ from gla_data.transforms import aggregate, crosswalk
8
8
  __version__ = version("gla-data")
9
9
  __all__ = [
10
10
  "load_boundaries",
11
- "crosswalk",
12
- "aggregate",
13
11
  "load_geography_lookup",
14
12
  "load_census_dwellings",
13
+ "crosswalk",
14
+ "aggregate",
15
15
  "catalogue",
16
16
  ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes