Skip to content

Commit

Permalink
Merge pull request #1 from yoshikaz1228/feature-swift-package-manager
Browse files Browse the repository at this point in the history
Feature swift package manager
  • Loading branch information
yoshikaz1228 authored Aug 7, 2022
2 parents d8b1907 + 5740a82 commit 27cfdcf
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 10 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 uhooi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 28 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Sigmoid",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Sigmoid",
targets: ["Sigmoid"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Sigmoid",
dependencies: []),
.testTarget(
name: "SigmoidTests",
dependencies: ["Sigmoid"]),
]
)
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[![CI](https://github.com/yoshikaz1228/Sigmoid/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/yoshikaz1228/Sigmoid/actions/workflows/main.yml)
[![Release](https://img.shields.io/github/v/release/yoshikaz1228/Sigmoid)](https://github.com/yoshikaz1228/Sigmoid/releases/latest)
[![License](https://img.shields.io/github/license/yoshikaz1228/Sigmoid)](https://github.com/yoshikaz1228/Sigmoid/blob/main/LICENSE)

# Sigmoid
implement sigmoid for swift.

## For example
```
var sigmoid = Sigmoid()
print(sigmoid.sigmoid(x:0.2))
let a = 1.0
let b = a.sigmoid()
```
13 changes: 13 additions & 0 deletions Sources/Sigmoid/Sigmoid.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// File.swift
// Sigmoid
//
// Created by Yoshikaz Matsubara on 2022/08/07.
//

import Foundation
extension Double {
public func sigmoid() -> Double {
return 1/(1+pow(M_E,-1.0 * self))
}
}
18 changes: 18 additions & 0 deletions Tests/SigmoidTests/SigmoidTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import XCTest
@testable import Sigmoid

final class SigmoidTests: XCTestCase {
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
var double: Double = 0.0
XCTAssertEqual(double.sigmoid(), 0.5)

double = 1.0
XCTAssertEqual(double.sigmoid(), 0.7310585786300049)

double = -1.0
XCTAssertEqual(double.sigmoid(), 0.2689414213699951)
}
}
8 changes: 0 additions & 8 deletions sigmoid.swift

This file was deleted.

25 changes: 25 additions & 0 deletions workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
DEVELOPER_DIR: /Applications/Xcode_13.4.1.app

jobs:
build:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: swift build -v

test:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v2
- name: Test
run: swift test -v

0 comments on commit 27cfdcf

Please sign in to comment.