diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..c4f3416 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,34 @@ +name: Coverage + +# This workflow generates a coverage report (how much of the codebase is covered by the +# unit tests) and uploads the information to Coveralls.io for reporting and analysis. + +on: + # push: + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install UrbanSim Templates + run: | + pip install . + pip install -r requirements-extras.txt + pip install -r requirements-dev.txt + - name: Run tests + run: | + cd tests + coverage run --source urbansim_templates --module pytest --verbose + coverage report --show-missing + - name: Upload to Coveralls + run: | + coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/cross-compatibility.yml b/.github/workflows/cross-compatibility.yml new file mode 100644 index 0000000..3a15348 --- /dev/null +++ b/.github/workflows/cross-compatibility.yml @@ -0,0 +1,32 @@ +name: Cross-compatibility + +# This workflow runs the UrbanSim Templates unit tests across a comprehensive range of +# Python versions and operating systems. + +on: + # push: + pull_request: + workflow_dispatch: + +jobs: + build-pip: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: [3.6, 3.7, 3.8] # no pip pytables for py39-mac or py39-win + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install UrbanSim Templates + run: | + pip install . + pip install -r requirements-extras.txt + pip install -r requirements-dev.txt + - name: Run tests + run: | + cd tests + pytest -s diff --git a/.github/workflows/installation.yml b/.github/workflows/installation.yml new file mode 100644 index 0000000..a9ecdff --- /dev/null +++ b/.github/workflows/installation.yml @@ -0,0 +1,49 @@ +name: Installation + +# This workflow installs UrbanSim Templates from Pip and Conda across a range of Python +# versions and operating systems. You can run this manually after a new release is posted +# to confirm that it installs smoothly. This workflow also runs periodically in the +# background to catch dependency updates that break UrbanSim Templates. + +on: + # push: + # pull_request: + workflow_dispatch: + schedule: + - cron: '0 3 * * 1' # every Monday at 3am UTC (Sunday evening Calif time) + +jobs: + build-pip: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: [3.6, 3.7, 3.8] # no pip pytables for py39-mac or py39-win + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install UrbanSim Templates + run: | + pip install urbansim_templates + + build-conda: + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -l {0} # needed for conda persistence + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: [3.6, 3.7, 3.8, 3.9] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: conda-incubator/setup-miniconda@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install UrbanSim Templates + run: | + conda install urbansim_templates --channel conda-forge diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000..63207f4 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,29 @@ +name: Unit tests + +# This workflow runs the UrbanSim Templates tests in a single generic environment (recent +# but stable Python version on recent but stable Ubuntu). The cross-compatibility.yml +# workflow runs the same tests across multiple platforms. + +on: + push: + # pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install UrbanSim Templates + run: | + pip install . + pip install -r requirements-extras.txt + pip install -r requirements-dev.txt + - name: Run tests + run: | + cd tests + pytest -s diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 99709b9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: python - -python: - - '2.7' - - '3.5' - - '3.6' - -matrix: - include: - - python: '3.7' # temp solution until python 3.7 is more cleanly supported - dist: xenial - sudo: true - allow_failures: - - python: '3.7' # dependencies are blocking installation - fast_finish: true - -install: - - pip install git+git://github.com/udst/choicemodels.git - - pip install . - - pip install -r requirements-extras.txt - - pip install -r requirements-dev.txt - - pip list - - pip show urbansim_templates - -script: - - cd tests - - coverage run --source urbansim_templates --module pytest --verbose - -after_success: - - coverage report --show-missing - - coveralls \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f0b62a..2085262 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # UrbanSim Templates change log +### 0.1.4 (2020-02-12) + +- adds a `residuals` attribute to fitted `OLSRegressionStep` models, for diagnostics + ### 0.1.3 (2019-07-15) - fixes a bug with `out_transform` parameter for OLS simulation diff --git a/README.md b/README.md index 9ecadd2..6f55039 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -[![Build Status](https://travis-ci.org/UDST/urbansim_templates.svg?branch=master)](https://travis-ci.org/UDST/urbansim_templates) [![Coverage Status](https://coveralls.io/repos/github/UDST/urbansim_templates/badge.svg?branch=master)](https://coveralls.io/github/UDST/urbansim_templates?branch=master) -[![Docs Status](https://readthedocs.org/projects/urbansim_templates/badge/?version=latest)](https://docs.udst.org/projects/urbansim-templates/en/latest) + # UrbanSim Templates @@ -9,6 +8,7 @@ UrbanSim Templates is a Python library that provides building blocks for Orca-ba The library contains templates for common types of model steps, plus a tool called ModelManager that runs as an extension to the [Orca](https://udst.github.io/orca) task orchestrator. ModelManager can register template-based model steps with the orchestrator, save them to disk, and automatically reload them for future sessions. The package was developed to make it easier to set up new simulation models — model step templates reduce the need for custom code and make settings more portable between models. ### Installation + UrbanSim Templates can be installed using the Pip or Conda package managers: ``` @@ -21,8 +21,8 @@ conda install urbansim_templates --channel conda-forge ### Documentation -See the online documentation for much more: [http://docs.udst.org/projects/urbansim-templates](https://docs.udst.org/projects/urbansim-templates/en/latest) +See the online documentation for much more: https://udst.github.io/urbansim_templates Some additional documentation is available within the repo in `CHANGELOG.md`, `CONTRIBUTING.md`, `/docs/README.md`, and `/tests/README.md`. -There's discussion of current and planned features in the [Pull requests](https://github.com/udst/urbansim_templates/pulls?utf8=✓&q=is%3Apr) and [Issues](https://github.com/udst/urbansim_templates/issues?utf8=✓&q=is%3Aissue), both open and closed. +There's discussion of current and planned features in the [pull requests](https://github.com/udst/urbansim_templates/pulls?utf8=✓&q=is%3Apr) and [issues](https://github.com/udst/urbansim_templates/issues?utf8=✓&q=is%3Aissue), both open and closed. diff --git a/requirements.txt b/requirements.txt index 286508c..eeebc66 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # minimal requirements for model management and core templates -choicemodels >= 0.2.dev4 +choicemodels >= 0.2 numpy >= 1.14 orca >= 1.4 pandas >= 0.22 diff --git a/setup.py b/setup.py index 943f905..b7a9d10 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='urbansim_templates', - version='0.1.3', + version='0.1.4', description='UrbanSim extension for managing model steps', author='UrbanSim Inc.', author_email='info@urbansim.com', @@ -17,6 +17,8 @@ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'License :: OSI Approved :: BSD License' ], packages=find_packages(exclude=['*.tests']), diff --git a/tests/README.md b/tests/README.md index 201f69a..30f042a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1 +1 @@ -Run tests from this folder using `pytest *.py -s`. \ No newline at end of file +Run tests from this folder using `pytest -s`. \ No newline at end of file diff --git a/tests/test_large_multinomial_logit.py b/tests/test_large_multinomial_logit.py index 2961ce9..70d4728 100644 --- a/tests/test_large_multinomial_logit.py +++ b/tests/test_large_multinomial_logit.py @@ -143,7 +143,9 @@ def test_simulation_unconstrained(m): obs = orca.get_table('obs').to_frame() assert sum(obs.choice == -1) == 0 - assert obs.loc[:24, 'choice'].equals(m.choices) + pd.testing.assert_series_equal(obs.loc[:24, 'choice'], m.choices, + check_dtype=False, check_names=False) + # assert obs.loc[:24, 'choice'].equals(m.choices) def test_simulation_single_occupancy(m): diff --git a/urbansim_templates/__init__.py b/urbansim_templates/__init__.py index adb9e1a..ec9c20c 100644 --- a/urbansim_templates/__init__.py +++ b/urbansim_templates/__init__.py @@ -1 +1 @@ -version = __version__ = '0.1.3' +version = __version__ = '0.1.4' diff --git a/urbansim_templates/models/regression.py b/urbansim_templates/models/regression.py index 8367f23..df4a89f 100644 --- a/urbansim_templates/models/regression.py +++ b/urbansim_templates/models/regression.py @@ -101,6 +101,7 @@ def __init__(self, tables=None, model_expression=None, filters=None, out_tables= # Placeholders for model fit data, filled in by fit() or from_dict() self.summary_table = None self.fitted_parameters = None + self.residuals = None self.model = None @@ -185,6 +186,7 @@ def fit(self): # code later on to not rely on RegressionModel any more. self.fitted_parameters = results.params.tolist() + self.residuals = results.resid def run(self):