Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 1

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
issues: write
pull-requests: write
steps:
- uses: actions/first-interaction@v1
- uses: actions/first-interaction@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pr-message: 'Hello @${{ github.actor }}, thank you for submitting a PR! We will respond as soon as possible.'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -27,8 +27,8 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- name: Build package
run: uv build
- name: Publish to PyPI
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- run: uvx ruff check .
- run: uvx ruff format --check .

Expand All @@ -17,8 +17,8 @@ jobs:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
14 changes: 13 additions & 1 deletion pypums/surveys.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Surveys module."""

import warnings
from dataclasses import dataclass
from pathlib import Path

Expand All @@ -18,14 +19,25 @@

@dataclass
class ACS:
"""American Community Survey base class."""
"""American Community Survey base class.

.. deprecated:: 0.2
Use :func:`pypums.get_pums` for PUMS microdata or
:func:`pypums.get_acs` for ACS summary tables instead.
"""

year: int = 2023
state: str = "California"
survey: str = "1-Year"
sample_unit: str = "person"

def __post_init__(self):
warnings.warn(
"ACS() is deprecated. Use get_pums() for PUMS microdata "
"or get_acs() for ACS summary tables.",
DeprecationWarning,
stacklevel=3,
)
self._year = _clean_year(self.year)
self._survey = _clean_survey(self.survey, self._year)
self._sample_unit = self.sample_unit[0].lower()
Expand Down
10 changes: 10 additions & 0 deletions tests/test_pypums.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_clean_year_range():
_clean_year(1999)


@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_acs_class_urls():
assert (
ACS()._survey_url
Expand All @@ -87,6 +88,7 @@ def test_acs_class_urls():
)


@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_acs_class_2020():
"""ACS for 2020 should always use 5-Year survey."""
acs_2020 = ACS(2020, "Ohio", "1-Year")
Expand All @@ -97,6 +99,7 @@ def test_acs_class_2020():
)


@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_acs_class_attributes():
assert ACS()._sample_unit == ACS().sample_unit[0].lower()
assert ACS(sample_unit="household")._sample_unit == "h"
Expand All @@ -105,10 +108,12 @@ def test_acs_class_attributes():
assert ACS(2020, survey="1-Year")._survey == "5-Year/"


@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_acs_class_as_df():
assert isinstance(ACS(state="alaska").as_dataframe(), DataFrame)


@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_instantiated_acs():
instantiated_ACS = ACS()
instantiated_ACS.download()
Expand All @@ -122,3 +127,8 @@ def test_instantiated_acs():
f"raw/acs_{str(instantiated_ACS._year)[-2:]}/"
)
assert isinstance(instantiated_df, DataFrame)


def test_acs_class_emits_deprecation_warning():
with pytest.warns(DeprecationWarning, match="ACS\\(\\) is deprecated"):
ACS()
Loading