testutils

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright 2025 César Nieto Sánchez

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const TestToleranceAbsolute = 1e-9

TestToleranceAbsolute defines the absolute tolerance used for comparing floating-point numbers in tests. It represents the maximum allowed absolute difference between the expected and actual values for the test to pass. A value of 1e-9 ensures that the comparison allows small discrepancies in the least significant digits, useful for large numbers.

View Source
const TestToleranceRelative = 1e-15

TestToleranceRelative defines the relative tolerance used for comparing floating-point numbers in tests. It represents the maximum allowed relative difference between the expected and actual values for the test to pass. A value of 1e-12 ensures that the comparison is precise up to 12 decimal places.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVFloat64Reader

type CSVFloat64Reader struct {
	// contains filtered or unexported fields
}

CSVFloat64Reader reads a CSV file and returns a slice of float64 values for each line. Fields:

  • reader (*csv.Reader): The CSV reader for the file.
  • file (*os.File): The file being read.
  • header ([]string): The header row of the CSV file.

func NewCSVFloat64Reader

func NewCSVFloat64Reader(filePath string) (*CSVFloat64Reader, error)

NewCSVFloat64Reader creates a new CSVFloat64Reader. Arguments:

  • filePath (string): The path to the CSV file.

Returns:

  • (*CSVFloat64Reader, error): A pointer to the CSVFloat64Reader and an error if any.

func (*CSVFloat64Reader) ReadLines

func (r *CSVFloat64Reader) ReadLines() <-chan LineData

ReadLines reads the CSV file and returns a channel to iterate over the rows. Returns:

  • (<-chan LineData): A channel that emits LineData for each row in the file.

type LineData

type LineData struct {
	LineNumber int       // Line number in the CSV file (starting from 1)
	Values     []float64 // Parsed content of the line as a slice of float64
	Err        error     // Error encountered while parsing the line
}

LineData represents a single line in the CSV file, including its line number and content. Fields:

  • LineNumber (int): Line number in the CSV file (starting from 1).
  • Values ([]float64): Parsed content of the line as a slice of float64.
  • Err (error): Error encountered while parsing the line.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL