Giter Club home page Giter Club logo

Comments (7)

markchatters avatar markchatters commented on July 17, 2024 1

Yes - the output on the Fair Simple Report

from pyfair.

theonaunheim avatar theonaunheim commented on July 17, 2024

Hey, @markchatters . Thanks for your interest.

Are you talking about the display on on the output of the FairSimpleReport?

from pyfair.

markchatters avatar markchatters commented on July 17, 2024

pyfairreport

from pyfair.

markchatters avatar markchatters commented on July 17, 2024

I may have missed something - perhaps there already is a way to do this ?

from pyfair.

theonaunheim avatar theonaunheim commented on July 17, 2024

Not nicely there's not. The only thing I can think of is supplying a new format string to the FairSimpleReport before you calculate it.

import pyfair

# Create using LEF (PERT), PL, (PERT), and SL (constant)
model1 = pyfair.FairModel(name="Regular Model 1", n_simulations=10_000)
model1.input_data('Threat Event Frequency', low=20, most_likely=100, high=900)
model1.input_data('Loss Magnitude', low=3_000_000, most_likely=3_500_000, high=5_000_000)
model1.input_data('Vulnerability', low=.011, most_likely=.225, high=.934)
model1.calculate_all()

# Create report comparing 2 vs metamodel.
fsr = pyfair.FairSimpleReport([model1])

################################################################
# Change your vuln format string
fsr._format_strings['Vulnerability'] = '{0:.3f}'
################################################################

# Output stuff
fsr.to_html('output.html')

image

from pyfair.

theonaunheim avatar theonaunheim commented on July 17, 2024

For the sake of completeness ....

The FairSimpleReport inherits from the FairBaseReport. This FairBaseReport has a formatting table. If you change a format string AFTER instantiation but BEFORE rendering, if should respect your new formatting. That said, the report is pretty fragile so anything beyond a few decimal places runs the risk of moving things out of place.

class FairBaseReport(object):
    """A base class for creating FairModel and FairMetaModel reports
    This class exists to provide a common base for mutliple report types.
    It carries with it formatting data, file paths, and a variety of 
    methods for creating report components. It is not intended to be
    instantiated on its own.
    """
    def __init__(self, currency_prefix='$'):
        # Add formatting strings
        self._currency_prefix = currency_prefix
        self._model_or_models = None
        self._currency_format_string     = currency_prefix + '{0:,.0f}'
        self._float_format_string      = '{0:.2f}'
        self._format_strings = {
            'Risk'                           : self._currency_format_string,
            'Loss Event Frequency'           : self._float_format_string,
            'Threat Event Frequency'         : self._float_format_string,
            'Vulnerability'                  : self._float_format_string,         
            'Contact Frequency'              : self._float_format_string,
            'Probability of Action'          : self._float_format_string,
            'Threat Capability'              : self._float_format_string,
            'Control Strength'               : self._float_format_string,
            'Loss Magnitude'                 : self._currency_format_string,
            'Primary Loss'                   : self._currency_format_string,
            'Secondary Loss'                 : self._currency_format_string,
            'Secondary Loss Event Frequency' : self._float_format_string,
            'Secondary Loss Event Magnitude' : self._currency_format_string,
        }

from pyfair.

markchatters avatar markchatters commented on July 17, 2024

great - thank you - that worked !

If I could be cheeky it would also be good if the distribution curve allowed for a max value less than 1 - but thank you for your prompt reply

from pyfair.

Related Issues (20)

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.