# HG changeset patch
# User Burcin Erocal <burcin@erocal.org>
# Date 1311238723 -3600
# Node ID b1aa063f5c9d38f4cb2d74876f2ad635d6eb1f2a
# Parent  461868191947707e8c6a764078c3bec7274088a6
trac #11116: Fix some circular imports.

diff --git a/sage/all.py b/sage/all.py
--- a/sage/all.py
+++ b/sage/all.py
@@ -72,7 +72,6 @@
 from sage.monoids.all    import *
 from sage.algebras.all   import *
 from sage.modular.all    import *
-from sage.schemes.all    import *
 from sage.graphs.all     import *
 from sage.groups.all     import *
 from sage.databases.all  import *
@@ -87,6 +86,9 @@
 from sage.functions.all  import *
 from sage.calculus.all   import *
 
+from sage.schemes.all    import *
+
+
 from sage.server.all     import *
 import sage.tests.all as tests
 
diff --git a/sage/geometry/lattice_polytope.py b/sage/geometry/lattice_polytope.py
--- a/sage/geometry/lattice_polytope.py
+++ b/sage/geometry/lattice_polytope.py
@@ -107,11 +107,6 @@
 from sage.misc.all import tmp_filename
 from sage.misc.misc import deprecation
 from sage.modules.all import vector
-from sage.plot.plot import hue
-from sage.plot.plot3d.index_face_set import IndexFaceSet
-from sage.plot.plot3d.all import line3d, point3d
-from sage.plot.plot3d.shapes2 import text3d
-from sage.plot.plot3d.tachyon import Tachyon
 from sage.rings.all import Integer, ZZ, QQ, gcd, lcm
 from sage.sets.set import Set_generic
 from sage.structure.all import Sequence
@@ -2460,6 +2455,7 @@
                         for i in range(self.nvertices(), self.npoints())]
         pplot = 0
         if show_facets:
+            from sage.plot.plot3d.index_face_set import IndexFaceSet
             if dim == 2:
                 pplot += IndexFaceSet([self.traverse_boundary()],
                         vertices, opacity=facet_opacity, rgbcolor=facet_color)
@@ -2472,12 +2468,15 @@
                     pplot += IndexFaceSet([f.traverse_boundary() for f in self.facets()],
                         vertices, opacity=facet_opacity, rgbcolor=facet_color)
         if show_edges:
+            from sage.plot.plot3d.all import line3d
             if dim == 1:
                 pplot += line3d(vertices, thickness=edge_thickness, rgbcolor=edge_color)
             else:
                 for e in self.edges():
                     pplot += line3d([vertices[e.vertices()[0]], vertices[e.vertices()[1]]],
                             thickness=edge_thickness, rgbcolor=edge_color)
+	from sage.plot.plot3d.all import point3d
+        from sage.plot.plot3d.shapes2 import text3d
         if show_vertices:
             pplot += point3d(vertices, size=vertex_size, rgbcolor=vertex_color)
         if show_vindices == None:
diff --git a/sage/geometry/polyhedra.py b/sage/geometry/polyhedra.py
--- a/sage/geometry/polyhedra.py
+++ b/sage/geometry/polyhedra.py
@@ -127,11 +127,9 @@
 from sage.rings.real_double import RDF
 from sage.modules.free_module_element import vector
 from sage.matrix.constructor import matrix, identity_matrix
-from sage.functions.other import sqrt, floor, ceil
-from sage.functions.trig import sin, cos
-
-from sage.plot.all import point2d, line2d, arrow, polygon2d
-from sage.plot.plot3d.all import point3d, line3d, arrow3d, polygon3d
+from math import sqrt, floor, ceil, sin, cos
+#from sage.functions.trig import sin, cos
+
 from sage.graphs.graph import Graph
 
 from sage.combinat.combinat import permutations
@@ -5577,6 +5575,7 @@
             sage: hex_points._Graphics__objects
             [Point set defined by 6 point(s)]
         """
+        from sage.plot.all import point2d
         return point2d(self.coordinates_of(self.points), **kwds)
 
 
@@ -5591,6 +5590,7 @@
             sage: outline._Graphics__objects[0]
             Line defined by 2 points
         """
+        from sage.plot.all import line2d, arrow
         wireframe = [];
         for l in self.lines:
             l_coords = self.coordinates_of(l)
@@ -5614,6 +5614,7 @@
             sage: filled_poly.axes_width()
             0.8000...
         """
+        from sage.plot.all import polygon2d
         poly = [polygon2d(self.coordinates_of(p), **kwds) 
                  for p in self.polygons]
         return sum(poly)
@@ -5631,6 +5632,7 @@
             sage: verts.bounding_box()
             ((-1.0, -1.0, -1.0), (1.0, 1.0, 1.0))
         """
+        from sage.plot.plot3d.all import point3d
         return point3d(self.coordinates_of(self.points), **kwds)
 
 
@@ -5646,6 +5648,7 @@
             sage: print wire.tachyon().split('\n')[77]  # for testing
             FCylinder base 1.0 -1.0 1.0 apex 1.0 1.0 1.0 rad 0.005 texture...
         """
+        from sage.plot.plot3d.all import line3d, arrow3d
         wireframe = [];
         for l in self.lines:
             l_coords = self.coordinates_of(l)
@@ -5667,6 +5670,7 @@
             sage: type(p_solid)
             <class 'sage.plot.plot3d.base.Graphics3dGroup'>
         """
+        from sage.plot.plot3d.all import polygon3d
         return sum([ polygon3d(self.coordinates_of(f), **kwds) 
                      for f in self.polygons ])
 
diff --git a/sage/geometry/toric_plotter.py b/sage/geometry/toric_plotter.py
--- a/sage/geometry/toric_plotter.py
+++ b/sage/geometry/toric_plotter.py
@@ -50,12 +50,9 @@
 from copy import copy
 from math import pi
 
-from sage.functions.all import arccos, arctan2, ceil, floor
+from math import ceil, floor, acos as arccos, atan2 as arctan2
 from sage.geometry.polyhedra import Polyhedron
 from sage.modules.all import vector
-from sage.plot.all import (Color, Graphics,
-                           arrow, disk, line, point, polygon, rainbow, text)
-from sage.plot.plot3d.all import text3d
 from sage.rings.all import RDF
 from sage.structure.sage_object import SageObject
 
@@ -390,6 +387,7 @@
             sage: print tp.plot_generators()
             Graphics object consisting of 1 graphics primitive
         """
+        from sage.plot.all import Graphics
         generators = self.generators
         result = Graphics()
         if not generators or not self.show_generators:
@@ -400,6 +398,8 @@
         origin = self.origin
         thickness = self.generator_thickness
         zorder = self.generator_zorder
+
+        from sage.plot.all import arrow, line
         for generator, ray, color in zip(generators, self.rays, colors):
             if ray.norm() < generator.norm():
                 result += line([origin, ray],
@@ -441,6 +441,8 @@
             sage: print tp.plot_labels("u", [(1.5,0)])
             Graphics object consisting of 1 graphics primitive
         """
+        from sage.plot.all import Graphics, text
+        from sage.plot.plot3d.all import text3d
         result = Graphics()
         color = self.label_color
         extra_options = self.extra_options
@@ -518,6 +520,7 @@
             sage: print tp.plot_points([(1,0), (0,1)])
             Graphics object consisting of 1 graphics primitive
         """
+        from sage.plot.all import point
         return point(points, color=self.point_color, size=self.point_size,
                      zorder=self.point_zorder, **self.extra_options)
         
@@ -572,6 +575,8 @@
         colors = color_list(self.ray_color, len(rays))
         thickness = self.ray_thickness
         zorder = self.ray_zorder
+        
+        from sage.plot.all import line
         for end, color in zip(rays, colors):
             result += line([origin, end],
                            color=color, thickness=thickness,
@@ -782,6 +787,7 @@
          RGB color (0.0, 1.0, 0.0),
          RGB color (0.0, 0.0, 1.0)]
     """
+    from sage.plot.all import Color, rainbow
     try:
         color = Color(color)
         return [color] * n
@@ -1102,6 +1108,7 @@
             phi1, phi2 = phi2, phi1
         if phi2 - phi1 > pi:
             phi1, phi2 = phi2, phi1 + 2 * pi                 
+        from sage.plot.all import disk
         return disk((0,0), r, (phi1, phi2), **extra_options)
     else:
         # Plot a polygon, 30 vertices per radian.
@@ -1111,4 +1118,5 @@
         points = (ray1 + i * dr for i in range(n + 1))
         points = [r / pt.norm() * pt for pt in points]
         points.append(vector(RDF, 3))
+        from sage.plot.all import polygon
         return polygon(points, **extra_options)
diff --git a/sage/graphs/graph_editor.py b/sage/graphs/graph_editor.py
--- a/sage/graphs/graph_editor.py
+++ b/sage/graphs/graph_editor.py
@@ -19,7 +19,6 @@
 from sage.misc.html import html
 
 import sagenb.notebook.interact
-from sagenb.misc.support import EMBEDDED_MODE
 
 
 def graph_to_js(g):
@@ -105,6 +104,7 @@
     if graph is None:
         graph = graphs.CompleteGraph(2)
         
+    from sagenb.misc.support import EMBEDDED_MODE
     if not EMBEDDED_MODE:
         return "This graph editor only runs in the Sage notebook."
 
diff --git a/sage/schemes/generic/toric_variety.py b/sage/schemes/generic/toric_variety.py
--- a/sage/schemes/generic/toric_variety.py
+++ b/sage/schemes/generic/toric_variety.py
@@ -251,7 +251,6 @@
                                            SchemeMorphism_on_points,
                                            is_SchemeMorphism)
 from sage.structure.sequence import Sequence
-from sage.functions.all import factorial
 
 
 # Default prefix for indexed coordinates
@@ -2836,6 +2835,7 @@
         if not self.part_of_degree(0).is_zero():
             raise ValueError, 'Must not have a constant part.'
         exp_x = self.parent().one()
+        from sage.functions.all import factorial
         for d in range(1,self.parent()._variety.dimension()+1):
             exp_x += self**d / factorial(d)
         return exp_x
 
