Skip to content

Commit

Permalink
boost_adaptbx: change imports
Browse files Browse the repository at this point in the history
- import boost_adaptbx.python -> import boost_adaptbx.boost.python as bp
- boost_adaptbx.optional -> boost_adaptbx.boost.optional
- boost_adaptbx.rational -> boost_adaptbx.boost.rational
- boost_adaptbx.std_pair -> boost_adaptbx.boost.std_pair
- boost_adaptbx.tuple -> boost_adaptbx.boost.tuple
- from boost_adaptbx import -> from boost_adaptbx.boost import (except for graph)
  • Loading branch information
bkpoon committed Aug 19, 2020
1 parent 0d50f14 commit 0300bb1
Show file tree
Hide file tree
Showing 264 changed files with 692 additions and 708 deletions.
4 changes: 2 additions & 2 deletions boost/optional.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import absolute_import, division, print_function
from boost_adaptbx.optional import *
from boost_adaptbx.boost.optional import *
import warnings

warnings.warn(
"importing from boost.optional is deprecated; this module will be removed shortly. "
"import from boost_adaptbx.optional instead. "
"import from boost_adaptbx.boost.optional instead. "
"Please see https://github.com/cctbx/cctbx_project/issues/458 for more information.",
FutureWarning,
stacklevel=2
Expand Down
6 changes: 3 additions & 3 deletions boost/python.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import absolute_import, division, print_function
from boost_adaptbx.python import *
from boost_adaptbx.boost.python import *
import warnings

warnings.warn(
"importing from boost.python is deprecated; this module will be removed shortly. "
"import from boost_adaptbx.python instead. "
"import from boost_adaptbx.boost.python instead. "
"Please see https://github.com/cctbx/cctbx_project/issues/458 for more information.",
FutureWarning,
stacklevel=2
Expand All @@ -18,7 +18,7 @@ class CrystalExt(boost.python.injector, Crystal):
please use
@boost_adaptbx.python.inject_into(Crystal)
@boost_adaptbx.boost.python.inject_into(Crystal)
class _(object):
'''
class __metaclass__(meta_class):
Expand Down
4 changes: 2 additions & 2 deletions boost/rational.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import absolute_import, division, print_function
from boost_adaptbx.rational import *
from boost_adaptbx.boost.rational import *
import warnings

warnings.warn(
"importing from boost.rational is deprecated; this module will be removed shortly. "
"import from boost_adaptbx.rational instead. "
"import from boost_adaptbx.boost.rational instead. "
"Please see https://github.com/cctbx/cctbx_project/issues/458 for more information.",
FutureWarning,
stacklevel=2
Expand Down
4 changes: 2 additions & 2 deletions boost/std_pair.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import absolute_import, division, print_function
from boost_adaptbx.std_pair import *
from boost_adaptbx.boost.std_pair import *
import warnings

warnings.warn(
"importing from boost.std_pair is deprecated; this module will be removed shortly. "
"import from boost_adaptbx.std_pair instead. "
"import from boost_adaptbx.boost.std_pair instead. "
"Please see https://github.com/cctbx/cctbx_project/issues/458 for more information.",
FutureWarning,
stacklevel=2
Expand Down
4 changes: 2 additions & 2 deletions boost/tuple.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import absolute_import, division, print_function
from boost_adaptbx.tuple import *
from boost_adaptbx.boost.tuple import *
import warnings

warnings.warn(
"importing from boost.tuple is deprecated; this module will be removed shortly. "
"import from boost_adaptbx.tuple instead. "
"import from boost_adaptbx.boost.tuple instead. "
"Please see https://github.com/cctbx/cctbx_project/issues/458 for more information.",
FutureWarning,
stacklevel=2
Expand Down
4 changes: 2 additions & 2 deletions boost_adaptbx/boost/optional.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import absolute_import, division, print_function
import boost_adaptbx.python
ext = boost_adaptbx.python.import_ext("boost_optional_ext")
import boost_adaptbx.boost.python as bp
ext = bp.import_ext("boost_optional_ext")
from boost_optional_ext import *
12 changes: 6 additions & 6 deletions boost_adaptbx/boost/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def fset(self, flag):
class trapping(object):
""" Synopsis:
>>> import boost_adaptbx.python
>>> import boost_adaptbx.boost.python as bp
>>> from scitbx.array_family import flex
>>> a = flex.double((0, 0, 0))
>>> with boost_adaptbx.python.trapping(division_by_zero=False):
>>> with bp.trapping(division_by_zero=False):
>>> b = 1/a
>>> tuple(b)
(inf, inf, inf)
Expand Down Expand Up @@ -154,7 +154,7 @@ def c_sizeof(typename):
if (line.startswith(pattern)):
break
else:
raise RuntimeError('boost_adaptbx.python.platform_info: "%s" not found.' % pattern)
raise RuntimeError('bp.platform_info: "%s" not found.' % pattern)
return int(line[len(pattern):])

sizeof_void_ptr = c_sizeof("void*")
Expand Down Expand Up @@ -193,11 +193,11 @@ def inject(target_class, *mixin_classes):
class _():
def method(...):
...
boost_adaptbx.python.inject(extension_class, _)
bp.inject(extension_class, _)
instead of the previous mechanism of
class _(boost_adaptbx.python.injector, extension_class):
class _(bp.injector, extension_class):
def method(...):
...
Expand All @@ -217,7 +217,7 @@ def inject_into(target_class, *mixin_classes):
It is used as follows:
@boost_adaptbx.python.inject_into(extension_class)
@bp.inject_into(extension_class)
class _():
def method(...):
...
Expand Down
4 changes: 2 additions & 2 deletions boost_adaptbx/boost/rational.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import, division, print_function
import boost_adaptbx.python
import boost_adaptbx.boost.python as bp
from six.moves import range
ext = boost_adaptbx.python.import_ext("boost_rational_ext")
ext = bp.import_ext("boost_rational_ext")
from boost_rational_ext import *

builtin_int = __builtins__["int"]
Expand Down
4 changes: 2 additions & 2 deletions boost_adaptbx/boost/std_pair.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import absolute_import, division, print_function
import boost_adaptbx.python
ext = boost_adaptbx.python.import_ext("std_pair_ext")
import boost_adaptbx.boost.python as bp
ext = bp.import_ext("std_pair_ext")
from std_pair_ext import *
4 changes: 2 additions & 2 deletions boost_adaptbx/boost/tuple.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import absolute_import, division, print_function
import boost_adaptbx.python
ext = boost_adaptbx.python.import_ext("boost_tuple_ext")
import boost_adaptbx.boost.python as bp
ext = bp.import_ext("boost_tuple_ext")
from boost_tuple_ext import *
12 changes: 6 additions & 6 deletions boost_adaptbx/command_line/divide_by_zero.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

# LIBTBX_SET_DISPATCHER_NAME boost_adaptbx.divide_by_zero

import boost_adaptbx.python
import boost_adaptbx.boost.python as bp
import sys

def run(args):
assert len(args) <= 1
if len(args) == 0:
print("Now dividing by zero (in C++) ...")
sys.stdout.flush()
result = boost_adaptbx.python.ext.divide_doubles(1, 0)
result = bp.ext.divide_doubles(1, 0)
print("Result:", result)
else:
boost_adaptbx.python.floating_point_exceptions.division_by_zero_trapped = False
bp.floating_point_exceptions.division_by_zero_trapped = False
print("Dividing by zero in C++: not gonna be caught")
result = boost_adaptbx.python.ext.divide_doubles(1, 0)
result = bp.ext.divide_doubles(1, 0)
print("Result:", result)
boost_adaptbx.python.floating_point_exceptions.division_by_zero_trapped = True
bp.floating_point_exceptions.division_by_zero_trapped = True
print()
print("Dividing by zero in C++: gonna crash")
sys.stdout.flush()
result = boost_adaptbx.python.ext.divide_doubles(1, 0)
result = bp.ext.divide_doubles(1, 0)
print("Result:", result)

if (__name__ == "__main__"):
Expand Down
6 changes: 3 additions & 3 deletions boost_adaptbx/command_line/double_overflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

# LIBTBX_SET_DISPATCHER_NAME boost_adaptbx.double_overflow

import boost_adaptbx.python
import boost_adaptbx.boost.python as bp
import sys

def run(args):
assert len(args) == 0
sizeof_double = boost_adaptbx.python.c_sizeof("double")
sizeof_double = bp.c_sizeof("double")
assert sizeof_double == 8
x = 1.e300
y = 1.e200
print("Now multiplying double values %g * %g ..." % (x, y))
sys.stdout.flush()
result = boost_adaptbx.python.ext.multiply_doubles(x, y)
result = bp.ext.multiply_doubles(x, y)
print("Result:", result)

if (__name__ == "__main__"):
Expand Down
2 changes: 1 addition & 1 deletion boost_adaptbx/command_line/gcd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import absolute_import, division, print_function

from boost_adaptbx.rational import gcd
from boost_adaptbx.boost.rational import gcd
from libtbx.utils import Usage
import libtbx.load_env
import sys
Expand Down
4 changes: 2 additions & 2 deletions boost_adaptbx/command_line/inexact.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

# LIBTBX_SET_DISPATCHER_NAME boost_adaptbx.inexact

import boost_adaptbx.python
import boost_adaptbx.boost.python as bp
import sys

def run(args):
assert len(args) == 0
print("Now creating a NaN in C++ as 0/0 ...")
sys.stdout.flush()
result = boost_adaptbx.python.ext.divide_doubles(0, 0)
result = bp.ext.divide_doubles(0, 0)
print("Result:", result)

if (__name__ == "__main__"):
Expand Down
6 changes: 3 additions & 3 deletions boost_adaptbx/command_line/int_overflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

# LIBTBX_SET_DISPATCHER_NAME boost_adaptbx.int_overflow

import boost_adaptbx.python
import boost_adaptbx.boost.python as bp
import sys

def run(args):
assert len(args) == 0
for itype in ["int", "long"]:
sizeof_itype = boost_adaptbx.python.c_sizeof(itype)
sizeof_itype = bp.c_sizeof(itype)
imax = 2**(8*sizeof_itype-1)-1
print("Now adding %s values %d + 1 ..." % (itype, imax))
sys.stdout.flush()
result = getattr(boost_adaptbx.python.ext, "add_%ss" % itype)(imax, 1)
result = getattr(bp.ext, "add_%ss" % itype)(imax, 1)
print("Result:", result)

if (__name__ == "__main__"):
Expand Down
2 changes: 1 addition & 1 deletion boost_adaptbx/command_line/lcm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import absolute_import, division, print_function
import gcd
from boost_adaptbx.rational import lcm
from boost_adaptbx.boost.rational import lcm
import sys

def run(args):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

def run(args):
assert len(args) == 2, "iterations_outer, iterations_inner"
import boost_adaptbx.python
count = boost_adaptbx.python.ext.nested_cpp_loops_with_check_signals(
import boost_adaptbx.boost.python as bp
count = bp.ext.nested_cpp_loops_with_check_signals(
iterations_outer=int(args[0]),
iterations_inner=int(args[1]))
print("actual iterations outer:", count)
Expand Down
4 changes: 2 additions & 2 deletions boost_adaptbx/command_line/segmentation_fault.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

# LIBTBX_SET_DISPATCHER_NAME boost_adaptbx.segmentation_fault

import boost_adaptbx.python
import boost_adaptbx.boost.python as bp
import sys

def run(args):
assert len(args) == 0
print("Now dereferencing null-pointer ...")
sys.stdout.flush()
result = boost_adaptbx.python.ext.dereference_char_pointer(None)
result = bp.ext.dereference_char_pointer(None)
print("Result:", result)

if (__name__ == "__main__"):
Expand Down
8 changes: 4 additions & 4 deletions boost_adaptbx/command_line/show_platform_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# LIBTBX_SET_DISPATCHER_NAME boost_adaptbx.show_platform_info

import boost_adaptbx.python
import boost_adaptbx.boost.python as bp
from libtbx import introspection
import libtbx.load_env
import platform
Expand All @@ -15,7 +15,7 @@ def __truediv__(O, other): return "true"

def run(out=None, omit_unicode_experiment=False):
if (out is None): out = sys.stdout
out.write(boost_adaptbx.python.platform_info)
out.write(bp.platform_info)
tag = libtbx.env.under_dist("boost", "TAG")
if (op.isfile(tag)):
tag = open(tag).read().strip()
Expand All @@ -29,15 +29,15 @@ def run(out=None, omit_unicode_experiment=False):
print("platform.architecture():", platform.architecture(), file=out)
for attr in ["division_by_zero", "invalid", "overflow"]:
attr = "floating_point_exceptions.%s_trapped" % attr
print("%s:" % attr, eval("boost_adaptbx.python.%s" % attr), file=out)
print("%s:" % attr, eval("bp.%s" % attr), file=out)
print("number of processors:", introspection.number_of_processors(
return_value_if_unknown="unknown"), file=out)
introspection.machine_memory_info().show(out=out)
try: import thread
except ImportError: print("import thread: NO", file=out)
else: print("import thread: OK", file=out)
print("Division operator semantics: %s division" % (div_probe() / 0))
c = getattr(boost_adaptbx.python.ext, "str_or_unicode_as_char_list", None)
c = getattr(bp.ext, "str_or_unicode_as_char_list", None)
if (c is not None and not omit_unicode_experiment):
print('"hello" =', c("hello"), file=out)
print('u"hello" =', c(u"hello"), file=out)
Expand Down
5 changes: 2 additions & 3 deletions boost_adaptbx/graph/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import, division, print_function

import boost_adaptbx.python
ext = boost_adaptbx.python.import_ext( "boost_adaptbx_graph_ext" )
import boost_adaptbx.boost.python as bp
ext = bp.import_ext( "boost_adaptbx_graph_ext" )
from boost_adaptbx_graph_ext import *

_abbreviation_for_component = {
Expand Down Expand Up @@ -42,4 +42,3 @@ def adjacency_list(

except AttributeError:
raise NotImplementedError

5 changes: 2 additions & 3 deletions boost_adaptbx/graph/breadth_first_search.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import, division, print_function

import boost_adaptbx.python
ext = boost_adaptbx.python.import_ext( "boost_adaptbx_graph_breadth_first_search_ext" )
import boost_adaptbx.boost.python as bp
ext = bp.import_ext( "boost_adaptbx_graph_breadth_first_search_ext" )
from boost_adaptbx_graph_breadth_first_search_ext import *

class visitor(object):
Expand Down Expand Up @@ -121,4 +121,3 @@ def tree_edge(self, edge, graph):
source = graph.source( edge )
target = graph.target( edge )
self.distance_for[ target ] = self.distance_for[ source ] + 1

4 changes: 2 additions & 2 deletions boost_adaptbx/graph/clustering_algorithm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import absolute_import, division, print_function

import boost_adaptbx.python
ext = boost_adaptbx.python.import_ext( "boost_adaptbx_graph_clustering_algorithm_ext" )
import boost_adaptbx.boost.python as bp
ext = bp.import_ext( "boost_adaptbx_graph_clustering_algorithm_ext" )

from boost_adaptbx_graph_clustering_algorithm_ext import *
5 changes: 2 additions & 3 deletions boost_adaptbx/graph/connected_component_algorithm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import, division, print_function

import boost_adaptbx.python
ext = boost_adaptbx.python.import_ext( "boost_adaptbx_graph_connected_component_algorithm_ext" )
import boost_adaptbx.boost.python as bp
ext = bp.import_ext( "boost_adaptbx_graph_connected_component_algorithm_ext" )


def connected_components(graph):
Expand All @@ -12,4 +12,3 @@ def connected_components(graph):
result.setdefault( component, [] ).append( desc )

return list(result.values())

5 changes: 2 additions & 3 deletions boost_adaptbx/graph/graph_structure_comparison.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import absolute_import, division, print_function

import boost_adaptbx.python
ext = boost_adaptbx.python.import_ext( "boost_adaptbx_graph_graph_structure_comparison_ext" )
import boost_adaptbx.boost.python as bp
ext = bp.import_ext( "boost_adaptbx_graph_graph_structure_comparison_ext" )
from boost_adaptbx_graph_graph_structure_comparison_ext import *

Loading

0 comments on commit 0300bb1

Please sign in to comment.