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
3 changes: 2 additions & 1 deletion .github/workflows/gh-page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ jobs:
- name: Install dependencies (uv)
run: |
set -e
uv sync
# Install runtime + docs group (mkdocs, plugins, nb toolchain)
uv sync --group docs --dev
if [ -n "${{ secrets.GH_TOKEN }}" ]; then
uv pip install git+https://${{ secrets.GH_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
else
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:

- name: Install deps
run: |
uv sync --dev
# Need docs stack to execute notebooks via mkdocs-jupyter/nbmake
uv sync --group docs --dev

- name: Run nbmake
env:
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## [0.9.0](https://github.com/SongshGeoLab/ABSESpy/compare/v0.8.5...v0.9.0) (2025-10-29)


### Features

* **actor, patch:** :sparkles: Add move_to method in Actor and count_agents method in PatchModule ([11e63b2](https://github.com/SongshGeoLab/ABSESpy/commit/11e63b2a95fc72232a5ab96d840bf9ad66743b30))
* **actor:** :sparkles: Add evaluate method to Actor for scoring candidates with rollback functionality ([bad83ac](https://github.com/SongshGeoLab/ABSESpy/commit/bad83ac22e769cafa092584414a83a603dda3c9b))
* **agents, space:** :sparkles: Enhance agent and cell functionality with new properties and methods ([cacf3d0](https://github.com/SongshGeoLab/ABSESpy/commit/cacf3d04957ddf54d949277c86e3bc80af415dad))
* **core:** Protocol-based architecture refactoring ([12534d8](https://github.com/SongshGeoLab/ABSESpy/commit/12534d8c93517336c57f0d86a57aaab366fb6af7))
* **examples:** :sparkles: Remove outdated agent and analysis files, add configuration and quick start notebook ([d1fed62](https://github.com/SongshGeoLab/ABSESpy/commit/d1fed623172cdeb8cddcfe3a560f0be94c340c68))
* **examples:** :white_check_mark: Introduce configuration file and enhance model dynamics ([1fa3e0c](https://github.com/SongshGeoLab/ABSESpy/commit/1fa3e0cc879c4c7e01f19b4040160e410006105e))
* **patch:** :sparkles: Implement __getitem__ method for PatchModule with numpy-style indexing ([1c66edb](https://github.com/SongshGeoLab/ABSESpy/commit/1c66edb3e833d145295e0ae139e54d89340e2c18))


### Bug Fixes

* **sequences:** Fix attribute access in better() method ([2f1089f](https://github.com/SongshGeoLab/ABSESpy/commit/2f1089f40267cb2b7b5967f2d7519fec6fff3a15))


### Documentation

* **docs:** :memo: Enhance UML documentation and integrate Mermaid diagrams ([62a9cdd](https://github.com/SongshGeoLab/ABSESpy/commit/62a9cdd62715c6c72439def968a1a8a896b16aae))
* **tutorials, docs:** :memo: Expand tutorial content and enhance documentation structure ([316c972](https://github.com/SongshGeoLab/ABSESpy/commit/316c97203b21c94c0a797bb9199d2a8ca4818c60))

## [0.7.5](https://github.com/SongshGeoLab/ABSESpy/compare/v0.7.4...v0.7.5) (2025-02-16)


Expand Down
19 changes: 14 additions & 5 deletions abses/space/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,12 +573,20 @@ def _select_by_geometry(
Args pass to the function `rasterasterio.mask.mask`.

Returns:
A numpy array of clipped cells.
A boolean numpy 2D array mask where True indicates selected cells.
"""
# TODO 研究一下为什么需要转换为整数,转换bool结果不一样了
return self.xda.astype(np.int32, casting="safe").rio.clip(
# Use float dtype so rioxarray can represent out-of-geometry as NaN.
# Boolean selection must be based on NaN mask, not on underlying cell values
# (otherwise cells with value 0 would be incorrectly excluded).
clipped = self.xda.astype(np.float32).rio.clip(
[geometry], all_touched=False, drop=False, **kwargs
)
# Convert to boolean mask: True where data is finite (inside geometry)
mask_da = np.isfinite(clipped.to_numpy())
# Ensure 2D mask (squeeze potential band dimension)
if mask_da.ndim == 3:
mask_da = np.squeeze(mask_da, axis=0)
return mask_da

def select(
self,
Expand Down Expand Up @@ -620,8 +628,9 @@ def select(
mask_ = self._attr_or_array(where).reshape(self.shape2d)
else:
raise TypeError(f"{type(where)} is not supported for selecting cells.")
mask_ = np.nan_to_num(mask_, nan=0.0).astype(bool)
return ActorsList(self.model, self.array_cells[mask_])
# mask_ is expected to be boolean here
mask_bool = mask_.astype(bool)
return ActorsList(self.model, self.array_cells[mask_bool])

sel = select

Expand Down
47 changes: 33 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ line_length = 79

[project]
name = "abses"
version = "0.7.5"
version = "0.9.0"
description = "ABSESpy makes it easier to build artificial Social-ecological systems with real GeoSpatial datasets and fully incorporate human behaviour."
authors = [{name = "Shuang Song", email = "songshgeo@gmail.com"}]
license = {text = "Apache 2.0 License"}
Expand Down Expand Up @@ -41,23 +41,38 @@ dependencies = [
"numpy<2",
"urllib3",
"icons",
"solara",
"mkdocs>=1.6.1",
# Note: mkdocs-material-insiders requires authentication and MUST NOT be declared here
# to avoid build backend variable expansion errors (e.g. Unknown context field).
# Install locally via environment variable before building docs, e.g.:
# export MKDOCS_INSIDER=your_token
# uv pip install "git+https://${MKDOCS_INSIDER}@github.com/squidfunk/mkdocs-material-insiders.git"
"mkdocs-jupyter>=0.25.1",
"mkdocstrings>=0.30.1",
"mkdocs-static-i18n>=1.3.0",
]

[project.urls]
Homepage = "https://github.com/SongshGeoLab/ABSESpy"
Documentation = "https://absespy.github.io/ABSESpy/"
Repository = "https://github.com/SongshGeoLab/ABSESpy"

[project.optional-dependencies]
# Optional docs-related dependencies. Not required at runtime.
docs = [
"mkdocs>=1.6.1",
"mkdocs-git-revision-date-localized-plugin>=1.2.0",
"mkdocs-minify-plugin>=0.7.1",
"mkdocs-redirects>=1.2.1",
"mkdocs-awesome-pages-plugin>=2.9.2",
"mkdocs-git-authors-plugin>=0.7.2",
"mkdocstrings>=0.30.1",
"mkdocstrings[python]>=0.24.0",
Comment on lines +60 to +61
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix version constraint inconsistency for mkdocstrings[python].

The base mkdocstrings>=0.30.1 requires version 0.30.1 or higher, but mkdocstrings[python]>=0.24.0 only requires 0.24.0. The extras version should match the base requirement to ensure consistency.

Apply this diff to align the version constraints:

- "mkdocstrings[python]>=0.24.0",
+ "mkdocstrings[python]>=0.30.1",

This change should be applied at both locations (line 61 and line 118).

Also applies to: 117-118

🤖 Prompt for AI Agents
In pyproject.toml around lines 60-61 and 117-118, the version constraint for the
extras entry "mkdocstrings[python]>=0.24.0" is inconsistent with the base
"mkdocstrings>=0.30.1"; update both occurrences so the extras match the base
requirement (e.g., change "mkdocstrings[python]>=0.24.0" to
"mkdocstrings[python]>=0.30.1") to ensure consistent versioning across the file.

"mkdocs-bibtex>=2.11.0",
"mkdocs-macros-plugin>=1.0.4",
"mkdocs-jupyter>=0.25.1",
"mkdocs-callouts>=1.9.1",
"mkdocs-glightbox>=0.3.4",
"mkdocs-exclude>=1.0.2",
"mkdocs-simple-hooks>=0.1.5",
"mkdocs-static-i18n>=1.3.0",
"pymdown-extensions>=10.7",
"mike>=2.0.0",
"nbmake>=1.5.5",
"nbconvert>=7.16.6",
]

[project.entry-points."hydra.searchpath"]
abses = "hydra_plugins.abses_searchpath_plugin:ABSESpySearchPathPlugin"

Expand Down Expand Up @@ -89,17 +104,21 @@ dev = [
"tox>=4.11.3",
"lxml>=5.2.1",
"griffe>=1.14.0",
# Docs dependencies
"mkdocs>=1.5.3",
]

# Dedicated group for docs build. Install with: uv sync --group docs
docs = [
"mkdocs>=1.6.1",
"mkdocs-git-revision-date-localized-plugin>=1.2.0",
"mkdocs-minify-plugin>=0.7.1",
"mkdocs-redirects>=1.2.1",
"mkdocs-awesome-pages-plugin>=2.9.2",
"mkdocs-git-authors-plugin>=0.7.2",
"mkdocstrings>=0.30.1",
"mkdocstrings[python]>=0.24.0",
"mkdocs-bibtex>=2.11.0",
"mkdocs-macros-plugin>=1.0.4",
"mkdocs-jupyter>=0.24.5",
"mkdocs-jupyter>=0.25.1",
"mkdocs-callouts>=1.9.1",
"mkdocs-glightbox>=0.3.4",
"mike>=2.0.0",
Expand Down
121 changes: 80 additions & 41 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading