Skip to content

Commit 5bc34d1

Browse files
authored
Merge pull request #84 from MineralsCloud:mpmath
Replace `bigfloat` with `mpmath` in docs
2 parents 88e4de0 + c0d6f22 commit 5bc34d1

File tree

5 files changed

+22
-37
lines changed

5 files changed

+22
-37
lines changed

README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ $ pip install qha
3838

3939
### Dependencies
4040

41-
- [bigfloat](https://pypi.python.org/pypi/bigfloat)
41+
- [mpmath](https://mpmath.org/)
4242
- [lazy-property](https://github.com/jackmaney/lazy-property)
4343
- [matplotlib](https://matplotlib.org)
4444
- [Numba](http://numba.pydata.org)
@@ -63,13 +63,6 @@ Notice that you have to use Python version 3.6.x to install. If you want to inst
6363
$ pip install -e .
6464
```
6565

66-
### Trouble shooting of installation
67-
68-
1. Error raised about `mpfr.h` file: To solve this error, `GMP` and `MPFR` libraries are required to use `bigfloat` package.
69-
* On Linux, install `libmpfr-dev` , for example, on Ubuntu type `apt-get install libmpfr-dev`;
70-
* On Windows, `bigfloat` can be installed from the binary file, please check [“Unofficial Windows Binaries for Python Extension Packages”](https://www.lfd.uci.edu/~gohlke/pythonlibs/), download the version suitable for the system, for example, for a 64-bit system, use pip to install it `pip(3) install /the/path/to/bigfloat‑0.3.0‑cp36‑cp36m‑win_amd64.whl`;
71-
* On macOS, install these libraries via `brew install mpfr`. Of course, you need the [Homebrew package manager](https://brew.sh) installed to run this command.
72-
7366
## Checking the examples
7467

7568
To run the examples, go to `examples/ice VII/` or `examples/silicon/` directories and type in terminal:

docs/source/tutorials/installing.rst

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Our supported platforms are:
2222

2323
Dependencies
2424
------------
25-
- `bigfloat <https://pypi.python.org/pypi/bigfloat>`_ [#b]_
25+
- `mpmath <https://mpmath.org>`_
2626
- `lazy-property <https://github.com/jackmaney/lazy-property>`_
2727
- `matplotlib <https://matplotlib.org>`_ [#m]_
2828
- `Numba <http://numba.pydata.org>`_
@@ -35,14 +35,6 @@ Dependencies
3535

3636
Notes:
3737

38-
.. [#b] ``GMP`` and ``MPFR`` libraries are required to use ``bigfloat`` package. On macOS,
39-
install these libraries via ``brew install mpfr``; on Linux, install ``libmpfr-dev`` ,
40-
for example, on Ubuntu use ``apt-get install libmpfr-dev``;
41-
on Windows, ``bigfloat`` can be installed from the binary file, please check
42-
`Unofficial Windows Binaries for Python Extension Packages <https://www.lfd.uci.edu/~gohlke/pythonlibs/>`_,
43-
download the version suitable for the system, for example,for a 64-bit system,
44-
use pip to install it ``pip(3) install /the/path/to/bigfloat‑0.3.0‑cp36‑cp36m‑win_amd64.whl``;
45-
4638
.. [#m] For some systems, ``python-tkinter`` package is needed by ``matplotlib``, otherwise the plot function will not work.
4739
4840
Installing the ``qha`` package

qha/multi_configurations/different_phonon_dos.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ def partition_functions_for_each_configuration(self):
118118
:return: A matrix, the partition function of each configuration of each volume.
119119
"""
120120
try:
121-
import bigfloat
121+
import mpmath
122122
except ImportError:
123-
raise ImportError("Install ``bigfloat`` package to use {0} object!".format(self.__class__.__name__))
123+
raise ImportError("Install ``mpmath`` package to use {0} object!".format(self.__class__.__name__))
124124

125-
with bigfloat.precision(self.precision):
125+
with mpmath.workprec(self.precision):
126126
# shape = (# of configurations, # of volumes for each configuration)
127127
exp = np.vectorize(bigfloat.exp)
128128
return exp(-self.aligned_free_energies_for_each_configuration / (K * self.temperature))
@@ -139,13 +139,13 @@ def partition_functions_for_all_configurations(self):
139139
:return: A vector, the partition function of each volume.
140140
"""
141141
try:
142-
import bigfloat
142+
import mpmath
143143
except ImportError:
144-
raise ImportError("Install ``bigfloat`` package to use {0} object!".format(self.__class__.__name__))
144+
raise ImportError("Install ``mpmath`` package to use {0} object!".format(self.__class__.__name__))
145145

146-
with bigfloat.precision(self.precision):
146+
with mpmath.workprec(self.precision):
147147
# shape = (# of volumes,)
148-
return np.array([bigfloat.exp(d) for d in
148+
return np.array([mpmath.exp(d) for d in
149149
logsumexp(-self.aligned_free_energies_for_each_configuration.T / (K * self.temperature),
150150
axis=1, b=self.degeneracies)])
151151

@@ -160,10 +160,10 @@ def get_free_energies(self):
160160
:return: The free energy on a temperature-volume grid.
161161
"""
162162
try:
163-
import bigfloat
163+
import mpmath
164164
except ImportError:
165-
raise ImportError("Install ``bigfloat`` package to use {0} object!".format(self.__class__.__name__))
165+
raise ImportError("Install ``mpmath`` package to use {0} object!".format(self.__class__.__name__))
166166

167-
with bigfloat.precision(self.precision):
168-
log_z = np.array([bigfloat.log(d) for d in self.partition_functions_for_all_configurations], dtype=float)
167+
with mpmath.workprec(self.precision):
168+
log_z = np.array([mpmath.log(d) for d in self.partition_functions_for_all_configurations], dtype=float)
169169
return -K * self.temperature * log_z

qha/multi_configurations/same_phonon_dos.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ def _static_part(self) -> Vector:
8484
:return: The static contribution on the temperature-volume grid.
8585
"""
8686
try:
87-
import bigfloat
87+
import mpmath
8888
except ImportError:
8989
raise ImportError(
90-
"You need to install ``bigfloat`` package to use {0} object!".format(self.__class__.__name__))
90+
"You need to install ``mpmath`` package to use {0} object!".format(self.__class__.__name__))
9191

92-
with bigfloat.precision(self.precision):
93-
return np.array([bigfloat.exp(d) for d in # shape = (# of volumes for each configuration, 1)
92+
with mpmath.workprec(self.precision):
93+
return np.array([mpmath.exp(d) for d in # shape = (# of volumes for each configuration, 1)
9494
logsumexp(-self.static_energies / (K * self.temperature), axis=1, b=self.degeneracies)])
9595

9696
@property
@@ -124,12 +124,12 @@ def get_free_energies(self):
124124
:return: The free energy on the temperature-volume grid.
125125
"""
126126
try:
127-
import bigfloat
127+
import mpmath
128128
except ImportError:
129-
raise ImportError("Install ``bigfloat`` package to use {0} object!".format(self.__class__.__name__))
129+
raise ImportError("Install ``mpmath`` package to use {0} object!".format(self.__class__.__name__))
130130

131-
with bigfloat.precision(self.precision):
132-
log_z = np.array([bigfloat.log(d) for d in self.total], dtype=float)
131+
with mpmath.workprec(self.precision):
132+
log_z = np.array([mpmath.log(d) for d in self.total], dtype=float)
133133
return -K * self.temperature * log_z
134134

135135

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def find_version(*file_paths):
4848
install_requires=[
4949
'lazy_property',
5050
'numba',
51+
'mpmath',
5152
'numpy',
52-
'bigfloat',
5353
'pandas',
5454
'scientific-string',
5555
'scipy',

0 commit comments

Comments
 (0)