IMP logo
IMP Reference Guide  2.14.0
The Integrative Modeling Platform
kmeans/__init__.py
1 # This file was automatically generated by SWIG (http://www.swig.org).
2 # Version 3.0.10
3 #
4 # Do not make changes to this file unless you know what you are doing--modify
5 # the SWIG interface file instead.
6 
7 # This wrapper is part of IMP,
8 # Copyright 2007-2020 IMP Inventors. All rights reserved.
9 
10 from __future__ import print_function, division, absolute_import
11 
12 
13 
14 
15 from sys import version_info as _swig_python_version_info
16 if _swig_python_version_info >= (2, 7, 0):
17  def swig_import_helper():
18  import importlib
19  pkg = __name__.rpartition('.')[0]
20  mname = '.'.join((pkg, '_IMP_kmeans')).lstrip('.')
21  try:
22  return importlib.import_module(mname)
23  except ImportError:
24  return importlib.import_module('_IMP_kmeans')
25  _IMP_kmeans = swig_import_helper()
26  del swig_import_helper
27 elif _swig_python_version_info >= (2, 6, 0):
28  def swig_import_helper():
29  from os.path import dirname
30  import imp
31  fp = None
32  try:
33  fp, pathname, description = imp.find_module('_IMP_kmeans', [dirname(__file__)])
34  except ImportError:
35  import _IMP_kmeans
36  return _IMP_kmeans
37  if fp is not None:
38  try:
39  _mod = imp.load_module('_IMP_kmeans', fp, pathname, description)
40  finally:
41  fp.close()
42  return _mod
43  _IMP_kmeans = swig_import_helper()
44  del swig_import_helper
45 else:
46  import _IMP_kmeans
47 del _swig_python_version_info
48 try:
49  _swig_property = property
50 except NameError:
51  pass # Python < 2.2 doesn't have 'property'.
52 
53 try:
54  import builtins as __builtin__
55 except ImportError:
56  import __builtin__
57 
58 def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
59  if (name == "thisown"):
60  return self.this.own(value)
61  if (name == "this"):
62  if type(value).__name__ == 'SwigPyObject':
63  self.__dict__[name] = value
64  return
65  method = class_type.__swig_setmethods__.get(name, None)
66  if method:
67  return method(self, value)
68  if (not static):
69  object.__setattr__(self, name, value)
70  else:
71  raise AttributeError("You cannot add attributes to %s" % self)
72 
73 
74 def _swig_setattr(self, class_type, name, value):
75  return _swig_setattr_nondynamic(self, class_type, name, value, 0)
76 
77 
78 def _swig_getattr(self, class_type, name):
79  if (name == "thisown"):
80  return self.this.own()
81  method = class_type.__swig_getmethods__.get(name, None)
82  if method:
83  return method(self)
84  raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
85 
86 
87 def _swig_repr(self):
88  try:
89  strthis = "proxy of " + self.this.__repr__()
90  except __builtin__.Exception:
91  strthis = ""
92  return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
93 
94 
95 def _swig_setattr_nondynamic_method(set):
96  def set_attr(self, name, value):
97  if (name == "thisown"):
98  return self.this.own(value)
99  if hasattr(self, name) or (name == "this"):
100  set(self, name, value)
101  else:
102  raise AttributeError("You cannot add attributes to %s" % self)
103  return set_attr
104 
105 
106 try:
107  import weakref
108  weakref_proxy = weakref.proxy
109 except __builtin__.Exception:
110  weakref_proxy = lambda x: x
111 
112 
113 class IMP_KMEANS_SwigPyIterator(object):
114  """Proxy of C++ swig::IMP_KMEANS_SwigPyIterator class."""
115 
116  thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
117 
118  def __init__(self, *args, **kwargs):
119  raise AttributeError("No constructor defined - class is abstract")
120  __repr__ = _swig_repr
121  __swig_destroy__ = _IMP_kmeans.delete_IMP_KMEANS_SwigPyIterator
122  __del__ = lambda self: None
123 
124  def value(self):
125  """value(IMP_KMEANS_SwigPyIterator self) -> PyObject *"""
126  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_value(self)
127 
128 
129  def incr(self, n=1):
130  """
131  incr(IMP_KMEANS_SwigPyIterator self, size_t n=1) -> IMP_KMEANS_SwigPyIterator
132  incr(IMP_KMEANS_SwigPyIterator self) -> IMP_KMEANS_SwigPyIterator
133  """
134  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_incr(self, n)
135 
136 
137  def decr(self, n=1):
138  """
139  decr(IMP_KMEANS_SwigPyIterator self, size_t n=1) -> IMP_KMEANS_SwigPyIterator
140  decr(IMP_KMEANS_SwigPyIterator self) -> IMP_KMEANS_SwigPyIterator
141  """
142  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_decr(self, n)
143 
144 
145  def distance(self, x):
146  """distance(IMP_KMEANS_SwigPyIterator self, IMP_KMEANS_SwigPyIterator x) -> ptrdiff_t"""
147  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_distance(self, x)
148 
149 
150  def equal(self, x):
151  """equal(IMP_KMEANS_SwigPyIterator self, IMP_KMEANS_SwigPyIterator x) -> bool"""
152  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_equal(self, x)
153 
154 
155  def copy(self):
156  """copy(IMP_KMEANS_SwigPyIterator self) -> IMP_KMEANS_SwigPyIterator"""
157  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_copy(self)
158 
159 
160  def next(self):
161  """next(IMP_KMEANS_SwigPyIterator self) -> PyObject *"""
162  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_next(self)
163 
164 
165  def __next__(self):
166  """__next__(IMP_KMEANS_SwigPyIterator self) -> PyObject *"""
167  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___next__(self)
168 
169 
170  def previous(self):
171  """previous(IMP_KMEANS_SwigPyIterator self) -> PyObject *"""
172  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_previous(self)
173 
174 
175  def advance(self, n):
176  """advance(IMP_KMEANS_SwigPyIterator self, ptrdiff_t n) -> IMP_KMEANS_SwigPyIterator"""
177  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_advance(self, n)
178 
179 
180  def __eq__(self, x):
181  """__eq__(IMP_KMEANS_SwigPyIterator self, IMP_KMEANS_SwigPyIterator x) -> bool"""
182  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___eq__(self, x)
183 
184 
185  def __ne__(self, x):
186  """__ne__(IMP_KMEANS_SwigPyIterator self, IMP_KMEANS_SwigPyIterator x) -> bool"""
187  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___ne__(self, x)
188 
189 
190  def __iadd__(self, n):
191  """__iadd__(IMP_KMEANS_SwigPyIterator self, ptrdiff_t n) -> IMP_KMEANS_SwigPyIterator"""
192  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___iadd__(self, n)
193 
194 
195  def __isub__(self, n):
196  """__isub__(IMP_KMEANS_SwigPyIterator self, ptrdiff_t n) -> IMP_KMEANS_SwigPyIterator"""
197  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___isub__(self, n)
198 
199 
200  def __add__(self, n):
201  """__add__(IMP_KMEANS_SwigPyIterator self, ptrdiff_t n) -> IMP_KMEANS_SwigPyIterator"""
202  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___add__(self, n)
203 
204 
205  def __sub__(self, *args):
206  """
207  __sub__(IMP_KMEANS_SwigPyIterator self, ptrdiff_t n) -> IMP_KMEANS_SwigPyIterator
208  __sub__(IMP_KMEANS_SwigPyIterator self, IMP_KMEANS_SwigPyIterator x) -> ptrdiff_t
209  """
210  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___sub__(self, *args)
211 
212  def __iter__(self):
213  return self
214 IMP_KMEANS_SwigPyIterator_swigregister = _IMP_kmeans.IMP_KMEANS_SwigPyIterator_swigregister
215 IMP_KMEANS_SwigPyIterator_swigregister(IMP_KMEANS_SwigPyIterator)
216 
217 
218 _value_types=[]
219 _object_types=[]
220 _raii_types=[]
221 _plural_types=[]
222 
223 IMP_DEBUG = _IMP_kmeans.IMP_DEBUG
224 IMP_RELEASE = _IMP_kmeans.IMP_RELEASE
225 IMP_SILENT = _IMP_kmeans.IMP_SILENT
226 IMP_PROGRESS = _IMP_kmeans.IMP_PROGRESS
227 IMP_TERSE = _IMP_kmeans.IMP_TERSE
228 IMP_VERBOSE = _IMP_kmeans.IMP_VERBOSE
229 IMP_MEMORY = _IMP_kmeans.IMP_MEMORY
230 IMP_NONE = _IMP_kmeans.IMP_NONE
231 IMP_USAGE = _IMP_kmeans.IMP_USAGE
232 IMP_INTERNAL = _IMP_kmeans.IMP_INTERNAL
233 IMP_KERNEL_HAS_LOG4CXX = _IMP_kmeans.IMP_KERNEL_HAS_LOG4CXX
234 IMP_COMPILER_HAS_AUTO = _IMP_kmeans.IMP_COMPILER_HAS_AUTO
235 IMP_COMPILER_HAS_DEBUG_VECTOR = _IMP_kmeans.IMP_COMPILER_HAS_DEBUG_VECTOR
236 IMP_COMPILER_HAS_UNIQUE_PTR = _IMP_kmeans.IMP_COMPILER_HAS_UNIQUE_PTR
237 IMP_KERNEL_HAS_BOOST_RANDOM = _IMP_kmeans.IMP_KERNEL_HAS_BOOST_RANDOM
238 IMP_KERNEL_HAS_NUMPY = _IMP_kmeans.IMP_KERNEL_HAS_NUMPY
239 IMP_KERNEL_HAS_GPERFTOOLS = _IMP_kmeans.IMP_KERNEL_HAS_GPERFTOOLS
240 IMP_KERNEL_HAS_TCMALLOC_HEAPCHECKER = _IMP_kmeans.IMP_KERNEL_HAS_TCMALLOC_HEAPCHECKER
241 IMP_KERNEL_HAS_TCMALLOC_HEAPPROFILER = _IMP_kmeans.IMP_KERNEL_HAS_TCMALLOC_HEAPPROFILER
242 IMPKERNEL_SHOW_WARNINGS = _IMP_kmeans.IMPKERNEL_SHOW_WARNINGS
243 
244 import sys
245 class _DirectorObjects(object):
246  """@internal Simple class to keep references to director objects
247  to prevent premature deletion."""
248  def __init__(self):
249  self._objects = []
250  def register(self, obj):
251  """Take a reference to a director object; will only work for
252  refcounted C++ classes"""
253  if hasattr(obj, 'get_ref_count'):
254  self._objects.append(obj)
255  def cleanup(self):
256  """Only drop our reference and allow cleanup by Python if no other
257  Python references exist (we hold 3 references: one in self._objects,
258  one in x, and one in the argument list for getrefcount) *and* no
259  other C++ references exist (the Python object always holds one)"""
260  objs = [x for x in self._objects if sys.getrefcount(x) > 3 \
261  or x.get_ref_count() > 1]
262 # Do in two steps so the references are kept until the end of the
263 # function (deleting references may trigger a fresh call to this method)
264  self._objects = objs
265  def get_object_count(self):
266  """Get number of director objects (useful for testing only)"""
267  return len(self._objects)
268 _director_objects = _DirectorObjects()
269 
270 class _ostream(object):
271  """Proxy of C++ std::ostream class."""
272 
273  thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
274 
275  def __init__(self, *args, **kwargs):
276  raise AttributeError("No constructor defined")
277  __repr__ = _swig_repr
278 
279  def write(self, osa_buf):
280  """write(_ostream self, char const * osa_buf)"""
281  return _IMP_kmeans._ostream_write(self, osa_buf)
282 
283 _ostream_swigregister = _IMP_kmeans._ostream_swigregister
284 _ostream_swigregister(_ostream)
285 
286 IMP_COMPILER_HAS_OVERRIDE = _IMP_kmeans.IMP_COMPILER_HAS_OVERRIDE
287 IMP_COMPILER_HAS_FINAL = _IMP_kmeans.IMP_COMPILER_HAS_FINAL
288 IMP_HAS_NOEXCEPT = _IMP_kmeans.IMP_HAS_NOEXCEPT
289 IMP_C_OPEN_BINARY = _IMP_kmeans.IMP_C_OPEN_BINARY
290 import IMP
291 IMP_KMEANS_HAS_BOOST_FILESYSTEM = _IMP_kmeans.IMP_KMEANS_HAS_BOOST_FILESYSTEM
292 IMP_KMEANS_HAS_BOOST_PROGRAMOPTIONS = _IMP_kmeans.IMP_KMEANS_HAS_BOOST_PROGRAMOPTIONS
293 IMP_KMEANS_HAS_BOOST_RANDOM = _IMP_kmeans.IMP_KMEANS_HAS_BOOST_RANDOM
294 IMP_KMEANS_HAS_BOOST_SYSTEM = _IMP_kmeans.IMP_KMEANS_HAS_BOOST_SYSTEM
295 IMP_KMEANS_HAS_NUMPY = _IMP_kmeans.IMP_KMEANS_HAS_NUMPY
296 IMPKMEANS_SHOW_WARNINGS = _IMP_kmeans.IMPKMEANS_SHOW_WARNINGS
297 
298 _object_types.append("KMeans")
299 
300 
301 def _object_cast_to_KMeans(o):
302  """_object_cast_to_KMeans(Object o) -> KMeans"""
303  return _IMP_kmeans._object_cast_to_KMeans(o)
304 KM_LLOYDS = _IMP_kmeans.KM_LLOYDS
305 KM_LOCAL_SWAP = _IMP_kmeans.KM_LOCAL_SWAP
306 KM_LOCAL_EZ_HYBRID = _IMP_kmeans.KM_LOCAL_EZ_HYBRID
307 KM_HYBRID = _IMP_kmeans.KM_HYBRID
308 class KMeans(IMP.Object):
309  """Proxy of C++ IMP::kmeans::KMeans class."""
310 
311  thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
312 
313  def __init__(self, *args):
314  """
315  __init__(IMP::kmeans::KMeans self, std::string const & fname_data, int dim, unsigned int max_nPts) -> KMeans
316  __init__(IMP::kmeans::KMeans self) -> KMeans
317  """
318  this = _IMP_kmeans.new_KMeans(*args)
319  try:
320  self.this.append(this)
321  except __builtin__.Exception:
322  self.this = this
323 
324  def get_version_info(self):
325  """get_version_info(KMeans self) -> VersionInfo"""
326  return _IMP_kmeans.KMeans_get_version_info(self)
327 
328 
329  def execute(self, *args):
330  """
331  execute(KMeans self, unsigned int k, IMP::kmeans::KM_ALG_TYPE alg_type, int stages=100)
332  execute(KMeans self, unsigned int k, IMP::kmeans::KM_ALG_TYPE alg_type)
333  execute(KMeans self, unsigned int k)
334  """
335  return _IMP_kmeans.KMeans_execute(self, *args)
336 
337 
338  def add_data_pt(self, p):
339  """add_data_pt(KMeans self, IMP::Floats const & p)"""
340  return _IMP_kmeans.KMeans_add_data_pt(self, p)
341 
342 
343  def clear_data(self):
344  """clear_data(KMeans self)"""
345  return _IMP_kmeans.KMeans_clear_data(self)
346 
347 
348  def get_data_point(self, i):
349  """get_data_point(KMeans self, unsigned int i) -> IMP::Floats const &"""
350  return _IMP_kmeans.KMeans_get_data_point(self, i)
351 
352 
353  def get_number_of_data_points(self):
354  """get_number_of_data_points(KMeans self) -> unsigned int"""
355  return _IMP_kmeans.KMeans_get_number_of_data_points(self)
356 
357 
358  def print_centers(self, *args):
359  """
360  print_centers(KMeans self, IMP::LogLevel ll)
361  print_centers(KMeans self)
362  """
363  return _IMP_kmeans.KMeans_print_centers(self, *args)
364 
365 
366  def get_center(self, i):
367  """get_center(KMeans self, unsigned int i) -> IMP::Floats"""
368  return _IMP_kmeans.KMeans_get_center(self, i)
369 
370 
371  def get_assignments(self):
372  """get_assignments(KMeans self) -> IMP::Ints"""
373  return _IMP_kmeans.KMeans_get_assignments(self)
374 
375 
376  def get_squared_distance_to_centers(self):
377  """get_squared_distance_to_centers(KMeans self) -> IMP::Floats"""
378  return _IMP_kmeans.KMeans_get_squared_distance_to_centers(self)
379 
380 
381  def get_number_of_centers(self):
382  """get_number_of_centers(KMeans self) -> unsigned int"""
383  return _IMP_kmeans.KMeans_get_number_of_centers(self)
384 
385 
386  def __str__(self):
387  """__str__(KMeans self) -> std::string"""
388  return _IMP_kmeans.KMeans___str__(self)
389 
390 
391  def __repr__(self):
392  """__repr__(KMeans self) -> std::string"""
393  return _IMP_kmeans.KMeans___repr__(self)
394 
395 
396  @staticmethod
397  def get_from(o):
398  return _object_cast_to_KMeans(o)
399 
400 KMeans_swigregister = _IMP_kmeans.KMeans_swigregister
401 KMeans_swigregister(KMeans)
402 
403 
404 def get_module_version():
405  """get_module_version() -> std::string const"""
406  return _IMP_kmeans.get_module_version()
407 
408 def get_example_path(fname):
409  """get_example_path(std::string fname) -> std::string"""
410  return _IMP_kmeans.get_example_path(fname)
411 
412 def get_data_path(fname):
413  """get_data_path(std::string fname) -> std::string"""
414  return _IMP_kmeans.get_data_path(fname)
415 
416 from . import _version_check
417 _version_check.check_version(get_module_version())
418 __version__ = get_module_version()
419 
420 
421 
Common base class for heavy weight IMP objects.
Definition: Object.h:106
std::string get_module_version()
Return the version of this module, as a string.
virtual VersionInfo get_version_info() const
Get information about the module and version of the object.
Definition: Object.h:173
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
std::string get_data_path(std::string file_name)
Return the full path to one of this module's data files.