Skip to content

Commit

Permalink
Merge pull request #92 from KingsburyLab/bugfix
Browse files Browse the repository at this point in the history
Solution.__add__: fix minor bug affecting inherited classes
  • Loading branch information
rkingsbury authored Jan 13, 2024
2 parents f7ca9b1 + 882149f commit 95ede9b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: '^docs/conf.py'
exclude: "^docs/conf.py"

default_stages: [commit]

Expand All @@ -12,7 +12,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.13
hooks:
- id: ruff
args: [--fix, --ignore, "D,E501", "--show-fixes"]
Expand Down Expand Up @@ -41,7 +41,6 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
rev: v4.0.0-alpha.8
hooks:
- id: prettier

- id: prettier
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- `Solution.__add_`: Bugfix in the addition operation `+` that could cause problems with
child classes (i.e., classes that inherit from `Solution`) to work improperly

### Changed

- Removed deprecated `pkg_resources` import in favor of `importlib.resources`
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ version_scheme = "no-guess-dev"
[tool.black]
line-length = 120

[tool.ruff.lint]
target-version = "py38"
[tool.ruff]
target-version = "py39"
line-length = 120
exclude = [".dat"]
src = ["src"]

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
Expand Down
6 changes: 3 additions & 3 deletions src/pyEQL/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import math
import os
import warnings
from importlib.resources import files
from functools import lru_cache
from importlib.resources import files
from pathlib import Path
from typing import Any, Literal

Expand Down Expand Up @@ -153,7 +153,7 @@ def __init__(
if database is None:
# load the default database, which is a JSONStore
db_store = IonDB
elif isinstance(database, (str, Path)):
elif isinstance(database, str | Path):
db_store = JSONStore(str(database), key="formula")
logger.info(f"Created maggma JSONStore from .json file {database}")
else:
Expand Down Expand Up @@ -2513,7 +2513,7 @@ def __add__(self, other: Solution):
mix_pE = -math.log10((mol_e_self + mol_e_other) / mix_vol.to("L").magnitude)

# create a new solution
return Solution(
return self.__class__(
mix_species.data, # pass a regular dict instead of the FormulaDict
volume=str(mix_vol),
pressure=str(mix_pressure),
Expand Down

0 comments on commit 95ede9b

Please sign in to comment.