Permalink
Browse files

converting to unix line endings and removing excess whitespace

  • Loading branch information...
1 parent 4dd0132 commit e74cbe119679580d395752bb258a8c57d1e9438f Ilan Schnell committed Jan 28, 2011
Showing with 645 additions and 651 deletions.
  1. +7 −7 enthought/interpolate/fitting.py
  2. +7 −7 enthought/interpolate/interpolate.py
  3. +1 −1 enthought/interpolate/setup.py
  4. +3 −3 enthought/interpolate/tests/test_basic.py
  5. +2 −2 enthought/mathematics/__init__.py
  6. +17 −18 enthought/physical_quantities/dimensions.py
  7. +21 −22 enthought/physical_quantities/tests/test_dimensions.py
  8. +0 −1 enthought/physical_quantities/tests/test_quantity_type.py
  9. +12 −12 enthought/physical_quantities/tests/test_units.py
  10. +37 −37 enthought/physical_quantities/tests/test_utils.py
  11. +43 −43 enthought/physical_quantities/units.py
  12. +23 −23 enthought/physical_quantities/util.py
  13. +24 −24 enthought/units/SI.py
  14. +1 −1 enthought/units/__init__.py
  15. +2 −2 enthought/units/acceleration.py
  16. +2 −2 enthought/units/angle.py
  17. +1 −1 enthought/units/api.py
  18. +3 −3 enthought/units/convert.py
  19. +1 −1 enthought/units/data/unit_families.txt
  20. +1 −1 enthought/units/data/unit_family_membership.txt
  21. +2 −2 enthought/units/density.py
  22. +25 −25 enthought/units/family_name_trait.py
  23. +2 −2 enthought/units/frequency.py
  24. +1 −1 enthought/units/function_signature.py
  25. +10 −10 enthought/units/has_units.py
  26. +3 −3 enthought/units/length.py
  27. +2 −2 enthought/units/mass.py
  28. +14 −14 enthought/units/meta_quantity.py
  29. +2 −2 enthought/units/plugin/action/set_unit_system_action.py
  30. +16 −16 enthought/units/plugin/images/image_LICENSE.txt
  31. +8 −8 enthought/units/plugin/new_quantity_wizard.py
  32. +9 −10 enthought/units/plugin/new_scalar_wizard.py
  33. +1 −1 enthought/units/plugin/quantity_node_type.py
  34. +8 −8 enthought/units/plugin/quantity_resource_editor.py
  35. +1 −1 enthought/units/plugin/quantity_resource_open_cookie.py
  36. +2 −2 enthought/units/plugin/quantity_resource_type.py
  37. +4 −4 enthought/units/plugin/resource_type_plugin_definition.py
  38. +3 −4 enthought/units/plugin/units_plugin.py
  39. +4 −4 enthought/units/plugin/units_plugin_definition.py
  40. +1 −1 enthought/units/plugin/units_resource_plugin_definition.py
  41. +3 −3 enthought/units/plugin/units_ui_plugin_definition.py
  42. +14 −14 enthought/units/quantity_trait.py
  43. +3 −3 enthought/units/quantity_traits.py
  44. +3 −3 enthought/units/scalar.py
  45. +23 −23 enthought/units/smart_unit.py
  46. +3 −3 enthought/units/speed.py
  47. +17 −17 enthought/units/style_manager.py
  48. +1 −1 enthought/units/temperature.py
  49. +1 −1 enthought/units/tests/has_units_test_case.py
  50. +6 −6 enthought/units/tests/meta_quantity_test_case.py
  51. +50 −51 enthought/units/tests/traits_test_case.py
  52. +7 −7 enthought/units/tests/unit_array_test_case.py
  53. +5 −5 enthought/units/tests/unit_manipulation_test_case.py
  54. +2 −2 enthought/units/time.py
  55. +13 −13 enthought/units/ui/meta_quantity_view.py
  56. +16 −16 enthought/units/ui/quantity_view.py
  57. +3 −3 enthought/units/unit_array.py
  58. +3 −3 enthought/units/unit_converter.py
  59. +4 −4 enthought/units/unit_manager.py
  60. +6 −6 enthought/units/unit_manipulation.py
  61. +1 −1 enthought/units/unit_parser.py
  62. +26 −26 enthought/units/unit_system.py
  63. +26 −26 enthought/units/unit_traits.py
  64. +2 −2 enthought/units/volume.py
  65. +16 −16 image_LICENSE.txt
  66. +65 −65 image_LICENSE_OOo.txt
@@ -1,7 +1,7 @@
""" Interpolation/Extrapolation classes.
Policies on under-specified data fits.
-
+
1. If the input arrays to a fit has 0 elements, numpy.NaN values
are returned from the __call__ method for all calculated y
values.
@@ -43,7 +43,7 @@ def clone(self):
new_int = self.__class__()
new_int.__dict__.update(self.__dict__)
return new_int
-
+
def set_xy(self, x, y):
x = numpy.atleast_1d(x)
y = numpy.atleast_1d(y)
@@ -122,13 +122,13 @@ def __eq__(self, other):
result = False
break;
else:
- result = False
- return result
-
+ result = False
+ return result
+
class Spline(DataFit):
""" Cubic-spline interpolation
- This class works for interpolation and extrapolation.
+ This class works for interpolation and extrapolation.
!! - extrapolation seems to be broken for this
!! - only works for 1d y arrays
"""
@@ -247,7 +247,7 @@ def interp(self, x):
class FillNaN(DataFit):
""" A DataFit which just returns all NaN's. """
-
+
def interp(self, x):
""" Return an numpy.array of numpy.NaN's in the same shape as x. """
y = numpy.arange(len(x)).astype(numpy.float)
@@ -83,10 +83,10 @@ def block_average_above(x, y, new_x):
if len(y.shape) == 2:
new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64)
for i in range(len(new_y)):
- bad_index = _interpolate.block_averave_above_dddd(x, y[i],
+ bad_index = _interpolate.block_averave_above_dddd(x, y[i],
new_x, new_y[i])
if bad_index is not None:
- break
+ break
else:
new_y = numpy.zeros(len(new_x), numpy.float64)
bad_index = _interpolate.block_average_above_dddd(x, y, new_x, new_y)
@@ -96,7 +96,7 @@ def block_average_above(x, y, new_x):
"is out of the x range (%f, %f)" % \
(bad_index, new_x[bad_index], x[0], x[-1])
raise ValueError, msg
-
+
return new_y
def window_average(x, y, new_x, width=10.0):
@@ -109,14 +109,14 @@ def window_average(x, y, new_x, width=10.0):
if len(y.shape) == 2:
new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64)
for i in range(len(new_y)):
- _interpolate.window_average_ddddd(x, y[i], new_x, new_y[i],
+ _interpolate.window_average_ddddd(x, y[i], new_x, new_y[i],
width)
else:
new_y = numpy.zeros(len(new_x), numpy.float64)
_interpolate.window_average_ddddd(x, y, new_x, new_y, width)
-
+
return new_y
-
+
def main():
from scipy import arange, ones
import time
@@ -140,7 +140,7 @@ def main():
t2 = time.clock()
print '1d block_average_above (sec):', t2 - t1
print new_y[:5]
-
+
N = 3000.
x = arange(N)
y = ones((100,N)) * arange(N)
@@ -9,7 +9,7 @@ def configuration(parent_package='enthought',top_path=None):
['_interpolate.cpp'],
include_dirs = ['.'],
depends = ['interpolate.h'])
-
+
config.add_data_dir('tests')
return config
@@ -8,10 +8,10 @@
class Test(unittest.TestCase):
-
+
def assertAllclose(self, x, y):
self.assert_(allclose(x, y))
-
+
def test_linear(self):
N = 3000.
x = arange(N)
@@ -27,7 +27,7 @@ def test_block_average_above(self):
N = 3000.
x = arange(N)
y = arange(N)
-
+
new_x = arange(N/2)*2
t1 = time.clock()
new_y = block_average_above(x, y, new_x)
@@ -2,6 +2,6 @@
# Copyright (c) 2006 by Enthought, Inc.
# All rights reserved.
#------------------------------------------------------------------------------
-""" Math abstractions and utility functions.
+""" Math abstractions and utility functions.
Part of the SciMath project of the Enthought Tool Suite.
-"""
+"""
@@ -30,10 +30,10 @@
class Dimensions(HasTraits):
"""The dimensions of a physical quantity.
-
+
This is essentially a thin wrapper around a dictionary which we perform
certain operations on.
-
+
Example
-------
>>> m = Dimensions({'mass': 1.0})
@@ -48,22 +48,22 @@ class Dimensions(HasTraits):
# a dictionary holding dimension names and quantities
# this should be frozen if you want to hash - don't change it
dimension_dict = DictStrFloat
-
+
# the quantity type as an expression in powers of base dimensions
expansion = Property(String, depends_on='dimension_dict')
-
+
def __init__(self, dimension_dict, **kwargs):
for key, value in dimension_dict.items():
if not value:
del dimension_dict[key]
super(self.__class__, self).__init__(dimension_dict=dimension_dict, **kwargs)
-
+
@classmethod
def from_expansion(cls, expansion):
"""Create a Dimension class instance from an expansion string
-
+
This is a fairly simplistic parser - no parens, division, etc.
-
+
Parameters
----------
expansion : string
@@ -81,41 +81,41 @@ def from_expansion(cls, expansion):
except:
raise InvalidExpansionError(expansion)
return cls(dimension_dict)
-
+
@cached_property
def _get_expansion(self):
if self.dimension_dict:
return format_expansion(self.dimension_dict)
else:
return "dimensionless"
-
+
def __repr__(self):
return "Dimensions(%s)" % repr(self.dimension_dict)
-
+
def __str__(self):
return self.expansion
-
+
def __eq__(self, other):
return isinstance(other, self.__class__) \
and self.dimension_dict == other.dimension_dict
-
+
def __hash__(self):
return hash(tuple(item for item in self.dimension_dict.items()))
-
+
def __mul__(self, other):
if isinstance(other, Dimensions):
return Dimensions(dict_add(self.dimension_dict,
other.dimension_dict))
else:
raise NotImplementedError
-
+
def __div__(self, other):
if isinstance(other, Dimensions):
return Dimensions(dict_sub(self.dimension_dict,
other.dimension_dict))
else:
raise NotImplementedError
-
+
def __pow__(self, other):
if isinstance(other, (float, int, long)):
return Dimensions(dict_mul(self.dimension_dict, other))
@@ -126,7 +126,7 @@ def __pow__(self, other):
class Dim(TraitType):
default_value = Dimensions({})
info_text = "a dimension information object"
-
+
def validate(self, object, name, value):
if isinstance(value, Dimensions):
return value
@@ -143,7 +143,6 @@ def validate(self, object, name, value):
class InvalidExpansionError(ArithmeticError):
def __init__(self, expansion):
self.expansion = expansion
-
+
def __str__(self):
return "Invalid expansion: " + repr(self.expansion)
-
@@ -13,83 +13,82 @@ def setUp(self):
self.force = Dimensions({"mass": 1.0, "length": 1.0, "time": -2.0})
self.also_force = Dimensions({"mass": 1.0, "length": 1.0,
"time": -2.0})
-
+
# Tests for basic initialization
def test_setup_simple(self):
assert self.length.dimension_dict == {"length": 1.0}
-
+
def test_setup_remove_dimensions(self):
assert self.mass.dimension_dict == {"mass": 1.0}
-
+
# Tests for expansion property
def test_expansion_dimensionless(self):
assert self.dimensionless.expansion == "dimensionless"
-
+
def test_expansion_simple(self):
assert self.length.expansion == "length"
-
+
def test_expansion_complex(self):
assert self.force.expansion == "length*mass*time**-2"
-
+
def test_expansion_expression(self):
velocity = self.length/self.time
assert velocity.expansion == "length*time**-1"
-
+
def test_expansion_complete_cancellation(self):
dimensionless = self.force/self.force
assert dimensionless.expansion == "dimensionless"
-
+
# Tests for __str__ method
def test_str_dimensionless(self):
assert str(self.dimensionless) == "dimensionless"
-
+
def test_str_simple(self):
assert str(self.length) == "length"
-
+
def test_str_complex(self):
assert str(self.force) == "length*mass*time**-2"
-
+
def test_str_expression(self):
velocity = self.length/self.time
assert str(velocity) == "length*time**-1"
-
+
# Tests for equality and inequality
def test_equality(self):
assert self.force == self.also_force
-
+
def test_inequality(self):
assert self.force != self.acceleration
-
+
# Tests for hashing
def test_hash(self):
assert hash(self.force) == hash(self.also_force)
-
+
def test_not_hash(self):
# there is a very small chance that this will fail when it should not
# because of a hash collision
assert hash(self.force) != hash(self.acceleration)
-
+
# Tests for arithmetic operations
def test_mul(self):
force = self.acceleration*self.mass
assert force.dimension_dict == {"length": 1.0, "time": -2.0, "mass": 1.0}
-
+
def test_div(self):
velocity = self.length/self.time
assert velocity.dimension_dict == {"length": 1.0, "time": -1.0}
-
+
def test_pow(self):
area = self.length**2
assert area.dimension_dict == {"length": 2.0}
-
+
def test_cancellation(self):
acceleration = self.force*self.time/self.mass
assert acceleration.dimension_dict == {"length": 1.0, "time": -1.0}
-
+
def test_complete_cancellation(self):
dimensionless = self.force/self.force
assert dimensionless.dimension_dict == {}
-
+
# TODO: write tests for Dim trait
-
@@ -8,4 +8,3 @@
#-----------------------------------------------------------------------------
-
Oops, something went wrong.

0 comments on commit e74cbe1

Please sign in to comment.