IMP logo
IMP Reference Guide  2.20.1
The Integrative Modeling Platform
kmeans/__init__.py
1 # This file was automatically generated by SWIG (https://www.swig.org).
2 # Version 4.1.1
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 
8 # This wrapper is part of IMP,
9 # Copyright 2007-2024 IMP Inventors. All rights reserved.
10 
11 from __future__ import print_function, division, absolute_import
12 
13 
14 
15 from sys import version_info as _swig_python_version_info
16 import _IMP_kmeans
17 
18 try:
19  import builtins as __builtin__
20 except ImportError:
21  import __builtin__
22 
23 def _swig_repr(self):
24  try:
25  strthis = "proxy of " + self.this.__repr__()
26  except __builtin__.Exception:
27  strthis = ""
28  return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
29 
30 
31 def _swig_setattr_nondynamic_instance_variable(set):
32  def set_instance_attr(self, name, value):
33  if name == "this":
34  set(self, name, value)
35  elif name == "thisown":
36  self.this.own(value)
37  elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
38  set(self, name, value)
39  else:
40  raise AttributeError("You cannot add instance attributes to %s" % self)
41  return set_instance_attr
42 
43 
44 def _swig_setattr_nondynamic_class_variable(set):
45  def set_class_attr(cls, name, value):
46  if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
47  set(cls, name, value)
48  else:
49  raise AttributeError("You cannot add class attributes to %s" % cls)
50  return set_class_attr
51 
52 
53 def _swig_add_metaclass(metaclass):
54  """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
55  def wrapper(cls):
56  return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
57  return wrapper
58 
59 
60 class _SwigNonDynamicMeta(type):
61  """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
62  __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
63 
64 
65 import weakref
66 
67 class IMP_KMEANS_SwigPyIterator(object):
68  r"""Proxy of C++ swig::IMP_KMEANS_SwigPyIterator class."""
69 
70  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
71 
72  def __init__(self, *args, **kwargs):
73  raise AttributeError("No constructor defined - class is abstract")
74  __repr__ = _swig_repr
75  __swig_destroy__ = _IMP_kmeans.delete_IMP_KMEANS_SwigPyIterator
76 
77  def value(self):
78  r"""value(IMP_KMEANS_SwigPyIterator self) -> PyObject *"""
79  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_value(self)
80 
81  def incr(self, n=1):
82  r"""incr(IMP_KMEANS_SwigPyIterator self, size_t n=1) -> IMP_KMEANS_SwigPyIterator"""
83  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_incr(self, n)
84 
85  def decr(self, n=1):
86  r"""decr(IMP_KMEANS_SwigPyIterator self, size_t n=1) -> IMP_KMEANS_SwigPyIterator"""
87  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_decr(self, n)
88 
89  def distance(self, x):
90  r"""distance(IMP_KMEANS_SwigPyIterator self, IMP_KMEANS_SwigPyIterator x) -> ptrdiff_t"""
91  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_distance(self, x)
92 
93  def equal(self, x):
94  r"""equal(IMP_KMEANS_SwigPyIterator self, IMP_KMEANS_SwigPyIterator x) -> bool"""
95  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_equal(self, x)
96 
97  def copy(self):
98  r"""copy(IMP_KMEANS_SwigPyIterator self) -> IMP_KMEANS_SwigPyIterator"""
99  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_copy(self)
100 
101  def next(self):
102  r"""next(IMP_KMEANS_SwigPyIterator self) -> PyObject *"""
103  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_next(self)
104 
105  def __next__(self):
106  r"""__next__(IMP_KMEANS_SwigPyIterator self) -> PyObject *"""
107  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___next__(self)
108 
109  def previous(self):
110  r"""previous(IMP_KMEANS_SwigPyIterator self) -> PyObject *"""
111  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_previous(self)
112 
113  def advance(self, n):
114  r"""advance(IMP_KMEANS_SwigPyIterator self, ptrdiff_t n) -> IMP_KMEANS_SwigPyIterator"""
115  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator_advance(self, n)
116 
117  def __eq__(self, x):
118  r"""__eq__(IMP_KMEANS_SwigPyIterator self, IMP_KMEANS_SwigPyIterator x) -> bool"""
119  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___eq__(self, x)
120 
121  def __ne__(self, x):
122  r"""__ne__(IMP_KMEANS_SwigPyIterator self, IMP_KMEANS_SwigPyIterator x) -> bool"""
123  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___ne__(self, x)
124 
125  def __iadd__(self, n):
126  r"""__iadd__(IMP_KMEANS_SwigPyIterator self, ptrdiff_t n) -> IMP_KMEANS_SwigPyIterator"""
127  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___iadd__(self, n)
128 
129  def __isub__(self, n):
130  r"""__isub__(IMP_KMEANS_SwigPyIterator self, ptrdiff_t n) -> IMP_KMEANS_SwigPyIterator"""
131  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___isub__(self, n)
132 
133  def __add__(self, n):
134  r"""__add__(IMP_KMEANS_SwigPyIterator self, ptrdiff_t n) -> IMP_KMEANS_SwigPyIterator"""
135  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___add__(self, n)
136 
137  def __sub__(self, *args):
138  r"""
139  __sub__(IMP_KMEANS_SwigPyIterator self, ptrdiff_t n) -> IMP_KMEANS_SwigPyIterator
140  __sub__(IMP_KMEANS_SwigPyIterator self, IMP_KMEANS_SwigPyIterator x) -> ptrdiff_t
141  """
142  return _IMP_kmeans.IMP_KMEANS_SwigPyIterator___sub__(self, *args)
143  def __iter__(self):
144  return self
145 
146 # Register IMP_KMEANS_SwigPyIterator in _IMP_kmeans:
147 _IMP_kmeans.IMP_KMEANS_SwigPyIterator_swigregister(IMP_KMEANS_SwigPyIterator)
148 
149 _value_types=[]
150 _object_types=[]
151 _raii_types=[]
152 _plural_types=[]
153 
154 IMP_DEBUG = _IMP_kmeans.IMP_DEBUG
155 
156 IMP_RELEASE = _IMP_kmeans.IMP_RELEASE
157 
158 IMP_SILENT = _IMP_kmeans.IMP_SILENT
159 
160 IMP_PROGRESS = _IMP_kmeans.IMP_PROGRESS
161 
162 IMP_TERSE = _IMP_kmeans.IMP_TERSE
163 
164 IMP_VERBOSE = _IMP_kmeans.IMP_VERBOSE
165 
166 IMP_MEMORY = _IMP_kmeans.IMP_MEMORY
167 
168 IMP_NONE = _IMP_kmeans.IMP_NONE
169 
170 IMP_USAGE = _IMP_kmeans.IMP_USAGE
171 
172 IMP_INTERNAL = _IMP_kmeans.IMP_INTERNAL
173 
174 IMP_KERNEL_HAS_LOG4CXX = _IMP_kmeans.IMP_KERNEL_HAS_LOG4CXX
175 
176 IMP_COMPILER_HAS_CEREAL_RAW_POINTER = _IMP_kmeans.IMP_COMPILER_HAS_CEREAL_RAW_POINTER
177 
178 IMP_COMPILER_HAS_DEBUG_VECTOR = _IMP_kmeans.IMP_COMPILER_HAS_DEBUG_VECTOR
179 
180 IMP_COMPILER_HAS_RANDOM_SHUFFLE = _IMP_kmeans.IMP_COMPILER_HAS_RANDOM_SHUFFLE
181 
182 IMP_COMPILER_HAS_THREE_WAY = _IMP_kmeans.IMP_COMPILER_HAS_THREE_WAY
183 
184 IMP_KERNEL_HAS_BOOST_RANDOM = _IMP_kmeans.IMP_KERNEL_HAS_BOOST_RANDOM
185 
186 IMP_KERNEL_HAS_NUMPY = _IMP_kmeans.IMP_KERNEL_HAS_NUMPY
187 
188 IMP_KERNEL_HAS_GPERFTOOLS = _IMP_kmeans.IMP_KERNEL_HAS_GPERFTOOLS
189 
190 IMP_KERNEL_HAS_TCMALLOC_HEAPCHECKER = _IMP_kmeans.IMP_KERNEL_HAS_TCMALLOC_HEAPCHECKER
191 
192 IMP_KERNEL_HAS_TCMALLOC_HEAPPROFILER = _IMP_kmeans.IMP_KERNEL_HAS_TCMALLOC_HEAPPROFILER
193 
194 IMPKERNEL_SHOW_WARNINGS = _IMP_kmeans.IMPKERNEL_SHOW_WARNINGS
195 
196 
197 import sys
198 class _DirectorObjects(object):
199  """@internal Simple class to keep references to director objects
200  to prevent premature deletion."""
201  def __init__(self):
202  self._objects = []
203  def register(self, obj):
204  """Take a reference to a director object; will only work for
205  refcounted C++ classes"""
206  if hasattr(obj, 'get_ref_count'):
207  self._objects.append(obj)
208  def cleanup(self):
209  """Only drop our reference and allow cleanup by Python if no other
210  Python references exist (we hold 3 references: one in self._objects,
211  one in x, and one in the argument list for getrefcount) *and* no
212  other C++ references exist (the Python object always holds one)"""
213  objs = [x for x in self._objects if sys.getrefcount(x) > 3 \
214  or x.get_ref_count() > 1]
215 # Do in two steps so the references are kept until the end of the
216 # function (deleting references may trigger a fresh call to this method)
217  self._objects = objs
218  def get_object_count(self):
219  """Get number of director objects (useful for testing only)"""
220  return len(self._objects)
221 _director_objects = _DirectorObjects()
222 
223 class _ostream(object):
224  r"""Proxy of C++ std::ostream class."""
225 
226  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
227 
228  def __init__(self, *args, **kwargs):
229  raise AttributeError("No constructor defined")
230  __repr__ = _swig_repr
231 
232  def write(self, osa_buf):
233  r"""write(_ostream self, char const * osa_buf)"""
234  return _IMP_kmeans._ostream_write(self, osa_buf)
235 
236 # Register _ostream in _IMP_kmeans:
237 _IMP_kmeans._ostream_swigregister(_ostream)
238 IMP_C_OPEN_BINARY = _IMP_kmeans.IMP_C_OPEN_BINARY
239 
240 import IMP
241 IMP_KMEANS_HAS_BOOST_FILESYSTEM = _IMP_kmeans.IMP_KMEANS_HAS_BOOST_FILESYSTEM
242 
243 IMP_KMEANS_HAS_BOOST_PROGRAMOPTIONS = _IMP_kmeans.IMP_KMEANS_HAS_BOOST_PROGRAMOPTIONS
244 
245 IMP_KMEANS_HAS_BOOST_RANDOM = _IMP_kmeans.IMP_KMEANS_HAS_BOOST_RANDOM
246 
247 IMP_KMEANS_HAS_BOOST_SYSTEM = _IMP_kmeans.IMP_KMEANS_HAS_BOOST_SYSTEM
248 
249 IMP_KMEANS_HAS_NUMPY = _IMP_kmeans.IMP_KMEANS_HAS_NUMPY
250 
251 IMPKMEANS_SHOW_WARNINGS = _IMP_kmeans.IMPKMEANS_SHOW_WARNINGS
252 
253 
254 _object_types.append("KMeans")
255 
256 
257 def _object_cast_to_KMeans(o):
258  r"""_object_cast_to_KMeans(Object o) -> KMeans"""
259  return _IMP_kmeans._object_cast_to_KMeans(o)
260 KM_LLOYDS = _IMP_kmeans.KM_LLOYDS
261 
262 KM_LOCAL_SWAP = _IMP_kmeans.KM_LOCAL_SWAP
263 
264 KM_LOCAL_EZ_HYBRID = _IMP_kmeans.KM_LOCAL_EZ_HYBRID
265 
266 KM_HYBRID = _IMP_kmeans.KM_HYBRID
267 
268 class KMeans(IMP.Object):
269  r"""Proxy of C++ IMP::kmeans::KMeans class."""
270 
271  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
272 
273  def __init__(self, *args):
274  r"""
275  __init__(KMeans self, std::string const & fname_data, int dim, unsigned int max_nPts) -> KMeans
276  __init__(KMeans self) -> KMeans
277  """
278  _IMP_kmeans.KMeans_swiginit(self, _IMP_kmeans.new_KMeans(*args))
279 
280  def get_version_info(self):
281  r"""get_version_info(KMeans self) -> VersionInfo"""
282  return _IMP_kmeans.KMeans_get_version_info(self)
283  __swig_destroy__ = _IMP_kmeans.delete_KMeans
284 
285  def execute(self, *args):
286  r"""execute(KMeans self, unsigned int k, IMP::kmeans::KM_ALG_TYPE alg_type=KM_LLOYDS, int stages=100)"""
287  return _IMP_kmeans.KMeans_execute(self, *args)
288 
289  def add_data_pt(self, p):
290  r"""add_data_pt(KMeans self, IMP::Floats const & p)"""
291  return _IMP_kmeans.KMeans_add_data_pt(self, p)
292 
293  def clear_data(self):
294  r"""clear_data(KMeans self)"""
295  return _IMP_kmeans.KMeans_clear_data(self)
296 
297  def get_data_point(self, i):
298  r"""get_data_point(KMeans self, unsigned int i) -> IMP::Floats const &"""
299  return _IMP_kmeans.KMeans_get_data_point(self, i)
300 
301  def get_number_of_data_points(self):
302  r"""get_number_of_data_points(KMeans self) -> unsigned int"""
303  return _IMP_kmeans.KMeans_get_number_of_data_points(self)
304 
305  def print_centers(self, *args):
306  r"""print_centers(KMeans self, IMP::LogLevel ll=PROGRESS)"""
307  return _IMP_kmeans.KMeans_print_centers(self, *args)
308 
309  def get_center(self, i):
310  r"""get_center(KMeans self, unsigned int i) -> IMP::Floats"""
311  return _IMP_kmeans.KMeans_get_center(self, i)
312 
313  def get_assignments(self):
314  r"""get_assignments(KMeans self) -> IMP::Ints"""
315  return _IMP_kmeans.KMeans_get_assignments(self)
316 
317  def get_squared_distance_to_centers(self):
318  r"""get_squared_distance_to_centers(KMeans self) -> IMP::Floats"""
319  return _IMP_kmeans.KMeans_get_squared_distance_to_centers(self)
320 
321  def get_number_of_centers(self):
322  r"""get_number_of_centers(KMeans self) -> unsigned int"""
323  return _IMP_kmeans.KMeans_get_number_of_centers(self)
324 
325  def __str__(self):
326  r"""__str__(KMeans self) -> std::string"""
327  return _IMP_kmeans.KMeans___str__(self)
328 
329  def __repr__(self):
330  r"""__repr__(KMeans self) -> std::string"""
331  return _IMP_kmeans.KMeans___repr__(self)
332 
333  @staticmethod
334  def get_from(o):
335  return _object_cast_to_KMeans(o)
336 
337 
338 # Register KMeans in _IMP_kmeans:
339 _IMP_kmeans.KMeans_swigregister(KMeans)
340 
341 def get_module_version():
342  r"""get_module_version() -> std::string const"""
343  return _IMP_kmeans.get_module_version()
344 
345 def get_example_path(fname):
346  r"""get_example_path(std::string fname) -> std::string"""
347  return _IMP_kmeans.get_example_path(fname)
348 
349 def get_data_path(fname):
350  r"""get_data_path(std::string fname) -> std::string"""
351  return _IMP_kmeans.get_data_path(fname)
352 
353 from . import _version_check
354 _version_check.check_version(get_module_version())
355 __version__ = get_module_version()
356 
357 
Common base class for heavy weight IMP objects.
Definition: Object.h:111
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:206
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.