Code Monkey home page Code Monkey logo

imprecise's People

Contributors

nutterb avatar

Watchers

 avatar  avatar

imprecise's Issues

Initial Work

Measured Class

as_measured

  • Expects a numeric or double value.
  • Requires an argument stating the place of precision. Precision is given as an integer power of 10. Thus, 0 is to the ones place; 1 is to the tens place; 2 is to the hundreds place; -1 is to the tenth, etc.
  • Accepts optional label and units arguments.
  • returns a vector with attributes precision, label, and units that has class c("measured", "[orig_class]")
  • Casts a warning if integer (integers are assumed to be constants)
  • Casts a warning if non-numeric and non-integer
  • When given a non-numeric or non-double value, returns the original vector unchanged.

is.measured

  • has an alias is_measured
  • returns a logical indicating if the value is a measured value.
  • returns FALSE with no warnings if applied to a non-numeric, non-double vector.

as_calculated

  • Expects a numeric or double value.
  • Requires an argument stating the significant figures.
  • Accepts optional label and units arguments.
  • returns a vector with attributes precision, label, and units that has class c("calculated", "measured", "[orig_class]")
  • Casts a warning if integer (integers are assumed to be constants)
  • Casts a warning if non-numeric and non-integer
  • When given a non-numeric or non-double value, returns the original vector unchanged.

is.measured

  • has an alias is_calculated
  • returns a logical indicating if the value is a calculated value.
  • returns FALSE with no warnings if applied to a non-numeric, non-double vector.

set_precision

  • Expects an object of class measured but not of calculated (precision may only be set on measurements)
  • Changes the precision attribute.
  • Casts a warning if the vector is not measured
  • Returns the original vector if it is not measured

get_precision

  • Gets the precision attribute of a measured vector.
  • Casts a warning if the vector is not measured but is numeric
  • Casts an error if the vector is not numeric
  • Returns Inf if the vector is numeric but not measured

set_label

  • sets the label attribute of a vector.

get_label

  • gets the label attribute of a vector. If there is no label attribute, returns the variable name as a string.

set_units

  • sets the units attribute of a vector

get_units

  • gets the units attribute of a vector. If there is no units attributes, an empty string is returned.

set_sigfig

  • sets the sigfig attribute of a calculated vector
  • casts a warning if the vector is not calculated
  • returns the original vector if it is not calculated

get_sigfig

  • gets the sigfig attribute of a calculated vector.
  • Casts a warning if the vector is not calculated and is numeric.
  • Casts an error if the vector is not numeric
  • Returns Inf if the vector is numeric but not calculated

print.measured

  • prints the value rounded to the appropriate precision

print.calculated

  • prints the value rounded to the appropriate significant figures.

Arithmetic

Methods for

  • addition
  • subtraction
  • multiplication
  • division
  • exponent
  • modulo
  • integer division
  • Arithmetic methods apply when either of both of the vectors are measured or calculated
  • Return an object of class calculated
  • What do we do about the label? (no label to start)
  • What do we do about the units? (no units to start)
  • Adds the sigfig attribute

Extraction methods needed

If m is a measured object, m[2] subsetting loses all of the attributes. There needs to be a method that gets the subset values of the vector and the precision and sigfig attributes to keep it all consistent.

The assignment methods seem to work okay. although it would be nice to have a process in set_precision and set_sigfig so that if I use set_precision(m[3], 2), the precision is set for the second element and everything else is preserved.

checkmate style functions

checkmate style functions

  • check_measured
  • test_measured
  • assert_measured
  • expect_measured
  • check_calculated
  • test_calculated
  • assert_calculated
  • expect_calculated

format methods needed

  • format.measured
  • format.calculated

These will allow values to be printed rounded to the correct form when printed in a data frame.

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.