Skip to content

Commit

Permalink
Solution.__add__: fix static reference to class; linting
Browse files Browse the repository at this point in the history
  • Loading branch information
rkingsbury committed Jan 13, 2024
1 parent e0b1a9c commit 882149f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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: 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 882149f

Please sign in to comment.