Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #471

Closed
wants to merge 2 commits into from
Closed
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 .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ max-line-length = 120
ignore = E203, E266, E501, W503, F403, F401, C901, W605
max-complexity = 20
select = B,C,E,F,W,T4,B9
exclude = .idea,.git,__pycache__,sphinx,.venv,venv,docs/*,benchmarks/*
exclude = .idea,.git,__pycache__,sphinx,.venv*,.venv,venv,docs/*,benchmarks/*
3 changes: 3 additions & 0 deletions .github/qgis_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ def replace_in_file(file_path, text_orig, suffix):
replace_in_file("../requirements.txt", "pandas", "<1.2")
replace_in_file("../pyproject.toml", "pandas", "<1.2")

replace_in_file("../requirements.txt", "scipy", "<1.11")
replace_in_file("../pyproject.toml", "scipy", "<1.11")

replace_in_file("../__version__.py", "{minor_version}", ".dev0")
4 changes: 2 additions & 2 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Build manylinux Python wheels
uses: RalfG/python-wheels-manylinux-build@v0.7.1
with:
python-versions: 'cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311'
python-versions: 'cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312'
pip-wheel-args: '--no-deps'

- name: Moves wheels
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Build manylinux Python wheels
uses: RalfG/python-wheels-manylinux-build@v0.7.1
with:
python-versions: 'cp38-cp38 cp39-cp39 cp310-cp310'
python-versions: 'cp39-cp39'
pip-wheel-args: '--no-deps'

- name: Moves wheels
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/build_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ jobs:
continue-on-error: true
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11']

python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
- name: Set Python environment
Expand Down Expand Up @@ -51,8 +50,8 @@ jobs:
twine upload dist/*.whl

- name: Publish tar files
if: ${{ (github.event_name == 'release') && (env.HAS_SECRETS == 'true') && (matrix.python-version == '3.9') }}
if: ${{ (github.event_name == 'release') && (env.HAS_SECRETS == 'true') && (matrix.python-version == '3.11') }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*.gz
run: twine upload dist/*.gz
2 changes: 1 addition & 1 deletion .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
continue-on-error: true
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11']
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
architecture: ['x64']
steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ jobs:
pip install -r docs/requirements-docs.txt
python -m pip install sphinx-gallery --user
sudo apt update
sudo apt install -y --fix-missing libsqlite3-mod-spatialite libspatialite-dev
sudo apt install -y --fix-missing libsqlite3-mod-spatialite libspatialite-dev pandoc
sudo ln -s /usr/lib/x86_64-linux-gnu/mod_spatialite.so /usr/lib/x86_64-linux-gnu/mod_spatialite

- name: Compile library
run: |
python setup.py build_ext --inplace
pip install .

- name: Check history of versions
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
runs-on: ${{ matrix.os}}
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11']
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
os: [windows-latest, ubuntu-latest]

max-parallel: 20
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
[![QAequilibraE artifacts](https://github.com/AequilibraE/aequilibrae/actions/workflows/build_artifacts_qgis.yml/badge.svg)](https://github.com/AequilibraE/aequilibrae/actions/workflows/build_artifacts_qgis.yml)


AequilibraE is the first comprehensive Python package for transportation modeling, and it aims to provide all the
AequilibraE is the first comprehensive Python package for transportation modeling. It aims to provide all the
resources not available from other open-source packages in the Python (NumPy, really) ecosystem.

## Comprehensive documentation

[AequilibraE documentation built with Sphinx ](http://www.aequilibrae.com>)
[AequilibraE documentation built with Sphinx ](http://www.aequilibrae.com)

## What is available

Expand Down
2 changes: 1 addition & 1 deletion __version__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version = 0.9
minor_version = "3"
minor_version = "5"
release_name = "Queluz"

release_version = f"{version}.{minor_version}"
10 changes: 5 additions & 5 deletions aequilibrae/distribution/ipf_core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ cdef _fratar(double[:, :] flows,
double[:] attr_factor,
int max_iter,
double toler,
int cpus):
int cpus) noexcept:

cdef double err = 1.0
cdef int iter = 0
Expand Down Expand Up @@ -99,7 +99,7 @@ cdef _fratar(double[:, :] flows,
cpdef void _total_attra(double[:, :] flows,
double[:] prod_tgt,
double[:] attr_tot,
int cpus):
int cpus) noexcept:

cdef long long i, j, jk
cdef double *local_buf
Expand Down Expand Up @@ -133,7 +133,7 @@ cpdef void _total_attra(double[:, :] flows,
cpdef void _total_prods(double[:, :] flows,
double[:] prod_tgt,
double[:] prod_tot,
int cpus)nogil:
int cpus) noexcept nogil:

cdef long long i, j
cdef long long I = flows.shape[0]
Expand All @@ -154,7 +154,7 @@ cpdef void _total_prods(double[:, :] flows,
cpdef double _factors(double[:] target,
double[:] total,
double[:] factor,
int cpus):
int cpus) noexcept:

cdef long long i, I = target.shape[0]
cdef double err = 1.0
Expand All @@ -174,7 +174,7 @@ cpdef double _factors(double[:] target,
@cython.embedsignature(True)
@cython.boundscheck(False)
cpdef double _calc_err(double[:] p_factor,
double[:] a_factor):
double[:] a_factor) noexcept:

cdef long long i, I = p_factor.shape[0]
cdef long long j, J = a_factor.shape[0]
Expand Down
4 changes: 4 additions & 0 deletions aequilibrae/matrix/aequilibrae_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def create_empty(
# raise ValueError('Data types need to be Python or Numpy data types')

for field in self.fields:
if not type(field) is str:
raise TypeError(field + " is not a string. You cannot use it as a field name")
if not field.isidentifier():
raise Exception(field + " is a not a valid identifier name. You cannot use it as a field name")
if field in object.__dict__:
raise Exception(field + " is a reserved name. You cannot use it as a field name")

Expand Down
25 changes: 16 additions & 9 deletions aequilibrae/matrix/aequilibrae_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import tempfile
import uuid
import warnings
from functools import reduce
from typing import List

Expand Down Expand Up @@ -399,7 +400,9 @@ def create_from_trip_list(self, path_to_file: str, from_column: str, to_column:

new_mat = AequilibraeMatrix()
nb_of_zones = len(zones_list)
new_mat.create_empty(file_name=path_to_file[:-4] + ".aem", zones=nb_of_zones, matrix_names=list_cores)
new_mat.create_empty(
file_name=path_to_file[:-4] + ".aem", zones=nb_of_zones, matrix_names=list_cores, memory_only=False
)

for idx, core in enumerate(list_cores):
m = (
Expand Down Expand Up @@ -677,6 +680,9 @@ def __flush(self, obj_to_flush: np.memmap):

def __getattr__(self, mat_name: str):
if mat_name in object.__dict__:
if mat_name == "matrix" and self.__omx:
warnings.warn("You can't access OMX matrix cores like that")
return
return self.__dict__[mat_name]

if mat_name in self.names:
Expand Down Expand Up @@ -748,18 +754,14 @@ def export(self, output_name: str, cores: List[str] = None):
>>> mat2.cores
2
"""

if self.__omx:
raise NotImplementedError("This operation does not make sense for OMX matrices")

fname, file_extension = os.path.splitext(output_name.upper())

if file_extension == ".OMX":
if not has_omx:
raise ValueError("Open Matrix is not installed. Cannot continue")

if file_extension not in [".AEM", ".CSV", ".OMX"]:
raise ValueError("File extension {} not implemented yet".format(file_extension))
raise NotImplementedError(f"File extension {file_extension} not implemented yet")

if cores is None:
cores = self.names
Expand All @@ -770,16 +772,21 @@ def export(self, output_name: str, cores: List[str] = None):
elif file_extension == ".OMX":
omx_export = omx.open_file(output_name, "w")
for c in cores:
omx_export[c] = self.matrix[c]

if self.__omx:
omx_export[c] = np.array(self.omx_file[c])
else:
omx_export[c] = self.matrix[c]
for i, idx in enumerate(self.index_names):
omx_export.create_mapping(idx, self.indices[:, i])
omx_export.close()

elif file_extension == ".CSV":

def f(name):
coo = coo_matrix(self.matrix[name])
if self.__omx:
coo = np.array(self.omx_file[name])
else:
coo = coo_matrix(self.matrix[name])
data = {"row": self.index[coo.row], "column": self.index[coo.col], name: coo.data}
return pd.DataFrame(data).set_index(["row", "column"])

Expand Down
34 changes: 33 additions & 1 deletion aequilibrae/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,30 @@ network:
description: name
osm_source: name
type: text
- cycleway:
description: cycleway, both way
osm_source: cycleway
type: text
- cycleway_right:
description: cycleway, right
osm_source: cycleway:right
type: text
- cycleway_left:
description: cycleway, left
osm_source: cycleway:left
type: text
- busway:
description: busway
osm_source: busway
type: text
- busway_right:
description: busway, right
osm_source: busway:right
type: text
- busway_left:
description: busway, left
osm_source: busway:left
type: text
two-way:
- lanes:
description: lanes
Expand Down Expand Up @@ -128,6 +152,14 @@ network:
modes:
bicycle:
link_types:
- primary
- primary_link
- secondary
- secondary_link
- tertiary
- tertiary_link
- living_street
- residential
- cycleway
- corridor
- pedestrian
Expand Down Expand Up @@ -313,7 +345,7 @@ network:
required: false
lanes:
description: Number of lanes in the direction of travel
type: inetger
type: integer
required: false
bike_facility:
description: Type of bicycle accommodation
Expand Down
Loading