Skip to content

Commit f06d37e

Browse files
committed
Merge branch 'dev' into py3
2 parents d813653 + 85764f8 commit f06d37e

File tree

4 files changed

+37
-128
lines changed

4 files changed

+37
-128
lines changed

README.md

Lines changed: 15 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# Convenient Interface to Inverse Ising
44

55
ConIII is a Python package for solving maximum entropy problems with a focus on the
6-
pairwise maximum entropy model, also known as the inverse Ising problem. Support for
7-
Python 3.8.3 and higher.
6+
pairwise maximum entropy model, also known as the inverse Ising problem.
87

98
If you use ConIII for your research, please consider citing the following:
109
> Lee, E.D. and Daniels, B.C., 2019. Convenient Interface to Inverse Ising (ConIII): A
@@ -16,25 +15,21 @@ The paper also contains an overview of the modules. For code documentation, see
1615

1716
## Installation
1817

19-
This package is available on PyPI. It can be installed by first installing the needed
20-
Boost C++ libraries and using pip.
18+
To set up an Anaconda environment called "test" and install from pip, run the following code. The openblas package is only recommended for AMD users.
2119
```bash
22-
$ conda install -c conda-forge boost==1.74
20+
$ conda create -n test -c conda-forge python=3.10 numpy scipy numba cython jupyter ipython multiprocess boost==1.74 matplotlib mpmath blas=*=openblas
2321
$ pip install coniii
2422
```
2523
If you have trouble using `pip`, then you can always build this package from
2624
source. The following code will down download the latest release from GitHub and install
27-
the package. Make sure that you are running Python 3.8.3 or higher and have boost v1.74.0
25+
the package. Make sure that you are running Python 3.10 and have boost v1.74.0
2826
installed.
2927
```bash
3028
$ git clone https://github.com/eltrompetero/coniii.git
3129
$ cd coniii
3230
$ ./pypi_compile.sh
3331
$ pip install dist/*.whl
3432
```
35-
(Note: Using setuptools in the usual way of `python
36-
setup.py install` will not work because eggs are incompatible with cached jit functions
37-
generated using numba.)
3833

3934
#### Setting up exact solution for systems *N > 9*
4035
If you would like to use the `Enumerate` solver for system sizes greater than 9 spins, you
@@ -48,79 +43,40 @@ starting a Python terminal and running
4843

4944
Once inside the install directory, you can run in your bash shell
5045
```bash
51-
$ python enumerate.py [N]
46+
$ python enumerate.py [N] 1
5247
```
5348

54-
where `[N]` should be replaced by the size of the system. This will write the equations
55-
for the Ising model in the {0,1} basis. On the other hand,
49+
where `[N]` should be replaced by the size of the system. This specifies that the system should be written for the {-1,1} basis. Note that the package uses the {-1,1} basis by default. For more details, see the `__main__` block at the end of the file enumerate.py.
5650

51+
For the {0,1} basis, use
5752
```bash
58-
$ python enumerate.py [N] 1
53+
$ python enumerate.py [N]
5954
```
6055

61-
specifies that the system should be written for the {-1,1} basis. Note that the package
62-
uses the {-1,1} basis by default. For more details, see the `__main__` block at the end of
63-
the file enumerate.py.
64-
65-
## Quick guide (with Jupyter notebook)
56+
## Quick guide with Jupyter notebook
6657

6758
A [Jupyter
6859
notebook](https://github.com/eltrompetero/coniii/blob/py3/ipynb/usage_guide.ipynb) with a
69-
brief introduction and examples for how to use ConIII is available. An HTML version is
70-
[here](https://github.com/eltrompetero/coniii/blob/py3/ipynb/usage_guide.html). The
71-
notebook is installed into your package directory if you used pip.
60+
brief introduction and examples for how to use ConIII is available. The
61+
notebook is also installed into your package directory if you used pip.
7262

73-
To use the notebook, install jupyter.
74-
```bash
75-
$ pip install jupyter
76-
```
77-
or if you are using the Conda package manager
78-
```bash
79-
$ conda install jupyter
80-
```
81-
82-
Then, first copy the notebook file "usage_guide.ipynb" into a directory outside the
83-
"coniii" directory. Change to this directory and run
63+
To use the notebook, install jupyter such as by following the setup instructions above. Then, copy the notebook file "usage_guide.ipynb" into a directory outside the "coniii" directory. Change to this directory and run
8464
```bash
8565
$ jupyter notebook
8666
```
8767

8868
This should open the notebook in your default web browser.
8969

90-
## Quick guide (console)
91-
92-
First, install iPython for a console-based interpreter and start it.
93-
```bash
94-
$ pip install ipython
95-
```
96-
or if you are using the Conda package manager
97-
```bash
98-
$ conda install ipython
99-
```
100-
101-
Then, first copy the notebook file
102-
["usage_guide.py"](https://github.com/eltrompetero/coniii/blob/py3/ipynb/usage_guide.py)
103-
into a directory outside the "coniii" directory. Change to this directory and run
104-
```bash
105-
$ ipython
106-
```
107-
108-
Once inside the iPython interpreter, run
109-
```python
110-
>>> %run usage_guide.py
111-
```
112-
This will run all the examples sequentially, so you may want to comment out unwanted lines.
113-
11470
## Troubleshooting
11571

11672
This package is only maintained for Python 3 and has only been tested for Python
117-
3.8.3. Check which version of Python you are running in your terminal with
73+
3.10. Check which version of Python you are running in your terminal with
11874
```bash
11975
$ python --version
12076
```
12177

12278
ConIII has been tested on the following systems
123-
* Ubuntu 20.04.1
79+
* Ubuntu 20.04.5
12480

12581
Trouble compiling the Boost extension manually? Check if your Boost library is
12682
included in your path. If it is not, then you can add an include directory entry
@@ -146,7 +102,7 @@ The package directory can be found by running inside python
146102

147103
You may also need to install pytest.
148104
```bash
149-
$ pip install pytest
105+
$ conda install -c conda-forge pytest
150106
```
151107

152108
### Updating

RELEASE_NOTES

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,11 @@
11
Log for major changes in releases
22

3-
MIT License
43

5-
Copyright (c) 2020 Edward D. Lee, Bryan C. Daniels
6-
7-
Permission is hereby granted, free of charge, to any person obtaining a copy
8-
of this software and associated documentation files (the "Software"), to deal
9-
in the Software without restriction, including without limitation the rights
10-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
copies of the Software, and to permit persons to whom the Software is
12-
furnished to do so, subject to the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included in all
15-
copies or substantial portions of the Software.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23-
SOFTWARE.
24-
25-
26-
v3.0.1 (2022/11)
4+
v3.0.1 (Released 2022/10)
275
----------------------------------------------------
286
- Bug fix in setup script.
297

30-
v3.0.0 (To be released 2022/06)
8+
v3.0.0 (Released 2022/06)
319
----------------------------------------------------
3210
- Conditional (fixed spin) Metropolis sampling now in C++).
3311
- Standardized method names for generating samples and data member names for

coniii/models.py

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,6 @@
22
# ConIII module for maxent models.
33
# Authors: Edward Lee (edlee@alumni.princeton.edu) and Bryan Daniels
44
# (bryan.daniels.1@asu.edu)
5-
#
6-
# MIT License
7-
#
8-
# Copyright (c) 2019 Edward D. Lee, Bryan C. Daniels
9-
#
10-
# Permission is hereby granted, free of charge, to any person obtaining a copy
11-
# of this software and associated documentation files (the "Software"), to deal
12-
# in the Software without restriction, including without limitation the rights
13-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14-
# copies of the Software, and to permit persons to whom the Software is
15-
# furnished to do so, subject to the following conditions:
16-
#
17-
# The above copyright notice and this permission notice shall be included in all
18-
# copies or substantial portions of the Software.
19-
#
20-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26-
# SOFTWARE.
275
# ====================================================================================== #
286
from importlib import import_module
297
import multiprocess as mp
@@ -37,7 +15,21 @@
3715
class Model():
3816
"""Basic model class outline.
3917
"""
40-
18+
def __init__(self, multipliers, rng=None, verbose=False):
19+
"""
20+
Parameters
21+
----------
22+
multipliers : list of ndarray or ndarray
23+
Can be an integer (all parameters are set to zero), list of vectors [fields,
24+
couplings], a vector of fields and couplings concatenated together, or a
25+
matrix of parameters where the diagonal entries are the fields.
26+
"""
27+
28+
self.multipliers = multipliers
29+
30+
self.rng = rng or np.random.RandomState() # this will get passed to sampler if it is set up
31+
self.verbose = verbose
32+
4133
def setup_sampler(self,
4234
sample_method='metropolis',
4335
sample_size=1000,
@@ -66,6 +58,11 @@ def setup_sampler(self,
6658
self.sampler = mcPotts3(self.n, self.multipliers, self.calc_e,
6759
rng=self.rng,
6860
**sampler_kwargs)
61+
elif sample_method=='metropolis':
62+
self.sampleMethod = sample_method
63+
self.sampler = Metropolis(self.n, self.multipliers, self.calc_e,
64+
rng=self.rng,
65+
**sampler_kwargs)
6966
else:
7067
raise NotImplementedError("Unrecognized sampler %s."%sample_method)
7168
self.sample = None

coniii/solvers.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
11
# =============================================================================================== #
22
# ConIII module for algorithms for solving the inverse Ising problem.
33
# Authors: Edward Lee (edlee@alumni.princeton.edu) and Bryan Daniels (bryan.daniels.1@asu.edu)
4-
#
5-
# MIT License
6-
#
7-
# Copyright (c) 2020 Edward D. Lee, Bryan C. Daniels
8-
#
9-
# Permission is hereby granted, free of charge, to any person obtaining a copy
10-
# of this software and associated documentation files (the "Software"), to deal
11-
# in the Software without restriction, including without limitation the rights
12-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13-
# copies of the Software, and to permit persons to whom the Software is
14-
# furnished to do so, subject to the following conditions:
15-
#
16-
# The above copyright notice and this permission notice shall be included in all
17-
# copies or substantial portions of the Software.
18-
#
19-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25-
# SOFTWARE.
264
# =============================================================================================== #
275
from scipy.optimize import minimize, fmin_ncg, minimize_scalar, root
286
import multiprocess as mp

0 commit comments

Comments
 (0)