Skip to content

Commit

Permalink
Merge pull request #41 from lewisamarshall/development
Browse files Browse the repository at this point in the history
Data structure upgrades.
  • Loading branch information
lewisamarshall committed Aug 31, 2015
2 parents 79c42a6 + 06bb4bf commit 9f8af0b
Show file tree
Hide file tree
Showing 15 changed files with 372 additions and 816 deletions.
5 changes: 4 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ ratings:
# You can globally exclude files from being analyzed by any engine using the
# exclude_paths key.

#exclude_paths:
exclude_paths:
- emigrate/tests.py
- examples/*
- benchmark.py
#- spec/**/*
#- vendor/**/*
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ before_install:
- ./miniconda.sh -b
- export PATH=/home/travis/miniconda/bin:$PATH
- conda update --yes conda
- pip install coveralls simplejson
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"

install:
- conda install --yes python=$TRAVIS_PYTHON_VERSION numpy scipy nose h5py coverage click matplotlib
- pip install ionize
- python setup.py install
- conda install --yes python=$TRAVIS_PYTHON_VERSION numpy scipy nose h5py coverage click matplotlib pip
- pip install coveralls simplejson ionize

script:
- coverage run --source=emigrate setup.py test
- bash test.sh

after_success:
- coveralls
186 changes: 0 additions & 186 deletions assert.sh

This file was deleted.

14 changes: 7 additions & 7 deletions emigrate/Frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class Frame(object):

# Core Properties
nodes = None
ions = []
ions = None
concentrations = None
time = None

# Solution Properties
pH = None
Expand Down Expand Up @@ -137,12 +138,12 @@ def _resolve_current(self):
self.current = self.area * self.current_density

# I/O
def serialize(self, compact=False):
def serialize(self, compact=True):
serial = {'__frame__': True}
serial.update(self.__dict__)

if compact:
sort_keys, indent, separators = False, None, (',', ':')
sort_keys, indent, separators = True, None, (',', ':')
else:
sort_keys, indent, separators = True, 4, (', ', ': ')

Expand All @@ -151,7 +152,7 @@ def serialize(self, compact=False):

def _encode(self, obj):
if isinstance(obj, ionize.Ion):
ion = obj.serialize()
ion = obj.serialize(nested=True)
ion.update({'__ion__': True})
return ion
elif isinstance(obj, np.ndarray):
Expand All @@ -162,13 +163,12 @@ def _encode(self, obj):
return json.JSONEncoder().default(obj)



if __name__ == '__main__':
my_solutions = [ionize.Solution(['hydrochloric acid', 'tris'], [.05, .1]),
ionize.Solution(['caproic acid', 'tris'], [.05, .1])
]
system = Frame({'lengths': [0.01]*2,
'solutions': my_solutions})
print system.concentrations
print Frame(system.serialize())
print Frame(system.serialize()).__dict__
print system
print system.serialize(compact=False)

0 comments on commit 9f8af0b

Please sign in to comment.