Permalink
Browse files

add Integer traitlet

Most int traits are now Integers

Integer differs from Long only in that small `long`s are cast to `int`, rather than
all `int`s being cast to `long`:

    Integer(4L) => 4
    Long(4) => 4L

closes gh-942, closes gh-996.

Rebased to avoid recursive merge for just one commit.
  • Loading branch information...
1 parent 9a89486 commit 293d3eed242cf7b2211c4f0303d679d2b3053733 @minrk minrk committed with fperez Nov 1, 2011
@@ -34,7 +34,7 @@
)
from IPython.utils.traitlets import (
- Unicode, List, Int, Enum, Dict, Instance, TraitError
+ Unicode, List, Enum, Dict, Instance, TraitError
)
from IPython.utils.importstring import import_item
from IPython.utils.text import indent, wrap_paragraphs, dedent
@@ -28,7 +28,7 @@
)
from IPython.utils.traitlets import (
- Bool, Unicode, Int, Float, List, Dict
+ Bool, Unicode, Integer, Float, List, Dict
)
#-----------------------------------------------------------------------------
@@ -37,14 +37,14 @@
class Foo(Configurable):
- i = Int(0, config=True, help="The integer i.")
- j = Int(1, config=True, help="The integer j.")
+ i = Integer(0, config=True, help="The integer i.")
+ j = Integer(1, config=True, help="The integer j.")
name = Unicode(u'Brian', config=True, help="First name.")
class Bar(Configurable):
- b = Int(0, config=True, help="The integer b.")
+ b = Integer(0, config=True, help="The integer b.")
enabled = Bool(True, config=True, help="Enable bar.")
@@ -27,7 +27,7 @@
)
from IPython.utils.traitlets import (
- Int, Float, Unicode
+ Integer, Float, Unicode
)
from IPython.config.loader import Config
@@ -39,14 +39,14 @@
class MyConfigurable(Configurable):
- a = Int(1, config=True, help="The integer a.")
+ a = Integer(1, config=True, help="The integer a.")
b = Float(1.0, config=True, help="The integer b.")
c = Unicode('no config')
mc_help=u"""MyConfigurable options
----------------------
---MyConfigurable.a=<Int>
+--MyConfigurable.a=<Integer>
Default: 1
The integer a.
--MyConfigurable.b=<Float>
@@ -55,15 +55,15 @@ class MyConfigurable(Configurable):
mc_help_inst=u"""MyConfigurable options
----------------------
---MyConfigurable.a=<Int>
+--MyConfigurable.a=<Integer>
Current: 5
The integer a.
--MyConfigurable.b=<Float>
Current: 4.0
The integer b."""
class Foo(Configurable):
- a = Int(0, config=True, help="The integer a.")
+ a = Integer(0, config=True, help="The integer a.")
b = Unicode('nope', config=True)
@@ -28,7 +28,7 @@
from IPython.testing.tools import mute_warn
-from IPython.utils.traitlets import Int, Unicode
+from IPython.utils.traitlets import Unicode
from IPython.config.configurable import Configurable
from IPython.config.loader import (
Config,
@@ -28,7 +28,7 @@
# Our own imports
from IPython.config.configurable import Configurable
from IPython.lib import pretty
-from IPython.utils.traitlets import Bool, Dict, Int, Unicode, CUnicode, ObjectName
+from IPython.utils.traitlets import Bool, Dict, Integer, Unicode, CUnicode, ObjectName
from IPython.utils.py3compat import unicode_to_str
@@ -357,7 +357,7 @@ def dtype_pprinter(obj, p, cycle):
verbose = Bool(False, config=True)
# The maximum width.
- max_width = Int(79, config=True)
+ max_width = Integer(79, config=True)
# The newline character.
newline = Unicode('\n', config=True)
@@ -29,7 +29,7 @@
from IPython.testing.skipdoctest import skip_doctest
from IPython.utils import io
from IPython.utils.path import locate_profile
-from IPython.utils.traitlets import Bool, Dict, Instance, Int, CInt, List, Unicode
+from IPython.utils.traitlets import Bool, Dict, Instance, Integer, List, Unicode
from IPython.utils.warn import warn
#-----------------------------------------------------------------------------
@@ -361,12 +361,12 @@ def _dir_hist_default(self):
output_hist_reprs = Dict()
# The number of the current session in the history database
- session_number = CInt()
+ session_number = Integer()
# Should we log output to the database? (default no)
db_log_output = Bool(False, config=True)
# Write to database every x commands (higher values save disk access & power)
# Values of 1 or less effectively disable caching.
- db_cache_size = Int(0, config=True)
+ db_cache_size = Integer(0, config=True)
# The input and output caches
db_input_cache = List()
db_output_cache = List()
@@ -74,7 +74,7 @@
from IPython.utils.strdispatch import StrDispatch
from IPython.utils.syspathcontext import prepended_to_syspath
from IPython.utils.text import num_ini_spaces, format_screen, LSString, SList
-from IPython.utils.traitlets import (Int, CBool, CaselessStrEnum, Enum,
+from IPython.utils.traitlets import (Integer, CBool, CaselessStrEnum, Enum,
List, Unicode, Instance, Type)
from IPython.utils.warn import warn, error, fatal
import IPython.core.hooks
@@ -226,7 +226,7 @@ class InteractiveShell(SingletonConfigurable, Magic):
Enable magic commands to be called without the leading %.
"""
)
- cache_size = Int(1000, config=True, help=
+ cache_size = Integer(1000, config=True, help=
"""
Set the size of the output cache. The default is 1000, you can
change it permanently in your config file. Setting it to 0 completely
@@ -277,7 +277,7 @@ class InteractiveShell(SingletonConfigurable, Magic):
def _exiter_default(self):
return ExitAutocall(self)
# Monotonically increasing execution counter
- execution_count = Int(1)
+ execution_count = Integer(1)
filename = Unicode("<ipython console>")
ipython_dir= Unicode('', config=True) # Set to get_ipython_dir() in __init__
@@ -317,7 +317,7 @@ def _exiter_default(self):
prompts_pad_left = CBool(True, config=True)
quiet = CBool(False, config=True)
- history_length = Int(10000, config=True)
+ history_length = Integer(10000, config=True)
# The readline stuff will eventually be moved to the terminal subclass
# but for now, we can't do that as readline is welded in everywhere.
@@ -35,7 +35,7 @@
from IPython.core.splitinput import split_user_input, LineInfo
from IPython.core import page
-from IPython.utils.traitlets import List, Int, Any, Unicode, CBool, Bool, Instance
+from IPython.utils.traitlets import List, Integer, Any, Unicode, CBool, Bool, Instance
from IPython.utils.text import make_quoted_expr
from IPython.utils.autoattr import auto_attr
@@ -369,7 +369,7 @@ def prefilter_lines(self, lines, continue_prompt=False):
class PrefilterTransformer(Configurable):
"""Transform a line of user input."""
- priority = Int(100, config=True)
+ priority = Integer(100, config=True)
# Transformers don't currently use shell or prefilter_manager, but as we
# move away from checkers and handlers, they will need them.
shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
@@ -398,7 +398,7 @@ def __repr__(self):
class AssignSystemTransformer(PrefilterTransformer):
"""Handle the `files = !ls` syntax."""
- priority = Int(100, config=True)
+ priority = Integer(100, config=True)
def transform(self, line, continue_prompt):
m = _assign_system_re.match(line)
@@ -417,7 +417,7 @@ def transform(self, line, continue_prompt):
class AssignMagicTransformer(PrefilterTransformer):
"""Handle the `a = %who` syntax."""
- priority = Int(200, config=True)
+ priority = Integer(200, config=True)
def transform(self, line, continue_prompt):
m = _assign_magic_re.match(line)
@@ -435,7 +435,7 @@ def transform(self, line, continue_prompt):
class PyPromptTransformer(PrefilterTransformer):
"""Handle inputs that start with '>>> ' syntax."""
- priority = Int(50, config=True)
+ priority = Integer(50, config=True)
def transform(self, line, continue_prompt):
@@ -456,7 +456,7 @@ def transform(self, line, continue_prompt):
class IPyPromptTransformer(PrefilterTransformer):
"""Handle inputs that start classic IPython prompt syntax."""
- priority = Int(50, config=True)
+ priority = Integer(50, config=True)
def transform(self, line, continue_prompt):
@@ -479,7 +479,7 @@ def transform(self, line, continue_prompt):
class PrefilterChecker(Configurable):
"""Inspect an input line and return a handler for that line."""
- priority = Int(100, config=True)
+ priority = Integer(100, config=True)
shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager')
enabled = Bool(True, config=True)
@@ -501,7 +501,7 @@ def __repr__(self):
class EmacsChecker(PrefilterChecker):
- priority = Int(100, config=True)
+ priority = Integer(100, config=True)
enabled = Bool(False, config=True)
def check(self, line_info):
@@ -514,7 +514,7 @@ def check(self, line_info):
class ShellEscapeChecker(PrefilterChecker):
- priority = Int(200, config=True)
+ priority = Integer(200, config=True)
def check(self, line_info):
if line_info.line.lstrip().startswith(ESC_SHELL):
@@ -523,7 +523,7 @@ def check(self, line_info):
class MacroChecker(PrefilterChecker):
- priority = Int(250, config=True)
+ priority = Integer(250, config=True)
def check(self, line_info):
obj = self.shell.user_ns.get(line_info.ifun)
@@ -535,7 +535,7 @@ def check(self, line_info):
class IPyAutocallChecker(PrefilterChecker):
- priority = Int(300, config=True)
+ priority = Integer(300, config=True)
def check(self, line_info):
"Instances of IPyAutocall in user_ns get autocalled immediately"
@@ -549,7 +549,7 @@ def check(self, line_info):
class MultiLineMagicChecker(PrefilterChecker):
- priority = Int(400, config=True)
+ priority = Integer(400, config=True)
def check(self, line_info):
"Allow ! and !! in multi-line statements if multi_line_specials is on"
@@ -566,7 +566,7 @@ def check(self, line_info):
class EscCharsChecker(PrefilterChecker):
- priority = Int(500, config=True)
+ priority = Integer(500, config=True)
def check(self, line_info):
"""Check for escape character and return either a handler to handle it,
@@ -586,7 +586,7 @@ def check(self, line_info):
class AssignmentChecker(PrefilterChecker):
- priority = Int(600, config=True)
+ priority = Integer(600, config=True)
def check(self, line_info):
"""Check to see if user is assigning to a var for the first time, in
@@ -604,7 +604,7 @@ def check(self, line_info):
class AutoMagicChecker(PrefilterChecker):
- priority = Int(700, config=True)
+ priority = Integer(700, config=True)
def check(self, line_info):
"""If the ifun is magic, and automagic is on, run it. Note: normal,
@@ -628,7 +628,7 @@ def check(self, line_info):
class AliasChecker(PrefilterChecker):
- priority = Int(800, config=True)
+ priority = Integer(800, config=True)
def check(self, line_info):
"Check if the initital identifier on the line is an alias."
@@ -644,7 +644,7 @@ def check(self, line_info):
class PythonOpsChecker(PrefilterChecker):
- priority = Int(900, config=True)
+ priority = Integer(900, config=True)
def check(self, line_info):
"""If the 'rest' of the line begins with a function call or pretty much
@@ -659,7 +659,7 @@ def check(self, line_info):
class AutocallChecker(PrefilterChecker):
- priority = Int(1000, config=True)
+ priority = Integer(1000, config=True)
def check(self, line_info):
"Check if the initial word/function is callable and autocall is on."
@@ -29,7 +29,7 @@
from IPython.config.configurable import LoggingConfigurable
from IPython.zmq.ipkernel import launch_kernel
from IPython.zmq.kernelmanager import KernelManager
-from IPython.utils.traitlets import Instance, Dict, List, Unicode, Float, Int
+from IPython.utils.traitlets import Instance, Dict, List, Unicode, Float, Integer
#-----------------------------------------------------------------------------
# Classes
@@ -196,7 +196,7 @@ class MappingKernelManager(MultiKernelManager):
kernel_argv = List(Unicode)
kernel_manager = Instance(KernelManager)
time_to_dead = Float(3.0, config=True, help="""Kernel heartbeat interval in seconds.""")
- max_msg_size = Int(65536, config=True, help="""
+ max_msg_size = Integer(65536, config=True, help="""
The max raw message size accepted from the browser
over a WebSocket connection.
""")
@@ -57,7 +57,7 @@
aliases as ipkernel_aliases,
IPKernelApp
)
-from IPython.utils.traitlets import Dict, Unicode, Int, List, Enum, Bool
+from IPython.utils.traitlets import Dict, Unicode, Integer, List, Enum, Bool
#-----------------------------------------------------------------------------
# Module globals
@@ -195,7 +195,7 @@ class NotebookApp(BaseIPythonApplication):
def _ip_changed(self, name, old, new):
if new == u'*': self.ip = u''
- port = Int(8888, config=True,
+ port = Integer(8888, config=True,
help="The port the notebook server will listen on."
)
@@ -20,7 +20,7 @@
from IPython.frontend.qt.rich_text import HtmlExporter
from IPython.frontend.qt.util import MetaQObjectHasTraits, get_font
from IPython.utils.text import columnize
-from IPython.utils.traitlets import Bool, Enum, Int, Unicode
+from IPython.utils.traitlets import Bool, Enum, Integer, Unicode
from ansi_code_processor import QtAnsiCodeProcessor
from completion_widget import CompletionWidget
from kill_ring import QtKillRing
@@ -59,7 +59,7 @@ class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):
ansi_codes = Bool(True, config=True,
help="Whether to process ANSI escape codes."
)
- buffer_size = Int(500, config=True,
+ buffer_size = Integer(500, config=True,
help="""
The maximum number of lines of text before truncation. Specifying a
non-positive number disables text truncation (not recommended).
@@ -112,7 +112,7 @@ def _font_family_default(self):
# Monospace should always exist, no need for a fallback
return 'Monospace'
- font_size = Int(config=True,
+ font_size = Integer(config=True,
help="""The font size. If unconfigured, Qt will be entrusted
with the size of the font.
""")
Oops, something went wrong.

0 comments on commit 293d3ee

Please sign in to comment.