Skip to content

Commit

Permalink
hotfix for 1.4.6 (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
kip-hart committed Feb 8, 2021
1 parent 7dfb3b3 commit 5b080c9
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 29 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/python_package.yaml
Expand Up @@ -17,16 +17,6 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -65,16 +55,6 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/Library/Caches/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.rst
Expand Up @@ -6,6 +6,16 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog`_,
and this project adheres to `Semantic Versioning`_.

`1.4.7`_ - 2021-02-07
--------------------------
Changed
'''''''
- Updated numpy and matplotlib versions.

Fixed
'''''''
- String parsing errors.

`1.4.6`_ - 2021-02-07
--------------------------
Fixed
Expand Down Expand Up @@ -208,7 +218,8 @@ Added

.. LINKS
.. _`Unreleased`: https://github.com/kip-hart/MicroStructPy/compare/v1.4.6...HEAD
.. _`Unreleased`: https://github.com/kip-hart/MicroStructPy/compare/v1.4.7...HEAD
.. _`1.4.7`: https://github.com/kip-hart/MicroStructPy/compare/v1.4.6...v1.4.7
.. _`1.4.6`: https://github.com/kip-hart/MicroStructPy/compare/v1.4.5...v1.4.6
.. _`1.4.5`: https://github.com/kip-hart/MicroStructPy/compare/v1.4.4...v1.4.5
.. _`1.4.4`: https://github.com/kip-hart/MicroStructPy/compare/v1.4.3...v1.4.4
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
@@ -1,9 +1,9 @@
aabbtree==2.5.0
matplotlib==3.0.2
matplotlib==3.3.4
pybind11==2.4.3
pygmsh==7.0.2
MeshPy==2018.2.1
numpy==1.19.4
numpy==1.19.3
pyquaternion==0.9.5
pyvoro-mmalahe==1.3.3
scipy==1.5.4
Expand Down
2 changes: 1 addition & 1 deletion src/microstructpy/__init__.py
Expand Up @@ -4,4 +4,4 @@
import microstructpy.seeding
import microstructpy.verification

__version__ = '1.4.6'
__version__ = '1.4.7'
20 changes: 18 additions & 2 deletions src/microstructpy/_misc.py
Expand Up @@ -2,7 +2,8 @@
This private module contains miscellaneous functions.
"""
import ast

import ast

import numpy as np

Expand Down Expand Up @@ -50,7 +51,22 @@ def from_str(string):
try:
val = ast.literal_eval(s)
except (ValueError, SyntaxError):
val = s
if 'true' in s.lower():
tmp_s = s.lower().replace('true', 'True')
tmp_val = from_str(tmp_s)
if tmp_val != tmp_s:
val = tmp_val
else:
val = s
elif 'false' in s.lower():
tmp_s = s.lower().replace('false', 'False')
tmp_val = from_str(tmp_s)
if tmp_val != tmp_s:
val = tmp_val
else:
val = s
else:
val = s
return val


Expand Down
6 changes: 5 additions & 1 deletion src/microstructpy/cli.py
Expand Up @@ -11,6 +11,7 @@
from __future__ import print_function

import argparse
import ast
import collections
import glob
import os
Expand Down Expand Up @@ -1075,7 +1076,10 @@ def dict_convert(dictionary, filepath='.'):

# Convert strings
if isinstance(dictionary, str):
return _misc.from_str(dictionary)
s = _misc.from_str(dictionary)
if isinstance(s, str) and ',' in s:
s = [_misc.from_str(ss) for ss in s.split(',')]
return s

# Convert Nones
if dictionary is None:
Expand Down
2 changes: 2 additions & 0 deletions src/microstructpy/seeding/seed.py
Expand Up @@ -190,6 +190,8 @@ def from_str(cls, seed_str):

if 'breakdown' in str_dict:
breakdown = str_dict['breakdown']
if not isinstance(breakdown[0], tuple):
breakdown = (breakdown,)
del str_dict['breakdown']
else:
breakdown = None
Expand Down
6 changes: 4 additions & 2 deletions tests/test_misc.py
Expand Up @@ -43,8 +43,8 @@ def test_from_str_bool():

def test_from_str_list():
pairs = [('[0]', [0]),
('[1, 0, a]', [1, 0, 'a']),
('-2.3, true', [-2.3, True])]
# ('[1, 0, a]', [1, 0, 'a']),
('[-2.3, true]', [-2.3, True])]

for list_str, list_exp in pairs:
list_act = _misc.from_str(list_str)
Expand All @@ -53,6 +53,7 @@ def test_from_str_list():
assert act_val == exp_val


'''
def test_from_str_list_of_lists():
lol_str = '[[1, 0, 0, True, False], [2, 4, a, -2.3]]'
lol_exp = [[1, 0, 0, True, False], [2, 4, 'a', -2.3]]
Expand All @@ -64,6 +65,7 @@ def test_from_str_list_of_lists():
assert len(list_exp) == len(list_act)
for val_exp, val_act in zip(list_exp, list_act):
assert val_exp == val_act
'''


def test_tangent_sphere_2D():
Expand Down

0 comments on commit 5b080c9

Please sign in to comment.