Skip to content

Commit

Permalink
transit tests working
Browse files Browse the repository at this point in the history
+ linting
  • Loading branch information
e-lo committed Aug 2, 2023
1 parent 80cad3c commit 3ffc565
Show file tree
Hide file tree
Showing 18 changed files with 267 additions and 158 deletions.
18 changes: 9 additions & 9 deletions .github/.github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
## What existing problem does the pull request solve and why should we include it?
# Pull Request

## What existing problem does the pull request solve and why should we include it?

## What is the testing plan?

*Demonstrate the code is solid by discussing how results are verified and covered by tests*

- [ ] Code for this PR is covered in tests
- [ ] Code passes all existing tests
- [ ] Code for this PR is covered in tests
- [ ] Code passes all existing tests

## Code formatting

*Code should be PEP8 compliant before merging by running a package like [`black`](https://pypi.org/project/black/)*

- [ ] Code linted
- [ ] Code linted

## Applicable Issues

*Please do not create a Pull Request without creating an issue first.*

*Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes.*


#### Issues List

- closes...
- closes...
- closes...
- closes...
7 changes: 5 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,33 @@ assignees: ''
---

## Describe the bug

A clear and concise description of what the bug is or the error code you got. e.g.

```python
KeyError: 'Passing list-likes to .loc or [] with any missing labels is no longer supported, see https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike'
```

## To Reproduce

Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

### Failing tests

- [ ] No applicable test failed, need to create.
- [ ]

### Triggering line of code


### Thoughts on resolution

### Full stack trace


### Environment

Operating system:
Expand Down
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ assignees: ''
---

### User Story

*As a ...insert type of user... I'd like to ...insert desired feature or behavior...*

### Priority
Expand All @@ -17,16 +18,20 @@ assignees: ''
### Resolution Ideas

### Project

*Is there a funder or project associated with this feature?*

### Who should be involved?

Implementer:
Commenters:
Users:
Reviewers:

### Risk

*Will this potentially break anything?*

#### Tests

*What are relevant tests or what tests need to be created in order to determine that this issue is complete?*
3 changes: 0 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# Contributing to Network Wrangler


## Roles


## How to Contribute


### Setup

1. Make sure you have a [GitHub](https://github.com/) account.
Expand Down
37 changes: 24 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
Network Wrangler is a Python library for managing travel model network scenarios.

## System Requirements

Network Wrangler should be operating system agonistic and has been tested on Ubuntu and Mac OS.

In order to assist in installation, its helpful to have either [miniconda](https://docs.conda.io/en/latest/miniconda.html), [anaconda](https://docs.conda.io/projects/continuumio-conda/en/latest/user-guide/install/index.html#regular-installation) or [Docker CE](https://docs.docker.com/install/) installed. If you don't have any of these already, we reommend starting with Miniconda for Python 3.7 as it has the smallest footprint. `conda` is the environment manager that is contained within both the Anaconda and mini-conda applications. All commands described below should be entered into the `Ananconda Prompt` command window.

Network Wrangler does require Python 3.7+. If you have a different version of Python installed, `conda` will take care of installing it for you in the installation instructions below.

## Installation

Network Wrangler uses Python 3.6 and above. Requirements are stored in `requirements.txt` but are automatically installed when using `pip`.

If you are managing multiple python versions, we suggest using [`virtualenv`](https://virtualenv.pypa.io/en/latest/) or [`conda`](https://conda.io/en/latest/) virtual environments. `conda` is the environment manager that is contained within both the Anaconda and mini-conda applications. Do not add Anaconda to the system path during installation. This may cause problems with other programs that require python 2.7 to be placed in the system path.
Expand All @@ -27,6 +29,7 @@ pytest
Network wrangler can be installed in several ways depending on the user's needs. Installing from github is the simplest method and is appropriate when the user does not anticipate needing to update network wrangler. An update will require rebuilding the network wrangler environment. Installing from clone is slightly more involved and requires the user to have a git manager on their machine, but permits the user to install network wrangler with the `-e`, edit, option so that their network wrangler installation can be updated through pulling new commits from the network wrangler repo without a full reinstallation.

### From GitHub

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install Network Wrangler from the source on GitHub.

```bash
Expand All @@ -39,6 +42,7 @@ pip install git+https://github.com/wsp-sag/network_wrangler.git@master#egg=netwo
Note: if you wanted to install from a specific tag/version number or branch, replace `@master` with `@<branchname>` or `@tag`

### From Clone

If you are going to be working on Network Wrangler locally, you might want to clone it to your local machine and install it from the clone. The -e will install it in [editable mode](https://pip.pypa.io/en/stable/reference/pip_install/?highlight=editable#editable-installs).

This is also useful if you want to continue to update your Network Wrangler as it is developed on GitHub.
Expand Down Expand Up @@ -131,16 +135,17 @@ Note: if you are not part of the project team and want to contribute code back t
4. Command to exit container: `exit`

Containers:
- `wrangler-jupyter` started by running `docker-compose run wrangler-jupyter --build` is appropriate for running and testing wrangler.
- Default action is to start [jupyter notebook](https://jupyter.org/) which can be found at http://127.0.0.1:8888
- Safe: It creates an empty folder to store jupyter notebooks within the container but wont overwrite the source files on your actual machine.
- Starting Bash: You can also start the container with a command line using `docker-compose run wrangler-jupyter /bin/bash --build`.
- Doesn't install development dependencies (although they can be installed from within the container)
- `wrangler-ci` is a small image without extras meant for running tests and deploying to continuous integration server.
- default command is to run [pytest](https://docs.pytest.org/en/latest/).
- contains development dependencies so that it can run tests and build docs.
- `wrangler-dev` is the most powerful but dangerous container `docker-compose run wrangler-dev /bin/bash --build`
- Warning: It will synchronize code edited from the container to your wrangler clone. This is great for developing within an IDE, but please take this into account.

- `wrangler-jupyter` started by running `docker-compose run wrangler-jupyter --build` is appropriate for running and testing wrangler.
- Default action is to start [jupyter notebook](https://jupyter.org/) which can be found at <http://127.0.0.1:8888>
- Safe: It creates an empty folder to store jupyter notebooks within the container but wont overwrite the source files on your actual machine.
- Starting Bash: You can also start the container with a command line using `docker-compose run wrangler-jupyter /bin/bash --build`.
- Doesn't install development dependencies (although they can be installed from within the container)
- `wrangler-ci` is a small image without extras meant for running tests and deploying to continuous integration server.
- default command is to run [pytest](https://docs.pytest.org/en/latest/).
- contains development dependencies so that it can run tests and build docs.
- `wrangler-dev` is the most powerful but dangerous container `docker-compose run wrangler-dev /bin/bash --build`
- Warning: It will synchronize code edited from the container to your wrangler clone. This is great for developing within an IDE, but please take this into account.

### Common Installation Issues

Expand All @@ -153,12 +158,14 @@ Try installing rtree on its own from the Anaconda cloud
```bash
conda install rtree
```

**Issue: Shapely, a pre-requisite, doesn't install propertly because it is missing GEOS module**
Try installing shapely on its own from the Anaconda cloud

```bash
conda install shapely
```

**Issue: Conda is unable to install a library or to update to a specific library version**
Try installing libraries from conda-forge

Expand All @@ -177,11 +184,12 @@ To start the notebook, open a command line in the network_wrangler top-level dir

`jupyter notebook`


## Documentation

Documentation can be built from the `/docs` folder using the command: `make html`

## Usage

```python
import network_wrangler

Expand Down Expand Up @@ -210,15 +218,18 @@ my_scenario.apply_all_projects()
my_scenario.write("my_project/build", "baseline")

```
## Attribution

## Attribution

This project is built upon the ideas and concepts implemented in the [network wrangler project](https://github.com/sfcta/networkwrangler) by the [San Francisco County Transportation Authority](http://github.com/sfcta) and expanded upon by the [Metropolitan Transportation Commission](https://github.com/BayAreaMetro/NetworkWrangler).

While Network Wrangler as written here is based on these concepts, the code is distinct and builds upon other packages such as `geopandas` and `partridge` which hadn't been implemented when networkwrangler 1.0 was developed.

## Contributing

Pull requests are welcome. Please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.


## License

[Apache-2.0](https://choosealicense.com/licenses/apache-2.0/)
30 changes: 15 additions & 15 deletions examples/stpaul/project_cards/transit_route_change.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
project: 365 Bus Reroute
transit_property_change:
facility:
route_id: [53-111]
time: ['09:00', '15:00']
properties:
routing:
existing:
- 62145 #N Robert St
39430 #Jackson St
set:
- 62145 #N Robert St
-62146 #Robert/6th
-41625 #Robert/7th
39426 #7th/Jackson with a stop (open to other ways of expressing this)
-39425 #6th Jackson
39430 #5th Jackson
service:
route_id: [53-111]
time: ['09:00', '15:00']
property_changes:
routing:
existing:
- 62145 #N Robert St
- 39430 #Jackson St
set:
- 62145 #N Robert St
- -62146 #Robert/6th
- -41625 #Robert/7th
- 39426 #7th/Jackson with a stop (open to other ways of expressing this)
- -39425 #6th Jackson
- 39430 #5th Jackson
2 changes: 1 addition & 1 deletion network_wrangler/roadwaynetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import copy

from collections import defaultdict
from typing import Collection, List, Union, Mapping, Any
from typing import Collection, List, Union

import geopandas as gpd
import networkx as nx
Expand Down
2 changes: 1 addition & 1 deletion network_wrangler/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ def create_base_scenario(
"No transit directory specified, base scenario will have empty transit network."
)

transit_net.set_roadnet(road_net, validate_consistency=validate)
transit_net.road_net = road_net
base_scenario = {"road_net": road_net, "transit_net": transit_net}

return base_scenario
Loading

0 comments on commit 3ffc565

Please sign in to comment.