Skip to content

Commit

Permalink
Merge branch 'release/4.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
pauliacomi committed Feb 24, 2022
2 parents 083b2b5 + aaac9a2 commit c6a4f3f
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 32 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Changelog

New features:

* ⚠️ To reduce import bloat pyGAPS is now **modular**. Previously global
functions must be accessed through submodules. For example:
``pygaps.area_BET`` now must be imported from
``pygaps.characterisation.area_BET``.
* 🎆 pyGAPS is now on ``conda-forge``
* Volumetric adsorbed amount is now given in either ``volume_gas`` or
`volume_liquid` basis, corresponding to the volume amount the adsorbate would
occupy in the bulk gas phase, or the volume of an ideal liquid phase of
Expand All @@ -23,7 +28,7 @@ New features:

Changes:

* Minimum python is now 3.7, maximum increased to 3.10.
* ⚠️ Minimum python is now 3.7, maximum increased to 3.10.
* Removed the need to pass DataFrame column names with the ``other_keys``
syntax. PointIsotherms, now save *all* passed DataFrame columns.
* Smart assigning of isotherm metadata caused confusion and was removed.
Expand Down
2 changes: 1 addition & 1 deletion conda_recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "pygaps" %}
{% set version = "4.0.1" %}
{% set version = "4.0.2" %}

package:
name: "{{ name|lower }}"
Expand Down
54 changes: 54 additions & 0 deletions pygaps/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{% set name = "pygaps" %}
{% set version = "4.0.1" %}

package:
name: {{ name|lower }}
version: {{ version }}

build:
skip: true # [py<37]
entry_points:
- pygaps = pygaps.cli:main
script: {{ PYTHON }} -m pip install . -vv
number: 0

source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/pygaps-{{ version }}.tar.gz
sha256: 5bdf02b497a955b19114bff9e42bce39fb133324da10a2d1c3e978b2ad452fc4

requirements:
host:
- pip
- python
run:
- coolprop >=6.0
- gemmi
- importlib-resources # [py<39]
- matplotlib-base
- numpy >=1.16.5
- openpyxl
- pandas
- python
- requests
- scipy >=1.6
- xlrd >=1.1
- xlwt >=1.3

test:
imports:
- pygaps
commands:
- pip check
- pygaps --help
requires:
- pip

about:
home: https://github.com/pauliacomi/pygaps
summary: A framework for processing adsorption data for porous materials.
license: MIT
license_file: LICENSE

extra:
recipe-maintainers:
- pauliacomi
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "src/pygaps/_version.py"
local_scheme = 'dirty-tag'
fallback_version = '4.0.1'
fallback_version = '4.0.2'

# linting: pylint
[tool.pylint.basic]
Expand Down Expand Up @@ -52,7 +52,7 @@ line_length = 120
known_first_party = "pygaps"
default_section = "THIRDPARTY"
forced_separate = "test_pygaps"
skip = [".tox",".eggs","ci/templates","build","dist"]
skip = [".tox", ".eggs", "ci/templates", "build", "dist"]

# testing: pytest.py
[tool.pytest.ini_options]
Expand Down
14 changes: 8 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[bumpversion]
current_version = 4.0.1
current_version = 4.0.2
commit = True
tag = False
message = '{current_version} → {new_version}'

[metadata]
name = pygaps
version = 4.0.1
version = 4.0.2
description = A framework for processing adsorption data for porous materials.
long_description = file: README.rst
long_description_content_type = text/x-rst
Expand All @@ -30,6 +30,7 @@ classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: Implementation :: CPython
Intended Audience :: Science/Research
Topic :: Scientific/Engineering :: Physics
Expand Down Expand Up @@ -60,9 +61,13 @@ install_requires =
requests
importlib_resources; python_version < "3.9"

[options.packages.find]
where = src

[options.package_data]
* = *.txt, *.rst
hello = *.msg
pygaps.data = *
pygaps.data.kernels = *.csv

[options.entry_points]
console_scripts =
Expand Down Expand Up @@ -91,9 +96,6 @@ docs =
nbsphinx
furo

[options.packages.find]
where = src

[bumpversion:file:setup.cfg]
search = version = {current_version}
replace = version = {new_version}
Expand Down
2 changes: 1 addition & 1 deletion src/pygaps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ._version import version
__version__ = version
except ImportError:
__version__ = '4.0.1'
__version__ = '4.0.2'

import sys
from .logging import logger
Expand Down
27 changes: 14 additions & 13 deletions src/pygaps/characterisation/psd_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
scope of this program.
"""

from pathlib import Path

import numpy
import pandas
from scipy import interpolate
Expand All @@ -14,14 +12,11 @@
from pygaps.core.adsorbate import Adsorbate
from pygaps.core.modelisotherm import ModelIsotherm
from pygaps.core.pointisotherm import PointIsotherm
from pygaps.data import KERNELS
from pygaps.utilities.exceptions import CalculationError
from pygaps.utilities.exceptions import ParameterError
from pygaps.utilities.math_utilities import bspline

_KERNELS = {
'DFT-N2-77K-carbon-slit': Path(__file__).parent / 'kernels' / 'DFT-N2-77K-carbon-slit.csv',
}

_LOADED = {} # We will keep loaded kernels here


Expand Down Expand Up @@ -145,10 +140,7 @@ def psd_dft(
raise ParameterError("Isotherm adsorbate is not known, cannot calculate PSD.")

# Get an internal kernel, otherwise assume it is a path
if kernel in _KERNELS:
kernel_path = _KERNELS[kernel]
else:
kernel_path = kernel
kernel_path = KERNELS.get(kernel, kernel)

# Get units
if kernel_units is None:
Expand Down Expand Up @@ -205,8 +197,16 @@ def psd_dft(
loading = loading[minimum:maximum + 1]

# Call the DFT function
pore_widths, pore_dist, pore_vol_cum, kernel_final_loading = psd_dft_kernel_fit(
pressure, loading, kernel_path, bspline_order
(
pore_widths,
pore_dist,
pore_vol_cum,
kernel_final_loading,
) = psd_dft_kernel_fit(
pressure,
loading,
kernel_path,
bspline_order,
) # mmol/g

if verbose:
Expand Down Expand Up @@ -373,7 +373,8 @@ def _load_kernel(path: str):
if path in _LOADED:
return _LOADED[path]

raw_kernel = pandas.read_csv(path, index_col=0)
with open(path, encoding="utf8") as fp:
raw_kernel = pandas.read_csv(fp, index_col=0)

# add a 0 in the dataframe for interpolation between lowest values
raw_kernel = raw_kernel.append(
Expand Down
9 changes: 8 additions & 1 deletion src/pygaps/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import importlib.resources as importlib_resources
from importlib.resources import files as importlib_resources_files
except ImportError:
# Try backported to PY<37 `importlib_resources`.
# TODO Deprecation after PY<39
# Use backported `importlib_resources`.
import importlib_resources as importlib_resources
from importlib_resources import files as importlib_resources_files

Expand Down Expand Up @@ -41,3 +42,9 @@ def load_data():

MATERIAL_LIST.extend(materials_from_db(verbose=False))
ADSORBATE_LIST.extend(adsorbates_from_db(verbose=False))


_kernel_res = importlib_resources_files('pygaps.data.kernels')
KERNELS = {
'DFT-N2-77K-carbon-slit': _kernel_res / 'DFT-N2-77K-carbon-slit.csv',
}
Empty file.
10 changes: 3 additions & 7 deletions src/pygaps/utilities/sqlite_db_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,16 @@ def db_create(pth: str, verbose: bool = False):
db_execute_general(pragma, pth, verbose=verbose)

# Get json files
try:
import importlib.resources as pkg_resources
except ImportError:
# Try backported to PY<37 `importlib_resources`.
import importlib_resources as pkg_resources
import importlib.resources as importlib_resources

# Get and upload adsorbate property types
ads_props_json = pkg_resources.read_text('pygaps.data', 'adsorbate_props.json')
ads_props_json = importlib_resources.read_text('pygaps.data', 'adsorbate_props.json')
ads_props = json.loads(ads_props_json)
for ap_type in ads_props:
pgsqlite.adsorbate_property_type_to_db(ap_type, db_path=pth, verbose=verbose)

# Get and upload adsorbates
ads_json = pkg_resources.read_text('pygaps.data', 'adsorbates.json')
ads_json = importlib_resources.read_text('pygaps.data', 'adsorbates.json')
adsorbates = json.loads(ads_json)
for ads in adsorbates:
pgsqlite.adsorbate_to_db(pygaps.Adsorbate(**ads), db_path=pth, verbose=verbose)
Expand Down

0 comments on commit c6a4f3f

Please sign in to comment.