Giter Site home page Giter Site logo

haggis's Introduction

This project, along with all my others, has moved to GitLab: https://gitlab.com/madphysicist/madphysicist. Please download the latest version and submit updates there rather than GitHub, which will no longer be monitored.

Introduction

Hi, I am algorithm engineer with a background in physics and signal processing. Coding is a hobby of mine. I like to contribute fixes and improvements to projects that I use frequently, such as the numpy / scipy / matplotlib stack. My ongoing pet project is scikit-guess. It's a collection of linearized optimization routines that started as a translation and python implementation of Jean Jacquelin's paper, which you can find in the repo.

Relevant Links

My Repos

Here is a selection of repos with a note about each one:

  • scikit-guess [PyPi] [RTD] See above.

  • haggis [PyPi] [RTD] Originally made to support imprint, this library has a whole bunch of routines I find useful on a regular basis for all kinds of projects.

  • imprint [PyPi] [RTD] A publication system for generating MS Word documents I made while at the Detector Characterization Lab at NASA GSFC. Only really useful in the case where you want to generate the same document over and over, but with different data.

  • is_integer_ufunc is a foray into the C code of numpy. It contains bit twiddling operations for determining whether an IEEE754 float (any format) is an integer or not. It's becoming pretty clear that a ufunc is inadequate for the purpose, so I am concocting two alternatives to the pure ufunc:

    • A numpy function that labels each element with whether it can be stored in an integer of specified bit-width.
    • The number of bits required to store the integer stored in a float, with negative numbers indicating a fractional portion.

    See the Stack Exchange section below for the inspiration.

  • puzzle-solvers [PyPi] [RTD] Another Stack Overflow-inspired package. This one is currently just a system for solving a zebra puzzle, which I really enjoyed writing. See the Stack Exchange section for the inspiration.

  • libpluck never got past the README phase, as it's more of an April fool's library than anything. Developed in conjunction with Ventsy Velev while working on GOES-R together. An idea that never made it even this far was a library for generating unit tests with gramatically meaningful, fancy sounding names, all of which pass after much output and fanfare.

  • BOFH is a small Java program that depends on JTools, and displays a GUI for the excuse generator from Simon Travaglia's BOFH series of articles.

  • JTools is a small library of Java utilities from many years ago when I coded in Java. It's so old that it was written before Java 7 even existed. There were no streams back in those days. The library has all sorts of tools for I/O, process management, GUI elements, XML parsing and the like.

  • JTools-extras is an extension of JTools that contains utilities with external dependencies (like TestNG).

Stack Exchange

I've been on Stack Exchange for a while now, and some of the open source work I've done is a direct consequence of my contributions there. The list below maps some of my PRs to the questions that they originated with. In most cases, I added an answer to the question referencing the contribution.

Part of the reason for putting this section here is that my SE profile is limited to 3000 characters, so I gave up on trying to squeeze it in there.

Stuff that might get turned into PRs one day:

haggis's People

Contributors

madphysicist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

haggis's Issues

Typing issue

Not sure if this belongs here or to the logging library but maybe you have also experienced this.

I add a trace level logger to the logging library using your library. Automatically the method is added. The problem is, that the type checker does not know about it because it happens in runtime.

Do you have any solution for this? Adding # type: ignore in every line where I use the logging.trace(โ€ฆ) is not very feasible.

import logging
import haggis.logs

haggis.logs.add_trace_level(haggis.logs.KEEP)

logger: logging.Logger = logging.getLogger(__name__)

logger.trace("Test")
[q-wertz@hoth testproject]$ mypy test.py
test.py:8: error: "Logger" has no attribute "trace"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

logging.LoggerAdapter does not recognize the new added level

import logging
from haggis import logs

class JobIdAdapter(logging.LoggerAdapter):
    def process(self,msg,kwargs):
        id = kwargs.pop('id', self.extra['id'])
        return '[%s] %s' % (id, msg), kwargs

conf_dict = {
    'version': 1,
    'formatters': {'simple': {'format': '%(asctime)s - %(module)s - %(levelname)s - %(message)s'}},
    'handlers': {
                'console': {
                    'class': 'logging.StreamHandler', 'formatter': 'simple', 'stream': 'ext://sys.stdout'
                    },
                'mxf': {
                    'class': 'logging.handlers.TimedRotatingFileHandler',
                    'formatter': 'simple',
                    'filename': '/xinet/Hotfolders/Logs/mxf.log',
                    'when': 'midnight',
                    'interval': 1,
                    'backupCount': 7,
                    'encoding': 'utf-8'
                    },
                'hfx': {
                     'class': 'logging.handlers.MemoryHandler',
                     'flushLevel': 60,
                     'formatter': 'simple',
                     'capacity': 1000,
                     'target': 'mxf',
                     'flushOnClose': True
                    }
                },
    'loggers': {
            'mxf': {'level': 'DEBUG', 'handlers': ['mxf'], 'propagate': True},
            'hfx': {'level': 'DEBUG', 'handlers': ['hfx'], 'propagate': True}},
            'root': {'level': 'DEBUG', 'handlers': ['console']}
                }

logging.config.dictConfig(conf_dict)
logs.add_logging_level('DETAIL',15)
hfx_log = logging.getLogger("hfx")
hfx_log = JobIdAdapter(hfx_log,{'id':10000})

hfx_log.detail('Some message',{'id':10})

Got this error:

  File "/cogito/MaxiFolders/x.py", line 45, in <module>
    hfx_log.detail('Some message',{'id':10})
AttributeError: 'JobIdAdapter' object has no attribute 'detail'

Process finished with exit code 1

What can be done about this.
Thank you for your help.

[Bug] add_logging_level

Hi @madphysicist,

I am using the logs module, namely add_logging_level and that results in the following error:

ValueError: Formatting field not found in record: 'level_name'
Call stack:
  File "C:\Users\REDACTED", line 92, in <module>
    main()
  File "C:\Users\REDACTED", line 25, in main
    logging.success("test")
  File "C:\Users\REDACTED\.venv\lib\site-packages\haggis\logs.py", line 197, in for_logging_module
    logging.log(level_num, *args, **kwargs)
Message: 'test'
Arguments: ()

Here is my code:

import coloredlogs
import logging
from haggis import logs

def init_logger(log_level):
    coloredlogs.install(fmt="%(level_name)s %(message)s",
                        level=logging.getLevelName(log_level))

    logs.add_logging_level('TRACE', logging.DEBUG - 5)
    logs.add_logging_level('SUCCESS', logging.INFO - 5)

    logging.trace('so did this')

    logging.getLogger('ccxt').setLevel(logging.ERROR)
    logging.getLogger('requests').setLevel(logging.ERROR)
    logging.getLogger('urllib3').setLevel(logging.ERROR)
    logging.getLogger('vectorbt').setLevel(logging.ERROR)

Any help?

EDIT: It seems that it got to do with my custom format %(level_name)s %(message)s, when removing it works, however, it is a project requirement to log the messages using this format. Is it possible to tweak your lib to support custom formats?

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.