Code Monkey home page Code Monkey logo

fable's Introduction

Hey there ๐Ÿ‘‹

I'm Yannis and I'm originally from Athens, Greece ๐Ÿ‡ฌ๐Ÿ‡ท. Currently, I'm working as a Software Engineer at Trovata on the Data Platform Engineering team. In the past, I've enjoyed working in a variety of similar roles including Data Engineering and Data Science. In my free time, I enjoy working out, traveling with my wife, programming, listening to music/podcasts, reading, and learning. If you'd like to get in touch, please feel free to reach out by email or you can contact me on Twitter or LinkedIn.


Tools, Technologies, Languages

GitHub Statistics

Yanni's GitHub Stats

Icons retrieved from Font Awesome Icons under the Creative Commons Attribution 4.0 International License

fable's People

Contributors

yanniskatsaros avatar

Stargazers

 avatar

Watchers

 avatar

fable's Issues

Better overall error-handling for parsing, and type errors

Current error-handling is very rough around the edges. In specific, several test cases are also failing due to incorrect error messages for the types of errors that should be occurring (type error vs nullable type error vs parsing error etc.). Furthermore, the current implementation stores all errors until the entire document has been parsed, then raises an exception with the slew of errors. This can be cleaned up.

Failing Test Cases

====================================================================== FAILURES =======================================================================
__________________________________________________ TestFloatDeclarations.test_catch_null_type_error ___________________________________________________

self = <test_fable.TestFloatDeclarations object at 0x10597dd30>

    def test_catch_null_type_error(self):
        s = 'float num null'
        result = parse_variable_declaration(s)
>       assert result.code == ErrorCode.NULLABLE_TYPE_ERROR
E       assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.NULLABLE_TYPE_ERROR: 2>
E         +<ErrorCode.TYPE_ERROR: 4>
E         -<ErrorCode.NULLABLE_TYPE_ERROR: 2>

tests/test_fable.py:67: AssertionError
___________________________________________________ TestFloatDeclarations.test_catch_parsing_error ____________________________________________________

self = <test_fable.TestFloatDeclarations object at 0x105a2d4e0>

    def test_catch_parsing_error(self):
        s = 'float num # woops forgot the value'
        result = parse_variable_declaration(s)
>       assert result.code == ErrorCode.PARSING_ERROR
E       assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.PARSING_ERROR: 1>
E         +<ErrorCode.TYPE_ERROR: 4>
E         -<ErrorCode.PARSING_ERROR: 1>

tests/test_fable.py:72: AssertionError
_________________________________________________________ TestFloatDeclarations.test_all_nans _________________________________________________________

self = <test_fable.TestFloatDeclarations object at 0x105a25630>

    def test_all_nans(self):
        nans = [
            'float num nan',
            'float num NaN',
            'float num NaN%',
            'float num NAN',
            'float num NaNQ',
            'float num NaNS',
            'float num qNaN',
            'float num sNaN',
            'float num 1.#SNAN',
            'float num 1.#QNAN',
            'float num +nan.0'
        ]
        for nan in nans:
            result = parse_variable_declaration(nan)
>           assert isnan(result.value)
E           AssertionError: assert False
E            +  where False = isnan(1.0)
E            +    where 1.0 = Variable(name='num', value=1.0).value

tests/test_fable.py:95: AssertionError
__________________________________________________ TestFloatDeclarations.test_negative_signed_floats __________________________________________________

self = <test_fable.TestFloatDeclarations object at 0x105931470>

    def test_negative_signed_floats(self):
        cases = [
            'float num -14.51',
            'float num -1.451E01',
            'float num -1.451E+01',
            'float num -1.451e01',
            'float num -1.451e+01'
        ]
        for s in cases:
            result = parse_variable_declaration(s)
            assert result == Variable('num', -14.51)

        cases = [
            'float num -0.001451',
            'float num -1.451E-03',
            'float num -1.451e-03'
        ]
        for s in cases:
            result = parse_variable_declaration(s)
>           assert result == Variable('num', -0.001451, False)
E           TypeError: __init__() takes 3 positional arguments but 4 were given

tests/test_fable.py:168: TypeError
__________________________________________________ TestStringDeclarations.test_catch_null_type_error __________________________________________________

self = <test_fable.TestStringDeclarations object at 0x10592d7b8>

    def test_catch_null_type_error(self):
        s = 'string message null'
        result = parse_variable_declaration(s)
>       assert result.code == ErrorCode.NULLABLE_TYPE_ERROR
E       assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.NULLABLE_TYPE_ERROR: 2>
E         +<ErrorCode.TYPE_ERROR: 4>
E         -<ErrorCode.NULLABLE_TYPE_ERROR: 2>

tests/test_fable.py:226: AssertionError
___________________________________________________ TestStringDeclarations.test_catch_parsing_error ___________________________________________________

self = <test_fable.TestStringDeclarations object at 0x105920470>

    def test_catch_parsing_error(self):
        s = 'string message # woops forgot the value'
        result = parse_variable_declaration(s)
>       assert result.code == ErrorCode.PARSING_ERROR
E       assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.PARSING_ERROR: 1>
E         +<ErrorCode.TYPE_ERROR: 4>
E         -<ErrorCode.PARSING_ERROR: 1>

tests/test_fable.py:231: AssertionError
_________________________________________________ TestBooleanDeclarations.test_catch_null_type_error __________________________________________________

self = <test_fable.TestBooleanDeclarations object at 0x10591b7f0>

    def test_catch_null_type_error(self):
        s = 'boolean is_happy null'
        result = parse_variable_declaration(s)
>       assert result.code == ErrorCode.NULLABLE_TYPE_ERROR
E       assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.NULLABLE_TYPE_ERROR: 2>
E         +<ErrorCode.TYPE_ERROR: 4>
E         -<ErrorCode.NULLABLE_TYPE_ERROR: 2>

tests/test_fable.py:257: AssertionError
__________________________________________________ TestBooleanDeclarations.test_catch_parsing_error ___________________________________________________

self = <test_fable.TestBooleanDeclarations object at 0x1059a37f0>

    def test_catch_parsing_error(self):
        s = 'boolean is_happy # woops forgot the rest'
        result = parse_variable_declaration(s)
>       assert result.code == ErrorCode.PARSING_ERROR
E       assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.PARSING_ERROR: 1>
E         +<ErrorCode.TYPE_ERROR: 4>
E         -<ErrorCode.PARSING_ERROR: 1>

tests/test_fable.py:262: AssertionError
=============================================================== short test summary info ===============================================================
FAILED tests/test_fable.py::TestFloatDeclarations::test_catch_null_type_error - assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.NULLABLE_TYPE_ERROR: 2>
FAILED tests/test_fable.py::TestFloatDeclarations::test_catch_parsing_error - assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.PARSING_ERROR: 1>
FAILED tests/test_fable.py::TestFloatDeclarations::test_all_nans - AssertionError: assert False
FAILED tests/test_fable.py::TestFloatDeclarations::test_negative_signed_floats - TypeError: __init__() takes 3 positional arguments but 4 were given
FAILED tests/test_fable.py::TestStringDeclarations::test_catch_null_type_error - assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.NULLABLE_TYPE_ERROR: 2>
FAILED tests/test_fable.py::TestStringDeclarations::test_catch_parsing_error - assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.PARSING_ERROR: 1>
FAILED tests/test_fable.py::TestBooleanDeclarations::test_catch_null_type_error - assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.NULLABLE_TYPE_ERROR...
FAILED tests/test_fable.py::TestBooleanDeclarations::test_catch_parsing_error - assert <ErrorCode.TYPE_ERROR: 4> == <ErrorCode.PARSING_ERROR: 1>
============================================================ 8 failed, 26 passed in 0.19s =============================================================

Implement specification v0.2.0

Below is the proposed specification for version 0.2.0.

Key differences and features include:

  • @var and @table tags are no longer required, we now have true "primitive" types defined
  • the %% directive is now purely for declaring the specification version and no longer requires the v to precede
  • table types no longer require declaration of the number of rows and columns
  • table types now require column type declarations, using one of the available fable types
  • string variable declarations now strictly require the use of " quotations
  • leading and trailing whitespace for each line is now definitively ignored

Below is an example of the proposed specification

%% 0.2.0
# ^specification version
# comments work, empty lines are ignored

# variable declaration and supported types
# <type> <name> <value>
integer my_integer 10
real my_float 3.14
boolean my_true_bool true
boolean my_false_bool false
string my_string "hello world"

# table declarations are similar but entries
# span over multiple rows
# table <name> <nrows> <ncols> true
# <type>,<type>,...,<type>
# <name>,<name>,...,<name>
# <value>,<value>,...,<value>
# ...

# table with a header row
table+ my_table_with_header
integer,integer,integer,real,real,integer
time,pipe_section,velocity,mass,pressure,temperature
0,1,83,0.01,7136,36
0,2,96,0.01,7579,39
0,3,95,0.02,7469,34
0,4,98,0.02,6227,38
0,5,96,0.04,7769,40
1,1,99,0.05,6219,36
1,2,89,0.01,6891,38
1,3,96,0.05,6926,39
1,4,80,0.05,7082,35
1,5,98,0.03,6200,39

# table without a header
table my_table_no_header
integer,integer,integer,real,real,integer
0,1,83,0.01,7136,36
0,2,96,0.01,7579,39
0,3,95,0.02,7469,34
0,4,98,0.02,6227,38
0,5,96,0.04,7769,40
1,1,99,0.05,6219,36
1,2,89,0.01,6891,38
1,3,96,0.05,6926,39
1,4,80,0.05,7082,35
1,5,98,0.03,6200,39

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.