10000 pep 8, some doc update and new site.template.cfg. · PythonOptimizers/HSL.py@2a8e666 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a8e666

Browse files
committed
pep 8, some doc update and new site.template.cfg.
1 parent 7bc5f39 commit 2a8e666

File tree

7 files changed

+61
-33
lines changed

7 files changed

+61
-33
lines changed

config/setup.cpy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ import pysparse
88
from distutils.core import setup
99
from setuptools import find_packages
1010
from distutils.extension import Extension
11-
from Cython.Distutils import build_ext
1211
from numpy.distutils.misc_util import Configuration
1312
from numpy.distutils.system_info import get_info
1413
from numpy.distutils.core import setup
1514

16-
from Cython.Build import cythonize
1715

1816
import numpy as np
1917

config/setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
from distutils.core import setup
99
from setuptools import find_packages
1010
from distutils.extension import Extension
11-
from Cython.Distutils import build_ext
1211
from numpy.distutils.misc_util import Configuration
1312
from numpy.distutils.system_info import get_info
1413
from numpy.distutils.core import setup
1514

16-
from Cython.Build import cythonize
1715

1816
import numpy as np
1917

doc/source/scaling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Example
2626

2727
Output
2828

29-
.. code-block:: bash
29+
.. code-block:: none
3030
3131
orignal values:
3232
i j val

hsl/solvers/pyma27.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from sils import Sils
99
from hsl.solvers import _pyma27
1010

11+
1112
class PyMa27Solver(Sils):
1213

1314
def __init__(self, A, **kwargs):
@@ -66,11 +67,11 @@ def __init__(self, A, **kwargs):
6667
# Statistics on A
6768
self.rwords = 0 # Number of real words used during factorization
6869
self.iwords = 0 # " int
69-
self.ncomp = 0 # " data compresses performed in analysis
70+
self.ncomp = 0 # " data compresses performed in analysis
7071
self.nrcomp = 0 # " real
7172
self.nicomp = 0 # " int
7273
self.n2x2pivots = 0 # " 2x2 pivots used
73-
self.neig = 0 # " negative eigenvalues detected
74+
self.neig = 0 # " negative eigenvalues detected
7475

7576
# Factors
7677
self.L = spmatrix.ll_mat(self.n, self.n, 0)

hsl/solvers/sils.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@
66

77
import numpy
88

9+
910
class Sils:
1011
"""
1112
Abstract class for the factorization and solution of symmetric indefinite
1213
systems of linear equations. The methods of this class must be overridden.
1314
"""
1415

1516
def __init__(self, A, **kwargs):
16-
if not A.issym:
17-
raise ValueError, 'Input matrix must be symmetric'
17+
try:
18+
symmetric = A.issym
19+
except:
20+
symmetric = A.is_symmetric
21+
22+
if not symmetric:
23+
raise ValueError('Input matrix must be symmetric')
1824
self.n = A.shape[0]
1925
self.sqd = 'sqd' in kwargs and kwargs['sqd']
2026

@@ -25,19 +31,13 @@ def __init__(self, A, **kwargs):
2531
self.context = None
2632

2733
def solve(self, b, get_resid=True):
28-
"""
29-
Must be subclassed.
30-
"""
34+
"""Must be subclassed."""
3135
raise NotImplementedError
3236

3337
def refine(self, b, nitref=3):
34-
"""
35-
Must be subclassed.
36-
"""
38+
"""Must be subclassed."""
3739
raise NotImplementedError
3840

3941
def fetch_perm(self):
40-
"""
41-
Must be subclassed.
42-
"""
42+
"""Must be subclassed."""
4343
raise NotImplementedError

hsl/solvers/src/_cyma27_base.cpx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ cdef extern from "ma27.h":
2020
int nsteps
2121
int iflag # Pivot selection
2222
double ops # Operation count
23-
23+
2424
char rankdef # Indicate whether matrix is rank-deficient
2525
int rank; # Matrix rank
26-
26+
2727
int la
2828
@type|generic_to_c_type@ *factors # Matrix factors
2929
int maxfrt
3030
@type|generic_to_c_type@ *w # Real workspace
31-
32-
@type|generic_to_c_type@ *residual # = b - Ax
31+
32+
@type|generic_to_c_type@ *residual # = b - Ax
3333
char fetched # Factors have been fetched
3434
# Used for de-allocation
3535

@@ -173,11 +173,12 @@ cdef class BaseMA27Solver_@index@_@type@:
173173

174174
def refine(self, np.ndarray[@type|generic_to_c_type@, ndim=1] x, np.ndarray[@type|generic_to_c_type@, ndim=1] rhs,
175175
np.ndarray[@type|generic_to_c_type@, ndim=1] residual, double tol=1e-8, int nitref=3, *args):
176-
"""
177-
refine performs iterative refinement if necessary
178-
until the scaled residual norm ||b-Ax||/(1+||b||) falls below a threshold 'tol'
179-
or until nitref steps are taken.
180-
176+
"""Perform iterative refinement.
177+
178+
If necessary, it performs iterative refinement until the scaled
179+
residual norm ||b-Ax||/(1+||b||) falls below a threshold 'tol' or until
180+
nitref steps are taken.
181+
181182
warning: Make sure you have called solve() with the same right-hand
182183
side b before calling refine().
183184

@@ -212,9 +213,7 @@ cdef class BaseMA27Solver_@index@_@type@:
212213
return (new_x, new_res)
213214

214215
def stats(self):
215-
"""
216-
Return statistics on the solve
217-
"""
216+
"""Return statistics on the solve."""
218217
return (self.data.info[8], # storage for real data of factors
219218
self.data.info[9], # storage for int data of factors
220219
self.data.info[10], # nb of data compresses performed in analysis

site.template.cfg

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,44 @@
9797
# named ma57d and one named mc29d. These should not be altered. The file
9898
# hsl_zd11d.f90 should be placed in hsl_dir.
9999
#
100-
# 4. You will also need the METIS library and header files. The source tree may
101-
# be downloaded from http://glaros.dtc.umn.edu/gkhome/metis/metis/download
100+
[CODE_GENERATION]
101+
# log file name **without** extension (by default, we use '.log')
102+
log_name = generator
103+
# DEBUG/INFO/WARNING/ERROR/CRITICAL
104+
log_level = DEBUG
105+
console_log_level = DEBUG
106+
file_log_level = DEBUG
107+
# 32bits/64bits
108+
# if left blank, we use INT64_t on 64 bits platforms and INT32_t on 32 bits platforms
109+
DEFAULT_INDEX_TYPE =
110+
# Do you want to generate the .c files from Cython?
111+
use_cython = true
112 6377 +
# Use debug symbols?
113+
use_debug_symbols = false
114+
115+
# Defaults
116+
# ========
117+
# The settings given here will apply to all other sections if not overridden.
118+
# This is a good place to add general library and include directories like
119+
# /usr/local/{lib,include}
120+
#
121+
[DEFAULT]
122+
library_dirs = /usr/local/lib
123+
include_dirs = /usr/local/include
124+
102125
[HSL]
103-
hsl_dir = /Users/syarra/work/programs/hsl
126+
hsl_rootdir = /Users/syarra/work/programs/hsl
127+
128+
# METIS
129+
# -----
130+
# You will need the METIS library and header files.
131+
# The source tree may be downloaded from
132+
# http://glaros.dtc.umn.edu/gkhome/metis/metis/download
104133

105134
[METIS]
106135
metis_dir = /usr/local/opt/metis4/lib
107136
metis_lib = metis
108137

138+
# Optional
139+
[CYSPARSE]
140+
cysparse_rootdir = /Users/syarra/work/VirtualEnvs/nlpy_new/programs/cysparse/

0 commit comments

Comments
 (0)
0